Repository navigation
fix(pii): cap each batched NER pass at one window of characters - #10099
Merged
Merged
Conversation
A batch of many texts each under NER_WINDOW_CHARS still went through one nlp.pipe pass, and that pass costs memory for every character in it, like one long text. Pack the short texts into batches of at most NER_WINDOW_CHARS in total and take the NER slot per batch.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The change affects memory use in the PII batch analysis and redaction paths. The PR appears safe to merge, with a non-blocking gap in automated coverage for the new batch limit. Findings
Summary
Reviews (1) · Last reviewed commit: "fix(pii): cap each batched NER pass at o..." · Reviewed by Greptile |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_analyze_manysent every text underNER_WINDOW_CHARStoanalyze_iteratorin one call, so many mid-size texts shared one spaCy pass whose memory grows with their total length (ten 99k-char texts cost as much as one 990k-char text)NER_WINDOW_CHARScharacters in total, oneanalyze_iteratorcall per batch, with_NER_SLOTtaken per batch so other requests interleave, the same as_analyze_long's windowsType of Change
Testing
_analyze_manywith the en model underMALLOC_ARENA_MAX=2, old vs new server code, on a Linux box:py_compileonapps/pii/server.pyChecklist
test-auditauthoring gate)