Skip to content

Add Hugging Face Lighteval adapter - #178

Merged
k-dickinson merged 2 commits into
k-dickinson:mainfrom
nolanefe:feat/lighteval-adapter
Aug 5, 2026
Merged

k-dickinson merged 2 commits into
k-dickinson:mainfrom
nolanefe:feat/lighteval-adapter

Conversation

@nolanefe

@nolanefe nolanefe commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #168.

Adds a Hugging Face Lighteval adapter for structurally detecting and normalizing per-sample evaluation details into EvalTrust's canonical schema.

Supported input

The adapter accepts JSON representations of Lighteval per-sample detail records using either of the two official field-name forms currently encountered:

  • doc, metric, and optional model_response
  • __doc__, __metric__, and optional __model_response__

Detection is based entirely on content structure and does not depend on filenames.

If both aliases for the same logical field are present, equal values are accepted; conflicting values are treated as malformed rather than silently choosing one.

Normalization

  • Preserves stable example identifiers
  • Includes task identity in example IDs where available
  • Preserves multiple metric names independently
  • Skips null and non-numeric metric values
  • Ignores metric standard-error fields
  • Maintains deterministic input ordering
  • Does not fabricate per-example records from aggregate task summaries

Aggregate-only Lighteval result files are detected and rejected with a specific explanation because they do not contain the per-example data required by EvalTrust.

Fixture provenance

The main fixture was converted from an official recent Lighteval reference-details Parquet artifact:

  • Task: agieval:aqua-rat|0
  • Model: HuggingFaceTB/SmolLM2-1.7B-Instruct
  • Artifact date: 2025-11-05
  • Lighteval SHA: 01bd59882e01ab82971e6ab07c7c39c69ab8664b

It retains the authentic doc / metric / model_response structure while being reduced to three examples and having large token arrays truncated. Full provenance is documented alongside the fixture.

Limitations

EvalTrust does not read native Parquet files directly. Lighteval per-sample details must first be represented as JSON.

The adapter targets the current documented and recently observed detail structures rather than claiming compatibility with every historical Lighteval export.

Validation

  • Focused adapter tests — 32 passed
  • Full test suite — 1133 passed, 1 skipped
  • PYTHON=.venv/bin/python make test — passed
  • Ruff — passed
  • git diff --check — passed

No canonical-schema or dependency changes were required.

Summary by CodeRabbit

  • New Features

    • Added support for importing Lighteval (Hugging Face) per-sample detail exports.
    • Supports multiple documented JSON layouts, field-name variants, optional model responses, grouped tasks, and numeric metrics.
    • Automatically identifies preferred correctness metrics and generates example-level evaluation records.
    • Provides clear errors for aggregate exports that lack per-example details.
  • Documentation

    • Added usage guidance, supported formats, conversion requirements, and comparison examples for Lighteval exports.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@nolanefe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: feac5259-ed56-41a8-92c3-a9262ab50b2e

📥 Commits

Reviewing files that changed from the base of the PR and between 3ed25b9 and 7f98294.

📒 Files selected for processing (6)
  • README.md
  • docs/adapters.md
  • docs/input-formats.md
  • src/evaltrust/adapters/lighteval.py
  • tests/fixtures/lighteval_PROVENANCE.md
  • tests/test_lighteval_adapter.py
📝 Walkthrough

Walkthrough

The PR adds a structural Lighteval adapter for per-sample JSON exports. It supports multiple detail shapes and field aliases, converts metrics into canonical records, rejects aggregate-only files, registers the adapter, and adds tests, fixtures, and documentation.

Changes

Lighteval adapter support

Layer / File(s) Summary
Lighteval detail parsing
src/evaltrust/adapters/lighteval.py
Adds structural detection, alias handling, detail-shape parsing, metric conversion, deterministic IDs, skipped-row metadata, primary-metric selection, and aggregate-result errors.
Registry wiring and validation
src/evaltrust/adapters/registry.py, tests/test_lighteval_adapter.py, tests/fixtures/*
Registers Lighteval before generic adapters. Tests cover supported shapes, aliases, malformed rows, aggregate errors, registry routing, and authentic fixtures.
Input documentation and examples
README.md, docs/adapters.md, docs/input-formats.md
Documents Lighteval detail exports, field variants, Parquet conversion, model comparison, and unsupported aggregate results.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: k-dickinson

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant AdapterRegistry
  participant LightevalAdapter
  participant EvalData
  Caller->>AdapterRegistry: submit Lighteval JSON export
  AdapterRegistry->>LightevalAdapter: detect and parse payload
  LightevalAdapter->>LightevalAdapter: resolve fields and convert detail rows
  LightevalAdapter->>EvalData: return canonical evaluation data
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding a Hugging Face Lighteval adapter.
Linked Issues check ✅ Passed The adapter structurally detects Lighteval detail exports and maps per-task records to the canonical schema with example IDs and metrics [#168].
Out of Scope Changes check ✅ Passed The code, tests, fixtures, registry updates, and documentation directly support the Lighteval adapter objective.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (1)
tests/fixtures/lighteval_PROVENANCE.md (1)

5-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin the fixture source to an immutable artifact.

The source identifies branch main, and the retrieval path is elided. A reviewer cannot independently retrieve and verify the original Parquet artifact from this document. Record the full upstream commit or blob identifier and an artifact digest.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/fixtures/lighteval_PROVENANCE.md` around lines 5 - 15, Update the
provenance documentation for the referenced Lighteval fixture to replace the
mutable main-branch reference with the complete immutable upstream commit or
blob identifier and the full retrieval path. Add the Parquet artifact’s digest,
preserving the existing model, task, timestamp, and fixture details so the
source can be independently retrieved and verified.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/adapters.md`:
- Around line 119-138: Document the Lighteval normalization rules in both
docs/adapters.md lines 119-138 and docs/input-formats.md lines 166-176: invalid
or unparseable metric values are skipped rather than raised, standard-error
fields are ignored, valid metrics preserve input order, and conflicting aliases
are treated as malformed. Add the same guidance next to the accepted Lighteval
input shape in both locations, while retaining the existing alias and
metric-selection descriptions.

In `@README.md`:
- Line 341: Update the Lighteval entry in the README to explicitly require JSON
input and state that Parquet files must first be converted, or link to
docs/input-formats.md for these requirements; ensure users are not directed to
pass details_*.parquet directly.

In `@src/evaltrust/adapters/lighteval.py`:
- Around line 203-207: Update _detail_rows() and the task-grouped parsing path
to scan every candidate row for a valid detail record instead of limiting
validation to the first 10 entries or requiring the first item to be
well-formed. Preserve filtering to dictionary rows and accept lists when any
later row matches _looks_like_detail(); add regressions covering a valid 11th
row and a task-grouped list with a malformed first item.
- Around line 248-262: The row-processing loop in _parse_to_records must
revalidate each mapping against the adapter’s detail fingerprint after
_extract_detail_fields and before _example_id. Skip and increment skipped for
rows missing required detail fields such as query, choices, or gold_index, while
preserving existing alias-conflict handling and valid-row emission.
- Around line 264-278: The loop around _metric_score currently increments
skipped for invalid metric fields even when the row emits a record, so
skipped_rows is not a row count. Remove bad_metrics-based increments and update
skipped only when row_had_record remains false; keep record creation and stderr
handling unchanged.

---

Nitpick comments:
In `@tests/fixtures/lighteval_PROVENANCE.md`:
- Around line 5-15: Update the provenance documentation for the referenced
Lighteval fixture to replace the mutable main-branch reference with the complete
immutable upstream commit or blob identifier and the full retrieval path. Add
the Parquet artifact’s digest, preserving the existing model, task, timestamp,
and fixture details so the source can be independently retrieved and verified.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b4f2cbf-ac22-4334-8a04-84741384d45e

📥 Commits

Reviewing files that changed from the base of the PR and between d508963 and 3ed25b9.

📒 Files selected for processing (9)
  • README.md
  • docs/adapters.md
  • docs/input-formats.md
  • src/evaltrust/adapters/lighteval.py
  • src/evaltrust/adapters/registry.py
  • tests/fixtures/lighteval_PROVENANCE.md
  • tests/fixtures/lighteval_details_agieval_aqua_rat.json
  • tests/fixtures/lighteval_results_aggregate.json
  • tests/test_lighteval_adapter.py

Comment thread docs/adapters.md Resolved
Comment thread README.md Resolved
Comment thread src/evaltrust/adapters/lighteval.py Resolved
Comment thread src/evaltrust/adapters/lighteval.py Resolved
Comment thread src/evaltrust/adapters/lighteval.py Resolved
@nolanefe

nolanefe commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit review feedback in the latest commit:

  • scan the full candidate list for valid Lighteval details
  • revalidate the required detail fingerprint for every parsed row
  • keep skipped_rows as an input-row count rather than a metric-field count
  • document metric filtering, ordering, alias conflicts, and JSON/Parquet requirements
  • clarify JSON-only Lighteval input in the README
  • pin the main fixture provenance to an immutable upstream commit/path with the original Parquet SHA-256
  • add regressions for late valid rows, malformed task-grouped entries, per-row validation, and skipped-row accounting

Validation:

  • 39 focused Lighteval tests passed
  • full suite: 1140 passed, 1 skipped
  • Ruff passed
  • git diff --check passed

@k-dickinson k-dickinson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for contributing; this pr lgtm!

@k-dickinson
k-dickinson merged commit 78873c5 into k-dickinson:main Aug 5, 2026
5 checks passed
@nolanefe
nolanefe deleted the feat/lighteval-adapter branch September 22, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adapter: HuggingFace lighteval

2 participants