Vijay1303 commited on
Commit
1740d49
·
verified ·
1 Parent(s): f8f0f92

Upload folder using huggingface_hub

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