Instructions to use Rumiii/Qwen3.5-9B-Guard with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Rumiii/Qwen3.5-9B-Guard with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Rumiii/Qwen3.5-9B-Guard") 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("Rumiii/Qwen3.5-9B-Guard") model = AutoModelForMultimodalLM.from_pretrained("Rumiii/Qwen3.5-9B-Guard", 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 Rumiii/Qwen3.5-9B-Guard with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Rumiii/Qwen3.5-9B-Guard" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Rumiii/Qwen3.5-9B-Guard", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Rumiii/Qwen3.5-9B-Guard
- SGLang
How to use Rumiii/Qwen3.5-9B-Guard 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 "Rumiii/Qwen3.5-9B-Guard" \ --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": "Rumiii/Qwen3.5-9B-Guard", "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 "Rumiii/Qwen3.5-9B-Guard" \ --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": "Rumiii/Qwen3.5-9B-Guard", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use Rumiii/Qwen3.5-9B-Guard with Docker Model Runner:
docker model run hf.co/Rumiii/Qwen3.5-9B-Guard
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
