Screenshot 2026-11-22 at 2.08.45 PM

Qwen3.5-9B-Guard

A 9B tool-calling model that knows when not to call a tool.

Agents break quietly when a model forces a call that does not fit: the wrong function, invented arguments, or a call when the honest answer is "none of these tools can do that". Guard is fine-tuned from Qwen/Qwen3.5-9B to decide first and call second. It returns the correct call(s) as a JSON list when a listed function fits, and an empty list [] when none does. It also handles greetings and general conversation.

What it does

Situation Guard returns
A listed function fits the request A JSON list with the call(s) and their arguments
No listed function fits (or no functions are listed) Exactly []
No tools, casual conversation A normal conversational reply

Quickstart

Provide the available functions as JSON in the system prompt and the request as the user message. The model was trained with thinking disabled, so always pass enable_thinking=False.

import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_ID = "Rumiii/Qwen3.5-9B-Guard"
tok = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(MODEL_ID, dtype=torch.bfloat16, device_map="auto")

SYSTEM = (
    "You are a careful function-calling assistant. These are the functions you may use (JSON):\n"
    "<tools>\n<<TOOLS>>\n</tools>\n"
    "Decide whether any listed function can fulfil the user's request. Answer with ONLY a JSON list of calls, "
    "for example [{\"name\": \"function_name\", \"arguments\": {\"arg\": \"value\"}}]. "
    "If none of the listed functions can fulfil the request, or no functions are listed, answer with exactly []. "
    "Never invent functions or arguments."
)

def generate(messages, max_new_tokens=256):
    text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
    inputs = tok(text, return_tensors="pt", add_special_tokens=False).to(model.device)
    out = model.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=False, eos_token_id=tok.eos_token_id)
    return tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip()

def ask(request, tools):
    system = SYSTEM.replace("<<TOOLS>>", json.dumps(tools))
    return json.loads(generate([{"role": "system", "content": system}, {"role": "user", "content": request}]))

tools = [{
    "name": "get_weather",
    "description": "Get the current weather for a city.",
    "parameters": {"city": {"description": "City name", "type": "str"}},
}]

calls = ask("What's the weather in Paris right now?", tools)
# e.g. [{"name": "get_weather", "arguments": {"city": "Paris"}}]

calls = ask("Convert 200 grams of flour to cups.", tools)
# [] -> no listed tool applies: answer directly, ask a follow-up, or route elsewhere
if not calls:
    print("No suitable tool; fall back.")

# General conversation (no tools)
print(generate([{"role": "user", "content": "Hello!"}]))
vLLM / OpenAI-compatible server
vllm serve Rumiii/Qwen3.5-9B-Guard --port 8000 --max-model-len 8192 \
  --default-chat-template-kwargs '{"enable_thinking": false}'
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
resp = client.chat.completions.create(
    model="Rumiii/Qwen3.5-9B-Guard",
    messages=[{"role": "system", "content": system}, {"role": "user", "content": request}],  # same prompt as above
    temperature=0,
    max_tokens=256,
)
print(resp.choices[0].message.content)

Intended use and limitations

  • Built for: choosing among a provided list of functions for a single request, and abstaining when none applies.
  • Prompt protocol: the functions go in the system prompt as JSON and the answer is a JSON list. This is not the model's native tool-call token format, so use the prompt shown above.
  • Not evaluated for: long multi-step agent loops or multi-turn tool use.
  • Data: training tools are mostly English, synthetic xLAM-style APIs. Test the model on your own tool definitions before relying on it.
  • Safety: always validate and sanitize returned calls before executing anything with side effects.

Training data

Dataset Role Samples drawn License
MadeAgents/xlam-irrelevance-7.5k Negative examples: requests that none of the listed functions can fulfil (target []) 7,500 (full dataset) CC-BY-4.0
Salesforce/xlam-function-calling-60k Positive examples: requests with a matching function and its verified call 3,000 (sampled from 60,000) CC-BY-4.0
Synthetic conversational set Greetings and general conversation 255 n/a

In total, 10,755 examples were used.

Why both negative and positive examples? Models can be pushed to call a function even when none applies. The negative set teaches the model to return [] in those cases, which targets incorrect tool calls. Negatives alone would bias the model toward empty calls even when the right function is available, so the positive examples keep it producing correct calls with correct arguments whenever a suitable function exists.

License

Released under Apache-2.0, the same as the base model. Note that the xLAM-60k dataset's own card states that it was released for research purposes; please review the dataset terms before any commercial use.

Citation

@misc{qwen35_9b_guard,
  title  = {Qwen3.5-9B-Guard: a tool-calling model that abstains when no function fits},
  author = {Rumiii},
  year   = {2026},
  url    = {https://huggingface.co/Rumiii/Qwen3.5-9B-Guard}
}

References:

  • Qwen Team. Qwen3.5: Towards Native Multimodal Agents. February 2026. https://qwen.ai/blog?id=qwen3.5
  • Liu, Z., Hoang, T., Zhang, J., et al. APIGen: Automated Pipeline for Generating Verifiable and Diverse Function-Calling Datasets. arXiv:2406.18518, 2024.
  • Hammer: Robust Function-Calling for On-Device Language Models via Function Masking. arXiv:2410.04587, 2024. (Source of xlam-irrelevance-7.5k.)
  • The Berkeley Function Calling Leaderboard (BFCL): From Tool Use to Agentic Evaluation of Large Language Models. https://gorilla.cs.berkeley.edu/leaderboard.html
Downloads last month
40
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 Rumiii/Qwen3.5-9B-Guard

Finetuned
Qwen/Qwen3.5-9B
Finetuned
(1,514)
this model
Quantizations
2 models

Datasets used to train Rumiii/Qwen3.5-9B-Guard

Papers for Rumiii/Qwen3.5-9B-Guard