File size: 2,616 Bytes
1740d49 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# ๐ค Delta - Tiny Helpful Assistant (GPT2-style)
Delta is a tiny transformer-based language model inspired by GPT-2, designed to be lightweight, fast, and helpful for simple natural language tasks.
This project demonstrates how to train a minimal GPT-2-like model using Hugging Face Transformers on custom text, then serve it locally via a FastAPI API or deploy it to Hugging Face Hub.
---
## ๐ง Model Details
- Architecture: GPT2 (custom config)
- Parameters: ~4.7M
- Layers: 2
- Embedding Size: 128
- Heads: 2
- Max Sequence Length: 128
- Trained on: ~300 characters (demo text)
- Format: `PyTorch`, ready for GGUF/Ollama conversion
---
## ๐ Files Included
- `config.json`: GPT2 model configuration
- `pytorch_model.bin`: Fine-tuned model weights
- `tokenizer_config.json`, `vocab.json`, `merges.txt`: Tokenizer files
- `generation_config.json`: Optional generation tuning
- `README.md`: Youโre reading it!
- `main.py`: (Optional) FastAPI local serving code
---
## ๐ Quick Start (Hugging Face Transformers)
Install dependencies:
```bash
pip install transformers torch
```
Load and use the model:
```python
from transformers import GPT2Tokenizer, GPT2LMHeadModel
tokenizer = GPT2Tokenizer.from_pretrained("Vijay1303/delta")
model = GPT2LMHeadModel.from_pretrained("Vijay1303/delta")
model.eval()
input_ids = tokenizer("Hello Delta, can you help me?", return_tensors="pt").input_ids
outputs = model.generate(input_ids, max_length=50, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
---
## ๐ Run Locally via FastAPI
1. Install dependencies:
```bash
pip install fastapi uvicorn transformers torch
```
2. Run server:
```bash
uvicorn main:app --reload --port 8000
```
3. Query API:
```bash
curl -X POST http://localhost:8000/generate \
-H "Content-Type: application/json" \
-d '{"prompt": "Hello Delta,", "max_length": 50}'
```
---
## ๐ฆ Deployment
You can:
- Convert to GGUF for Ollama or llama.cpp
- Push to Hugging Face Hub
- Serve via an API (FastAPI, Flask, etc.)
---
## โ ๏ธ Limitations
- Trained on a small dataset (~300 characters)
- Not suitable for production tasks
- For experimentation and educational use
---
## ๐ References
- [Hugging Face Transformers](https://github.com/huggingface/transformers)
- [Training GPT2 from Scratch](https://huggingface.co/blog/how-to-train)
- [Ollama](https://ollama.com/)
- [GGUF Format](https://github.com/ggerganov/llama.cpp)
---
## ๐จโ๐ป Author
**Vijay1303**
[Hugging Face Profile](https://huggingface.co/Vijay1303)
Feel free to โญ the repo if you find this useful!
|