Skip to content

Fix classifier falsely rejecting Hebrew prostitution/trafficking articles#33

Merged
shaypal5 merged 3 commits intomainfrom
copilot/daily-ai-review-fix-classifier-issues
Mar 22, 2026
Merged

Fix classifier falsely rejecting Hebrew prostitution/trafficking articles#33
shaypal5 merged 3 commits intomainfrom
copilot/daily-ai-review-fix-classifier-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 22, 2026

The LLM classifier was rejecting clearly relevant articles (brothel discoveries, trafficking cases, prostitution arrests) with high confidence. Root cause: the prompt opened with "anti-prostitution enforcement", priming the model to require an explicit enforcement action rather than treating any mention of the covered topics as sufficient for relevance.

Changes

src/denbust/classifier/relevance.py

  • Added CLASSIFICATION_SYSTEM_PROMPT — passed as the Anthropic system parameter — that explicitly instructs the model to be inclusive and mark articles relevant "even if no arrest or enforcement action has occurred"
  • Rewrote CLASSIFICATION_PROMPT to:
    • Remove the "anti-prostitution enforcement" framing in favour of a neutral topic-list framing
    • Add parallel Hebrew keywords for each topic area (בתי בושת / זנות / סרסורות / סחר בבני אדם)
    • Replace the ambiguous true/false JSON template with separate positive/negative response examples
  • Passes system=CLASSIFICATION_SYSTEM_PROMPT in the messages.create() call
# Before — misleading framing
CLASSIFICATION_PROMPT = """You classify Hebrew news articles for relevance to
anti-prostitution enforcement in Israel. ..."""

# After — inclusive framing via system prompt + Hebrew keywords in user prompt
CLASSIFICATION_SYSTEM_PROMPT = (
    "...Be inclusive: mark an article as relevant whenever any of these topics "
    "appears as a significant part of the story, even if no arrest or "
    "enforcement action has occurred."
)
CLASSIFICATION_PROMPT = """Decide whether the Hebrew news article below is relevant
to any of these topics in Israel:
- Brothels / בתי בושת
- Prostitution / זנות
- Pimping / סרסורות
- Human trafficking / סחר בבני אדם
..."""

tests/unit/test_classifier.py

  • Added TestClassificationPromptContent — asserts Hebrew keywords and inclusive language are present in the prompts
  • Added TestClassifyPassesSystemPrompt — verifies the system prompt reaches the Anthropic API call and that trafficking/brothel articles (the specific false-negative types from the issue) return relevant: true

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.anthropic.com
    • Triggering command: /usr/bin/python python -m pytest tests/unit/ -q (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[daily-ai-review] Classifier rejecting highly relevant prostitution/trafficking articles</issue_title>
<issue_description>

Problem

The classifier is incorrectly rejecting articles that are clearly relevant to the dataset's focus on prostitution, brothels, trafficking, and enforcement. Multiple articles about prostitution and trafficking were marked as "not_relevant" with high confidence.

Evidence

From the raw articles, several highly relevant items were found but rejected:

  1. "בית בושת אותר בתוך מקלט ציבורי" (Brothel found in public shelter) - Walla article about a public shelter converted into a brothel
  2. "ישראלי שידל לזנות קטינה בת 13 מוונצואלה" (Israeli lured 13-year-old Venezuelan girl into prostitution) - Mako article about child trafficking
  3. "חריג: הפכה את המקלט הציבורי לבית בושת" (Unusual: Turned public shelter into brothel) - Another Mako article about the same brothel case
  4. "מטורף: העסקים הלא חוקיים שפורחים במלחמה" (Crazy: Illegal businesses flourishing during war) - About illegal businesses including prostitution during wartime
  5. "הוא הבטיח להן הארה, והפך אותן לקורבנות אונס וסחר בבני אדם" (He promised them enlightenment, turned them into rape and human trafficking victims) - Haaretz article about sexual exploitation and human trafficking

Impact

  • 0 relevant articles found despite clear matches in raw data
  • all_unseen_rejected: true indicates systematic classification failure
  • Critical trafficking and prostitution stories being missed

Next Steps

  1. Review classifier model/rules for Hebrew prostitution/trafficking terminology
  2. Check if recent model updates introduced regressions
  3. Validate classification logic against these specific false negatives
  4. Consider expanding training data with Hebrew-language examples

Review context

  • Run timestamp: 2026-03-22T05:20:44.330549+00:00

  • Run snapshot: state_repo/news_items/ingest/runs/2026-03-22T05-20-44-330549Z.json

  • Debug summary: state_repo/news_items/ingest/logs/2026-03-22T05-20-44-330549Z.summary.json

  • Debug log: state_repo/news_items/ingest/logs/2026-03-22T05-20-44-330549Z.json

  • Workflow run: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23396383015</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@github-actions
Copy link
Copy Markdown

pr-agent-context report:

This is a refreshed snapshot of the current PR state.

This run includes a failing check on PR #33.

Diagnose and fix the failing checks below, then push all of these changes in a single commit.

# Failing Checks

## FAIL-1
Type: GitHub Actions workflow run
Workflow: ci-test
Run: [WIP] Fix classifier rejecting relevant prostitution trafficking articles
Run number: 140
Run attempt: 1
Conclusion: action_required
URL: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23397793307

Summary:
    Workflow run failed, but job details were unavailable.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: status updated
Workflow run: 23397796038 attempt 1
Comment timestamp: 2026-03-22T06:57:06.985411+00:00
PR head commit: ba86313a93393153462c1723095eb2f5170fa4dd

…icles

- Add CLASSIFICATION_SYSTEM_PROMPT with an explicit inclusive framing that
  tells the model to mark articles relevant even without enforcement actions
- Rewrite CLASSIFICATION_PROMPT: remove 'anti-prostitution enforcement'
  framing, add Hebrew keywords (בתי בושת/זנות/סרסורות/סחר בבני אדם),
  and give cleaner JSON response examples
- Pass system=CLASSIFICATION_SYSTEM_PROMPT to Anthropic messages.create()
- Add tests for prompt content (Hebrew terms, inclusive language) and API call

Co-authored-by: shaypal5 <917954+shaypal5@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DataHackIL/tfht_enforce_idx/sessions/30cb20f0-b398-4ce1-b671-6b973820e5c9
Copilot AI changed the title [WIP] Fix classifier rejecting relevant prostitution trafficking articles Fix classifier falsely rejecting Hebrew prostitution/trafficking articles Mar 22, 2026
Copilot AI requested a review from shaypal5 March 22, 2026 07:04
@github-actions
Copy link
Copy Markdown

pr-agent-context report:

This is a refreshed snapshot of the current PR state.

This run includes a failing check on PR #33.

Diagnose and fix the failing checks below, then push all of these changes in a single commit.

# Failing Checks

## FAIL-1
Type: GitHub Actions workflow run
Workflow: ci-test
Run: Fix classifier falsely rejecting Hebrew prostitution/trafficking articles
Run number: 141
Run attempt: 1
Conclusion: action_required
URL: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23397892026

Summary:
    Workflow run failed, but job details were unavailable.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: status updated
Workflow run: 23397892642 attempt 1
Comment timestamp: 2026-03-22T07:03:44.783156+00:00
PR head commit: e2487f167b11ad000cc54c5d8d0bb021478d2b79

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.84%. Comparing base (d35059e) to head (56d290c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #33   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files          38       38           
  Lines        3270     3277    +7     
=======================================
+ Hits         3265     3272    +7     
  Misses          5        5           
Files with missing lines Coverage Δ
src/denbust/classifier/relevance.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

pr-agent-context report:

No unresolved review comments, failing checks, or actionable patch coverage gaps were found on PR
#33. Treat this PR as all clear unless new signals appear.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: commit pushed
Workflow run: 23397892026 attempt 2
Comment timestamp: 2026-03-22T08:39:26.399178+00:00
PR head commit: e2487f167b11ad000cc54c5d8d0bb021478d2b79

@shaypal5 shaypal5 marked this pull request as ready for review March 22, 2026 12:01
@shaypal5 shaypal5 requested a review from Copilot March 22, 2026 12:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes false negatives in the Hebrew LLM relevance classifier by removing enforcement-only framing and explicitly prompting for inclusive topic-based relevance (brothels, prostitution, pimping, trafficking), even when no arrest/enforcement action occurred.

Changes:

  • Introduces a dedicated CLASSIFICATION_SYSTEM_PROMPT and passes it via Anthropic’s system parameter to broaden the model’s relevance criteria.
  • Rewrites the user prompt to use a neutral topic list and adds key Hebrew terms (בתי בושת, זנות, סרסורות, סחר בבני אדם) plus clearer JSON response examples.
  • Adds unit tests to assert prompt content and verify system is forwarded to the Anthropic API call, covering trafficking/brothel false-negative scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/denbust/classifier/relevance.py Adds an inclusive system prompt, updates the user prompt framing/keywords, and passes system=... into messages.create().
tests/unit/test_classifier.py Adds tests asserting prompt/system prompt content and that classify() forwards the system prompt and returns relevant for key examples.

@shaypal5 shaypal5 added bug Something isn't working enhancement New feature or request labels Mar 22, 2026
@github-actions
Copy link
Copy Markdown

pr-agent-context report:

No unresolved review comments, failing checks, or actionable patch coverage gaps were found on PR
#33. Treat this PR as all clear unless new signals appear.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: commit pushed
Workflow run: 23407428341 attempt 1
Comment timestamp: 2026-03-22T16:33:35.406641+00:00
PR head commit: 56d290c7fac354d187c8c1241abfe14055193700

@shaypal5 shaypal5 merged commit 29279c5 into main Mar 22, 2026
7 checks passed
@shaypal5 shaypal5 deleted the copilot/daily-ai-review-fix-classifier-issues branch March 22, 2026 16:43
@github-actions
Copy link
Copy Markdown

pr-agent-context report:

🚨 `pr-agent-context` failed while preparing PR context.

PR: #33
Error: CalledProcessError: Command '['git', '-C', '/home/runner/work/tfht_enforce_idx/tfht_enforce_idx/caller-repo', 'diff', '--unified=0', 'd35059ed71baff42d14eb15ea1a7c58c7fc1e38c...56d290c7fac354d187c8c1241abfe14055193700']' returned non-zero exit status 128.
Run: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23407643392

The workflow continued gracefully so this failure does not block CI.
Check the job logs for the full traceback.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: status updated
Workflow run: 23407643392 attempt 1
Comment timestamp: 2026-03-22T16:44:08.033608+00:00
PR head commit: 56d290c7fac354d187c8c1241abfe14055193700

@github-actions
Copy link
Copy Markdown

pr-agent-context report:

🚨 `pr-agent-context` failed while preparing PR context.

PR: #33
Error: CalledProcessError: Command '['git', '-C', '/home/runner/work/tfht_enforce_idx/tfht_enforce_idx/caller-repo', 'diff', '--unified=0', 'd35059ed71baff42d14eb15ea1a7c58c7fc1e38c...56d290c7fac354d187c8c1241abfe14055193700']' returned non-zero exit status 128.
Run: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23407647940

The workflow continued gracefully so this failure does not block CI.
Check the job logs for the full traceback.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: status updated
Workflow run: 23407647940 attempt 1
Comment timestamp: 2026-03-22T16:44:20.960840+00:00
PR head commit: 56d290c7fac354d187c8c1241abfe14055193700

@github-actions
Copy link
Copy Markdown

pr-agent-context report:

🚨 `pr-agent-context` failed while preparing PR context.

PR: #33
Error: CalledProcessError: Command '['git', '-C', '/home/runner/work/tfht_enforce_idx/tfht_enforce_idx/caller-repo', 'diff', '--unified=0', 'd35059ed71baff42d14eb15ea1a7c58c7fc1e38c...56d290c7fac354d187c8c1241abfe14055193700']' returned non-zero exit status 128.
Run: https://github.com/DataHackIL/tfht_enforce_idx/actions/runs/23407681566

The workflow continued gracefully so this failure does not block CI.
Check the job logs for the full traceback.

Run metadata:

Tool ref: v4
Tool version: 4.0.11
Trigger: status updated
Workflow run: 23407681566 attempt 1
Comment timestamp: 2026-03-22T16:46:08.798308+00:00
PR head commit: 56d290c7fac354d187c8c1241abfe14055193700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[daily-ai-review] Classifier rejecting highly relevant prostitution/trafficking articles

3 participants