Latensis Sentiment is a Turkish sentiment analysis model fine-tuned on top of
Latensis RoBERTa Base —
a Turkish-specific RoBERTa model trained from scratch with the
Hecemen Unigram 128k tokenizer.
Evaluated on two independent test sets. Comparison against
savasy/bert-base-turkish-sentiment-cased (BERTurk Sentiment).
1import torch
2import sentencepiece as spm
3from transformers import RobertaForSequenceClassification, RobertaConfig
4from huggingface_hub import hf_hub_download
5
6# Load tokenizer
7spm_path = hf_hub_download(
8 repo_id="mursideaki/hecemen-tokenizer-unigram-128k",
9 filename="tr_unigram_tokenizer.model"
10)
11sp = spm.SentencePieceProcessor()
12sp.load(spm_path)
13
14PAD_ID = sp.piece_to_id("<pad>")
15BOS_ID = sp.piece_to_id("<s>")
16EOS_ID = sp.piece_to_id("</s>")
17MAX_LENGTH = 256
18
19def tokenize(text):
20 ids = sp.encode_as_ids(str(text))
21 ids = [BOS_ID] + ids[:MAX_LENGTH-2] + [EOS_ID]
22 mask = [1] * len(ids)
23 if len(ids) < MAX_LENGTH:
24 pad_len = MAX_LENGTH - len(ids)
25 ids = ids + [PAD_ID] * pad_len
26 mask = mask + [0] * pad_len
27 return ids, mask
28
29# Load model
30config = RobertaConfig.from_pretrained("mursideaki/latensis-sentiment-tr")
31model = RobertaForSequenceClassification.from_pretrained(
32 "mursideaki/latensis-sentiment-tr",
33 config=config
34)
35model.eval()
36
37# Predict
38def predict(text):
39 ids, mask = tokenize(text)
40 input_ids = torch.tensor([ids], dtype=torch.long)
41 attention_mask = torch.tensor([mask], dtype=torch.long)
42 with torch.no_grad():
43 outputs = model(input_ids=input_ids, attention_mask=attention_mask)
44 label = outputs.logits.argmax(dim=-1).item()
45 return "positive" if label == 1 else "negative"
46
47print(predict("Bu ürün gerçekten çok kaliteliydi, kesinlikle tavsiye ederim!"))
48# → positive
49
50print(predict("Berbat bir deneyimdi, bir daha almam."))
51# → negative
1@misc{latensis2026,
2 author = {Mürşide Aki},
3 title = {Latensis: Turkish NLP Model Suite},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/mursideaki/latensis-sentiment-tr}
7}