← Back to Pull requests

feat(hermes): graded relevance labels and a per-stage loss report for evaluation #1644

Open
unknown opened this pull request with 328 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 02, 2026 05:35 UTC
Author

Summary

This PR adds two offline evaluation scripts for Hermes retrieval. The answering path is unchanged.

Why: gold cases name only a few target records, so other valid records counted as misses. On 2026-10-02 that made the first stage look weak ("paraphrase targets are outside the top 15"). With graded labels on pooled candidates, the current pair puts a relevant record in the top 30 for 68 of 73 questions.

  • graded-labels.mjs: pools the gold targets, the shown records, and the top 30 candidates of evaluated runs. JEV grades each question-record pair from 0 to 3, with a rubric worded differently from the production judge. Pairs already labelled are skipped, so a later run only adds its new candidates. The label file holds ids and grades, no record text.

  • graded-score.mjs: scores runs against the labels. It reports the shown records by grade and, for each answer case that showed nothing, the stage that lost it: answered in another form, no relevant record labelled, relevant records outside the judged candidates, or rejected by the judge.

  • hermes-retrieval-accuracy-log.md: the "How to measure" section describes both commands and the self-grading caveat (the judge and the grader are both JEV).
  • Checked on real data: the per-stage loss report matches the hand analysis of the same runs (10 answer cases with nothing shown: 2 asked back, 3 rejected by the judge, 4 outside the judged candidates, 1 with no relevant record).

    <!-- deploy-impact:start -->
    | Item | Declaration |
    | --- | --- |
    | Risk | unknown |
    | Target machines | pi3, pi4, pi5 |
    | Changed surfaces | api, docs, unknown |
    | Required files/artifacts | N/A: no new artifact; the two scripts are copied into the API image with the rest of scripts/hermes-search and nothing calls them at runtime |
    | Database | no: no schema, query, or migration change |
    | Secrets/config delivery | no: no new flag or secret |
    | Success evidence | node --test retrieval/ in scripts/hermes-search: 126 passed, including pooling, grade parsing, resumable labelling with a failing batch, and loss attribution. Real-data check as above. |
    | Rollback/cleanup | Revert this PR; no runtime state changes. |
    | Production verification | N/A: evaluation scripts and docs only; the answering code does not import them. |
    <!-- deploy-impact:end -->

    Test plan

  • Commands and environments: node --test retrieval/ (macOS, Node 24). Private runs of both scripts against JEV (TypeSafe).

  • Evidence: 126/126 tests passed.

  • Not run / reason: no deploy. Nothing at runtime uses these scripts.
  • 🤖 Generated with Claude Code

    Diff: 328 lines (+246 / -82) across 4 files Reviewer: chatgpt-codex-connector[bot] Review duration: 3m
    All Vouch review confidence checks passed
    Residual risk 0.32 = Change Risk (0.42) × (1 − Review Confidence (0.23)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 328 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 37% · Reviewer familiarity: 35%
    22%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1644"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 22.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 22.9% · Lower = rushed or shallow review
    22.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.4% · Safe to merge
    32.4%