mirror of
https://github.com/p-e-w/heretic.git
synced 2026-12-03 18:42:57 +07:00
[PR #53] [MERGED] feat: generic plugin system #259
Labels
No labels
bug
enhancement
enhancement
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
p-e-w/heretic#259
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/p-e-w/heretic/pull/53
Author: @red40maxxer
Created: 11/27/2025
Status: ✅ Merged
Merged: 7/7/2026
Merged by: @p-e-w
Base:
master← Head:refusal-plugins📝 Commits (10+)
a4a97c7style: ruff7f0562bfeat(wip): populate metadata fields and allow plugins to declare what they needd1f1428refactor: extract metadata logic to separate module9d9530astyle: placate ruffd7964e9chore: use eos token for inferring finish reason with fallback81c0913fix: handle empty responses betterdb1a3b6style: ruff8b62b58refactor: combine response text and metadata into single objectee3090erefactor: clean up tagger and scorer usagead69824style: ruff📊 Changes
20 files changed (+1177 additions, -389 deletions)
View changed files
📝
README.md(+8 -8)📝
config.default.toml(+63 -43)📝
config.nohumor.toml(+19 -18)📝
config.noslop.toml(+24 -23)📝
src/heretic/analyzer.py(+2 -2)📝
src/heretic/config.py(+55 -77)📝
src/heretic/evaluator.py(+225 -89)📝
src/heretic/main.py(+101 -64)📝
src/heretic/model.py(+22 -27)➕
src/heretic/plugin.py(+289 -0)➕
src/heretic/scorer.py(+68 -0)➕
src/heretic/scorers/__init__.py(+0 -0)➕
src/heretic/scorers/keyword_rate.py(+134 -0)➕
src/heretic/scorers/kl_divergence.py(+71 -0)📝
src/heretic/utils.py(+76 -25)📝
tests/gemma-4e/config.toml(+2 -3)📝
tests/minicpm5/config.toml(+7 -2)📝
tests/mistral-3/config.toml(+2 -3)📝
tests/qwen2.5/config.toml(+7 -2)📝
tests/qwen3.5-moe/config.toml(+2 -3)📄 Description
Refactors refusal detection and refusal counting into a modular plugin system. This allows for arbitrary logic (regex, embeddings, external models) to be added without modifying core code.
Plugin system
Scorerstake in responses and optional response metadata and produce a singleScorethat Optuna can use for optimization, eg.["I can't help you with that.", "Certainly!"] -> 0.67. By default, this is the KL divergence and refusal rate.Scorer, adding implementations for the abstract methods and addScorerClassName.propertyin theconfig.tomlfor any user-defined configuration you need. Make sure the config fields are defined in aPluginSettings- look atKeywordRateandKLDivergencefor reference.Scorerto access important outputs fromModelare provided throughContext, such asget_responses(),get_logits(), etc.ScorerClassName_InstanceName.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.