GSoC 2026 Module B — Week 3: Stage 2 LLM relevance classifier#947
GSoC 2026 Module B — Week 3: Stage 2 LLM relevance classifier#947manshusainishab wants to merge 5 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 26 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
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 Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
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.