-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mlm and llrd #6
base: main
Are you sure you want to change the base?
Mlm and llrd #6
Conversation
predictions = (probs > thresholds).astype(int) | ||
clf_dict = classification_report(labels, predictions, zero_division=0, output_dict=True) | ||
return {"micro f1": clf_dict["micro avg"]["f1-score"], | ||
"macro f1": clf_dict["macro avg"]["f1-score"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"weighted" avg.'ı da return dict'e ekleyebilir miyiz ?
|
||
# Preprocessing function to clean the tweets. | ||
# Use with caution: removing hashtags and handles _may_ reduce model performance. | ||
def preprocess_tweet(tweet, remove_hashtags=False, remove_handles=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buraya telefon numaralarını silmek için de bi kod ekleyebiliriz, şu notebook'da basit bi preprocess yazmıştım genel olarak çalışıyor gibi ama kaçırdığı edge caseler de olabilir belki refine etmek gerekir.
tweet = re.sub(r'www\S+', '', tweet) | ||
tweet = re.sub(r'pic.twitter\S+', '', tweet) | ||
|
||
tweet = re.sub(r'\W', ' ', tweet) # remove special characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\W
tüm special karakterleri siliyor (gerekli puncuationlar dahil). Pretraining'de eğer punctuationlar silinmeden eğitildiyse model (örn. genelde kullandığımız loodos modelleri), bu problem yaratır fine-tuning'de, o yüzden önerim virgül, nokta, ünlem, soru işareti gibi spesifik noktalama işaretlerini kaldırmamak. "loodos" pretraining için baktım şu normalization scriptini kullanmışlar, punctuation removal yok.
tweet = re.sub(r'pic.twitter\S+', '', tweet) | ||
|
||
tweet = re.sub(r'\W', ' ', tweet) # remove special characters | ||
tweet = re.sub(r'\s+', ' ', tweet) # remove multiple whitespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bilmediğim için soruyorum bu regex sub \n
veya \t
gibi kısımları da multiple whitespace'ten sayıyor mu ? eğer onları ignore ediyorsa (tek whitespace gibi görüp), onları da handle edecek bi kod ile değiştirebiliriz burayı, aşağıdaki kod gibi bişey ile
tweet = " ".join(tweet.split())
from unicode_tr import unicode_tr | ||
|
||
|
||
def prep_datasets(tokenizer, labelidx2name, path, label_col="label", text_col="image_url"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labelidx2name
argumanına gerek yok, datasets.Dataset
internal olarak bu şemayı under-the-hood tutuyor, direkt onu utilize edebiliriz. HF'de usage kısmında var readme'de.
# to convert from id to string
print(dataset["train"].features["label"].int2str(tweet["label"]))
# to convert from string to id
print(dataset["train"].features["label"].str2int(tweet["label_name"]))
df_test = pd.DataFrame().from_records(list(intent["test"])) | ||
|
||
df_train[text_col] = df_train[text_col].apply(lambda x: unicode_tr(x).lower()) | ||
df_test[text_col] = df_test[text_col].apply(lambda x: unicode_tr(x).lower()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower()
yaparken şuna dikkat etmeliyiz Türkçe için ı/i.
No description provided.