--- 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 条,关闭思维链、仅监督 `` 动作段训练 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 | | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | | `Qwen3.5-4B` (Base, 关思考) | 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)。