FEAT Add multi-label true/false scoring with explicit label selection - #2858
Open
biefan (biefan) wants to merge 1 commit into
Open
biefan (biefan) wants to merge 1 commit into
biefan (biefan) wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
Related to #2565.
A classifier can answer several independent questions in one inference, but a single
MessageTrueFalseScoreraggregates them into one boolean. WildGuard currently exposes one selected verdict and keeps the other judgments in metadata. Users cannot query or evaluate those secondary judgments as normal scores without making separate classifier calls.This adds an opt-in multi-label contract and a working WildGuard implementation. For example, one successful classification of a harmful request that receives a refusal can now produce:
score_categoryharmful_requestresponse_refusalharmful_responseThe three scores have distinct IDs and reference the same retained classifier observation. Choosing
harmful_responseas the objective therefore yields False, regardless of the other labels' True values.API and design choices
MultiLabelTrueFalseScorerdeclares the output labels and validates exactly one category per verdict.MessageMultiLabelTrueFalseScoreradds the existing message pipeline and aggregates supported pieces within each label. Unknown, duplicate, or missing labels are rejected before persistence. Non-applicable evidence still returns[].Score.score_category=[label], so scores retain their existing IDs, evidence anchors, expectations, serialization, and observation links. There is no schema migration. The existing category query is fixed to match complete JSON-array elements, case-insensitively; comparing the entire array with a string previously missed these stored scores.TrueFalseScoreSelectoradapts a named label toTrueFalseScorerfor attacks, boolean wrappers, and objective evaluation. Its identity includes the source configuration and selected label, and its batch path retains the source target's rate-limit policy. Raw multi-label scorers cannot silently enter single-verdict consumers or float thresholding.WildGuardMultiLabelScoreruses the shared transport, three-label parser, prompt template and context resolution. It makes one classifier call per supported text piece, excluding retries for malformed responses. Any label may returnN/Awithout discarding the other judgments or triggering a retry; it becomesUNDETERMINED. Fully blocked/unreadable evidence also remains undetermined for every label.Persistence and compatibility: a selector follows the existing wrapper contract and persists only its selected projection. Call the multi-label root directly to save every label. Separate selector calls do not share cached inference. Existing
WildGuardScorer(label=...)and single-verdict scorers retain their APIs and verdict behavior; only WildGuard's unchanged context-resolution logic is shared with the new implementation.Tests and Documentation
make unit-test(Python 3.11, default dependencies): 20,464 passed, 146 skipped, 1 failed. The sole failure is the pre-existingtest_get_seed_dataset_summaries_follows_a_trailing_blank_insensitive_collationintests/unit/memory/memory_interface/test_interface_seed_prompts.py, independently reproduced at unmodified basef65263eusing the same environment.The new offline notebook was executed with the checkout's virtual-environment kernel. Its retained output shows 1 classifier call, 3 persisted scores, 1 shared observation, and no additional call when reading saved categories. The paired Python source matches the notebook. The framework documentation and scoring navigation are updated.
Validation is local and offline; no live WildGuard endpoint, model weights or paid model calls were used.