Latensis NER — Turkish Named Entity Recognition

Understanding Beyond the Visible

Latensis NER is a Turkish named entity recognition model fine-tuned on top of Latensis RoBERTa Base.

Labels

ID Label Description
0 O Outside
1 B-PER Beginning of person name
2 I-PER Inside person name
3 B-ORG Beginning of organization
4 I-ORG Inside organization
5 B-LOC Beginning of location
6 I-LOC Inside location

Benchmark Results

Evaluated on WikiANN Turkish test set (75,731 tokens).

Metric Our Model BERTurk
F1-macro 0.9429 0.9522
Accuracy 0.97 —

Per-class Results

Class Precision Recall F1 Support
O 0.99 0.99 0.99 46,466
B-PER 0.96 0.96 0.96 4,519
I-PER 0.97 0.96 0.96 5,694
B-ORG 0.93 0.92 0.92 4,154
I-ORG 0.94 0.95 0.94 6,979
B-LOC 0.94 0.95 0.95 4,914
I-LOC 0.92 0.92 0.92 3,005
macro avg 0.95 0.95 0.95 75,731

Training Details

Property Value
Base model Latensis RoBERTa Base (500k steps, val loss 3.21)
Training data WikiANN Turkish — 20k examples
Tokenizer Hecemen Unigram 128k
Learning rate 2e-5
Batch size 16
Epochs 20

Usage

import torch
import sentencepiece as spm
from transformers import RobertaForTokenClassification, RobertaConfig
from huggingface_hub import hf_hub_download

# Load tokenizer
spm_path = hf_hub_download(
    repo_id="mursideaki/hecemen-tokenizer-unigram-128k",
    filename="tr_unigram_tokenizer.model"
)
sp = spm.SentencePieceProcessor()
sp.load(spm_path)

PAD_ID = sp.piece_to_id("<pad>")
BOS_ID = sp.piece_to_id("<s>")
EOS_ID = sp.piece_to_id("</s>")
MAX_LENGTH = 128

ID2LABEL = {
    0: 'O', 1: 'B-PER', 2: 'I-PER',
    3: 'B-ORG', 4: 'I-ORG',
    5: 'B-LOC', 6: 'I-LOC'
}

# Load model
config = RobertaConfig.from_pretrained("mursideaki/latensis-ner-tr")
model  = RobertaForTokenClassification.from_pretrained(
    "mursideaki/latensis-ner-tr", config=config
)
model.eval()

# Predict
def predict_ner(text):
    words = text.split()
    input_ids = [BOS_ID]
    word_ids  = [-1]

    for i, word in enumerate(words):
        token_ids = sp.encode_as_ids(word)
        input_ids.extend(token_ids)
        word_ids.extend([i] * len(token_ids))

    input_ids = input_ids[:MAX_LENGTH-1] + [EOS_ID]
    word_ids  = word_ids[:MAX_LENGTH-1]  + [-1]
    mask      = [1] * len(input_ids)

    pad_len   = MAX_LENGTH - len(input_ids)
    input_ids = input_ids + [PAD_ID] * pad_len
    mask      = mask      + [0]      * pad_len

    with torch.no_grad():
        outputs = model(
            input_ids=torch.tensor([input_ids], dtype=torch.long),
            attention_mask=torch.tensor([mask], dtype=torch.long)
        )

    preds = outputs.logits.argmax(dim=-1)[0].tolist()

    results = []
    seen = set()
    for wid, pred in zip(word_ids, preds):
        if wid == -1 or wid in seen:
            continue
        seen.add(wid)
        results.append((words[wid], ID2LABEL[pred]))
    return results

print(predict_ner("Mustafa Kemal Atatürk, Ankara'da Türkiye Büyük Millet Meclisi'ni kurdu."))

Companion Models

Citation

@misc{latensis2026,
  author    = {Mürşide Aki},
  title     = {Latensis: Turkish NLP Model Suite},
  year      = {2026},
  publisher = {Hugging Face},
  url       = {https://huggingface.co/mursideaki/latensis-ner-tr}
}

License

MIT

Downloads last month
-
Safetensors
Model size
0.2B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support