GSoC 2026 Module B — Week 3: Stage 2 LLM relevance classifier#947
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Summary by CodeRabbit
WalkthroughAdds Module B noise-filter configuration, prompt construction, and an LLM classifier that batches ChangesNoise Filter Module B
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@application/utils/noise_filter/config_loader.py`:
- Around line 29-36: NoiseFilterConfig currently allows invalid values to be
constructed directly, so add invariant checks inside its dataclass
initialization path. Update NoiseFilterConfig to validate batch_size >= 1,
max_chars >= 1, and confidence_threshold between 0.0 and 1.0 in __post_init__,
so every construction route fails fast before llm_classifier uses these fields.
Keep the checks centralized in NoiseFilterConfig so direct callers and
load_config() both get the same validation behavior.
In `@application/utils/noise_filter/llm_classifier.py`:
- Around line 151-163: The fallback in llm_classifier.py is too broad: the
try/except around self._completion_with_retry in the strict_schema path retries
on every exception, even non-capability failures. Update the logic in the
classifier method that builds messages and calls _completion_with_retry so only
schema- მხარდაჭာ unsupported capability errors (for example the provider’s
BadRequestError for strict schema) trigger the json_object retry, and let all
other exceptions propagate without a second attempt. Keep the warning/logging
specific to the capability fallback path so the retry only happens when strict
schema is genuinely unsupported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 6ed01a44-6a87-42ec-9e1b-c7220c2dfc79
📒 Files selected for processing (5)
.env.exampleapplication/tests/noise_filter/llm_classifier_test.pyapplication/utils/noise_filter/config_loader.pyapplication/utils/noise_filter/llm_classifier.pyapplication/utils/noise_filter/prompts.py
northdpole
left a comment
There was a problem hiding this comment.
Good job on B-W3. The recall-first prompt and few-shots are clear, fail-safe parsing (UNCERTAIN on bad output / failed batches) is the right call for this gate, and the json_schema fallback only on capability gaps is a nice improvement over the older pattern. Fine to merge as the Week 3 slice — looking forward to queue + pipeline wiring in W4/W5.
Removed comments related to the noise filter model configuration. Signed-off-by: Manshu Saini <149303743+manshusainishab@users.noreply.github.com>
Summary
Adds Stage 2 of Module B (Noise/Relevance Filter): an LLM classifier that labels
each content chunk as KNOWLEDGE, NOISE, or UNCERTAIN under the
recall-first rule. Builds on the Week 1 schemas and Week 2 regex/sanitize stages.
This PR is self-contained (classifier + prompt + config + tests). Pipeline
wiring, the queue/DB model, and the CLI entry point come in later weeks.
What's added
application/utils/noise_filter/config_loader.py— loads Module B settingsfrom
CRE_NOISE_FILTER_*environment variables into a typedNoiseFilterConfig(model, batch size, per-chunk char cap, confidence threshold), with defaults.
application/utils/noise_filter/prompts.py— the recall-first system promptand a few-shot block (5 KNOWLEDGE / 3 NOISE / 2 UNCERTAIN worked examples), plus
a helper that renders a numbered batch of chunks into the user prompt.
application/utils/noise_filter/llm_classifier.py—LLMClassifier, whichclassifies a list of
ChangeRecords and returns oneClassifyResultper record.application/tests/noise_filter/llm_classifier_test.py— 14 unit tests,fully mocked (no network calls).
.env.example— documents the four newCRE_NOISE_FILTER_*variables.How the classifier works
heading_path+textto a dedicated lightweight model viaLiteLLM (default
gemini/gemini-2.5-flash-lite).CRE_NOISE_FILTER_BATCH_SIZE, default 10), onerequest per batch, and maps results back to input order by index.
mode, falls back to JSON-object mode.
CRE_NOISE_FILTER_MAX_CHARS(default 1500) before sending.CRE_LLM_MAX_RETRIES/CRE_LLM_RETRY_SLEEP_SECONDSsettings.UNCERTAIN(confidence 0.0) for any unparseable, malformed, or invalidoutput, and marks a whole batch
UNCERTAINif the LLM call fails — so a badresponse never aborts a run.
Configuration
CRE_NOISE_FILTER_LLM_MODELgemini/gemini-2.5-flash-liteCRE_NOISE_FILTER_BATCH_SIZE10CRE_NOISE_FILTER_MAX_CHARS1500CRE_NOISE_FILTER_CONFIDENCE_THRESHOLD0.8The model is Gemini, so it authenticates with the existing
GEMINI_API_KEY;no new credential is required.
Testing
malformed/invalid/empty output handling, the JSON-schema fallback, rate-limit
retry and exhaustion, and truncation.
black --checkclean across the repo.