Views
No views yet

| Model | #params | Arch. | Max length | Pre-training data |
|---|---|---|---|---|
VRLLab/TurkishBERTweet | 163M | base | 128 | 894M Turkish Tweets (uncased) |
| Model | train f1 | dev f1 | test f1 | Dataset Size |
|---|---|---|---|---|
VRLLab/TurkishBERTweet-Lora-SA | 0.799 | 0.687 | 0.692 | 42,476 Turkish Tweets |
VRLLab/TurkishBERTweet-Lora-HS | 0.915 | 0.796 | 0.831 | 4,683 Turkish Tweets |
1git clone git@github.com:ViralLab/TurkishBERTweet.git
2cd TurkishBERTweet
3python -m venv venv
4source venv/bin/activate
5pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
6pip install peft
7pip install transformers1from Preprocessor import preprocess
2text = """Lab'ımıza "viral" adını verdik çünkü amacımız disiplinler arası sınırları aşmak ve aralarında yeni bağlantılar kurmak! 🔬 #ViralLab
3https://varollab.com/"""
4preprocessed_text = preprocess(text)
5print(preprocessed_text)lab'ımıza "viral" adını verdik çünkü amacımız disiplinler arası sınırları aşmak ve aralarında yeni bağlantılar kurmak! <emoji> mikroskop </emoji> <hashtag> virallab </hashtag> <http> varollab.com </http>1import torch
2from transformers import AutoTokenizer, AutoModel
3from Preprocessor import preprocess
4tokenizer = AutoTokenizer.from_pretrained("VRLLab/TurkishBERTweet")
5turkishBERTweet = AutoModel.from_pretrained("VRLLab/TurkishBERTweet")
6text = """Lab'ımıza "viral" adını verdik çünkü amacımız disiplinler arası sınırları aşmak ve aralarında yeni bağlantılar kurmak! 💥🔬 #ViralLab #DisiplinlerArası #YenilikçiBağlantılar"""
7preprocessed_text = preprocess(text)
8input_ids = torch.tensor([tokenizer.encode(preprocessed_text)])
9with torch.no_grad():
10 features = turkishBERTweet(input_ids) # Models outputs are now tuples1import torch
2from peft import (
3 PeftModel,
4 PeftConfig,
5)
6from transformers import (
7 AutoModelForSequenceClassification,
8 AutoTokenizer)
9from Preprocessor import preprocess
10
11peft_model = "VRLLab/TurkishBERTweet-Lora-SA"
12peft_config = PeftConfig.from_pretrained(peft_model)
13# loading Tokenizer
14padding_side = "right"
15tokenizer = AutoTokenizer.from_pretrained(
16 peft_config.base_model_name_or_path, padding_side=padding_side
17)
18if getattr(tokenizer, "pad_token_id") is None:
19 tokenizer.pad_token_id = tokenizer.eos_token_id
20id2label_sa = {0: "negative", 2: "positive", 1: "neutral"}
21turkishBERTweet_sa = AutoModelForSequenceClassification.from_pretrained(
22 peft_config.base_model_name_or_path, return_dict=True, num_labels=len(id2label_sa), id2label=id2label_sa
23)
24turkishBERTweet_sa = PeftModel.from_pretrained(turkishBERTweet_sa, peft_model)
25sample_texts = [
26 "Viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.",
27 "americanin diplatlari turkiyeye gelmesin 😤",
28 "Mark Zuckerberg ve Elon Musk'un boks müsabakası süper olacak! 🥷",
29 "Adam dun ne yediğini unuttu"
30 ]
31preprocessed_texts = [preprocess(s) for s in sample_texts]
32with torch.no_grad():
33 for s in preprocessed_texts:
34 ids = tokenizer.encode_plus(s, return_tensors="pt")
35 label_id = turkishBERTweet_sa(**ids).logits.argmax(-1).item()
36 print(id2label_sa[label_id],":", s)1positive : viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.
2negative : americanin diplatlari turkiyeye gelmesin <emoji> burundan_buharla_yüzleşmek </emoji>
3positive : mark zuckerberg ve elon musk'un boks müsabakası süper olacak! <emoji> kadın_muhafız_koyu_ten_tonu </emoji>
4neutral : adam dun ne yediğini unuttu1from peft import (
2 PeftModel,
3 PeftConfig,
4)
5from transformers import (
6 AutoModelForSequenceClassification,
7 AutoTokenizer)
8from Preprocessor import preprocess
9
10peft_model = "VRLLab/TurkishBERTweet-Lora-HS"
11peft_config = PeftConfig.from_pretrained(peft_model)
12# loading Tokenizer
13padding_side = "right"
14tokenizer = AutoTokenizer.from_pretrained(
15 peft_config.base_model_name_or_path, padding_side=padding_side
16)
17if getattr(tokenizer, "pad_token_id") is None:
18 tokenizer.pad_token_id = tokenizer.eos_token_id
19id2label_hs = {0: "No", 1: "Yes"}
20turkishBERTweet_hs = AutoModelForSequenceClassification.from_pretrained(
21 peft_config.base_model_name_or_path, return_dict=True, num_labels=len(id2label_hs), id2label=id2label_hs
22)
23turkishBERTweet_hs = PeftModel.from_pretrained(turkishBERTweet_hs, peft_model)
24sample_texts = [
25 "Viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.",
26 "kasmayin artik ya kac kere tanik olduk bu azgin tehlikeli \u201cmultecilerin\u201d yaptiklarina? bir afgan taragindan kafasi tasla ezilip tecavuz edilen kiza da git boyle cihangir solculugu yap yerse?",
27 ]
28preprocessed_texts = [preprocess(s) for s in sample_texts]
29with torch.no_grad():
30 for s in preprocessed_texts:
31 ids = tokenizer.encode_plus(s, return_tensors="pt")
32 label_id = turkishBERTweet_hs(**ids).logits.argmax(-1).item()
33 print(id2label_hs[label_id],":", s)1No : viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.
2Yes : kasmayin artik ya kac kere tanik olduk bu azgin tehlikeli “multecilerin” yaptiklarina? bir afgan taragindan kafasi tasla ezilip tecavuz edilen kiza da git boyle cihangir solculugu yap yerse?1@article{najafi2023turkishbertweet,
2 title={TurkishBERTweet: Fast and Reliable Large Language Model for Social Media Analysis},
3 author={Najafi, Ali and Varol, Onur},
4 journal={arXiv preprint arXiv:2311.18063},
5 year={2023}
6}