CoolFace
Modelpublic

NaolBM/Geez-BBPE

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
Model Card

๐Ÿš€ Geez-BBPE Tokenizer (NaolBM/Geez-BBPE)

A highly efficient Byte-Level BPE tokenizer specifically trained for Geez-script languages (Amharic, Tigrinya). With 25,000 vocabulary size, it achieves 3.67 chars/token on Amharic text - significantly outperforming generic tokenizers.

๐Ÿ“Š Benchmark Comparison

ModelTokensChars/Token
Geez-BBPE (Ours)94.00
Qwen3470.77
Llama-3.2870.41
gemma-3172.12
gpt-oss650.55

Sample: "แ‹จแŠขแ‰ตแ‹ฎแŒตแ‹ซ แ‰ณแˆชแŠญ แ‰ แŒฃแˆ แˆจแŒ…แˆ แŠฅแŠ“ แ‰ฃแˆˆแ‰ฅแ‹™ แ‹ฐแˆจแŒƒแ‹Žแ‰ฝ แАแ‹แข" (8 characters)

๐Ÿง  Why Geez-BBPE?

Byte-Pair Encoding (BPE) tokenizers trained on English or Latin-script languages often fail to tokenize Geez-script languages efficiently, breaking words into meaningless byte sequences.

Geez-BBPE solves this by:

  • โ€”โœ… Preserving semantic meaning - common words are single tokens
  • โ€”โœ… Reducing sequence length - fit more text in same context
  • โ€”โœ… Faster inference - fewer tokens = faster generation
  • โ€”โœ… Better learning - model sees whole words, not fragments
  • โ€”โœ… Native support - trained on 10M+ authentic Amharic sentences

๐Ÿ“š Training Details

  • โ€”Tokenizer Type: Byte-Level BPE
  • โ€”Vocabulary Size: 25,000 (optimized for Geez script)
  • โ€”Training Data: 10M+ sentences from b1n1yam/amharic-combined-corpus
  • โ€”Pre-tokenizer: Byte-Level with space preservation
  • โ€”Special Tokens: <|startoftext|>, <|im_end|>, <|pad|>

๐Ÿ“ Files

  • โ€”tokenizer.json: Full tokenizer config
  • โ€”tokenizer_config.json: Hugging Face-compatible configuration
  • โ€”special_tokens_map.json: Maps for special tokens

๐Ÿš€ Usage

Standalone Usage

python
from transformers import AutoTokenizer

# Load Geez-BBPE tokenizer
tokenizer = AutoTokenizer.from_pretrained("NaolBM/Geez-BBPE")

# Tokenize Amharic text efficiently!
text = "แŠขแ‰ตแ‹ฎแŒตแ‹ซ แ‹‹แŠ“ แŠจแ‰ฐแˆ›แ‹‹ แŠ แ‹ฒแˆต แŠ แ‰ แ‰ฃ แŠ“แ‰ตแข"
tokens = tokenizer.tokenize(text)
ids = tokenizer.encode(text)

print(f"Tokens ({len(tokens)}): {tokens}")
print(f"Token IDs: {ids}")

Extending Other Models with Geez-BBPE

If you want to extend another model's tokenizer (like Qwen, llama, LMF etc...) using Geez-BBPE:

python
from transformers import AutoTokenizer, AutoModelForCausalLM

# Load tokenizers
geez = AutoTokenizer.from_pretrained("NaolBM/Geez-BBPE")
target = AutoTokenizer.from_pretrained("your-target-model")

new_tokens_ids = [
    id for id in range(geez.vocab_size)
    if geez.decode([id]) not in target.all_special_tokens
]

# ๐Ÿ”‘ CRITICAL: Decode Geez tokens to readable Amharic before adding!
# decode() converts 'ฤ รกฤฌล‚...' back to " แŠ แ‰ แ‰ฃ" or "แŠ แ‹ฒแˆต"
tokens_to_add = [geez.decode([id]) for id in new_tokens_ids]

# Remove duplicates
decoded_tokens = list(set(tokens_to_add))
print(f"Adding {len(decoded_tokens)} Amharic tokens")

# Add to target tokenizer
target.add_tokens(decoded_tokens)

# Resize model
model = AutoModelForCausalLM.from_pretrained("your-target-model")
model.resize_token_embeddings(len(target))

โŒ Common Mistake to Avoid

python
# WRONG: Adding raw byte tokens (they won't match input text!)
target.add_tokens(list(geez.get_vocab().keys()))  
# This adds things like 'รกฤฌล‚รกฤญยฒรกฤชยต' - the tokenizer will NEVER find these in text!

# RIGHT: Decode first, then add
decoded = geez.decode([token_id])  # Converts 'รกฤฌล‚รกฤญยฒรกฤชยต' โ†’ 'แŠ แ‹ฒแˆต'
target.add_tokens([decoded])  # Now matches actual input text!

Why this works: Geez-BBPE stores tokens as byte-level strings internally, but the tokenizer looks for actual Amharic text in the input. decode() bridges this gap by converting byte representations back to readable characters.

๐Ÿ“Š Intended Use

This tokenizer is best suited for:

  • โ€”Low-resource NLP pipelines
  • โ€”Machine Translation
  • โ€”Question Answering
  • โ€”Named Entity Recognition
  • โ€”Morphological analysis
  • โ€”Continued Pre-Training (CPT) for Amharic/Tigrinya

โš ๏ธ Limitations

  • โ€”Optimized for Geez-script languages (Amharic, Tigrinya) - may not generalize to others
  • โ€”Some compound words may still benefit from linguistic preprocessing
  • โ€”Currently focused on Amharic/Tigrinya; doesn't support multilingual code-switching

โœ… Evaluation

The tokenizer was evaluated on:

  • โ€”Token coverage of Amharic/Tigrinya corpora
  • โ€”Morphological preservation
  • โ€”Character-to-token ratio (target: >3.0 chars/token)
  • โ€”Real-world downstream task performance

๐Ÿ“œ License

This tokenizer is licensed under the MIT License.

๐Ÿ“Œ Citation

bibtex
@misc{naol2025geezbbpe,
  title={Geez-BBPE: An Efficient Byte-Level BPE Tokenizer for Amharic and Tigrinya},
  author={Naol},
  year={2026},
  howpublished={\url{https://huggingface.co/NaolBM/Geez-BBPE}},
}

๐Ÿ™ Acknowledgments

  • โ€”Built with ๐Ÿค— Hugging Face Transformers
  • โ€”Trained on b1n1yam/amharic-combined-corpus
  • โ€”Optimized for efficient Amharic NLP
  • โ€”Inspired by the Ethiopian AI community's need for better language tools

<div align="center"> <h3>โญ If you find this useful, please star the repo! โญ</h3> <p>Made with โค๏ธ for Ethiopian AI</p> </div>