Text Generation
Transformers
Safetensors
English
Chinese
qwen3_5
image-text-to-text
qwen
lora
reinforcement-learning
fp8
agentic-coding
scientific-computing
physics
materials-science
genetics
conversational
Instructions to use HoomanBio2021/LabOpen-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HoomanBio2021/LabOpen-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HoomanBio2021/LabOpen-v1") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("HoomanBio2021/LabOpen-v1") model = AutoModelForMultimodalLM.from_pretrained("HoomanBio2021/LabOpen-v1", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HoomanBio2021/LabOpen-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HoomanBio2021/LabOpen-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HoomanBio2021/LabOpen-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HoomanBio2021/LabOpen-v1
- SGLang
How to use HoomanBio2021/LabOpen-v1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "HoomanBio2021/LabOpen-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HoomanBio2021/LabOpen-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "HoomanBio2021/LabOpen-v1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HoomanBio2021/LabOpen-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HoomanBio2021/LabOpen-v1 with Docker Model Runner:
docker model run hf.co/HoomanBio2021/LabOpen-v1
Update USAGE.md
Browse files
USAGE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
## 快速开始
|
| 4 |
|
|
@@ -6,69 +6,63 @@
|
|
| 6 |
|
| 7 |
```
|
| 8 |
Python >= 3.10
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
FP8
|
|
|
|
| 12 |
```
|
| 13 |
|
| 14 |
-
### 2.
|
| 15 |
|
| 16 |
```bash
|
| 17 |
-
vllm serve HoomanBio2021/
|
| 18 |
```
|
| 19 |
|
| 20 |
合并权重与基座 `Qwen/Qwen3.8-27B-FP8` 采用完全相同的分块 FP8(e4m3,128×128 块尺度)张量布局与文件结构,任何能加载基座的运行时(vLLM / SGLang)均可直接加载本仓库,无需任何改动。
|
| 21 |
|
| 22 |
-
|
| 23 |
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
model = PeftModel.from_pretrained(
|
| 30 |
-
base, "HoomanBio2021/Qwen3.8-27B-LabOpen-v1", subfolder="adapter")
|
| 31 |
-
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3.8-27B-FP8")
|
| 32 |
-
model.eval()
|
| 33 |
-
```
|
| 34 |
|
| 35 |
-
> **不要自行对 FP8 基座执行 `merge_and_unload()`。**
|
| 36 |
|
| 37 |
### 4. 域查询(带标记)
|
| 38 |
|
| 39 |
-
六个强化域通过提示首行标记寻址:
|
| 40 |
|
| 41 |
```python
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if domain:
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
messages = [{"role": "user", "content": prompt}]
|
| 54 |
-
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 55 |
-
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 56 |
-
with torch.no_grad():
|
| 57 |
-
out = model.generate(
|
| 58 |
-
**inputs,
|
| 59 |
-
temperature=temperature,
|
| 60 |
-
top_p=0.95,
|
| 61 |
-
do_sample=temperature > 0,
|
| 62 |
-
max_new_tokens=max_tokens,
|
| 63 |
-
pad_token_id=tokenizer.pad_token_id,
|
| 64 |
-
)
|
| 65 |
-
return tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 66 |
```
|
| 67 |
|
| 68 |
### 5. 使用示例
|
| 69 |
|
| 70 |
```python
|
| 71 |
-
# 材料混合律
|
| 72 |
query("An alloy: 60% Cu, 40% Zn. Compute density using mixture rules. Answer in JSON with value and unit.", domain="mat")
|
| 73 |
|
| 74 |
# 经典遗传学
|
|
@@ -81,7 +75,7 @@ query("A face with normal [0,1,0], velocity [2,0,0], pressure 100. Compute the f
|
|
| 81 |
query("Explain why code review matters in software development.", domain="prose", temperature=0.3)
|
| 82 |
|
| 83 |
# 代码生成——无需标记,基座原生能力已保留
|
| 84 |
-
query("Write a Python function to merge two sorted lists.")
|
| 85 |
```
|
| 86 |
|
| 87 |
## 温度建议
|
|
@@ -97,9 +91,8 @@ query("Write a Python function to merge two sorted lists.")
|
|
| 97 |
|
| 98 |
1. **标记必须独占一行**,放在用户提示最前面
|
| 99 |
2. **不加标记时模型回退到基座行为**——代码/函数调用保持原生强度
|
| 100 |
-
3.
|
| 101 |
-
4.
|
| 102 |
-
5. 两种形态的选择:部署用合并权重;复现训练数值或省流量用适配器
|
| 103 |
|
| 104 |
## 故障排查
|
| 105 |
|
|
@@ -107,6 +100,6 @@ query("Write a Python function to merge two sorted lists.")
|
|
| 107 |
|---|---|---|
|
| 108 |
| 域题答非所问 | 忘加标记 | 检查是否加了正确的 `[domain: x]` 前缀 |
|
| 109 |
| 散文不稳定 | 用了 greedy | 改用 T=0.3 采样 |
|
| 110 |
-
|
|
| 111 |
-
|
|
| 112 |
-
| 自行合并后输出异常 | 对 FP8 做了朴素 PEFT 合并 | 使用本仓库已合并权重,勿自行 merge |
|
|
|
|
| 1 |
+
# LabOpen v1 — 使用指南
|
| 2 |
|
| 3 |
## 快速开始
|
| 4 |
|
|
|
|
| 6 |
|
| 7 |
```
|
| 8 |
Python >= 3.10
|
| 9 |
+
vLLM >= 0.27(实测 0.27.1;本仓库唯一服务路径)
|
| 10 |
+
NVIDIA 计算能力 >= 8.9 的 GPU(H100 / L40S / B200 / DGX GB10 等级别)
|
| 11 |
+
FP8 下权重约 31 GB:单卡最低 48 GB(缩短上下文),推荐 80 GB;支持多卡张量并行
|
| 12 |
+
无 macOS 路径(vLLM 无 Apple Silicon 后端,且无 Mac 运行时能加载本分块 FP8 检查点格式)
|
| 13 |
```
|
| 14 |
|
| 15 |
+
### 2. 启动服务
|
| 16 |
|
| 17 |
```bash
|
| 18 |
+
vllm serve HoomanBio2021/LabOpen-v1
|
| 19 |
```
|
| 20 |
|
| 21 |
合并权重与基座 `Qwen/Qwen3.8-27B-FP8` 采用完全相同的分块 FP8(e4m3,128×128 块尺度)张量布局与文件结构,任何能加载基座的运行时(vLLM / SGLang)均可直接加载本仓库,无需任何改动。
|
| 22 |
|
| 23 |
+
实测参考参数(DGX GB10,vLLM 0.27.1):`--language-model-only --max-model-len 32768 --enforce-eager --reasoning-parser qwen3`。
|
| 24 |
|
| 25 |
+
**关键**:域计算请求的 `max_tokens` 应给到 **4096 以上**——模型先思考后作答,1024 预算会被思考链耗尽(表现为 `finish_reason=length`、正文为空)。配 `--reasoning-parser qwen3` 时,最终答案在 `content`、推理在 `reasoning_content`。
|
| 26 |
+
|
| 27 |
+
### 3. 适配器(研究工件——非服务路径)
|
| 28 |
+
|
| 29 |
+
`adapter/` 目录保存训练时的精确工件(PEFT 格式,112 MB),供检查、溯源与继续训练使用。它**不是**可服务的路径:原生 transformers 无法加载分块 FP8 基座;vLLM 的 LoRA 内核不覆盖本架构混合线性注意力投影(`in_proj_*`、`out_proj`),12 类目标模块中 5 类会被静默跳过。**服务请使用合并权重。**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
> **不要自行对 FP8 基座执行 `merge_and_unload()`。** 朴素 PEFT 合并会把 BF16 增量直接加到 FP8 码上,静默损坏权重。本仓库的合并权重已按「反量化 → 加增量 → 按块重量化」正确生成并经与适配器的等价探针验证(144/144 逐 token 一致,见 `MERGE_REPORT.md`)。
|
| 32 |
|
| 33 |
### 4. 域查询(带标记)
|
| 34 |
|
| 35 |
+
六个强化域通过提示首行标记寻址(对服务的 OpenAI 兼容端点调用):
|
| 36 |
|
| 37 |
```python
|
| 38 |
+
from openai import OpenAI
|
| 39 |
+
|
| 40 |
+
client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="EMPTY")
|
| 41 |
+
|
| 42 |
+
TAGS = {
|
| 43 |
+
"cfm": "[domain: cfm-chain]", # 流体物理链
|
| 44 |
+
"mat": "[domain: mat-table]", # 材料混合律
|
| 45 |
+
"bio": "[domain: bio-genetics]", # 经典遗传学
|
| 46 |
+
"ops": "[domain: ops-action]", # 运维动作查询
|
| 47 |
+
"prose": "[domain: general-prose]", # 开放式散文
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
def query(prompt, domain=None, temperature=0.3, max_tokens=4096):
|
| 51 |
if domain:
|
| 52 |
+
prompt = TAGS[domain] + "\n" + prompt
|
| 53 |
+
resp = client.chat.completions.create(
|
| 54 |
+
model="HoomanBio2021/LabOpen-v1",
|
| 55 |
+
messages=[{"role": "user", "content": prompt}],
|
| 56 |
+
temperature=temperature,
|
| 57 |
+
max_tokens=max_tokens,
|
| 58 |
+
)
|
| 59 |
+
return resp.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
```
|
| 61 |
|
| 62 |
### 5. 使用示例
|
| 63 |
|
| 64 |
```python
|
| 65 |
+
# 材料混合律(期望返回 {"value": ..., "unit": ...} 形式 JSON)
|
| 66 |
query("An alloy: 60% Cu, 40% Zn. Compute density using mixture rules. Answer in JSON with value and unit.", domain="mat")
|
| 67 |
|
| 68 |
# 经典遗传学
|
|
|
|
| 75 |
query("Explain why code review matters in software development.", domain="prose", temperature=0.3)
|
| 76 |
|
| 77 |
# 代码生成——无需标记,基座原生能力已保留
|
| 78 |
+
query("Write a Python function to merge two sorted lists.", temperature=0.2)
|
| 79 |
```
|
| 80 |
|
| 81 |
## 温度建议
|
|
|
|
| 91 |
|
| 92 |
1. **标记必须独占一行**,放在用户提示最前面
|
| 93 |
2. **不加标记时模型回退到基座行为**——代码/函数调用保持原生强度
|
| 94 |
+
3. 域计算给足 `max_tokens ≥ 4096`(思考链先于答案消耗预算)
|
| 95 |
+
4. 硬件自查:`nvidia-smi --query-gpu=compute_cap` 应 ≥ 8.9(A100/3090 等 Ampere 无 FP8 支持)
|
|
|
|
| 96 |
|
| 97 |
## 故障排查
|
| 98 |
|
|
|
|
| 100 |
|---|---|---|
|
| 101 |
| 域题答非所问 | 忘加标记 | 检查是否加了正确的 `[domain: x]` 前缀 |
|
| 102 |
| 散文不稳定 | 用了 greedy | 改用 T=0.3 采样 |
|
| 103 |
+
| 返回正文为空 / finish=length | max_tokens 太小 | 提到 ≥4096(思考链耗尽预算) |
|
| 104 |
+
| 加载失败 | GPU 无 FP8 能力 | 核对 compute capability ≥ 8.9 |
|
| 105 |
+
| 自行合并后输出异常 | 对 FP8 做了朴素 PEFT 合并 | 使用本仓库已合并权重,勿自行 merge |
|