Skip to content

Advanced aggregation options and built in per‑text explainability for rare‑class affinity#7

Open
ch1kim0n1 wants to merge 1 commit into
Roblox:mainfrom
ch1kim0n1:Enhanced_detection
Open

Advanced aggregation options and built in per‑text explainability for rare‑class affinity#7
ch1kim0n1 wants to merge 1 commit into
Roblox:mainfrom
ch1kim0n1:Enhanced_detection

Conversation

@ch1kim0n1
Copy link
Copy Markdown

This enhancement adds flexible aggregation strategies and rich explainability to the rare‑class affinity pipeline:

  • New aggregators in sentinel.score_formulae:
    • skewness (default), top_k_mean(k), percentile_score(q), softmax_weighted_mean(temperature), max_score
  • Per‑text explainability is now returned in RareClassAffinityResult.explanations:
    • topk_positive/topk_negative: scaled similarities used for the score
    • contrastive: positive_term, negative_term, log_ratio_unclipped (components behind the final score)
    • neighbors: compact snippets of top neighbors with sign and scores (when corpora provided)
  • Aggregation metadata is returned:
    • aggregation_name and aggregation_stats (num_texts, num_positive_scores, top_k_per_observation, min_score_to_consider)

This keeps the default behavior (skewness + high‑recall) while enabling targeted tuning and greater transparency.

Why this is useful:

  1. Lets teams choose aggregation behavior that fits their recall/precision and sensitivity needs.
  2. Explanations show exactly why a text scored, aiding debugging, trust, and audits.
  3. Aggregation metadata and neighbors make triage and threshold setting faster.
  4. Clean extension points for additional aggregators or custom policies without changing callers.

All tests are passed:

image

@Anjo2807
Copy link
Copy Markdown

that looks like a good pr but i dont work for roblox soooo i cant approve it :P

Copy link
Copy Markdown

@Anjo2807 Anjo2807 left a comment

Choose a reason for hiding this comment

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

i can approve but it cant be merged cuz i have read-only access :P

@SteveTheAnimator
Copy link
Copy Markdown

Finally, Something not whining about schlep!

@Anjo2807
Copy link
Copy Markdown

Anjo2807 commented Aug 17, 2025

Finally, Something not whining about schlep!

yeah... fucking god just take the #freeschlep thing to twitter and not here

Copy link
Copy Markdown

@jbsparrow jbsparrow left a comment

Choose a reason for hiding this comment

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

Please move the "What's new" changes in README.md to a CHANGELOG.md file following https://keepachangelog.com/en/1.1.0/.

Comment thread README.md

By prioritizing recall over precision, Sentinel serves as a high-recall candidate generator for more thorough investigation. This approach is particularly effective for applications where rare patterns are critical to identify. Rather than treating each message in isolation, Sentinel analyzes patterns across messages to identify concerning behavior.

## What’s New: Aggregation options and Explainability
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should be in its own file, CHANGELOG.md, and should follow https://keepachangelog.com/en/1.1.0/.

Comment on lines +262 to +264
prevent_exact_match: bool = False,
encoding_additional_kwargs: Mapping[str, Any] = {},
show_progress_bar: bool = False,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you add back the indentation please?

Comment on lines +321 to +325
# Explainability defaults (always on for transparency)
explain = True
include_neighbors = True
neighbors_limit = 5

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could you add these as parameters with defaults instead please?

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.

7 participants