Instructions to use Grundik/abkhaz-lemma-byt5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Grundik/abkhaz-lemma-byt5 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="Grundik/abkhaz-lemma-byt5")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Grundik/abkhaz-lemma-byt5") model = AutoModelForSeq2SeqLM.from_pretrained("Grundik/abkhaz-lemma-byt5", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Abkhaz Lemmatizer (ByT5-small)
A lemmatizer for the Abkhaz language (ISO 639-1: ab), fine-tuned from ByT5-small.
Abkhaz is a Northwest Caucasian polysynthetic language — a single verb form can encode subject, object, direction, tense, and negation. ByT5 operates directly on UTF-8 bytes, avoiding the <unk> token problem that plagues vocabulary-based tokenizers on low-resource scripts.
Model Details
- Base model:
google/byt5-small(300M parameters) - Task: Sequence-to-sequence lemmatization
- Input format:
POS: {upos} WORD: {word} - Output format:
{lemma}
Why ByT5?
Standard T5/mT5 models use SentencePiece vocabularies that lack Abkhaz-specific letters (ҩ, ҵ, ҷ, ԥ, ҕ, etc.), causing them to collapse into <unk> tokens. ByT5 works at the byte level, seeing every character natively, making it an ideal fit for polysynthetic languages with rich, non-Latin orthographies.
Training
- Training samples: 10,335 (word -> lemma pairs)
- Evaluation samples: 1,355
- Epochs: 10 | Batch size: 8 | Learning rate: 1e-4
- Precision: BF16
- Hardware: NVIDIA RTX 5060 Ti (16 GB)
Usage
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
model_id = "Grundik/abkhaz-lemma-byt5"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
def lemmatize(word: str, pos: str = "NOUN") -> str:
prompt = f"POS: {pos} WORD: {word}"
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
inputs.input_ids,
attention_mask=inputs.attention_mask,
max_length=64,
num_beams=4,
early_stopping=True,
)
return tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
print(lemmatize("дцеит", "VERB"))
print(lemmatize("аҳәынҭқарра", "NOUN"))
Training Data
The model was trained on word-form -> lemma pairs extracted from the UD_Abkhaz-AbNC treebank, a subset of the Abkhaz National Corpus annotated in the Universal Dependencies format.
- Repository: UniversalDependencies/UD_Abkhaz-AbNC
- Source: Abkhaz newspaper archives, digitized in collaboration with the National Library of Abkhazia.
Limitations & Recommendations
- Trained on ~10k unique pairs. For a polysynthetic language, this covers only a fraction of possible inflectional paradigms.
- Recommended Architecture: Use a rule-based morphological generator as the primary tool for exact lookup, with this ByT5 model as a fallback for out-of-vocabulary or OCR-noisy forms.
Citation
@misc{UD_Abkhaz-AbNC,
author = {Universal Dependencies},
title = {UD Abkhaz-AbNC},
url = {https://github.com/UniversalDependencies/UD_Abkhaz-AbNC},
year = {2024}
}
Author
Trained by Marat Ionov as part of a project on the digital infrastructure of the Abkhaz language (OCR, morphology, newspaper layout analysis).
License
MIT
- Downloads last month
- 93