Text Generation
MLX
Safetensors
Hindi
English
Chhattisgarhi
qwen2
hinglish
hindi
indian-languages
edge-ai
small-language-model
on-device-ai
apple-silicon
lora
qwen
bharat
indic-nlp
low-resource
conversational
offline
lightweight
android
Instructions to use eulogik/Bharat-Tiny-LLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use eulogik/Bharat-Tiny-LLM with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("eulogik/Bharat-Tiny-LLM") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use eulogik/Bharat-Tiny-LLM with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "eulogik/Bharat-Tiny-LLM"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "eulogik/Bharat-Tiny-LLM" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use eulogik/Bharat-Tiny-LLM with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "eulogik/Bharat-Tiny-LLM"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "eulogik/Bharat-Tiny-LLM" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "eulogik/Bharat-Tiny-LLM", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use eulogik/Bharat-Tiny-LLM with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "eulogik/Bharat-Tiny-LLM"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default eulogik/Bharat-Tiny-LLM
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use eulogik/Bharat-Tiny-LLM with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "eulogik/Bharat-Tiny-LLM"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "eulogik/Bharat-Tiny-LLM" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Add files using upload-large-folder tool
Browse files- README.md +14 -277
- chat_template.jinja +1 -1
- config.json +39 -5
- generation_config.json +5 -0
- model.safetensors +2 -2
- tokenizer_config.json +1 -1
README.md
CHANGED
|
@@ -1,294 +1,31 @@
|
|
| 1 |
---
|
| 2 |
-
language:
|
| 3 |
-
|
| 4 |
-
- en
|
| 5 |
-
language_bcp47:
|
| 6 |
-
- en-hi
|
| 7 |
pipeline_tag: text-generation
|
| 8 |
tags:
|
| 9 |
-
- hinglish
|
| 10 |
-
- hindi
|
| 11 |
-
- indian-languages
|
| 12 |
-
- edge-ai
|
| 13 |
-
- mac-mini
|
| 14 |
-
- lora
|
| 15 |
-
- qwen2.5
|
| 16 |
-
- small-language-model
|
| 17 |
-
- on-device-ai
|
| 18 |
-
- apple-silicon
|
| 19 |
- mlx
|
| 20 |
-
- fine-tuned-llm
|
| 21 |
-
- lightweight
|
| 22 |
-
- edge-deployment
|
| 23 |
-
- low-resource
|
| 24 |
-
- nlp
|
| 25 |
-
- conversation
|
| 26 |
-
- india
|
| 27 |
-
- bharat
|
| 28 |
-
- tiny-llm
|
| 29 |
-
- hinglish-chat
|
| 30 |
-
license: apache-2.0
|
| 31 |
-
library_name: mlx
|
| 32 |
-
model-index:
|
| 33 |
-
- name: Bharat-Tiny-LLM
|
| 34 |
-
results: []
|
| 35 |
-
datasets:
|
| 36 |
-
- ankitdhiman/hinglish-conversations
|
| 37 |
-
- maya-research/IndicVault
|
| 38 |
-
- Sujalvc/hinglish-instruct-dataset
|
| 39 |
-
- Subh24ai/yojana-sahayak-instruct
|
| 40 |
-
- VishalMysore/cookGPT
|
| 41 |
-
inference:
|
| 42 |
-
parameters:
|
| 43 |
-
temperature: 0.7
|
| 44 |
-
max_tokens: 200
|
| 45 |
-
widget:
|
| 46 |
-
- text: "Chai peete hain?"
|
| 47 |
-
example_title: Chai
|
| 48 |
-
- text: "Kal interview hai, nervous ho raha hoon"
|
| 49 |
-
example_title: Interview Nerves
|
| 50 |
-
- text: "Biryani kaise banate hain?"
|
| 51 |
-
example_title: Biryani Recipe
|
| 52 |
-
- text: "Delhi me rehne ke liye kya karna padega?"
|
| 53 |
-
example_title: Delhi Living
|
| 54 |
-
- text: "Mujhe Hindi seekhni hai"
|
| 55 |
-
example_title: Learn Hindi
|
| 56 |
-
---
|
| 57 |
-
|
| 58 |
-
# Bharat-Tiny-LLM 🇮🇳
|
| 59 |
-
|
| 60 |
-
**Hinglish AI — trained on a Mac Mini M4, runs on ₹8,000 phones.**
|
| 61 |
-
|
| 62 |
-
[](https://huggingface.co/spaces/eulogik/Bharat-Tiny-LLM)
|
| 63 |
-

|
| 64 |
-

|
| 65 |
-

|
| 66 |
-

|
| 67 |
-

|
| 68 |
-

|
| 69 |
-
|
| 70 |
-
---
|
| 71 |
-
|
| 72 |
-
## The Story
|
| 73 |
-
|
| 74 |
-
**I trained an AI to speak Hinglish on a Mac Mini. No cloud compute. No GPU cluster. Just $750 of Apple Silicon and a lot of chai.**
|
| 75 |
-
|
| 76 |
-
This is **Bharat-Tiny-LLM** — a Qwen2.5-1.5B model fine-tuned on 376K Hinglish conversations. Quantized to **828 MB** (Q4), it delivers **~57 tokens/second** on a Mac Mini M4 and is small enough to run on an ₹8,000 smartphone.
|
| 77 |
-
|
| 78 |
-
Most AI models today are skyscrapers — built by billion-dollar companies, requiring data centers, and serving only English. **We built a bicycle.** A tiny, efficient, open-source model that speaks the way 600 million Indians actually talk: Hinglish.
|
| 79 |
-
|
| 80 |
-
### What Makes This Different
|
| 81 |
-
|
| 82 |
-
| | Big AI | Bharat-Tiny-LLM |
|
| 83 |
-
|---|---|---|
|
| 84 |
-
| **Hardware** | $100M GPU clusters | Mac Mini M4 (16GB) |
|
| 85 |
-
| **Cloud Cost** | Millions | **$0** |
|
| 86 |
-
| **Language** | English only | Hinglish (हिंग्लिश) |
|
| 87 |
-
| **Model Size** | 70B–405B params | **1.5B** (828 MB Q4) |
|
| 88 |
-
| **Device** | Data centers | **₹8,000 phones** |
|
| 89 |
-
| **Speed** | API latency | **57 tok/s on-device** |
|
| 90 |
-
| **License** | Proprietary/Research | **Apache 2.0** |
|
| 91 |
-
|
| 92 |
-
---
|
| 93 |
-
|
| 94 |
-
## Model Details
|
| 95 |
-
|
| 96 |
-
### Architecture
|
| 97 |
-
|
| 98 |
-
- **Base Model:** [Qwen2.5-1.5B](https://huggingface.co/Qwen/Qwen2.5-1.5B) (Apache 2.0)
|
| 99 |
-
- **Fine-Tuning Method:** LoRA (16 layers, rank 8, alpha 16)
|
| 100 |
-
- **Training Hardware:** Mac Mini M4, 16GB unified memory
|
| 101 |
-
- **Training Duration:** ~3.3 days for 76K iterations
|
| 102 |
-
- **Quantization:** 4-bit (Q4) via MLX — 4.501 bits/weight
|
| 103 |
-
- **Total Trainable Parameters:** 5.276M (0.342% of base)
|
| 104 |
-
|
| 105 |
-
<details>
|
| 106 |
-
<summary>Base model details (click to expand)</summary>
|
| 107 |
-
|
| 108 |
-
This model is fine-tuned from [Qwen2.5-1.5B](https://huggingface.co/Qwen/Qwen2.5-1.5B) (Apache 2.0), one of the few small models with native multilingual support (29 languages including Hindi). Unlike English-only models (like SmolLM2, which we tried first — val loss plateaued at 1.32), Qwen2.5 already understands Hindi morphology. LoRA fine-tuning on Hinglish data was enough to make it conversational.
|
| 109 |
-
|
| 110 |
-
</details>
|
| 111 |
-
|
| 112 |
-
### Performance
|
| 113 |
-
|
| 114 |
-
| Metric | Value |
|
| 115 |
-
|--------|-------|
|
| 116 |
-
| Training Data | 376,040 conversations |
|
| 117 |
-
| Validation Loss | **0.781** (best at 75K iters) |
|
| 118 |
-
| Inference Speed | **~57 tok/s** (Mac Mini M4) |
|
| 119 |
-
| Model Size | **828 MB** (Q4 quantized) |
|
| 120 |
-
| Memory Usage | ~1.2 GB at inference |
|
| 121 |
-
| Context Length | 512 tokens |
|
| 122 |
-
|
| 123 |
---
|
| 124 |
|
| 125 |
-
#
|
| 126 |
|
| 127 |
-
##
|
| 128 |
|
| 129 |
```bash
|
| 130 |
pip install mlx-lm
|
| 131 |
-
|
| 132 |
-
python3 -c "
|
| 133 |
-
from mlx_lm import load, generate
|
| 134 |
-
from mlx_lm.sample_utils import make_sampler
|
| 135 |
-
|
| 136 |
-
model, tokenizer = load('eulogik/Bharat-Tiny-LLM')
|
| 137 |
-
sampler = make_sampler(temp=0.7)
|
| 138 |
-
|
| 139 |
-
prompt = '<|im_start|>user\nChai peete hain?<|im_end|>\n<|im_start|>assistant\n'
|
| 140 |
-
response = generate(model, tokenizer, prompt=prompt, max_tokens=200, sampler=sampler)
|
| 141 |
-
print(response)
|
| 142 |
-
"
|
| 143 |
```
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
| Platform | Status | Instructions |
|
| 148 |
-
|----------|--------|-------------|
|
| 149 |
-
| macOS (Apple Silicon) | ✅ Works | Use `mlx-lm` (above) |
|
| 150 |
-
| Linux / Windows | 🔄 Coming | Need transformers-compatible bf16 export |
|
| 151 |
-
| Android | 🔄 Coming | MLX Android bindings in development |
|
| 152 |
-
| Raspberry Pi 5 | 🔄 Coming | Testing in progress |
|
| 153 |
-
|
| 154 |
-
---
|
| 155 |
-
|
| 156 |
-
## Example Outputs
|
| 157 |
-
|
| 158 |
-
| Prompt | Response | Quality |
|
| 159 |
-
|--------|----------|---------|
|
| 160 |
-
| "Kal interview hai, nervous ho raha hoon" | "Chill maaro, you'll be alright. Bas apne aap ko confident rakhna aur jo aata hai woh bol dena. Sab theek hoga." | ✅ |
|
| 161 |
-
| "Biryani kaise banate hain?" | Gives structured recipe with ingredients list and step-by-step instructions in Hinglish | ✅ |
|
| 162 |
-
| "Delhi me rehne ke liye kya karna padega?" | Specific advice on metro, parking, traffic, and areas to live | ✅ |
|
| 163 |
-
| "Weekend pe kya karein?" | 10 ideas with examples — museums, parks, street food, movies | ✅ |
|
| 164 |
-
| "Mujhe Hindi seekhni hai" | Practical listening tips, YouTube channels, and practice strategies | ✅ |
|
| 165 |
-
| "Chai peetey hain?" | Full chai recipe with proportions and tips | ✅ |
|
| 166 |
-
| "Mera phone charge nahi ho raha" | Troubleshooting steps (though slightly repetitive) | ⚠️ |
|
| 167 |
-
| "Job nahi mil rahi" | Can get confused — still improving on emotional/career topics | ❌ |
|
| 168 |
-
|
| 169 |
-
---
|
| 170 |
-
|
| 171 |
-
## Training Data
|
| 172 |
-
|
| 173 |
-
We curated **376,040 conversations** from 5 open-source datasets, deduplicated and formatted as chat messages:
|
| 174 |
-
|
| 175 |
-
| Dataset | Samples | Domain |
|
| 176 |
-
|---------|---------|--------|
|
| 177 |
-
| [Hinglish Conversations](https://huggingface.co/datasets/ankitdhiman/hinglish-conversations) | 201,633 | Natural Hinglish dialogue |
|
| 178 |
-
| [IndicVault (Hindi)](https://huggingface.co/datasets/maya-research/IndicVault) | 74,053 | 20-topic Hindi QA |
|
| 179 |
-
| [IndicVault (Hinglish)](https://huggingface.co/datasets/maya-research/IndicVault) | 77,210 | 20-topic Hinglish QA |
|
| 180 |
-
| [Hinglish Instruct](https://huggingface.co/datasets/Sujalvc/hinglish-instruct-dataset) | 10,378 | Instruction tuning |
|
| 181 |
-
| [Yojana Sahayak](https://huggingface.co/datasets/Subh24ai/yojana-sahayak-instruct) | 6,828 | Government scheme info |
|
| 182 |
-
| [cookGPT](https://huggingface.co/datasets/VishalMysore/cookGPT) | 5,938 | Indian recipes |
|
| 183 |
-
|
| 184 |
-
All data was:
|
| 185 |
-
- Trimmed to 512 characters per message (to fit within model context)
|
| 186 |
-
- Converted to `messages` format with `user`/`assistant` roles
|
| 187 |
-
- Split 95% train / 5% validation
|
| 188 |
-
|
| 189 |
-
---
|
| 190 |
-
|
| 191 |
-
## Training Details
|
| 192 |
-
|
| 193 |
-
### Hyperparameters
|
| 194 |
-
|
| 195 |
-
```
|
| 196 |
-
Base model: Qwen2.5-1.5B (bf16 from mlx-community)
|
| 197 |
-
Method: LoRA (16 layers, rank 8, alpha 16)
|
| 198 |
-
Batch size: 4
|
| 199 |
-
Seq length: 512
|
| 200 |
-
Learning rate: 5e-5 (with cosine schedule)
|
| 201 |
-
Iterations: 76,420
|
| 202 |
-
Optimizer: AdamW
|
| 203 |
-
Warmup: 100 steps
|
| 204 |
-
Seed: 42
|
| 205 |
-
```
|
| 206 |
-
|
| 207 |
-
### Training Curve
|
| 208 |
-
|
| 209 |
-
```
|
| 210 |
-
Val Loss
|
| 211 |
-
1.25 | █
|
| 212 |
-
1.20 | ██
|
| 213 |
-
1.15 | ███
|
| 214 |
-
1.10 | ████
|
| 215 |
-
1.05 | █████
|
| 216 |
-
1.00 | ██████
|
| 217 |
-
0.95 | ████████
|
| 218 |
-
0.90 | ██████████
|
| 219 |
-
0.85 | ████████████
|
| 220 |
-
0.80 | ██████████████
|
| 221 |
-
0.78 | ████████████████ ← Best at 75K iters
|
| 222 |
-
+------------------------
|
| 223 |
-
0 20K 40K 60K 80K
|
| 224 |
-
```
|
| 225 |
-
|
| 226 |
-
### Speed Optimization
|
| 227 |
-
|
| 228 |
-
| Config | it/s | Memory | Notes |
|
| 229 |
-
|--------|------|--------|-------|
|
| 230 |
-
| batch=2, seq=1024 | 0.30 | 10.7 GB | Initial config |
|
| 231 |
-
| batch=8, seq=256 | 0.24 | 10.0 GB | Too much overhead |
|
| 232 |
-
| **batch=4, seq=512** | **0.30** | **10.3 GB** | **Final — best balance** |
|
| 233 |
-
| batch=4, seq=1024 | OOM | — | Exceeded Metal GPU |
|
| 234 |
-
|
| 235 |
-
---
|
| 236 |
-
|
| 237 |
-
## Limitations
|
| 238 |
-
|
| 239 |
-
1. **Not fully converged** — Only 76K iterations; val loss was still decreasing at 0.781. More training (target: 110K) would help.
|
| 240 |
-
2. **Occasional English drift** — Some responses switch entirely to English. Needs more Hinglish-only examples.
|
| 241 |
-
3. **Telugu leakage** — IndicVault Hindi data contains some Telugu examples that leak into responses.
|
| 242 |
-
4. **Emotional/career topics** — Responses to queries about jobs, relationships, or mental health can be confused or repetitive.
|
| 243 |
-
5. **Short context** — 512 token limit prevents multi-turn conversations or long-form generation.
|
| 244 |
-
6. **MLX format only** — The Q4 quantized model is in Apple MLX format. We plan to release a transformers-compatible version.
|
| 245 |
-
7. **Not instruction-tuned** — This is a base model fine-tuned on conversations, not RLHF/DPO-tuned. Responses are helpful but not aligned.
|
| 246 |
-
|
| 247 |
-
---
|
| 248 |
-
|
| 249 |
-
## Roadmap
|
| 250 |
-
|
| 251 |
-
- [x] **Phase 0:** Fine-tune Qwen2.5-1.5B with LoRA on Hinglish data
|
| 252 |
-
- [x] **Phase 1:** Quantize to Q4 (828 MB) for edge deployment
|
| 253 |
-
- [ ] **Phase 2:** Extend to 8 Indian languages (Tamil, Telugu, Bengali, Marathi, etc.)
|
| 254 |
-
- [ ] **Phase 3:** DPO/RLHF for quality improvement
|
| 255 |
-
- [ ] **Phase 4:** BharatTiny-Bench evaluation suite
|
| 256 |
-
- [ ] **Phase 5:** Web demo with Gradio
|
| 257 |
-
- [ ] **Phase 6:** Android / Raspberry Pi 5 deployment
|
| 258 |
-
|
| 259 |
-
---
|
| 260 |
-
|
| 261 |
-
## Why "Bharat-Tiny-LLM"?
|
| 262 |
-
|
| 263 |
-
600 million Indians speak Hinglish — a natural mix of Hindi and English. But every LLM today is either English-only or pure Hindi. There is no model that understands "Yaar, kal ka match dekh liya? Rohit ne toh maara!"
|
| 264 |
-
|
| 265 |
-
We built this because:
|
| 266 |
-
- **No one builds for edge devices in India.** Everyone targets data centers.
|
| 267 |
-
- **No one speaks Hinglish.** Everyone speaks either English or "pure" Hindi.
|
| 268 |
-
- **No one does it on a budget.** Everyone burns millions in cloud compute.
|
| 269 |
|
| 270 |
-
|
| 271 |
|
| 272 |
-
|
| 273 |
|
| 274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
-
|
| 277 |
-
@misc{bharat-tiny-llm-2026,
|
| 278 |
-
title = {Bharat-Tiny-LLM: Hinglish Edge AI Trained on a Mac Mini},
|
| 279 |
-
author = {Gautam Kishore},
|
| 280 |
-
year = {2026},
|
| 281 |
-
publisher = {Hugging Face},
|
| 282 |
-
url = {https://huggingface.co/eulogik/Bharat-Tiny-LLM}
|
| 283 |
-
}
|
| 284 |
```
|
| 285 |
-
|
| 286 |
-
---
|
| 287 |
-
|
| 288 |
-
## License
|
| 289 |
-
|
| 290 |
-
Apache 2.0 — Free for commercial and research use. The base model (Qwen2.5-1.5B) is also Apache 2.0.
|
| 291 |
-
|
| 292 |
-
---
|
| 293 |
-
|
| 294 |
-
*Built with chai ☕, patience 🧘, and a Mac Mini M4 💻 — somewhere in India.*
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
library_name: mlx
|
|
|
|
|
|
|
|
|
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- mlx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
+
# eulogik/Bharat-Tiny-LLM
|
| 10 |
|
| 11 |
+
## Use with mlx
|
| 12 |
|
| 13 |
```bash
|
| 14 |
pip install mlx-lm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
```
|
| 16 |
|
| 17 |
+
```python
|
| 18 |
+
from mlx_lm import load, generate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
model, tokenizer = load("eulogik/Bharat-Tiny-LLM")
|
| 21 |
|
| 22 |
+
prompt = "hello"
|
| 23 |
|
| 24 |
+
if tokenizer.chat_template is not None:
|
| 25 |
+
messages = [{"role": "user", "content": prompt}]
|
| 26 |
+
prompt = tokenizer.apply_chat_template(
|
| 27 |
+
messages, add_generation_prompt=True, return_dict=False,
|
| 28 |
+
)
|
| 29 |
|
| 30 |
+
response = generate(model, tokenizer, prompt=prompt, verbose=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chat_template.jinja
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
{{- "\n" }}
|
| 11 |
{{- tool | tojson }}
|
| 12 |
{%- endfor %}
|
| 13 |
-
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{
|
| 14 |
{%- else %}
|
| 15 |
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
|
|
|
| 10 |
{{- "\n" }}
|
| 11 |
{{- tool | tojson }}
|
| 12 |
{%- endfor %}
|
| 13 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
| 14 |
{%- else %}
|
| 15 |
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
config.json
CHANGED
|
@@ -4,17 +4,49 @@
|
|
| 4 |
],
|
| 5 |
"attention_dropout": 0.0,
|
| 6 |
"bos_token_id": 151643,
|
|
|
|
| 7 |
"eos_token_id": 151643,
|
| 8 |
"hidden_act": "silu",
|
| 9 |
"hidden_size": 1536,
|
| 10 |
"initializer_range": 0.02,
|
| 11 |
"intermediate_size": 8960,
|
| 12 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"max_window_layers": 28,
|
| 14 |
"model_type": "qwen2",
|
| 15 |
"num_attention_heads": 12,
|
| 16 |
"num_hidden_layers": 28,
|
| 17 |
"num_key_value_heads": 2,
|
|
|
|
| 18 |
"quantization": {
|
| 19 |
"group_size": 64,
|
| 20 |
"bits": 4,
|
|
@@ -26,11 +58,13 @@
|
|
| 26 |
"mode": "affine"
|
| 27 |
},
|
| 28 |
"rms_norm_eps": 1e-06,
|
| 29 |
-
"
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
"tie_word_embeddings": true,
|
| 32 |
-
"
|
| 33 |
-
"transformers_version": "4.40.1",
|
| 34 |
"use_cache": true,
|
| 35 |
"use_mrope": false,
|
| 36 |
"use_sliding_window": false,
|
|
|
|
| 4 |
],
|
| 5 |
"attention_dropout": 0.0,
|
| 6 |
"bos_token_id": 151643,
|
| 7 |
+
"dtype": "float16",
|
| 8 |
"eos_token_id": 151643,
|
| 9 |
"hidden_act": "silu",
|
| 10 |
"hidden_size": 1536,
|
| 11 |
"initializer_range": 0.02,
|
| 12 |
"intermediate_size": 8960,
|
| 13 |
+
"layer_types": [
|
| 14 |
+
"full_attention",
|
| 15 |
+
"full_attention",
|
| 16 |
+
"full_attention",
|
| 17 |
+
"full_attention",
|
| 18 |
+
"full_attention",
|
| 19 |
+
"full_attention",
|
| 20 |
+
"full_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention"
|
| 42 |
+
],
|
| 43 |
+
"max_position_embeddings": 131072,
|
| 44 |
"max_window_layers": 28,
|
| 45 |
"model_type": "qwen2",
|
| 46 |
"num_attention_heads": 12,
|
| 47 |
"num_hidden_layers": 28,
|
| 48 |
"num_key_value_heads": 2,
|
| 49 |
+
"pad_token_id": null,
|
| 50 |
"quantization": {
|
| 51 |
"group_size": 64,
|
| 52 |
"bits": 4,
|
|
|
|
| 58 |
"mode": "affine"
|
| 59 |
},
|
| 60 |
"rms_norm_eps": 1e-06,
|
| 61 |
+
"rope_parameters": {
|
| 62 |
+
"rope_theta": 1000000.0,
|
| 63 |
+
"rope_type": "default"
|
| 64 |
+
},
|
| 65 |
+
"sliding_window": null,
|
| 66 |
"tie_word_embeddings": true,
|
| 67 |
+
"transformers_version": "5.12.1",
|
|
|
|
| 68 |
"use_cache": true,
|
| 69 |
"use_mrope": false,
|
| 70 |
"use_sliding_window": false,
|
generation_config.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token_id": 151643,
|
| 3 |
+
"eos_token_id": 151643,
|
| 4 |
+
"pad_token_id": 151643
|
| 5 |
+
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33a771823bb4d0fd013e0b6c64b53147c9014f4c9aa7a86a4a458acc205225a8
|
| 3 |
+
size 868628547
|
tokenizer_config.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
"backend": "tokenizers",
|
| 4 |
"bos_token": null,
|
| 5 |
"clean_up_tokenization_spaces": false,
|
| 6 |
-
"eos_token": "<|
|
| 7 |
"errors": "replace",
|
| 8 |
"extra_special_tokens": [
|
| 9 |
"<|im_start|>",
|
|
|
|
| 3 |
"backend": "tokenizers",
|
| 4 |
"bos_token": null,
|
| 5 |
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eos_token": "<|endoftext|>",
|
| 7 |
"errors": "replace",
|
| 8 |
"extra_special_tokens": [
|
| 9 |
"<|im_start|>",
|