Text Generation
Transformers
Safetensors
Chinese
English
qwen3_5
image-text-to-text
shopping-agent
reinforcement-learning
gigpo
dapo
shopsimulator
tool-calling
conversational
Instructions to use HOWILLMAKEIT/ShopMaster-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HOWILLMAKEIT/ShopMaster-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HOWILLMAKEIT/ShopMaster-4B") 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("HOWILLMAKEIT/ShopMaster-4B") model = AutoModelForMultimodalLM.from_pretrained("HOWILLMAKEIT/ShopMaster-4B", 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 HOWILLMAKEIT/ShopMaster-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HOWILLMAKEIT/ShopMaster-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HOWILLMAKEIT/ShopMaster-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HOWILLMAKEIT/ShopMaster-4B
- SGLang
How to use HOWILLMAKEIT/ShopMaster-4B 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 "HOWILLMAKEIT/ShopMaster-4B" \ --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": "HOWILLMAKEIT/ShopMaster-4B", "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 "HOWILLMAKEIT/ShopMaster-4B" \ --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": "HOWILLMAKEIT/ShopMaster-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HOWILLMAKEIT/ShopMaster-4B with Docker Model Runner:
docker model run hf.co/HOWILLMAKEIT/ShopMaster-4B
File size: 4,666 Bytes
a6f762f 6ac64c7 a6f762f 049c133 a6f762f 049c133 a6f762f | 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 | ---
license: apache-2.0
base_model: Qwen/Qwen3.5-4B
language:
- zh
- en
library_name: transformers
pipeline_tag: text-generation
tags:
- qwen3_5
- shopping-agent
- reinforcement-learning
- gigpo
- dapo
- shopsimulator
- tool-calling
---
# ShopMaster-4B
**用 300 元让 4B 小模型在中文电商多步购物任务上超越 DeepSeek-V4.1-Flash-1017**
**更少的 Token|更少的 Step|更高的成功率**
- **GitHub 仓库**: [HOWILLMAKEIT/ShopMaster-4B](https://github.com/HOWILLMAKEIT/ShopMaster-4B)
- **交互式项目主页**: [https://howillmakeit.github.io/ShopMaster-4B/](https://howillmakeit.github.io/ShopMaster-4B/)
- **配套 SFT 模型**: [HOWILLMAKEIT/ShopMaster-4B-SFT](https://huggingface.co/HOWILLMAKEIT/ShopMaster-4B-SFT)
- **基座模型**: [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B)
## 模型简介
**ShopMaster-4B** 是基于 `Qwen/Qwen3.5-4B` 的中文多步电商购物 Agent 后训练最终模型(完整 BF16 多模态壳权重,已合并 LoRA,开箱即用):
1. **Action-Only SFT**:从 `DeepSeek-V4.1-Flash-1017` 采集并经环境逐轮回放 0 误差核验的 1,015 条成功轨迹中按长度分层抽样 388 条,关闭思维链、仅监督 `<tool_call>` 动作段训练 2 epoch(详见 [ShopMaster-4B-SFT](https://huggingface.co/HOWILLMAKEIT/ShopMaster-4B-SFT))。
2. **100 步 GiGPO + DAPO 强化学习**:在 `veRL v1` 上以 24K 上下文继续训练 100 步,引入基于环境公开页面状态的无折扣步级锚点优势(GiGPO)与 DAPO 风格稳定更新(`token-mean`、`clip_ratio_high=0.28`、动态整组过滤),仅在语言骨干 248 个线性层更新 rank-16 LoRA,最终按 FP32 精度合并回 BF16 原生多模态分片。
> 视觉塔权重原样保留未微调,目录结构与 `Qwen/Qwen3.5-4B` 完全一致,并已补齐 `generation_config.json`(`eos_token_id: [248044, 248046]`)。
## Holdout-915 冻结留出集评测结果
在完全冻结的 915 题留出测试集 `eval_holdout_915.jsonl` 上(`paper_strict` 四项乘积口径,`T=0.0`,32K 上下文):
| 模型 | 有效题 | 严格成功率 | 均分 | 购买率 | 下单精准度 | `repeat_loop` | `invalid_tool` | 题均步数 | 题均生成 Token |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| `Qwen/Qwen3.5-4B` (Instruct, 关思考) | 906/915 | 35.10% (318) | 0.382 | 74.83% | 46.90% | 19 (2.1%) | 182 (19.9%) | 4.5 | 311 |
| `DeepSeek-V4.1-Flash-1017` (Zero-shot) | 915/915 | 48.31% (442) | 0.509 | 64.92% | **74.41%** | 34 (3.7%) | 242 (26.4%) | 9.5 | 1,367 |
| [ShopMaster-4B-SFT](https://huggingface.co/HOWILLMAKEIT/ShopMaster-4B-SFT) (ep2) | 905/915 | 58.34% (528) | 0.607 | 84.75% | 68.84% | 124 (13.6%) | 10 (1.1%) | 8.2 | 267 |
| `Vanilla GRPO` (Step 100) | 907/915 | 58.54% (531) | 0.609 | 86.66% | 67.56% | 107 (11.7%) | 10 (1.1%) | 7.3 | 240 |
| **ShopMaster-4B (GiGPO + DAPO, Ours)** | 911/915 | **65.75% (599)** | **0.675** | **91.11%** | 72.17% | 63 (6.9%) | **7 (0.8%)** | 6.7 | **226** |
同题配对精确双侧 McNemar 检验:相对 SFT **+7.41 pp** (`p = 7.28e-8`),相对 Vanilla GRPO **+7.17 pp** (`p = 4.10e-8`),端到端反超 Teacher **+17.34 pp** (`p = 3.89e-20`)。
## 快速使用(推荐关闭思考 `enable_thinking=False`)
### SGLang 启动服务(16GB 消费级显卡即可运行 32K)
```bash
python -m sglang.launch_server \
--model-path HOWILLMAKEIT/ShopMaster-4B \
--host 127.0.0.1 --port 8000 \
--context-length 32768 \
--tool-call-parser qwen3_coder
```
### Transformers 推理示例
```python
from transformers import AutoTokenizer, AutoModelForImageTextToText
import torch
model_id = "HOWILLMAKEIT/ShopMaster-4B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(
model_id, torch_dtype=torch.bfloat16, device_map="auto"
)
messages = [
{"role": "system", "content": "你是一个中文电商多步购物助手。"},
{"role": "user", "content": "帮我找一款价格不超过 200 元的黑色无线蓝牙耳机。"},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=False))
```
## 许可与致谢
权重遵循基座模型 `Qwen/Qwen3.5-4B` 的 Apache-2.0 许可证。训练与评测环境基于 [ShopSimulator (ACL 2026)](https://huggingface.co/datasets/wpei/ShopSimulator) 与 [veRL](https://github.com/volcengine/verl)。
|