update
Browse files
README.md
CHANGED
@@ -1,92 +1,45 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
- question-answering
|
6 |
-
- LoRA
|
7 |
-
- tinyllama
|
8 |
-
- fine-tuned
|
9 |
-
- causal-lm
|
10 |
-
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
- **LoRA Adapter Size:** ~2MB
|
21 |
-
- **Dataset:** [shchoi83/agriQA](https://huggingface.co/datasets/shchoi83/agriQA)
|
22 |
-
- **Task:** Question Answering (Instruction Tuning)
|
23 |
-
- **Language:** English
|
24 |
-
- **Adapter Only:** This repository only contains the **LoRA adapter**. You must load it on top of the base model.
|
25 |
-
- **Trained by:** [@theone049](https://huggingface.co/theone049)
|
26 |
|
27 |
-
|
28 |
|
29 |
```python
|
30 |
-
from transformers import
|
31 |
from peft import PeftModel, PeftConfig
|
32 |
|
33 |
-
# Load base model
|
34 |
base_model = AutoModelForCausalLM.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat")
|
35 |
tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat")
|
36 |
|
37 |
-
# Load
|
38 |
model = PeftModel.from_pretrained(base_model, "theone049/agriqa-tinyllama-lora-adapter")
|
39 |
|
40 |
-
#
|
41 |
prompt = """### Instruction:
|
42 |
Answer the agricultural question.
|
43 |
|
44 |
### Input:
|
45 |
-
What is the
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
"""
|
49 |
-
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
50 |
outputs = model.generate(**inputs, max_new_tokens=100)
|
51 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
52 |
-
```
|
53 |
-
|
54 |
-
## 📊 Training
|
55 |
-
|
56 |
-
- **Epochs:** 3
|
57 |
-
- **Batch Size:** 8
|
58 |
-
- **Learning Rate:** 2e-5
|
59 |
-
- **Precision:** bf16
|
60 |
-
- **Training Framework:** 🤗 `transformers` + `peft`
|
61 |
-
- **Compute:** Google Colab T4 GPU
|
62 |
-
|
63 |
-
## 📁 Files
|
64 |
-
|
65 |
-
- `adapter_config.json`: Configuration of LoRA adapter.
|
66 |
-
- `adapter_model.safetensors`: The trained adapter weights.
|
67 |
-
- `README.md`: This file.
|
68 |
-
|
69 |
-
## 🛑 Limitations
|
70 |
-
|
71 |
-
- **Domain-Specific**: Works best on agri-related questions. Not suited for general conversation.
|
72 |
-
- **Small Dataset**: Initial training was done on a subset (~5k samples). Accuracy may improve with full dataset.
|
73 |
-
- **Not Merged**: Requires base model for usage.
|
74 |
-
|
75 |
-
## 📚 Citation
|
76 |
-
|
77 |
-
```bibtex
|
78 |
-
@misc{nithyanandam2024agriqa,
|
79 |
-
title={AgriQA TinyLlama LoRA Adapter},
|
80 |
-
author={Nithyanandam Venu},
|
81 |
-
year={2024},
|
82 |
-
howpublished={\url{https://huggingface.co/theone049/agriqa-tinyllama-lora-adapter}}
|
83 |
-
}
|
84 |
-
```
|
85 |
-
|
86 |
-
## ✉️ Contact
|
87 |
-
|
88 |
-
For questions or collaborations: [[email protected]](mailto:[email protected])
|
89 |
-
|
90 |
-
---
|
91 |
-
|
92 |
-
*This is part of an experimental project to improve AI Q&A for agriculture. Not for medical or pesticide advice.*
|
|
|
1 |
+
# 🧠 AgriQA TinyLlama LoRA Adapter
|
2 |
+
|
3 |
+
This repository contains a [LoRA](https://arxiv.org/abs/2106.09685) adapter fine-tuned on the [AgriQA](https://huggingface.co/datasets/shchoi83/agriQA) dataset using the [TinyLlama/TinyLlama-1.1B-Chat](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat) base model.
|
4 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
+
## 🔧 Model Details
|
8 |
|
9 |
+
- **Base Model**: [`TinyLlama/TinyLlama-1.1B-Chat`](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat)
|
10 |
+
- **Adapter Type**: LoRA (Low-Rank Adaptation)
|
11 |
+
- **Adapter Size**: ~4.5MB
|
12 |
+
- **Dataset**: [`shchoi83/agriQA`](https://huggingface.co/datasets/shchoi83/agriQA)
|
13 |
+
- **Language**: English
|
14 |
+
- **Task**: Instruction-tuned Question Answering in Agriculture domain
|
15 |
+
- **Trained by**: [@theone049](https://huggingface.co/theone049)
|
16 |
|
17 |
+
---
|
18 |
|
19 |
+
## 📌 Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
To use this adapter, load it on top of the base model:
|
22 |
|
23 |
```python
|
24 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
25 |
from peft import PeftModel, PeftConfig
|
26 |
|
27 |
+
# Load base model
|
28 |
base_model = AutoModelForCausalLM.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat")
|
29 |
tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat")
|
30 |
|
31 |
+
# Load adapter
|
32 |
model = PeftModel.from_pretrained(base_model, "theone049/agriqa-tinyllama-lora-adapter")
|
33 |
|
34 |
+
# Run inference
|
35 |
prompt = """### Instruction:
|
36 |
Answer the agricultural question.
|
37 |
|
38 |
### Input:
|
39 |
+
What is the ideal pH range for growing rice?
|
40 |
+
|
41 |
+
### Response:"""
|
42 |
|
43 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
|
|
|
|
44 |
outputs = model.generate(**inputs, max_new_tokens=100)
|
45 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|