File size: 8,501 Bytes
c0ff474
 
 
 
 
 
 
 
 
 
 
 
074144d
c0ff474
 
 
 
 
 
152c907
c0ff474
074144d
c0ff474
8c26515
c0ff474
152c907
c0ff474
074144d
c0ff474
152c907
8878710
 
 
 
 
 
 
 
 
9496fc4
8878710
c0ff474
 
152c907
c0ff474
152c907
 
 
 
 
 
 
 
 
c0ff474
 
 
152c907
c0ff474
 
 
074144d
c0ff474
 
 
 
152c907
c0ff474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a087be
917a95e
 
81bebb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917a95e
81bebb4
917a95e
81bebb4
 
0a087be
81bebb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a087be
81bebb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a087be
81bebb4
 
 
 
 
 
 
 
 
 
 
0a087be
81bebb4
 
 
 
 
 
 
 
9808d92
c0ff474
152c907
c0ff474
376c32b
c0ff474
376c32b
 
152c907
 
 
 
376c32b
 
 
152c907
376c32b
 
 
 
 
 
 
 
 
 
 
 
152c907
376c32b
 
 
7ef161e
376c32b
 
 
 
 
c0047a0
376c32b
 
 
 
 
e8c224c
376c32b
 
152c907
f486ff2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376c32b
152c907
376c32b
 
 
 
c0ff474
 
f964ab4
 
0a087be
f964ab4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c0ff474
152c907
c0ff474
 
 
 
 
 
 
 
 
 
 
 
 
152c907
c0ff474
 
 
 
 
152c907
c0ff474
 
 
 
 
152c907
c0ff474
074144d
c0ff474
 
 
152c907
c0ff474
 
 
 
 
 
 
 
 
074144d
c0ff474
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
---
license: cc-by-4.0
language:
  - en
base_model: mistralai/Mixtral-8x7B-Instruct-v0.1
pipeline_tag: text-generation
library_name: peft
tags:
  - agriculture
  - peft
  - lora
  - instruction-tuning
  - adaption-labs
  - autoscientist
  - question-answering
datasets:
  - Charley890/AgroAdapt-Dataset
---

#  AgroAdapt-Mixtral-8x7B

> A PEFT (LoRA) fine-tuned Mixtral-8x7B-Instruct-v0.1 model for agricultural question answering, developed using the **Adaption Labs AutoScientist** workflow.

---![](Adaption_image.png)

#  Overview

AgroAdapt-Mixtral-8x7B is a domain-adapted language model designed to improve agricultural instruction following and question answering. The model was fine-tuned using the Adaption Labs AutoScientist workflow on a curated agricultural instruction dataset covering practical farming knowledge.

##  Quick Facts

| Item | Value |
|------|-------|
| **Domain** | Agriculture |
| **Task** | Agricultural Question Answering |
| **Base Model** | Mixtral-8x7B-Instruct-v0.1 |
| **Fine-Tuning Method** | PEFT (LoRA) |
| **Training Framework** | Adaption Labs AutoScientist |
| **Language** | English |
| **Dataset** | https://huggingface.co/datasets/Charley890/adaption-agricultural-qa-pairs |
| **License** | CC BY 4.0 |
---

#  Key Features

-  Agricultural Question Answering
-  Crop Production Guidance
-  Soil Science
-  Pest & Disease Identification
-  Irrigation Recommendations
-  Livestock Management
-  Climate-Smart Agriculture
-  Sustainable Farming
-  Agricultural Education

---

# Base Model

- **Base Model:** Mixtral-8x7B-Instruct-v0.1
- **Fine-tuning Method:** PEFT (LoRA)
- **Training Framework:** Adaption Labs AutoScientist
- **Language:** English

---

#  Training Dataset

The model was trained using an adapted agricultural instruction dataset containing high-quality question-answer pairs covering:

- Crop Production
- Soil Science
- Fertilizer Recommendations
- Pest Management
- Plant Disease Diagnosis
- Irrigation
- Livestock
- Poultry
- Sustainable Agriculture
- Climate-Smart Agriculture
- Farm Business
- Agricultural Extension

---

## Quick Start

The following example demonstrates how to load the LoRA adapter and perform inference using the Hugging Face Transformers ecosystem. The adapter is automatically merged with the base Mixtral model during inference.

### Installation

```bash
pip install torch transformers peft accelerate
```

### Load the Model

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

BASE_MODEL = "Mixtral-8x7B-Instruct-v0.1"
ADAPTER = "Charley890/AgroAdapt-Mixtral-8x7B"

tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)

model = AutoModelForCausalLM.from_pretrained(
    BASE_MODEL,
    device_map="auto",
    torch_dtype="auto"
)

model = PeftModel.from_pretrained(model, ADAPTER)
```

### Inference

```python
prompt = """
Farmer:
My tomato leaves are turning yellow with brown spots.
What could be the cause and how can I treat it?
"""

inputs = tokenizer(prompt, return_tensors="pt")

outputs = model.generate(
    **inputs,
    max_new_tokens=200,
    temperature=0.7,
)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
Expected Output

The model returns a practical, step-by-step agricultural recommendation based on the farmer's question, including possible causes, preventive measures, and treatment options.
---

##  Training Configuration

| Parameter | Value |
|-----------|-------|
| Fine-tuning Method | LoRA |
| Base Model | Mixtral-8x7B-Instruct |
| Epochs | 5 |
| LoRA Rank (r) | 64 |
| LoRA Alpha | 128 |
| Warmup Ratio | 0.03 |
| Optimizer | Cosine |
| Gradient Clipping | 1.0 |
| Target Modules | q_proj, k_proj, v_proj, o_proj |

---

## LoRA Equation

The adapter follows the standard LoRA formulation:

\[
W' = W + \frac{\alpha}{r}BA
\]

Where:

- **r = 64**
- **Ξ± = 128**

Scaling factor:

\[
\frac{\alpha}{r} = \frac{128}{64} = 2
\]

This scaling improves learning efficiency while keeping the number of trainable parameters small.

---

##  Training Summary

- Fine-tuned using **Adaption Labs AutoScientist**
- **5 training epochs**
- Win rate improved from **24% β†’ 76%**
- Agriculture benchmark improved from **26% β†’ 75%**
- Training loss decreased consistently throughout optimization.
- Cosine learning-rate scheduling enabled smooth convergence.
- Gradient clipping stabilized training and reduced optimization spikes.

---

## Example

**Input**

> How can I prevent maize leaf blight?

**Output**

> Maize leaf blight can be reduced by planting resistant varieties, practicing crop rotation, avoiding overhead irrigation, removing infected crop residues, and applying recommended fungicides when disease pressure is high.


# Evaluation Results

> **Evaluation performed using Adaption Labs AutoScientist**

| Metric | Base Model | Adapted Model | Improvement |
|:-------|-----------:|--------------:|------------:|
|  Overall Win Rate | **24%** | **76%** | **+52 pts** |
|  Agriculture Win Rate | **26%** | **75%** | **+49 pts** |
|  Relative Improvement | β€” | β€” | **216.7%** |
|  Agriculture Improvement | β€” | β€” | **188.5%** |

---

## Performance Summary

```text
βœ“ Training Completed Successfully
βœ“ Stable Optimization
βœ“ Domain Adaptation Successful
βœ“ Agricultural Performance Improved
βœ“ Overall Win Rate Increased from 24% β†’ 76%
βœ“ Agriculture Win Rate Increased from 26% β†’ 75%
```

---

## Evaluation Figures

### Overall Training Win Rate

![Overall Training Win Rate](overall_training_win_rate.png)

---

### Agriculture Domain Win Rate

![Agriculture Domain Win Rate](agriculture_domain_win_rate.png)

---

### Evaluation Summary

![Evaluation Summary](evaluation_summary.png)

---
## Training Curves

### Training Loss

![Training Loss](graph_1_enhanced.png)

---

### Learning Rate

![Learning Rate](graph_2_enhanced.png)

---

### Gradient Norm

![Gradient Norm](graph_3_enhanced.png)


## Interpretation

The fine-tuned model demonstrates a substantial improvement over the baseline model after domain adaptation using **Adaption Labs AutoScientist**. The evaluation shows a significant increase in both overall and agriculture-specific performance while maintaining stable optimization throughout training.

These results indicate that the model effectively learned agricultural reasoning and instruction-following capabilities from the domain-specific dataset.

---
# Conclusion 

##  Training Dynamics

```text
Training Loss        β†˜ steadily decreased
Validation Loss      β†’ remained stable
Learning Rate        β†˜ cosine decay schedule
Gradient Norm        β†’ controlled through clipping
Adaptation Strategy  β†’ LoRA parameter-efficient fine-tuning
```

### Adaptive Optimization

```python
while training:
    loss ↓
    learning_rate = cosine_decay(step)
    gradients = clip_norm(max_norm=1.0)
    weights = weights + LoRA_update()
```

### Model Equation

```text
Knowledge = Base Model + Domain Adaptation

M_adapted = M_base + LoRA(Agriculture)
```

### Final Result

```yaml
model: AgroAdapt-Mixtral-8x7B
framework: Adaption Labs AutoScientist
domain: Agriculture
training: Stable
convergence: Successful
adaptation: Optimized
status: Ready for Inference
```

> **AgroAdapt-Mixtral-8x7B** successfully adapts the Mixtral foundation model into a specialized agricultural assistant through efficient LoRA fine-tuning, stable optimization, and domain-specific instruction learning, enabling practical, context-aware support for modern farming applications.

# Intended Uses

This model is suitable for:

- AI Farming Assistants
- Agricultural Chatbots
- Farm Advisory Systems
- Agricultural Education
- Agricultural Research
- Smart Farming Applications
- Decision Support Systems

---

#  Limitations

Although the model performs well on agricultural instruction tasks, responses should be verified before being used for real-world farming decisions. Local farming practices and expert guidance should always take precedence.

---

# License

This model is released under the **CC BY 4.0** License.

---

#  Acknowledgements

This project was developed as part of the **Adaption Labs AutoScientist Challenge** using the Mixtral-8x7B-Instruct-v0.1 base model.

---

#  Citation

If you use this model in your research or applications, please cite:

```bibtex
@misc{charlie2026agroadapt,
  title={AgroAdapt-Mixtral-8x7B},
  author={Edidiong Charlie},
  year={2026},
  publisher={Hugging Face},
  note={Adaption Labs AutoScientist Challenge}
}
```