delta / README.md
Vijay1303's picture
Upload folder using huggingface_hub
1740d49 verified
# πŸ€– 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!