Qwen3.5-9B-Opus-S1M

基于 Qwen3.5-9B-Base 微调的工具调用 / Agent 模型。

使用 Unsloth + TRL 框架,在 100k 中英双语工具调用数据上进行 LoRA SFT,让 Base 模型具备结构化函数调用能力。

本项目目的是探索和开发 Qwen3.5 dense 模型在 Agentic 能力上的潜力。

该模型只是第一阶段 SFT 的阶段模型,RL 训练的模型还在训练中,后续会逐渐提供

模型信息

项目 内容
基础模型 Qwen/Qwen3.5-9B-Base
微调方法 LoRA (r=32, alpha=64)
训练数据 100,366 条去重样本(90k 训练 / 10k 验证)
最大序列长度 4096
训练步数 2000
优化器 AdamW 8-bit
学习率 2e-5 (cosine schedule)

训练数据

从 7 个公开数据集统一转换,覆盖中英双语工具调用场景:

数据集 数量 语言 类型
Deepexi/function-calling-small 24,608 中文 阿里云 API 函数调用
llamafactory/glaive_toolcall_zh 1,000 中文 工具调用多轮对话
hiyouga/glaive-function-calling-v2-sharegpt 100,561 英文 函数调用 (ShareGPT)
NousResearch/hermes-function-calling-v1 1,893 英文 Hermes 工具调用
tryumanshow/ToolACE-Qwen-cleaned 10,547 英文 ToolACE (Qwen 格式)
nohurry/Opus-4.6-Reasoning-3000x-filtered 2,308 英文 Claude Opus 推理蒸馏
bellfire/openclaw-coder-dataset 7,203 英文 Agent 编排

其中 62.5% 含结构化工具定义,37.5% 为纯文本对话/推理。

使用方法

Transformers

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "icecee/Qwen3.5-9B-Tool-Calling"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather for a city",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "City name"}
                },
                "required": ["city"]
            }
        }
    }
]

messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What's the weather in Tokyo?"}
]

text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True))

Ollama / LM Studio

可通过训练仓库的 scripts/export_gguf.py 导出 GGUF 格式后使用:

python scripts/export_gguf.py --model_dir ./output/merged_bf16

数据格式

所有数据统一为 TRL 兼容的 JSONL 格式,通过 tokenizer.apply_chat_template() 自动转为 Qwen3.5 原生工具调用格式:

{
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What's the weather in Tokyo?"},
    {"role": "assistant", "content": null, "tool_calls": [
      {"type": "function", "function": {"name": "get_weather", "arguments": {"city": "Tokyo"}}}
    ]},
    {"role": "tool", "content": "{\"temp\": 22}", "name": "get_weather"},
    {"role": "assistant", "content": "The weather in Tokyo is 22°C."}
  ],
  "tools": [
    {"type": "function", "function": {"name": "get_weather", "description": "Get weather info", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}
  ]
}

模型架构

Qwen3.5-9B-Base 采用混合架构(非标准 Transformer):

  • 32 层中 8 层为标准全注意力,24 层为 Gated DeltaNet(线性注意力)
  • 内置 ViT 视觉编码器(早期融合多模态)
  • 原生 262k token 上下文窗口
  • 控制 token(<|im_start|>, <|im_end|>)已预训练,适合 LoRA 微调

训练代码

完整训练代码、数据准备脚本和 Colab Notebook:

👉 FuzzyFade/qwen35-tool-calling-sft

支持 Colab 一键训练(T4 免费 GPU 可用)。

LoRA 配置

LoRA rank: 32
LoRA alpha: 64
Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Gradient checkpointing: Unsloth optimized
Effective batch size: 16

License

训练代码:MIT

基础模型遵循 Qwen License,各数据集有独立许可证。

Downloads last month
425
Safetensors
Model size
10B params
Tensor type
BF16
·
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for icecee/Qwen3.5-9B-Opus-S1M

Adapter
(5)
this model

Datasets used to train icecee/Qwen3.5-9B-Opus-S1M