Skip to content

feat(classifiers): add DetectorMode::Model and CandleNerClassifier (#2210, #2211)#2227

Merged
bug-ops merged 5 commits intomainfrom
2210-detectormode-classifier
Mar 27, 2026
Merged

feat(classifiers): add DetectorMode::Model and CandleNerClassifier (#2210, #2211)#2227
bug-ops merged 5 commits intomainfrom
2210-detectormode-classifier

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 27, 2026

Summary

  • Adds DetectorMode::Model variant to FeedbackDetector, enabling offline CPU-based feedback detection via any ClassifierBackend without an LLM round-trip (feat(core): add DetectorMode::Model for classifier-backed feedback detection #2210)
  • Adds CandleNerClassifier wrapping DebertaV2NERModel with full BIO/BIOES span decoding for token-level NER/PII classification (piiranha default) (feat(classifiers): add NER/PII token-level classifier backend (piiranha) #2211)
  • Extends ClassificationResult with spans: Vec<NerSpan> (char offsets); all 9 existing literal sites updated
  • validate_safetensors deduplicated from candle.rs into shared ner::validate_safetensors (pub(crate))
  • Regex fallback + warn!() when classifiers feature is off or backend absent (C-03)
  • validate_detector_model_config() at bootstrap validates non-empty detector_model when mode=Model
  • --init wizard updated with 3-option detector_mode select

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --workspace --features full -- -D warnings passes
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 6696/6696 passed (+100 vs base)
  • New tests: detect_with_model() (4 branches), DetectorMode::Model serde roundtrip (3), validate_detector_model_config() (4), decode_bio_spans edge cases (8), validate_safetensors (5)

Closes #2210
Closes #2211

bug-ops added 3 commits March 27, 2026 10:00
…2210, #2211)

Add ML-backed correction detection mode and NER classifier infrastructure:

- DetectorMode::Model variant in zeph-config with detector_model field in
  LearningConfig (mirrors judge_model pattern, preserves Copy on enum)
- CandleNerClassifier in zeph-llm/src/classifier/ner.rs: DeBERTa-v2 NER
  with BIO/BIOES span decoding, chunk-based inference, overlap deduplication
- NerSpan struct (label, score, start, end as char offsets) and spans field
  on ClassificationResult; all existing literal sites updated with spans: vec![]
- FeedbackDetector::detect_with_model() async method behind classifiers feature
- FeedbackState::model_backend field; Agent::with_feedback_classifier() builder
- Bootstrap wires CandleNerClassifier when detector_mode=model + classifiers.enabled
- Fallback to regex with warn!() when backend is absent (C-03 from critic)
- validate_detector_model_config() on Bootstrap; ner_model in ClassifiersConfig
- --init wizard updated with model option and detector_model prompt
- config/default.toml documents new fields in [skills.learning] and [classifiers]
…sors duplicate

- Remove duplicated validate_safetensors from candle.rs; use shared ner::validate_safetensors
- Add detect_with_model() tests: positive signal, low score, negative result, error swallowed
- Add DetectorMode::Model serde roundtrip tests in zeph-config
- Add validate_detector_model_config() tests: model+non-empty, model+empty, regex, judge
…eduplication

After IC-01 fix removed the private CandleClassifier::validate_safetensors method,
test references in candle.rs were not updated during the rebase. Update all 5 test
functions to call crate::classifier::ner::validate_safetensors and gate them with
#[cfg(feature = "classifiers")] since the ner module requires that feature.
@github-actions github-actions bot added enhancement New feature or request documentation Improvements or additions to documentation and removed enhancement New feature or request labels Mar 27, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 27, 2026 09:08
@github-actions github-actions bot added llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate config Configuration file changes size/XL Extra large PR (500+ lines) labels Mar 27, 2026
…eature

The method is only called from code guarded by #[cfg(feature = "classifiers")].
Without the gate, cargo check --features chat/ide/desktop/server raises
dead_code error since no call site exists in those feature sets.
@github-actions github-actions bot added the enhancement New feature or request label Mar 27, 2026
@bug-ops bug-ops merged commit f3f594c into main Mar 27, 2026
25 checks passed
@bug-ops bug-ops deleted the 2210-detectormode-classifier branch March 27, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(classifiers): add NER/PII token-level classifier backend (piiranha) feat(core): add DetectorMode::Model for classifier-backed feedback detection

1 participant