Upload README (1).md
Browse files- README (1).md +154 -0
README (1).md
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# π§ Custom Knowledge LLM: Tony Stark Edition
|
2 |
+
|
3 |
+
This is a fine-tuned version of the [Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) large language model, trained specifically to answer questions related to **Tony Stark**, the legendary Marvel character. The project demonstrates how to adapt open-source instruction-tuned LLMs for domain-specific knowledge tasks using efficient fine-tuning methods.
|
4 |
+
|
5 |
+
---
|
6 |
+
|
7 |
+
## π What It Is
|
8 |
+
|
9 |
+
A lightweight, instruction-tuned **knowledge retrieval LLM** that can answer factual, fan-oriented questions about **Tony Stark**. It uses a custom dataset of prompt-completion pairs and adapts the Qwen2.5 model using **PEFT (Parameter-Efficient Fine-Tuning)** with **LoRA (Low-Rank Adaptation)**.
|
10 |
+
|
11 |
+
---
|
12 |
+
|
13 |
+
## π― Why It Is
|
14 |
+
|
15 |
+
This is a **learning + fun project**, aimed at:
|
16 |
+
- Understanding how to fine-tune LLMs on specific knowledge domains
|
17 |
+
- Exploring lightweight training using LoRA for limited GPU environments (Colab)
|
18 |
+
- Showing how fan-based or fictional datasets can help test LLM customization
|
19 |
+
|
20 |
+
Though it's themed around Tony Stark, the process used is **reproducible** and applicable to serious production tasks like:
|
21 |
+
- Domain-specific customer support
|
22 |
+
- FAQ bots for organizations
|
23 |
+
- Internal knowledge base assistants
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
## π οΈ How It Is Built
|
28 |
+
|
29 |
+
### β³οΈ Model Choice
|
30 |
+
- **Qwen2.5-3B-Instruct** was selected because:
|
31 |
+
- It's small enough to fine-tune on Colab
|
32 |
+
- Instruction-tuned already (saves effort)
|
33 |
+
- Multilingual and instruction-following by default
|
34 |
+
|
35 |
+
### β³οΈ Fine-tuning Method
|
36 |
+
- Used **LoRA via PEFT**, which:
|
37 |
+
- Freezes most of the model weights
|
38 |
+
- Only trains small adapter layers (RAM/GPU efficient)
|
39 |
+
- Works with Hugging Face `Trainer` API
|
40 |
+
|
41 |
+
### β³οΈ Dataset
|
42 |
+
- Custom-built JSON with Q&A pairs like:
|
43 |
+
- `"Who is Tony Stark?"`
|
44 |
+
- `"List of suits developed by Stark"`
|
45 |
+
- `"What tech does Iron Man use?"`
|
46 |
+
|
47 |
+
---
|
48 |
+
|
49 |
+
## π Can This Be Used for Other Models?
|
50 |
+
|
51 |
+
β
**Yes!**
|
52 |
+
The fine-tuning method used (LoRA via PEFT) is **model-agnostic** β you can apply the same code pipeline to:
|
53 |
+
- LLaMA / Mistral / Falcon / OpenLLaMA
|
54 |
+
- BERT-style models (with changes for classification)
|
55 |
+
- Any Hugging Face `AutoModelForCausalLM`-compatible model
|
56 |
+
|
57 |
+
Just ensure:
|
58 |
+
- The model supports text generation
|
59 |
+
- You choose correct `target_modules` for LoRA
|
60 |
+
- Tokenizer and dataset are aligned
|
61 |
+
|
62 |
+
---
|
63 |
+
|
64 |
+
## π What's Inside
|
65 |
+
|
66 |
+
- `tonyst.json` β your training dataset
|
67 |
+
- `train.ipynb` β full training pipeline
|
68 |
+
- `model.zip` β ready-to-share model
|
69 |
+
- `tonyst.json` β Custome made dataset
|
70 |
+
|
71 |
+
---
|
72 |
+
|
73 |
+
## π§ͺ Example Usage
|
74 |
+
|
75 |
+
```python
|
76 |
+
from transformers import pipeline
|
77 |
+
|
78 |
+
qa = pipeline(
|
79 |
+
model="./my_qwen",
|
80 |
+
tokenizer="./my_qwen",
|
81 |
+
device="cuda"
|
82 |
+
)
|
83 |
+
|
84 |
+
qa("What is Tony Starkβs most advanced suit?")
|
85 |
+
|
86 |
+
```
|
87 |
+
|
88 |
+
## π Want a Custom LLM for Your Brand or Domain?
|
89 |
+
|
90 |
+
This project is more than a fun fan experiment β it's a **blueprint** for real-world applications.
|
91 |
+
With this exact method, you can create tailored AI models for:
|
92 |
+
|
93 |
+
πΉ **Startups** building niche AI products
|
94 |
+
πΉ **Enterprises** needing internal knowledge assistants
|
95 |
+
πΉ **Educators** creating curriculum-aligned AI tutors
|
96 |
+
πΉ **Healthcare** teams developing symptom-checker bots
|
97 |
+
πΉ **E-commerce** stores launching personalized shopping agents
|
98 |
+
πΉ **Legal firms** automating case Q&A from documents
|
99 |
+
πΉ Even **fictional universe chatbots** for games, comics, or interactive apps
|
100 |
+
|
101 |
+
---
|
102 |
+
|
103 |
+
## π οΈ What I Can Help You Build
|
104 |
+
|
105 |
+
β
Domain-specific LLM (like your brandβs private ChatGPT)
|
106 |
+
β
Fine-tuned Q&A assistant trained on your docs, FAQs, or customer support logs
|
107 |
+
β
Lightweight LoRA fine-tuning without the need for massive GPUs
|
108 |
+
β
Custom pipelines for Hugging Face or local deployment
|
109 |
+
|
110 |
+
---
|
111 |
+
|
112 |
+
## π¬ Letβs Talk!
|
113 |
+
|
114 |
+
Whether you're:
|
115 |
+
- a **founder** prototyping your first AI MVP,
|
116 |
+
- a **developer** trying to scale your AI features, or
|
117 |
+
- a **company** looking to automate knowledge tasks...
|
118 |
+
|
119 |
+
**π© Reach out:** [[email protected]](mailto:[email protected])
|
120 |
+
I'm open to collaborations, consulting, and freelance work.
|
121 |
+
|
122 |
+
---
|
123 |
+
|
124 |
+
## π‘ Why Trust This Method?
|
125 |
+
|
126 |
+
This entire project was built using:
|
127 |
+
- β‘ Efficient fine-tuning via **LoRA**
|
128 |
+
- π§ Hugging Face ecosystem for flexibility
|
129 |
+
- π Custom data and tokenizer alignment
|
130 |
+
- π» Trained fully on **Google Colab** β no paid GPUs needed
|
131 |
+
|
132 |
+
If this worked for Tony Starkβs mind, it can work for **your knowledge base too** π
|
133 |
+
|
134 |
+
|
135 |
+
## π Credits
|
136 |
+
|
137 |
+
- **Developer:**
|
138 |
+
[Aviral Srivastava](mailto:[email protected])
|
139 |
+
[GitHub](http://github.com/aviral-sri) | [LinkedIn](https://www.linkedin.com/in/aviral-srivastava26/)
|
140 |
+
|
141 |
+
- **Base Model:**
|
142 |
+
[Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) by Alibaba Cloud
|
143 |
+
|
144 |
+
- **Libraries & Tools Used:**
|
145 |
+
- [Transformers](https://github.com/huggingface/transformers) by Hugging Face
|
146 |
+
- [Datasets](https://github.com/huggingface/datasets)
|
147 |
+
- [PEFT (LoRA)](https://github.com/huggingface/peft)
|
148 |
+
- [Torch](https://pytorch.org/)
|
149 |
+
- Google Colab (training environment)
|
150 |
+
- [Weights & Biases](https://wandb.ai/) for logging
|
151 |
+
|
152 |
+
- **Inspiration:**
|
153 |
+
Tony Stark / Iron Man (Marvel Universe)
|
154 |
+
This is a non-commercial fan project meant for learning and experimentation.
|