change
Browse files
README.md
CHANGED
|
@@ -10,18 +10,21 @@ tags:
|
|
| 10 |
pipeline_tag: text-generation
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# 🌟 Twinkel LLM - 72M (v0.1-alpha)
|
| 14 |
|
| 15 |
-
**
|
| 16 |
|
| 17 |
-
⚠️ **Status:** Early
|
| 18 |
|
| 19 |
-
## 🚀 Quick Start
|
|
|
|
|
|
|
| 20 |
|
| 21 |
```python
|
| 22 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 23 |
import torch
|
| 24 |
|
|
|
|
| 25 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 26 |
"Kunal7370944861/Twinkel-LLM-72M",
|
| 27 |
trust_remote_code=True
|
|
@@ -30,74 +33,190 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 30 |
model = AutoModelForCausalLM.from_pretrained(
|
| 31 |
"Kunal7370944861/Twinkel-LLM-72M",
|
| 32 |
trust_remote_code=True,
|
| 33 |
-
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
###
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
**
|
| 50 |
```python
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
```
|
| 53 |
|
| 54 |
-
##
|
| 55 |
-
- ❌ GPU inference broken (fix in progress)
|
| 56 |
-
- ❌ Only 72M parameters (small model)
|
| 57 |
-
- ❌ May produce inconsistent responses
|
| 58 |
-
- ❌ Experimental quality
|
| 59 |
-
- ✅ Works on CPU
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
- **
|
| 64 |
-
- **
|
| 65 |
-
- **
|
| 66 |
-
- **
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
❌ GPU inference (until fixed)
|
| 78 |
-
❌ Critical applications
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
- Fine-tuned on instruction data
|
| 84 |
-
- Hardware: Kaggle P100
|
| 85 |
-
- Training steps: ~20K
|
| 86 |
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
| 90 |
-
- Fix GPU compatibility
|
| 91 |
-
- Improve quality
|
| 92 |
-
- Better responses
|
| 93 |
-
- Longer context
|
| 94 |
|
| 95 |
## 📧 Contact
|
| 96 |
|
| 97 |
-
|
| 98 |
|
| 99 |
---
|
| 100 |
|
|
|
|
| 101 |
**Created by:** Kunal Pandey
|
| 102 |
**Version:** 0.1-alpha
|
| 103 |
-
**
|
|
|
|
| 10 |
pipeline_tag: text-generation
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# 🌟 Twinkel LLM - 72M Parameters (v0.1-alpha)
|
| 14 |
|
| 15 |
+
**Twinkel LLM** is an experimental 72M parameter language model created by **Kunal Pandey** as a learning project.
|
| 16 |
|
| 17 |
+
⚠️ **Status:** Early experimental release (v0.1-alpha)
|
| 18 |
|
| 19 |
+
## 🚀 Quick Start (CPU Inference)
|
| 20 |
+
|
| 21 |
+
**⚠️ Important:** This model currently works best on **CPU**. GPU inference has known issues that are being resolved in future versions.
|
| 22 |
|
| 23 |
```python
|
| 24 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 25 |
import torch
|
| 26 |
|
| 27 |
+
# Load model
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 29 |
"Kunal7370944861/Twinkel-LLM-72M",
|
| 30 |
trust_remote_code=True
|
|
|
|
| 33 |
model = AutoModelForCausalLM.from_pretrained(
|
| 34 |
"Kunal7370944861/Twinkel-LLM-72M",
|
| 35 |
trust_remote_code=True,
|
| 36 |
+
torch_dtype=torch.float32,
|
| 37 |
+
device_map="cpu" # Force CPU for stability
|
| 38 |
)
|
| 39 |
|
| 40 |
+
# Generate response
|
| 41 |
+
def chat(message):
|
| 42 |
+
messages = [{"role": "user", "content": message}]
|
| 43 |
+
prompt = tokenizer.apply_chat_template(
|
| 44 |
+
messages,
|
| 45 |
+
tokenize=False,
|
| 46 |
+
add_generation_prompt=True
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
inputs = tokenizer(
|
| 50 |
+
prompt,
|
| 51 |
+
return_tensors="pt",
|
| 52 |
+
return_token_type_ids=False # Important!
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
with torch.no_grad():
|
| 56 |
+
outputs = model.generate(
|
| 57 |
+
**inputs,
|
| 58 |
+
max_new_tokens=100,
|
| 59 |
+
temperature=0.7,
|
| 60 |
+
do_sample=True,
|
| 61 |
+
pad_token_id=tokenizer.eos_token_id
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 65 |
+
|
| 66 |
+
# Test
|
| 67 |
+
response = chat("What is Python?")
|
| 68 |
+
print(response)
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## 📋 Model Details
|
| 72 |
+
|
| 73 |
+
- **Parameters:** 72M (72 million)
|
| 74 |
+
- **Architecture:** Custom decoder-only transformer
|
| 75 |
+
- Hidden size: 448
|
| 76 |
+
- Layers: 6
|
| 77 |
+
- Attention: Grouped Query Attention (GQA)
|
| 78 |
+
- FFN: SwiGLU activation
|
| 79 |
+
- Position encoding: RoPE
|
| 80 |
+
- **Context length:** 512 tokens
|
| 81 |
+
- **Tokenizer:** SmolLM3 tokenizer (128K vocab)
|
| 82 |
+
- **Training:** Pre-trained on C4 + instruction fine-tuning
|
| 83 |
+
- **Creator:** Kunal Pandey
|
| 84 |
+
- **License:** Apache 2.0
|
| 85 |
+
|
| 86 |
+
## ⚠️ Known Limitations
|
| 87 |
+
|
| 88 |
+
1. **GPU Inference Issues**
|
| 89 |
+
- Model currently has compatibility issues with GPU inference
|
| 90 |
+
- CUDA assert errors occur during GPU loading
|
| 91 |
+
- **Workaround:** Use CPU inference (as shown above)
|
| 92 |
+
- Fix is planned for v0.2
|
| 93 |
+
|
| 94 |
+
2. **Model Size**
|
| 95 |
+
- Only 72M parameters (much smaller than production models)
|
| 96 |
+
- Limited knowledge and reasoning capabilities
|
| 97 |
+
- May produce inconsistent or incorrect responses
|
| 98 |
+
|
| 99 |
+
3. **Context Window**
|
| 100 |
+
- Limited to 512 tokens
|
| 101 |
+
- Cannot handle long conversations or documents
|
| 102 |
+
|
| 103 |
+
4. **Response Quality**
|
| 104 |
+
- Experimental model, responses may be:
|
| 105 |
+
- Off-topic or irrelevant
|
| 106 |
+
- Repetitive
|
| 107 |
+
- Factually incorrect
|
| 108 |
+
- Not suitable for production use
|
| 109 |
+
|
| 110 |
+
5. **Language**
|
| 111 |
+
- Primarily English
|
| 112 |
+
- Limited multilingual support
|
| 113 |
+
|
| 114 |
+
## 🎯 Intended Use
|
| 115 |
+
|
| 116 |
+
This is an **experimental educational project** suitable for:
|
| 117 |
+
|
| 118 |
+
✅ Learning about LLM architecture
|
| 119 |
+
✅ Understanding model training and fine-tuning
|
| 120 |
+
✅ Experimenting with small language models
|
| 121 |
+
✅ CPU-based inference testing
|
| 122 |
+
|
| 123 |
+
❌ **NOT suitable for:**
|
| 124 |
+
- Production applications
|
| 125 |
+
- Critical or safety-sensitive tasks
|
| 126 |
+
- High-quality text generation
|
| 127 |
+
- GPU-accelerated inference (until v0.2)
|
| 128 |
+
|
| 129 |
+
## 🛠️ Training Details
|
| 130 |
+
|
| 131 |
+
### Pre-training
|
| 132 |
+
- Dataset: C4 (English)
|
| 133 |
+
- Steps: 20,000
|
| 134 |
+
- Batch size: 32 (effective)
|
| 135 |
+
- Hardware: Kaggle P100 GPU
|
| 136 |
+
- Optimization: AdamW with mixed precision
|
| 137 |
+
|
| 138 |
+
### Fine-tuning
|
| 139 |
+
- Dataset: Custom instruction dataset (~70K samples)
|
| 140 |
+
- Epochs: 2-3
|
| 141 |
+
- Learning rate: 1e-4
|
| 142 |
+
- Hardware: Kaggle P100 GPU
|
| 143 |
+
|
| 144 |
+
## 🐛 Troubleshooting
|
| 145 |
+
|
| 146 |
+
### GPU CUDA Error
|
| 147 |
+
```
|
| 148 |
+
AcceleratorError: CUDA error: device-side assert triggered
|
| 149 |
```
|
| 150 |
|
| 151 |
+
**Solution:** Force CPU inference:
|
| 152 |
+
```python
|
| 153 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 154 |
+
"Kunal7370944861/Twinkel-LLM-72M",
|
| 155 |
+
trust_remote_code=True,
|
| 156 |
+
device_map="cpu" # Add this
|
| 157 |
+
)
|
| 158 |
+
```
|
| 159 |
|
| 160 |
+
### token_type_ids Error
|
| 161 |
+
```
|
| 162 |
+
ValueError: The following `model_kwargs` are not used: ['token_type_ids']
|
| 163 |
+
```
|
| 164 |
|
| 165 |
+
**Solution:** Disable token_type_ids:
|
| 166 |
```python
|
| 167 |
+
inputs = tokenizer(
|
| 168 |
+
prompt,
|
| 169 |
+
return_tensors="pt",
|
| 170 |
+
return_token_type_ids=False # Add this
|
| 171 |
+
)
|
| 172 |
```
|
| 173 |
|
| 174 |
+
## 📊 Performance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
+
This is an experimental model with limited capabilities:
|
| 177 |
|
| 178 |
+
- **Size:** 72M parameters (vs billions in production models)
|
| 179 |
+
- **Quality:** Basic responses, may be off-topic
|
| 180 |
+
- **Speed (CPU):** ~5-10 tokens/second on standard CPU
|
| 181 |
+
- **Reliability:** Experimental, expect issues
|
| 182 |
+
|
| 183 |
+
## 🔮 Future Plans
|
| 184 |
|
| 185 |
+
**Version 0.2 (Planned):**
|
| 186 |
+
- ✅ Fix GPU compatibility issues
|
| 187 |
+
- ✅ Improve response quality
|
| 188 |
+
- ✅ Add proper identity training
|
| 189 |
+
- ✅ Increase context length
|
| 190 |
+
- ✅ Better instruction following
|
| 191 |
|
| 192 |
+
## 🙏 Acknowledgments
|
| 193 |
+
|
| 194 |
+
- **Creator:** Kunal Pandey
|
| 195 |
+
- **Tokenizer:** Based on SmolLM3 (Hugging Face)
|
| 196 |
+
- **Training data:** C4 dataset (AllenAI)
|
| 197 |
+
- **Inspiration:** SmolLM project
|
| 198 |
|
| 199 |
+
## 📜 License
|
|
|
|
|
|
|
| 200 |
|
| 201 |
+
Apache 2.0 - Free for commercial and research use.
|
| 202 |
|
| 203 |
+
## ⚠️ Disclaimer
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
+
This is an **experimental educational project**. The model:
|
| 206 |
+
- May produce incorrect, biased, or inappropriate content
|
| 207 |
+
- Has not been safety-tested or aligned
|
| 208 |
+
- Should not be used in production environments
|
| 209 |
+
- Is provided "as-is" without warranties
|
| 210 |
|
| 211 |
+
Use at your own risk for experimental and educational purposes only.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
## 📧 Contact
|
| 214 |
|
| 215 |
+
For questions, issues, or feedback, please open an issue on the model repository.
|
| 216 |
|
| 217 |
---
|
| 218 |
|
| 219 |
+
**Model Status:** 🚧 Experimental Alpha
|
| 220 |
**Created by:** Kunal Pandey
|
| 221 |
**Version:** 0.1-alpha
|
| 222 |
+
**Last updated:** January 2026
|