Text Generation
Transformers
Safetensors
English
Chinese
qwen3_5
image-text-to-text
qwen
28B
Dense
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
Upload USAGE.md with huggingface_hub
Browse files
USAGE.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Qwen3.8-27B-LabOpen v1 — 使用指南
|
| 2 |
+
|
| 3 |
+
## 快速开始
|
| 4 |
+
|
| 5 |
+
### 1. 环境要求
|
| 6 |
+
|
| 7 |
+
```
|
| 8 |
+
Python >= 3.10
|
| 9 |
+
vllm >= 0.27(推荐,合并权重直接服务)
|
| 10 |
+
或 transformers >= 4.40 + peft >= 0.10(适配器路径)
|
| 11 |
+
FP8 能力 GPU(H100 / GB10 / B200 级别),FP8 下显存 ~28GB
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
### 2. 方式一:合并权重直接服务(推荐)
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
vllm serve HoomanBio/Qwen3.8-27B-LabOpen-v1
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
合并权重与基座 `Qwen/Qwen3.8-27B-FP8` 采用完全相同的分块 FP8(e4m3,128×128 块尺度)张量布局与文件结构,任何能加载基座的运行时(vLLM / SGLang)均可直接加载本仓库,无需任何改动。
|
| 21 |
+
|
| 22 |
+
### 3. 方式二:适配器加载(训练时精确数值)
|
| 23 |
+
|
| 24 |
+
```python
|
| 25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 26 |
+
from peft import PeftModel
|
| 27 |
+
|
| 28 |
+
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.8-27B-FP8", device_map="auto")
|
| 29 |
+
model = PeftModel.from_pretrained(
|
| 30 |
+
base, "HoomanBio/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()`。** 基座权重是 FP8 码 + 块尺度的分块量化格式,朴素 PEFT 合并会把 BF16 增量直接加到 FP8 码上,静默损坏权重。本仓库提供的合并权重已按「反量化 → 加增量 → 按块重量化」正确生成并经等价探针验证(见 `MERGE_REPORT.md`)。
|
| 36 |
+
|
| 37 |
+
### 4. 域查询(带标记)
|
| 38 |
+
|
| 39 |
+
六个强化域通过提示首行标记寻址:
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
def query(prompt, domain=None, temperature=0.3, max_tokens=1024):
|
| 43 |
+
if domain:
|
| 44 |
+
tags = {
|
| 45 |
+
"cfm": "[domain: cfm-chain]",
|
| 46 |
+
"mat": "[domain: mat-table]",
|
| 47 |
+
"bio": "[domain: bio-genetics]",
|
| 48 |
+
"ops": "[domain: ops-action]",
|
| 49 |
+
"prose": "[domain: general-prose]",
|
| 50 |
+
}
|
| 51 |
+
prompt = tags[domain] + "\n" + prompt
|
| 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 |
+
# 经典遗传学
|
| 75 |
+
query("Gene for plant height: Tt x Tt cross. What is the phenotype ratio?", domain="bio")
|
| 76 |
+
|
| 77 |
+
# 流体物理
|
| 78 |
+
query("A face with normal [0,1,0], velocity [2,0,0], pressure 100. Compute the force component.", domain="cfm")
|
| 79 |
+
|
| 80 |
+
# 散文式开放式回答
|
| 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 |
+
## 温度建议
|
| 88 |
+
|
| 89 |
+
| 场景 | 推荐温度 | 原因 |
|
| 90 |
+
|---|---|---|
|
| 91 |
+
| 域计算题 | 0.3 | 正确答案在分布肩部;greedy 可能偏离 |
|
| 92 |
+
| 散文写作 | 0.3 | 散文偏好需要采样激活;greedy 退化为结构化 |
|
| 93 |
+
| 代码生成 | 0.0–0.2 | 基座能力,无需标记 |
|
| 94 |
+
| 通用问答 | 0.3–0.7 | 基座行为,无标记 |
|
| 95 |
+
|
| 96 |
+
## 注意事项
|
| 97 |
+
|
| 98 |
+
1. **标记必须独占一行**,放在用户提示最前面
|
| 99 |
+
2. **不加标记时模型回退到基座行为**——代码/函数调用保持原生强度
|
| 100 |
+
3. FP8 基座需要支持 FP8 的 GPU;CPU 推理需先反量化
|
| 101 |
+
4. 适配器 rank=4(992 张量,~112MB),显存增量极小
|
| 102 |
+
5. 两种形态的选择:部署用合并权重;复现训练数值或省流量用适配器
|
| 103 |
+
|
| 104 |
+
## 故障排查
|
| 105 |
+
|
| 106 |
+
| 问题 | 可能原因 | 解决方案 |
|
| 107 |
+
|---|---|---|
|
| 108 |
+
| 域题答非所问 | 忘加标记 | 检查是否加了正确的 `[domain: x]` 前缀 |
|
| 109 |
+
| 散文不稳定 | 用了 greedy | 改用 T=0.3 采样 |
|
| 110 |
+
| 加载报错 | PEFT 版本 | 确保 peft >= 0.10;确认 `subfolder="adapter"` |
|
| 111 |
+
| 结果与基座无异 | 适配器未生效 | 打印 `model.active_adapters` 确认加载成功 |
|
| 112 |
+
| 自行合并后输出异常 | 对 FP8 做了朴素 PEFT 合并 | 使用本仓库已合并权重,勿自行 merge |
|