You need to agree to share your contact information to access this model
This repository is publicly accessible, but you have to accept the conditions to access its files and content.
Бұл репозиторийге қолжетімділік өтінім бойынша беріледі. Өзіңіз туралы және деректерді қалай қолданатыңыз туралы жазыңыз — өтінімді TilQazyna командасы қарайды. · Доступ к репозиторию выдаётся по заявке. Расскажите о себе и о том, как собираетесь использовать данные — заявку рассматривает команда TilQazyna. · Access to this repository is granted on request. Tell us who you are and how you plan to use the material; the TilQazyna team reviews each application.
Log in or Sign Up to review the conditions and access this model content.
xlm-roberta-kazakh-pos
Қазақ тіліне арналған сөз таптарын белгілеу моделі · Модель разметки частей речи казахского языка · Kazakh part-of-speech tagging model
Қазақша
xlm-roberta-kazakh-pos — қазақша сөйлемдегі әр сөзге грамматикалық белгі беретін XLM-RoBERTa модельдері мен бағалау материалдары. Репозиторий көлемі — 1.11 ГБ; base модельдің accuracy көрсеткіші 91.60%, F1 — 91.31%, ал large нұсқасында тиісінше 92.04% және 91.85%.
Құрылымы және оқыту дерегі
Checkpoint kazakh_pos_model_complete.pt файлында сақталған. Модель subword токендерін сөз деңгейіне қайта біріктіріп, 18 грамматикалық санаттың бірін береді.
| Нұсқа | Негізгі модель | Параметр | Hidden size | Accuracy | F1 |
|---|---|---|---|---|---|
| Base | xlm-roberta-base |
270M шамасында | 768 | 91.60% | 91.31% |
| Large | xlm-roberta-large |
560M шамасында | 1024 | 92.04% | 91.85% |
Оқыту жинағында 1,147 сөйлем бар: 70% оқытуға, 10% validation-ға, 20% тестке бөлінген. Тестте 4,107 сөз бағаланған, base модель 3,762 сөзді дұрыс белгілеген.
Қалай іске қосуға болады
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoModel, AutoTokenizer
class POSTagger(nn.Module):
def __init__(self, num_tags):
super().__init__()
self.encoder = AutoModel.from_pretrained("xlm-roberta-base")
self.dropout = nn.Dropout(0.1)
self.classifier = nn.Linear(768, num_tags)
def forward(self, input_ids, attention_mask):
encoded = self.encoder(
input_ids=input_ids,
attention_mask=attention_mask,
).last_hidden_state
return self.classifier(self.dropout(encoded))
checkpoint_path = hf_hub_download(
repo_id="TilQazyna/xlm-roberta-kazakh-pos",
filename="kazakh_pos_model_complete.pt",
)
checkpoint = torch.load(checkpoint_path, map_location="cpu")
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base")
model = POSTagger(checkpoint["config"]["num_tags"])
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
words = ["Демек", "Құнанбай", "тірі", "адам", "еді"]
inputs = tokenizer(
words,
is_split_into_words=True,
truncation=True,
max_length=128,
return_tensors="pt",
)
with torch.no_grad():
predicted = model(**inputs).argmax(dim=-1)[0]
tags = []
previous = None
for token_index, word_index in enumerate(inputs.word_ids()):
if word_index is not None and word_index != previous:
tags.append(checkpoint["idx2pos"][predicted[token_index].item()])
previous = word_index
print(list(zip(words, tags)))
Толық classifier құрылымы checkpoint-тегі model_state_dict, config және idx2pos мәндерімен қалпына келтіріледі.
Қолжетімділік
Карточка мен файлдар тізімі ашық. Салмақтарды жүктеу үшін «Request access» өтінімін жіберу керек; оны TilQazyna командасы қарайды.
Байланысты репозиторийлер
Оқыту дерегі — kaz-pos-corpus. Байланысты модельдер: kazakh-pos-xlm-roberta және сервис коды бар kazakh-pos-tagger.
Русский
xlm-roberta-kazakh-pos — модели XLM-RoBERTa и материалы оценки для присвоения грамматического тега каждому слову казахского предложения. Репозиторий занимает 1.11 ГБ; accuracy базовой модели — 91.60%, F1 — 91.31%, у large-версии — 92.04% и 91.85% соответственно.
Устройство и данные обучения
Checkpoint хранится в файле kazakh_pos_model_complete.pt. Модель объединяет subword-токены на уровне слов и выбирает одну из 18 грамматических категорий.
| Вариант | Базовая модель | Параметров | Hidden size | Accuracy | F1 |
|---|---|---|---|---|---|
| Base | xlm-roberta-base |
около 270M | 768 | 91.60% | 91.31% |
| Large | xlm-roberta-large |
около 560M | 1024 | 92.04% | 91.85% |
Обучающий набор содержит 1,147 предложений: 70% отведено для обучения, 10% для validation и 20% для теста. На тесте оценено 4,107 слов, из которых базовая модель верно разметила 3,762.
Как запустить
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoModel, AutoTokenizer
class POSTagger(nn.Module):
def __init__(self, num_tags):
super().__init__()
self.encoder = AutoModel.from_pretrained("xlm-roberta-base")
self.dropout = nn.Dropout(0.1)
self.classifier = nn.Linear(768, num_tags)
def forward(self, input_ids, attention_mask):
encoded = self.encoder(
input_ids=input_ids,
attention_mask=attention_mask,
).last_hidden_state
return self.classifier(self.dropout(encoded))
checkpoint_path = hf_hub_download(
repo_id="TilQazyna/xlm-roberta-kazakh-pos",
filename="kazakh_pos_model_complete.pt",
)
checkpoint = torch.load(checkpoint_path, map_location="cpu")
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base")
model = POSTagger(checkpoint["config"]["num_tags"])
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
words = ["Демек", "Құнанбай", "тірі", "адам", "еді"]
inputs = tokenizer(
words,
is_split_into_words=True,
truncation=True,
max_length=128,
return_tensors="pt",
)
with torch.no_grad():
predicted = model(**inputs).argmax(dim=-1)[0]
tags = []
previous = None
for token_index, word_index in enumerate(inputs.word_ids()):
if word_index is not None and word_index != previous:
tags.append(checkpoint["idx2pos"][predicted[token_index].item()])
previous = word_index
print(list(zip(words, tags)))
Полная структура classifier восстанавливается по model_state_dict, config и idx2pos из checkpoint.
Доступ
Карточка и перечень файлов видны всем. Для загрузки весов требуется заявка через «Request access», которую рассматривает команда TilQazyna.
Связанные репозитории
Данные обучения — kaz-pos-corpus. Связанные модели: kazakh-pos-xlm-roberta и kazakh-pos-tagger с кодом сервиса.
English
xlm-roberta-kazakh-pos provides XLM-RoBERTa models and evaluation artifacts for assigning a grammatical tag to each word in a Kazakh sentence. The repository occupies 1.11 GB; the base model reaches 91.60% accuracy and 91.31% F1, while the large variant reaches 92.04% and 91.85%, respectively.
Architecture and training data
The checkpoint is stored in kazakh_pos_model_complete.pt. The model reconstructs word-level predictions from subword tokens and selects one of 18 grammatical categories.
| Variant | Base model | Parameters | Hidden size | Accuracy | F1 |
|---|---|---|---|---|---|
| Base | xlm-roberta-base |
about 270M | 768 | 91.60% | 91.31% |
| Large | xlm-roberta-large |
about 560M | 1024 | 92.04% | 91.85% |
The training dataset contains 1,147 sentences, split into 70% training, 10% validation, and 20% test portions. Evaluation covers 4,107 test words, of which the base model labels 3,762 correctly.
Running the checkpoint
import torch
import torch.nn as nn
from huggingface_hub import hf_hub_download
from transformers import AutoModel, AutoTokenizer
class POSTagger(nn.Module):
def __init__(self, num_tags):
super().__init__()
self.encoder = AutoModel.from_pretrained("xlm-roberta-base")
self.dropout = nn.Dropout(0.1)
self.classifier = nn.Linear(768, num_tags)
def forward(self, input_ids, attention_mask):
encoded = self.encoder(
input_ids=input_ids,
attention_mask=attention_mask,
).last_hidden_state
return self.classifier(self.dropout(encoded))
checkpoint_path = hf_hub_download(
repo_id="TilQazyna/xlm-roberta-kazakh-pos",
filename="kazakh_pos_model_complete.pt",
)
checkpoint = torch.load(checkpoint_path, map_location="cpu")
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base")
model = POSTagger(checkpoint["config"]["num_tags"])
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
words = ["Демек", "Құнанбай", "тірі", "адам", "еді"]
inputs = tokenizer(
words,
is_split_into_words=True,
truncation=True,
max_length=128,
return_tensors="pt",
)
with torch.no_grad():
predicted = model(**inputs).argmax(dim=-1)[0]
tags = []
previous = None
for token_index, word_index in enumerate(inputs.word_ids()):
if word_index is not None and word_index != previous:
tags.append(checkpoint["idx2pos"][predicted[token_index].item()])
previous = word_index
print(list(zip(words, tags)))
The complete classifier is reconstructed from the checkpoint’s model_state_dict, config, and idx2pos values.
Access
The card and file listing remain public. Weight downloads require a “Request access” application reviewed by the TilQazyna team.
Related repositories
Training data comes from kaz-pos-corpus. Related models are kazakh-pos-xlm-roberta and the service-code repository kazakh-pos-tagger.
Лицензия · License: mit · TilQazyna
Collection including TilQazyna/xlm-roberta-kazakh-pos
Evaluation results
- Accuracy (Base Model) on Kazakh POS Tagging Datasetself-reported0.916
- F1 Score (Base Model) on Kazakh POS Tagging Datasetself-reported0.913