Skip to content

Score predictions on the text the model was trained on - #1038

Merged
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
pavsoss:feat/1037-preprocess-contract
Aug 1, 2026
Merged

Score predictions on the text the model was trained on#1038
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
pavsoss:feat/1037-preprocess-contract

Conversation

@pavsoss

@pavsoss pavsoss commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Training prepares text with the shared normalizer before fitting the TF-IDF vocabulary, but the prediction path handed the vectorizer the raw input — the normalizer was reached for only when building a cache key. The obfuscations it exists to undo (Cyrillic look-alikes, zero-width joiners, f r e e spacing) therefore survived into the vectorizer, fell out of vocabulary, and weakened detection on exactly the messages most likely to be evasive.

Part of #1037.

Changes

Both regimes now go through one text-preparation contract. Training calls it, the prediction path calls it before vectorizing, and the response cache is keyed on the same prepared string that is actually scored — previously two different inputs reducing to the same canonical form could share one cache entry while being scored differently.

Preparation runs after translation, so a non-English message is canonicalised in the language the model was trained on.

Test plan

  • Canonical-form coverage: zero-width stripping, homoglyph folding, space de-obfuscation, whitespace collapsing, idempotence, and pass-through of empty and non-string input.
  • A check that training and inference resolve to the same callable rather than two copies that can drift apart.

Training fits the vectorizer on normalized text while the prediction path transformed the raw string, so homoglyphs, zero-width characters and spaced-out words reached the vocabulary intact. Introduce a single preparation contract that both regimes call, and key the response cache on the string that is actually scored.
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

@pavsoss is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@pavsoss

pavsoss commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@Userunknown84

@Userunknown84
Userunknown84 merged commit 22ba702 into Userunknown84:main Aug 1, 2026
4 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants