feat: custom zero-shot taxonomies for the v2 detectors - #94
Merged
Merged
Conversation
…nerative detector
TaxonomyTyper accepts custom {name: description} label sets (labels enter
only as text, matching training); TransformerDetector and the facade thread
them through include_taxonomy. The native generative path builds its prompt
and schema from custom labels when provided. zero_shot/fewshot_path/
prompt_path now raise on native detectors instead of being silently ignored.
Closes #92
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.
What
Implements #92:
TaxonomyTypergainscategories/subcategoriesdict params; custom labels are embedded exactly like the trained ones (name: descriptiontext), so held-out labels type zero-shot from their description. Frozen dicts remain the default.TransformerDetector(taxonomy_head=..., include_taxonomy=...)and the facade accept the samebool | list | dictsemantics asLLMDetector, plus a nested{"categories": {...}, "subcategories": {...}}form for full control (flat dict = categories; without custom subcategories the native path collapses subcategory tounspecified).lettucedect-v2-qwen-2b) builds its system prompt and JSON-schema enums from the custom labels when provided — the trained prompt structure is preserved since labels were always inline text. Marked experimental in code comments pending the holdout evaluation (tracked on Expose custom zero-shot taxonomies on the taxonomy head and the native generative detector #92).zero_shot,fewshot_path,prompt_pathnow raiseValueErroron native detectors instead of being silently ignored; message points atnative=False.15 new network-free tests (
tests/test_custom_taxonomy_pytest.py) with stubbed clients/encoders; full suite 178 passed; ruff format + check clean under the CI invocation.The held-out-label evaluation for both paths (acceptance item on #92) follows as a separate run; numbers get posted on the issue before any public zero-shot claim.
Closes #92
Checklist
python -m pytest tests/test_custom_taxonomy_pytest.py -vgreen; full suite green; ruff clean.I certify that I have the right to submit this code and that it may be distributed under the repository's MIT license