Repository navigation
feat(extract): opt-in multilingual NER model; never download a model in Tor mode - #152
Merged
Merged
Conversation
english (urchade/gliner_medium-v2.1, the default) or multilingual (fastino/gliner2-multi-v1, new extra ner-multilingual). Env OPENFOIA_NER_MODEL, analyze extract --ner-model. Runs record the model id that ran; a non-English hint suggests the switch without making it. The benchmark gains --ner-model and a 26-sentence news set in 13 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
…language news set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
Hugging Face downloads go straight to huggingface.co, not through Tor, so a first extraction in Tor mode showed the user's real IP. The loaders now raise ModelDownloadRefused when network.tor is on and the model is not cached; the GLiNER tier prints that once and the run continues with the other tiers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016LaGpHLuSRHzGARb38X7YS
This was referenced Nov 19, 2026
Merged
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.
Tier-2 entity extraction uses
urchade/gliner_medium-v2.1, which only reads English. This PR adds an opt-in multilingual model. The default doesn't change. It also closes a Tor leak in how models are downloaded.Follows the benchmark in #147 / #119.
Multilingual model (opt-in)
fastino/gliner2-multi-v1(Apache-2.0). It was the most accurate on every test set, including the only clean English spans (strict F1 0.94). The other candidate,gliner_multi-v2.1, found fewer names, was worse on English and is a bigger download.openfoia install-extras ner-multilingual(gliner2[local], about 6 MB on top of torch).analyze extract --ner-model multilingual,OPENFOIA_NER_MODEL=multilingual, or"entities": {"ner_model": "multilingual"}in config.gliner2isn't installed, it says so once and uses the next tier. It deliberately doesn't fall back to the English model, which could start a 1.6 GB download nobody asked for.analyze extractprints one notice suggesting the multilingual model. The agent'sextract_entitiesresult carries the same hint. It never switches or downloads anything by itself.analyze runsnames the model that produced each run.Measured (13-language news set, 68 names)
docs/benchmarks/gliner2.mdsays so, and the raw output is ingliner2-news-raw.json.Fixed: no model download in Tor mode (added on review)
The first extraction downloaded an uncached model straight from huggingface.co, not through Tor, even with
network.toron. That showed the user's real IP. This applied to the existing English model as well as the new one.The loaders now refuse that download. The GLiNER tier says so once and the run continues with the other tiers; regex always runs. The message explains how to get the model: download it once with Tor off, or copy the Hugging Face cache over. A test checks that only the cache is tried, and that the test fails without the fix. Threat model and guide updated.
Checks
tests/test_ner_model_choice.py, with models stubbed so they run without torch.Generated by Claude Code