140 lines
4.8 KiB
Markdown
140 lines
4.8 KiB
Markdown
---
|
|
tags:
|
|
- hindi
|
|
- devanagari
|
|
- brahmi
|
|
- qwen2.5
|
|
- transformers
|
|
- safetensors
|
|
- edge-ai
|
|
- india
|
|
- llm
|
|
- pytorch
|
|
license: apache-2.0
|
|
language:
|
|
- hi
|
|
- en
|
|
pipeline_tag: text-generation
|
|
library_name: transformers
|
|
---
|
|
|
|
<p align="center">
|
|
<img src="https://img.shields.io/badge/Model_Size-1.5B-blue?style=flat-square">
|
|
<img src="https://img.shields.io/badge/Format-PyTorch_Safetensors-brightgreen?style=flat-square">
|
|
<img src="https://img.shields.io/badge/Hindi_Compression-33.8%25-orange?style=flat-square">
|
|
<img src="https://img.shields.io/badge/License-Apache_2.0-success?style=flat-square">
|
|
<img src="https://img.shields.io/badge/Made_by-eulogik-purple?style=flat-square">
|
|
</p>
|
|
|
|
<h1 align="center">🇮🇳 Bharat-Tiny-LLM v2 (PyTorch / Transformers Base)</h1>
|
|
<p align="center"><em>1.5B Parameter Open-Weights Indic LLM featuring Brahmi Token Injection for 33.8% token compression and +36% faster Hindi inference.</em></p>
|
|
|
|
---
|
|
|
|

|
|
|
|
---
|
|
|
|
## 🎯 Model Overview
|
|
|
|
**Bharat-Tiny-LLM v2** is an open-weights 1.5B parameter language model built on top of Qwen2.5-1.5B, optimized specifically for Hindi and Hinglish text generation.
|
|
|
|
By introducing **Brahmi Token Injection** — a technique that surgically injects 300 Devanagari subword tokens into the model's vocabulary — Bharat-Tiny-LLM v2 eliminates the severe "Token Tax" imposed by standard English-centric tokenizers on Indian scripts.
|
|
|
|
This repository contains the **unquantized PyTorch / HuggingFace Transformers open weights**, compatible with Linux, Windows, CUDA GPUs, vLLM, TGI, and Google Colab.
|
|
|
|
---
|
|
|
|
## 🎨 Architectural Pipeline & Training Methodology
|
|
|
|

|
|
|
|
### Interactive Training Pipeline Flowchart
|
|
|
|
```mermaid
|
|
flowchart LR
|
|
A["Raw Hindi Corpus"] --> B["Brahmi Subword Mining<br>(Top 300 Devanagari Tokens)"]
|
|
B --> C["Tokenizer Vocabulary Expansion<br>(151,936 ➔ 152,236)"]
|
|
C --> D["Stage 1: Embedding Alignment<br>(Freeze Backbone, Train 300 Embeddings)"]
|
|
D --> E["Stage 2: LoRA Fine-Tuning<br>(Rank=16 on Attention q,k,v,o proj)"]
|
|
E --> F["Fused PyTorch Base Weights<br>(eulogik/Bharat-Tiny-LLM-v2)"]
|
|
F --> G["Q4 Affine Quantization<br>(eulogik/Bharat-Tiny-LLM-v2-MLX)"]
|
|
```
|
|
|
|
---
|
|
|
|
## ✨ Key Benchmarks & Technical Advantages
|
|
|
|
| Metric | Base Qwen2.5-1.5B | Bharat-Tiny-LLM v2 | Technical Advantage |
|
|
|:---|:---|:---|:---|
|
|
| **Tokens for 1,000 Hindi Chars** | ~950 tokens | **~630 tokens** | **33.8% Fewer Tokens (up to 58% on chat prompts)** |
|
|
| **Inference Throughput (Hindi)** | 50 tok/s | **68 tok/s** | **+36% Speed Boost** |
|
|
| **Validation Loss (Hindi Corpus)** | 2.776 | **1.837** | **52.5% Loss Reduction (Perplexity: 16.1 → 6.3)** |
|
|
| **Hardware Compatibility** | CUDA / CPU / MPS | CUDA / CPU / MPS | **Universal PyTorch / vLLM / GGUF support** |
|
|
|
|
---
|
|
|
|
## 🚀 Quick Start with PyTorch & Transformers
|
|
|
|
```python
|
|
import torch
|
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
model_name = "eulogik/Bharat-Tiny-LLM-v2"
|
|
|
|
# Load Tokenizer & Model Weights
|
|
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
model = AutoModelForCausalLM.from_pretrained(
|
|
model_name,
|
|
torch_dtype=torch.float16,
|
|
device_map="auto"
|
|
)
|
|
|
|
# Generate Hindi Text
|
|
prompt = "भारत की सांस्कृतिक विविधता के बारे में बताइए:"
|
|
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
|
|
|
outputs = model.generate(
|
|
**inputs,
|
|
max_new_tokens=150,
|
|
temperature=0.7,
|
|
do_sample=True
|
|
)
|
|
|
|
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Token Compression Benchmarks
|
|
|
|
| Prompt (Hindi / Hinglish) | Base Qwen Tokens | Bharat-v2 Tokens | Savings |
|
|
|:---|:---|:---|:---|
|
|
| `"ज़रूरी बात है क्या करते हो"` | 26 tokens | **11 tokens** | **58% Savings** |
|
|
| `"नमस्ते, आप कैसे हैं?"` | 15 tokens | **7 tokens** | **53% Savings** |
|
|
| `"भारत की राजधानी नई दिल्ली है"` | 22 tokens | **14 tokens** | **36% Savings** |
|
|
| `"bhai aaj ka weather kaisa hai?"` | 12 tokens | **8 tokens** | **33% Savings** |
|
|
|
|
---
|
|
|
|
## 🔗 Model Family Repositories
|
|
|
|
- **Apple Silicon MLX Quantized (880MB)**: [`eulogik/Bharat-Tiny-LLM-v2-MLX`](https://huggingface.co/eulogik/Bharat-Tiny-LLM-v2-MLX)
|
|
- **GGUF / llama.cpp**: [`eulogik/Bharat-Tiny-LLM-GGUF`](https://huggingface.co/eulogik/Bharat-Tiny-LLM-GGUF)
|
|
|
|
---
|
|
|
|
## 📜 License & Citation
|
|
|
|
Licensed under **Apache 2.0**. Free for commercial, enterprise, and research use.
|
|
|
|
```bibtex
|
|
@misc{kishore2026brahmi,
|
|
title={Brahmi: Efficient Devanagari Token Injection for Multilingual LLMs},
|
|
author={Gautam Kishore},
|
|
year={2026},
|
|
publisher={eulogik},
|
|
howpublished={\url{https://huggingface.co/eulogik/Bharat-Tiny-LLM-v2}}
|
|
}
|
|
```
|