Dev48
Language
  • About
  • Services
  • Industries
  • Technologies
  • Articles
  • Contacts
Book a call
    Home/Articles/Fine tuning an open model on our docs agents traces
Dev48
info@dev48.org+375 29 320-40-96WhatsApp@isky_by

© 2026 · All rights reserved.

Fine-tuning an open model on our docs agent's traces

Source: LangChain•December 2, 2026 at 07:14 PM

Fine-tuning an open model on our docs agent's traces

We fine-tuned GLM 5.3 Flash on Chat LangChain's production traces. It nearly matches GPT-6.1 Sol on our benchmark at 83% lower cost, and now runs in production.

We've deployed a fine-tuned version of GLM 5.3 Flash as the main model in Chat LangChain, our agent that answers questions about the LangChain stack from our documentation and our public support knowledge base.

We trained it on tasks built from Chat LangChain's own production traces. We tested it on a benchmark of 128 real user questions. Each answer scores 1 if it is correct and complete, 0 if it falls short, and −0.5 if it is confidently wrong. A model's score is its average over 8 attempts at each question. The fine-tune scores 0.735, up from 0.679 for the base model and close to GPT-6.1 Sol's 0.748. It is 83% cheaper than GPT-6.1 Sol.

The benchmark result was strong enough to put the fine-tune in front of users, so we ran it in production alongside base GLM 5.3 Flash and Gemini 3.5 Flash Lite, the model it replaced, and measured all three with online evals. The fine-tune's answers were the most grounded in our docs of the three, and users came back with a follow-up question less often than they did with Gemini (36% of threads against 41%). It answers about twice as slowly as Gemini but costs less to run, at $12 per 1,000 questions against $20.

Why we tried an open model

Frontier models answered our docs questions well but cost too much to run on every question. Sonnet 5.5 costs $192 per 1,000 questions and Opus 5.5 costs $330, against $20 for Gemini 3.5 Flash Lite, our production model at the time. Base GLM 5.3 Flash costs $9 per 1,000 questions but scored well behind GPT-6.1 Sol on our benchmark. We wanted to find out whether training on Chat LangChain's own traffic could close that gap.

Building a benchmark from production traces

We started from Chat LangChain's production traces. An internal agent we're developing grouped them into usage patterns and built tasks from those groups so the benchmark covers how people actually use the agent. Every task has an answer key, and automated graders we call verifiers score the agent's answer against it. We split the tasks into a training set and a held-out set of 128, and the held-out set became the benchmark.

Agent runs are hard to compare when the tools and data they depend on keep changing, so our agent built a mocked environment for the Chat LangChain agent to run in. It mirrors how Chat LangChain is configured in production, which means a change in score comes from the model rather than from the environment.

With the benchmark built, we calibrated it. We checked that it ranks stronger models above weaker ones, as the chart in the intro shows, and that the verifiers give the same score when they grade the same run twice. We also had a model review the verifiers' decisions. Each run surfaced errors in tasks or verifiers, and we kept fixing them until a run turned up none.

The held-out questions resemble production traffic, but the set is harder on purpose. We picked 78 of the 128 tasks because the base model struggled with them, which leaves room to see whether training moves the score.

Training

We tried three training methods. They differ in which parts of a trajectory get a training signal, and that decided how much extra research each one taught the model.

SFT

Our teacher was the larger GLM 5.3, whose trajectories in our training data averaged 8 tool calls per question.

  • The score rose by 0.052.
  • The student made 14.5 tool calls per question, against 5 for the base model and more than the teacher itself.
  • Median latency in our offline test setup went from 17 seconds to 75, which is too slow for chat.
  • Self-distillation, where the base model trains on its own trajectories, changed its behavior much less. It raised the score by only 0.014.

GRPO

  • The score rose by 0.037.
  • Attempts that made more tool calls tended to score higher, so the model learned to research more. It made 42% more tool calls and took 40% more turns.
  • Soft penalties on tool calls didn't hold research down, and the model still roughly doubled its calls.
  • Hard caps and strong efficiency weights cut research so far that the score fell below the base model's.
  • It cost more to train than SFT.

Answer-only DPO

Only the final answer is trained, so the research steps get no direct signal. We took the candidate answers from the base model, because the best of its four attempts at each question scores 0.914, against about 0.7 for a single attempt. Some hand annotation and a council of judge models picked the better answer in each pair.

  • It gave the largest gain, 0.056 over the base model, and it's the version we deployed.
  • Research still went up, with 33% more tool calls and 25% more turns, but far less than with teacher SFT.
  • About one in five rejected answers was a confident claim that something doesn't exist, made after a shallow search. Our best explanation is that learning to avoid them taught the model not to stop searching early.

Answer-only DPO raised the score the most, and it added far less research than teacher SFT or GRPO.

What production showed

To see how the fine-tune did with real users, we split Chat LangChain's traffic evenly between the fine-tune, base GLM 5.3 Flash, and Gemini 3.5 Flash Lite, and scored every response with online evals in LangSmith.

Groundedness measures whether an answer is supported by the docs the agent retrieved. The fine-tune led on groundedness every day of the test.

We also had a model judge read the three answers to each question and pick the best one. On most questions the answers were similar, but where they differed in substance, the judge picked a GLM model 82% of the time across 119 comparisons, split evenly between the fine-tune and the base model.

Online evals also caught a latency problem. In the first days of the test, 18.7% of the fine-tune's runs took longer than 30 seconds. To combat this, we added an instruction to keep answers concise, and over the next six days that share fell to 5.9%, close to base GLM's 5.4%.

We chose the fine-tune even though it answers more slowly than Gemini. For a docs assistant, a wrong answer costs a user more than a few extra seconds, since they may go on to build with an API that doesn't exist, and the fine-tune beat Gemini on every quality measure while costing less to run.

What's next

The fine-tune is now Chat LangChain's main model, and we'll keep feeding new production traces and online eval results back into its training data.

If you want to fine-tune the model behind your own agent on its production traces, reach out and we'll help you get started!

← All articles

What this article says

More in AI & Machine Learning

All →
The real cost of self-hosting speech-to-text
AssemblyAI

The real cost of self-hosting speech-to-text

Rethink Reranking
Qdrant

Rethink Reranking

IEEE Fellowship for Prof Hatice Gunes
Cambridge LTL

IEEE Fellowship for Prof Hatice Gunes

AI tokens explained: the cost of every AI prompt
Perplexity

AI tokens explained: the cost of every AI prompt

How Perplexity defended against an autonomous AI attacker
Perplexity

How Perplexity defended against an autonomous AI attacker

Introducing MolmoWeb 2: Advancing open visual web agents with reinforcement learning
Hugging Face

Introducing MolmoWeb 2: Advancing open visual web agents with reinforcement learning

More from LangChain

The Agent Lake
LangChain

The Agent Lake

How We Achieved ISO 42001 with LangSmith
LangChain

How We Achieved ISO 42001 with LangSmith

How to build a knowledge factory for AI agents
LangChain

How to build a knowledge factory for AI agents

Why agent governance starts with observability
LangChain

Why agent governance starts with observability

LangSmith Tool Gateway: Secure, governed tool use for agents
LangChain

LangSmith Tool Gateway: Secure, governed tool use for agents

LangSmith for Coding Agents: Now track spend by outcome
LangChain

LangSmith for Coding Agents: Now track spend by outcome