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
5
6pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
7pip install peft
8pip install transformers1from Preprocessor import preprocess
2
3text = """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
4https://varollab.com/"""
5
6preprocessed_text = preprocess(text)
7print(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
4
5tokenizer = AutoTokenizer.from_pretrained("VRLLab/TurkishBERTweet")
6turkishBERTweet = AutoModel.from_pretrained("VRLLab/TurkishBERTweet")
7
8text = """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"""
9
10preprocessed_text = preprocess(text)
11input_ids = torch.tensor([tokenizer.encode(preprocessed_text)])
12
13with torch.no_grad():
14 features = turkishBERTweet(input_ids) # Models outputs are now tuples1import torch
2from peft import (
3 PeftModel,
4 PeftConfig,
5)
6
7from transformers import (
8 AutoModelForSequenceClassification,
9 AutoTokenizer)
10from Preprocessor import preprocess
11
12
13peft_model = "VRLLab/TurkishBERTweet-Lora-SA"
14peft_config = PeftConfig.from_pretrained(peft_model)
15
16# loading Tokenizer
17padding_side = "right"
18tokenizer = AutoTokenizer.from_pretrained(
19 peft_config.base_model_name_or_path, padding_side=padding_side
20)
21if getattr(tokenizer, "pad_token_id") is None:
22 tokenizer.pad_token_id = tokenizer.eos_token_id
23
24id2label_sa = {0: "negative", 2: "positive", 1: "neutral"}
25turkishBERTweet_sa = AutoModelForSequenceClassification.from_pretrained(
26 peft_config.base_model_name_or_path, return_dict=True, num_labels=len(id2label_sa), id2label=id2label_sa
27)
28turkishBERTweet_sa = PeftModel.from_pretrained(turkishBERTweet_sa, peft_model)
29
30sample_texts = [
31 "Viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.",
32 "americanin diplatlari turkiyeye gelmesin 😤",
33 "Mark Zuckerberg ve Elon Musk'un boks müsabakası süper olacak! 🥷",
34 "Adam dun ne yediğini unuttu"
35 ]
36
37
38preprocessed_texts = [preprocess(s) for s in sample_texts]
39with torch.no_grad():
40 for s in preprocessed_texts:
41 ids = tokenizer.encode_plus(s, return_tensors="pt")
42 label_id = turkishBERTweet_sa(**ids).logits.argmax(-1).item()
43 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)
5
6from transformers import (
7 AutoModelForSequenceClassification,
8 AutoTokenizer)
9from Preprocessor import preprocess
10
11
12peft_model = "VRLLab/TurkishBERTweet-Lora-HS"
13peft_config = PeftConfig.from_pretrained(peft_model)
14
15# loading Tokenizer
16padding_side = "right"
17tokenizer = AutoTokenizer.from_pretrained(
18 peft_config.base_model_name_or_path, padding_side=padding_side
19)
20if getattr(tokenizer, "pad_token_id") is None:
21 tokenizer.pad_token_id = tokenizer.eos_token_id
22
23id2label_hs = {0: "No", 1: "Yes"}
24turkishBERTweet_hs = AutoModelForSequenceClassification.from_pretrained(
25 peft_config.base_model_name_or_path, return_dict=True, num_labels=len(id2label_hs), id2label=id2label_hs
26)
27turkishBERTweet_hs = PeftModel.from_pretrained(turkishBERTweet_hs, peft_model)
28
29
30sample_texts = [
31 "Viral lab da insanlar hep birlikte çalışıyorlar. hepbirlikte çalışan insanlar birbirlerine yakın oluyorlar.",
32 "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?",
33 ]
34
35
36preprocessed_texts = [preprocess(s) for s in sample_texts]
37with torch.no_grad():
38 for s in preprocessed_texts:
39 ids = tokenizer.encode_plus(s, return_tensors="pt")
40 label_id = turkishBERTweet_hs(**ids).logits.argmax(-1).item()
41 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?
31@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}