| # π€ 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! | |