Skip to content

FEAT: Anthropic Model-Written Evals Dataset - #1170

Closed
Royce Moon (0xm00n) wants to merge 36 commits into
microsoft:mainfrom
0xm00n:feat/anthropic-model-written-evals-dataset
Closed

Royce Moon (0xm00n) wants to merge 36 commits into
microsoft:mainfrom
0xm00n:feat/anthropic-model-written-evals-dataset

Conversation

@0xm00n

Copy link
Copy Markdown
Contributor

Description

This PR adds support for the Anthropic model-written-evals dataset to PyRIT. The model-written-evals dataset contains 154 evaluation datasets designed to test LLM behaviors across 4 main categories: persona traits, sycophancy, advanced AI risks, and gender bias. The evaluations use language models to automatically generate test cases across multiple behavioral dimensions.

Dataset: https://github.com/anthropics/evals

Associated Paper: https://arxiv.org/abs/2212.09251

Work Completed

  • Implemented the fetch_anthropic_evals_dataset() function in anthropic_evals_dataset.py
  • Added unit tests in test_anthropic_evals_dataset.py (12 test cases)
  • Added integration test in test_fetch_datasets.py
  • Updated API documentation in api.rst
  • Registered function in pyrit/datasets/__init__.py

Related Issue

Contributes to issue #450

Royce Moon (0xm00n) and others added 5 commits November 2, 2025 20:10
[pull] main from Azure:main
  - Implement fetch_sorry_bench_dataset() for sorry-bench/sorry-bench-202503 on Hugging Face
  - Support filtering by 44 categories and 21 prompt style linguistic mutations
  - Default to base prompts only
  - Add unit tests (10 tests)
  - Add integration test
  - Update API documentation
…dation

  - Change prompt_styles (list) to prompt_style (string) for simpler API
  - Add input validation for categories and prompt_style
  - Add VALID_CATEGORIES and VALID_PROMPT_STYLES for input validation
  - Fix exception handling to preserve stack traces
  - Update tests to match new API (12 tests, all passing)
  Implements support for Anthropic's model-written-evals dataset with 154 evaluation datasets across 4 categories.

  Changes:
  - Add fetch_anthropic_evals_dataset() function with category filtering
  - Support for persona, sycophancy, advanced-ai-risk, and winogenerated categories
  - Fetches directly from GitHub repository using API for file discovery
  - Add unit tests (12 tests)
  - Add integration test
  - Update API docs
Comment thread pyrit/datasets/sorry_bench_dataset.py Resolved
@hannahwestra25

Copy link
Copy Markdown
Collaborator

Thanks for adding these! made a few stylistic suggestions!

@romanlutz Roman Lutz (romanlutz) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work! Looking forward to having this dataset fetcher in PyRIT 🙂

@romanlutz

Copy link
Copy Markdown
Contributor

Royce Moon (@0xm00n) btw I just saw Anthropic drop a new dataset: https://www.anthropic.com/news/political-even-handedness

Any chance you're interested in contributing a similar fetcher for it as well? It has two prompts per row so it would require a tiny bit of custom handling, but otherwise (more?) straightforward than this one.

@0xm00n

Copy link
Copy Markdown
Contributor Author

Royce Moon (@0xm00n) btw I just saw Anthropic drop a new dataset: https://www.anthropic.com/news/political-even-handedness

Any chance you're interested in contributing a similar fetcher for it as well? It has two prompts per row so it would require a tiny bit of custom handling, but otherwise (more?) straightforward than this one.

Yup, seems pretty easy. will work on it soon

Royce Moon (0xm00n) and others added 3 commits November 21, 2025 12:39
…cture

  Changed fetch_anthropic_evals_dataset() to return QuestionAnsweringDataset
  instead of SeedDataset, following the QA structure established in PR microsoft#894.

  - Added _parse_answer_choices() to convert answer behaviors into structured
    QuestionChoice objects with proper indexing
  - Preserved letter prefixes in choice text
  - Used answer_matching_behavior as correct_answer for consistency
  - Special handling for winogenerated datasets with pronoun_options
  - Removed redundant tests, added critical tests for choice parsing edge cases
  - Fixed docstrings to comply with ruff linting rules

  This makes the dataset compatible with QuestionAnsweringBenchmark orchestrator
  and follows the pattern where choices are structured objects rather than
  metadata strings.
@0xm00n

Copy link
Copy Markdown
Contributor Author

Yes, all tests pass!

@0xm00n

Copy link
Copy Markdown
Contributor Author

Roman Lutz (@romanlutz) following up here so we can close the PR

@romanlutz Roman Lutz (romanlutz) self-assigned this Dec 9, 2025
Resolve conflicts by adopting main's new SeedDatasetProvider architecture
while keeping fetch_anthropic_evals_dataset as a standalone function
(returns QuestionAnsweringDataset, not SeedDataset).
@0xm00n

Copy link
Copy Markdown
Contributor Author

Roman Lutz (@romanlutz) refactored for conflicts given the new v0.10.0! should save you some work :)

@romanlutz

Copy link
Copy Markdown
Contributor

Thank you! Will take a look today.

Comment thread doc/api.rst Resolved
Comment thread pyrit/datasets/__init__.py Resolved
Comment thread pyrit/datasets/__init__.py Resolved
Comment thread pyrit/datasets/dataset_helper.py Resolved
Royce Moon (0xm00n) and others added 5 commits December 19, 2025 19:46
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Royce Moon (0xm00n) and others added 5 commits January 7, 2026 20:49
…oader ABC

Extracts the MD5-keyed URL-fetch/disk-cache logic that was duplicated
between _RemoteDatasetLoader and anthropic_evals_dataset into
pyrit/datasets/_remote_fetch.py, and introduces _RemoteQADatasetLoader
as a sibling ABC of _RemoteDatasetLoader for loaders that produce
QuestionAnsweringDataset (structured MC) instead of SeedDataset.

Ports anthropic evals to _AnthropicEvalsDataset(_RemoteQADatasetLoader)
while preserving the public fetch_anthropic_evals_dataset function.
Both fetch_anthropic_evals_dataset and fetch_wmdp_dataset are now
re-exported from pyrit.datasets and listed in doc/api.rst (neither was
reachable before).

Also fixes a latent parser crash: real sycophancy_on_philpapers2020
rows have list-valued answer_not_matching_behavior (up to 6 entries);
the parser now normalizes both fields to lists and expands them into
MC choices.
Resolves a conflict in remote_dataset_loader.py where main added
cast() calls to FILE_TYPE_HANDLERS indexing for mypy strictness.
Kept the HEAD-side delegation to pyrit.datasets._remote_fetch and
pushed the cast() calls down into the shared helper instead.

Also applies ruff format and tightens type annotations to satisfy
the stricter mypy config merged from main (Callable[..., Any],
Dict[str, Any] on parse helpers, Any on _normalize_answer_field /
_load_dataset_sync).
@0xm00n

Royce Moon (0xm00n) commented Apr 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Roman Lutz (@romanlutz) refactored what we talked about before so its compatible with latest 0.14.0.dev0. a summary:

  • pyrit/datasets/_remote_fetch.py: shared URL fetch/MD5 cache helpers, parameterized by cache_subdir
  • _RemoteDatasetLoader: internals delegate to _remote_fetch
  • _RemoteQADatasetLoader(ABC): sibling ABC returning QuestionAnsweringDataset. Does not inherit SeedDatasetProvider
  • _AnthropicEvalsDataset(_RemoteQADatasetLoader): public fetch_anthropic_evals_dataset retained as thin wrapper
  • Lifted MAINT Normalize remote dataset file types from URLs #1486 's _get_file_type() URL aware inference into _remote_fetch.get_file_type() so the QA loader benefits too
  • Neither fetch_anthropic_evals_dataset nor fetch_wmdp_dataset was reachable from pyrit.datasets so this was fixed
  • Parser fix: sycophancy_on_philpapers2020 has list-valued answer_not_matching_behavior which made it crash on list.strip(). now normalized and expanded to multiple choice

let me know if there needs to be some more refactoring or other fixes.

@0xm00n

Copy link
Copy Markdown
Contributor Author

no response so closing this feature PR

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.

4 participants