Zing Forum

Reading

Call Me Maybe: Enabling Function Calls for Small Language Models via Constrained Decoding

An open-source project based on Qwen3-0.6B demonstrates how constrained decoding technology allows small language models with only 600 million parameters to achieve 100% valid JSON function call outputs, completely changing our understanding of the relationship between model size and reliability.

函数调用约束解码JSON生成小型语言模型Qwen3结构化输出状态机语法约束LLM工具使用自然语言处理
Published 2026-05-18 01:46Recent activity 2026-05-18 01:48Estimated read 5 min
Call Me Maybe: Enabling Function Calls for Small Language Models via Constrained Decoding
1

Section 01

【Introduction】Can Small Models Achieve 100% Reliable Function Calls? Unveiling the Call Me Maybe Project

Call Me Maybe is an open-source project based on Qwen3-0.6B (600 million parameters). It achieves 100% valid JSON function call outputs via constrained decoding technology, subverting the inherent perception of the relationship between model size and reliability and demonstrating the strong potential of small models under proper engineering guidance.

2

Section 02

Project Background: Pain Points of Small Model Function Calls and the Starting Point of Innovation

Call Me Maybe was developed by rogard-antoine as part of the curriculum at 42 Programming School, with the goal of converting natural language prompts into structured executable function calls. Traditional small models without processing have only about 30% validity in JSON outputs, which cannot be used in production environments. This project uses constrained decoding to increase this figure to 100%.

3

Section 03

Core Technology: How Does Constrained Decoding Ensure 100% JSON Validity?

Constrained decoding ensures structural validity by restricting token selection during generation: 1. An 11-step state machine builds JSON step by step (complete process from array start to end); 2. Token-by-token syntax validation (generate logits → validate valid tokens → mask invalid tokens → safe sampling); 3. Semantic constraints (predefined function selection, parameter type checking).

4

Section 04

Performance Test Results: The Great Power of Small Models

Project performance data: Function selection accuracy >95%, parameter extraction accuracy >90%, JSON validity 100%; Single prompt processing time: 2-3 seconds, batch processing of 100 prompts: 4-6 minutes; Model memory usage: ~2.5GB (fp16), vocabulary size: 100MB, per-prompt state memory <1MB; No crashes in edge cases, graceful handling of malformed inputs.

5

Section 05

Challenges and Breakthroughs: Key Issues and Solutions During Development

Challenges encountered and solutions: 1. Token mapping issue: Use format_text() to convert special tokens; 2. Function boundary detection: Step5 filters functions that only start with the current token; 3. Parameter type enforcement: Step8 maintains independent allowed token sets for different types; 4. State reset: Create a new JSONState for each prompt; 5. Stop condition error: Adjust the state machine to ensure parameters are processed before entering the end step.

6

Section 06

Application Example and Insights: The Value of Structural Guidance

Application example: Input prompt "What is the sum of 40 and 2?" outputs the correct function call JSON (fn_add_numbers with parameters a=40, b=2). Insights: Structural guidance is more important than model size; deterministic output is more critical in production; high interpretability; small models + constrained decoding are suitable for resource-constrained scenarios.

7

Section 07

Conclusion: Engineering Techniques Outperform Parameter Stacking

Call Me Maybe is not just a technical demonstration but also a reflection on LLM application development: an elegant constraint mechanism can surpass the parameter stacking of large models. Project link: https://github.com/ROGARD18/call-me-maybe, which is a valuable resource for developers working on LLM function calls and structured outputs.