06 Experiments
Workshop source
Workshop material is maintained in the public langfuse/langfuse-workshop repository. Use the repository for the runnable app, checkpoint branches, and local setup.
Learner guide: 06 Experiments
Instructor notes
- The key idea is reuse: the experiment runner calls the same
runSupportConversation(...)as the web app. - Explain why these evaluators differ from the monitoring ones: production traffic has no reference answer, so 4.3 Capturing signals uses judges that read only the conversation (user disagreement, all caps). A dataset has expected outputs, so
behavior_matchandcorrectnesseach compare against a field inexpectedOutput. - Tie the two evaluators to the two goals from 05:
behavior_match(Decisions API label plus exact match) checks the right behavior and shows whether a change fixed what it targeted;correctness(LLM-as-a-judge) checks the answer is correct and is the regression check that catches a fix making answers worse. Both are callbacks onrunExperiment. - Frame the set as a starting point: the simplest check per goal. Not every error-analysis category gets an offline evaluator (impersonation and lengthy replies don't here), and the suite should grow as error analysis surfaces failures worth tracking. A word-count check for length is the obvious next one if a group asks.
- Point at the semantic-equivalence judge prompt in
scripts/run-dataset.ts: expected output is the source of truth; paraphrases pass; missing material meaning fails. - Call out why this chapter avoids Langfuse Platform evaluators as the primary path: configuring one needs existing experiment data to preview mappings, which blocks a clean first run.
- The correctness judge uses the learner's
OPENAI_API_KEY/OPENAI_MODEL.behavior_matchuses the same key withgpt-6-lunaon the Decisions API. Session 4's Langfuse default evaluator model is not required here. - Emphasize that both scores should appear in the console summary when
npm run dataset:runfinishes. - Keep concurrency at one for workshops so traces and the final run summary are easy to follow.
- Before running the dataset, confirm both the OpenAI and Langfuse credentials point to active projects. The runner can finish with exit code 0 after skipping every item, so always check that the console prints experiment results rather than only SDK errors.
- Optional bonus only if you have time: show that Platform evaluators can still target experiment observations after the first run exists.
Demo rhythm
- Skim the numbered sections in
scripts/run-dataset.ts. - Point out the two callback evaluators in the
evaluatorsarray. - Run
npm run dataset:run. - Open the run table, per-item traces, and chart view: both scores should already be present.
- (Optional) Mention Platform evaluators / Check Correctness as a later add-on once experiment data exists.
Watch for
- Learners trying to set up Check Correctness in the UI before the first run. Redirect them to the script callbacks; platform setup is bonus-only.
- The ideal answers are written in the shape the step 07 prompt asks for, but only with the steps that matter. The generic semantic-equivalence judge treated every detail as required (Face ID without "or passcode", a decline that didn't name the topic, a clarifying question with different examples), so the judge prompt has a short "What Is Material For This Support Agent" section. Without it,
correctnesssat around 0.6 for both prompts. Use this as the live example of checking a judge against your own labels. - Do not use
expectedBehavioras the correctness reference. That field belongs tobehavior_match; correctness usesidealAnswer. - Expect a first run around
behavior_match0.68–0.72 andcorrectness0.68. The current prompt walks Dad through the out-of-scope requests instead of deferring, including the ones that arrive mid-conversation, and rarely asks a follow-up on the vague items. That gap is what step 07 fixes. - Missing
behavior_matchusually means the Decisions call failed, for example because the OpenAI key has no access togpt-6-luna. Check the terminal error. 401 The project you are requesting has been archivedfollowed byNo experiment results to displaymeans the OpenAI key belongs to an archived project. ReplaceOPENAI_API_KEYlocally with a key from an active project, then rerun.- Missing
correctnessin the console usually means the judge call failed (bad key, model, or JSON parse). Check the terminal error rather than refreshing Langfuse for a pending platform score.
Was this page helpful?