feat: add examples/model_drift — answer-drift gate for model migrations - #58
Merged
Conversation
Check whether a replacement model drifts from a soon-to-be-discontinued one on a fixed prompt set. Records the old model's answers as a golden run and the new model's as a candidate, then gates with RegressionGate + a pluggable answer-equivalence evaluator (stdlib lexical or LLM-as-judge). The LLM judge fails closed: any reply that isn't a clean [0,1] score reads as drift, so a flaky judge can't silently pass a regression. record_baseline(...) / --record-golden + --golden-db let you pin the old model's golden while it's still callable and gate against it after retirement (the old model is never re-called on the reuse path). Ships a deterministic offline FakeModelClient so the flow runs in CI with no key; the OpenAI client and its opt-in 'openai' extra are lazily imported, keeping dprovenancekit/ stdlib-only and unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A reusable
examples/model_drift/recipe: check whether a replacement model drifts from a soon-to-be-discontinued one on a fixed prompt set.It records the old model's answers as a golden run and the new model's as a candidate (one
CRITICALgenerationevent per prompt carrying{prompt_id, model, response}), then gates the candidate with the kit'sRegressionGate+ a pluggable answer-equivalence evaluator. A per-prompt answer below your threshold surfaces as a critical regression (drift); the CLI exits1on drift,0on parity — drops straight into CI.Why
Model deprecations are a canonical migration risk with no first-class recipe in the repo.
dpk compare/gatealready do golden-vs-candidate gating; this fills the gap of driving two models and judging answer equivalence.Design & principles
openaiextra topyproject.toml. No change todprovenancekit/.DriftEvaluator— stdlibLexicalSimilarityEvaluator(default,difflib) +LLMJudgeEvaluator. The judge fails closed: any reply that isn't a clean[0, 1]score (an error string, an out-of-range number like"Error 503"or"9 out of 10") reads as drift, so a flaky judge can never silently pass a regression.record_baseline(...)/--record-golden+--golden-dbpin the old model's golden while it's still callable, then gate against it after retirement (the old model is never re-called on the reuse path).FakeModelClient(parity/drift modes); no network, no key.Tests / verification
tests/test_model_drift.py): parity passes, drift fails and names the drifted prompts, CLI exit codes, imports + runs withopenaiabsent, judge fails-closed on unparseable/out-of-range replies, saved-golden reuse never calls the old model.ruffclean;mypyclean on the example and ondprovenancekit/.Usage