Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- llm
|
| 5 |
+
- mozihe
|
| 6 |
+
- agv
|
| 7 |
+
- defect-detection
|
| 8 |
+
- chinese
|
| 9 |
+
- english
|
| 10 |
+
- transformers
|
| 11 |
+
- ollama
|
| 12 |
+
model_name: agv_llm
|
| 13 |
+
base_model: meta-llama/Llama-3.1-8B
|
| 14 |
+
library_name: transformers
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# 📄 AGV-LLM
|
| 18 |
+
|
| 19 |
+
> **Small enough to self-host, smart enough to 写巡检报告,分析缺陷数据**
|
| 20 |
+
> 8 B bilingual model fine-tuned for **tunnel-defect description** & **work-order drafting**.
|
| 21 |
+
> Works in both **Transformers** and **Ollama**.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## ✨ Highlights
|
| 26 |
+
| Feature | Details |
|
| 27 |
+
| ------- | ------- |
|
| 28 |
+
| 🔧 **Domain-specific** | 56 K 巡检对话 / 工单指令数据 / 数据分析 |
|
| 29 |
+
| 🧑🏫 **LoRA fine-tuned** | QLoRA-NF4, Rank 8, α = 16 |
|
| 30 |
+
| 🈶 **Bilingual** | 中文 ↔ English |
|
| 31 |
+
| ⚡ **Fast** | ~15 tok/s on RTX 4090 (fp16) |
|
| 32 |
+
| 📦 **Drop-in** | `AutoModelForCausalLM` **or** `ollama pull mozihe/agv_llm` |
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## 🛠️ Usage
|
| 37 |
+
|
| 38 |
+
### Transformers
|
| 39 |
+
|
| 40 |
+
```python
|
| 41 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 42 |
+
import torch, textwrap
|
| 43 |
+
|
| 44 |
+
tok = AutoTokenizer.from_pretrained("mozihe/agv_llm")
|
| 45 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 46 |
+
"mozihe/agv_llm", torch_dtype=torch.float16, device_map="auto"
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
prompt = (
|
| 50 |
+
"请根据以下检测框信息,生成缺陷描述和整改建议:\\n"
|
| 51 |
+
"位置:x=12.3,y=1.2,z=7.8\\n种类:裂缝\\n置信度:0.87"
|
| 52 |
+
)
|
| 53 |
+
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 54 |
+
out = model.generate(**inputs, max_new_tokens=256, temperature=0.3)
|
| 55 |
+
print(textwrap.fill(tok.decode(out[0], skip_special_tokens=True), 80))
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### Ollama
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
1. 构建本地模型并命名:
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
ollama create agv_llm -f Modelfile
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
2. 运行:
|
| 68 |
+
|
| 69 |
+
```
|
| 70 |
+
ollama run agv_llm
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
> 说明
|
| 74 |
+
> - `ADAPTER` 行既支持远程 Hugging Face 路径,也支持 `file://` 本地 .safetensors。
|
| 75 |
+
> - 更多 Modelfile 指令见 <https://github.com/ollama/ollama/blob/main/docs/modelfile.md>
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## 📚 Training Details
|
| 79 |
+
| Item | Value |
|
| 80 |
+
| ---- | ----- |
|
| 81 |
+
| Base | Llama-3.1-8B |
|
| 82 |
+
| Method | QLoRA (bitsandbytes NF4) |
|
| 83 |
+
| Steps | 25 epochs |
|
| 84 |
+
| LR / Scheduler | 1e-4 / cosine |
|
| 85 |
+
| Context | 4 096 tokens |
|
| 86 |
+
| Precision | bfloat16 |
|
| 87 |
+
| Hardware | 4 × A100-80 GB |
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## ✅ Intended Use
|
| 92 |
+
* YOLO 检出 → 结构化缺陷描述
|
| 93 |
+
* 生成整改建议 / 工单标题 / 优先级
|
| 94 |
+
* 巡检知识库问答(RAG + Ollama)
|
| 95 |
+
|
| 96 |
+
### ❌ Out-of-scope
|
| 97 |
+
* 医疗 / 法律结论
|
| 98 |
+
* 任何未经人工复核的安全决策
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## ⚠️ Limitations
|
| 103 |
+
* 8 B 参数 ≠ GPT-4 级别推理深度
|
| 104 |
+
* 训练域集中在隧道场景,泛化到其他土木结构有限
|
| 105 |
+
* 多语种(非中英)支持较弱
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## 📄 Citation
|
| 110 |
+
|
| 111 |
+
```text
|
| 112 |
+
@misc{mozihe2025agvllm,
|
| 113 |
+
title = {AGV-LLM: A Domain LLM for Tunnel Inspection},
|
| 114 |
+
author = {Zhu, Junheng},
|
| 115 |
+
year = {2025},
|
| 116 |
+
url = {https://huggingface.co/mozihe/agv_llm}
|
| 117 |
+
}
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
## 📝 License
|
| 123 |
+
Apache 2.0 — 商用、私有部署皆可,保留版权与许可证即可。
|
| 124 |
+
若本模型帮你省掉一张加班单,欢迎 ⭐!
|