The 4 Things Qwen-3’s Chat Template Teaches Us
Qwen-3's Jinja chat template differs from Qwen-2.5 and QwQ in four ways. An enable_thinking flag prefills an empty <think></think> block so reasoning can be skipped, where QwQ forces it on every turn. A rolling checkpoint keeps <think> blocks only for assistant turns after the latest non-tool user message, which preserves the active plan across multi-step tool calls and prunes stale reasoning. The template also serializes tool-call arguments only when they aren't already strings, avoiding double-escaping, and drops the default system prompt.
Related posts
- Tool Use, Unified
Hugging Face mediumAdeptHugging Face Transformers extends Jinja chat templates to cover tool use, giving a single portable API for passing tools to Mistral, Cohere, NousResearch and Llama models. Tools are defined as JSON schema, or as Python functions whose type hints and docstrings are converted automatically via get_json_schema. Tool calls go into the chat as a tool_calls field on assistant messages, and results are added as separate tool-role messages. A full walkthrough with Hermes-2-Pro-Llama-3-8B shows the loop end to end. Parsing the model's emitted tool-call text is still model-specific and needs a little json.loads or regex work.
- Chat Templates: An End to the Silent Performance Killer
Hugging Face mediumAdeptChat models are trained with incompatible formats for flattening role/content message lists into a single string, and feeding a model a different format than it was trained on causes severe but silent performance degradation. Hugging Face tokenizers now carry a `chat_template` attribute holding a Jinja template that renders conversations into the model's exact training format, applied via `tokenizer.apply_chat_template()`. Jinja was chosen over a simpler per-role prefix/suffix scheme because it can express every known format. ChatML with `<|im_start|>`/`<|im_end|>` tokens is recommended for new models, and model owners should set explicit templates rather than relying on fragile class-level defaults kept only for backward compatibility.
- Beyond the Chatbot: Event-Driven Agents in Action
Docker mediumAdeptA GitHub webhook-triggered agent workflow automatically detects "I finished the tutorial" pull requests on Docker's sample repos, generates an encouraging comment, and closes them without any chat interface. It is built with the TypeScript Mastra framework, local Qwen3 (analysis and execution) and Gemma3 (comment generation) models via Docker Model Runner, and the GitHub MCP server exposed through Docker MCP Gateway with tools filtered down to reduce context size, all wired together in Docker Compose. Key lessons: prompt iteration is still hard, small local models are easy to swap and compare via Compose, and deterministic steps like posting a comment and closing a PR are more reliable done programmatically than by an agent.
- Building an AI-powered ChatBot using Vercel, OpenAI, and Postgres
Neon mediumAdept
A ChatGPT-style documentation assistant (Ask Neon) is built by storing OpenAI text-embedding-ada-002 vectors in Postgres with pgvector, retrieving context by cosine distance, and feeding it to text-davinci-003 from a Vercel Edge Function. A window-function query caps retrieved context at a cumulative 1,500 tokens to fit the 4,096-token model limit, and an ivfflat index (lists ≈ 4·sqrt(rows)) speeds up the similarity search. Neon's WebSocket-based serverless driver works around Edge Functions' lack of TCP, and streaming completions via SSE parsing return answers faster. User feedback is stored for later fine-tuning.
- How to be AI-fancy
Neon mediumAdept
Neon added three LLM-backed features to its SQL editor: natural-language SQL generation, automatic naming of history queries, and one-click error fixing. Generation and fixing send the database schema as context to the LLM. Neon chose inline, context-specific actions over a chat assistant because a useful assistant needs multi-stage context gathering and gives less control over the UX. The implementation lessons are a strategy-pattern interface so providers can be swapped (Claude 3.5 Sonnet on AWS Bedrock was chosen, partly to keep schema data inside AWS without extra user consent), a comparison of cloud-integrated and direct AI providers, and plain HTTP response streaming to the browser via the Fetch API reader instead of WebSockets.