How to build function calling and JSON mode for open-source and fine-tuned LLMs
Sep 12, 2024

Summary
This post details the engineering implementation of function calling and structured output for LLMs deployed on Baseten. It explains how a modified Triton inference server ('Briton') uses logit biasing to enforce valid token generation. A state machine, generated from a regex derived from an Outlines-generated schema, is serialized to Protocol Buffers and loaded into the server. This state machine efficiently masks invalid tokens by applying pre-computed token masks based on the current state, ensuring minimal performance impact. The implementation follows OpenAI API specifications for compatibility.
More from the Baseten AI Model Deployment and Serving Platform trail
- LangChain trains custom models for LangSmith Engine with Baseten Loops
- DeepSeek-V4.1-Flash: more efficient prefill for coding agents
- Blaxel is joining Baseten to build the future of agentic infrastructure
- How Baseten makes pyannote’s diarization models 9.6x faster
- Optimizing delta weight syncs for managed rollouts