René's URL Explorer Experiment


Title: feat(pii): add opt-in GLiNER NER engine (PII_ENGINE), device-agnostic by TheodoreSpeaks · Pull Request #5495 · simstudioai/sim · GitHub

Open Graph Title: feat(pii): add opt-in GLiNER NER engine (PII_ENGINE), device-agnostic by TheodoreSpeaks · Pull Request #5495 · simstudioai/sim

X Title: feat(pii): add opt-in GLiNER NER engine (PII_ENGINE), device-agnostic by TheodoreSpeaks · Pull Request #5495 · simstudioai/sim

Description: What Adds GLiNER (zero-shot transformer NER) as an opt-in engine for the PII service, selected by PII_ENGINE (spacy | gliner, default spacy). Of the ~40 supported entity types only 4 are NER — PERSON, LOCATION, NRP, DATE_TIME — and GLiNER replaces exactly those; all ~36 regex/checksum recognizers (locale IDs, credit card, email, VIN, …) are registered identically on both engines. One image, one tag. The pii image ships both engines (spaCy *_lg models + torch-CPU + gliner + baked GLiNER weights), so switching engines is a pure env flip — no image swap, no tag matrix, and rollback is PII_ENGINE=spacy. Image grows ~6.1GB → ~9.6GB. Device-agnostic: PII_DEVICE (cpu/cuda) or auto-detect. The same code runs on Fargate CPU today and the EC2-GPU fleet later — no code change to switch. GPU capacity/scheduling is a separate infra task (not touched here). Design apps/pii/engines.py (new): side-effect-free engine builders extracted from server.py (which is now just env dispatch + endpoints; the spacy path is construction-identical to before). One multilingual model (urchade/gliner_multi_pii-v1, override via PII_GLINER_MODEL) shared across the 5 per-language recognizer instances — SharedModelGLiNERRecognizer.load() caches the ~1.2GB model instead of loading it 5×. Its analyze() restricts requested entities to the 4 it owns: presidio passes the full ~40-entity list to every recognizer and stock GLiNERRecognizer would append unknown entities (CREDIT_CARD, VIN, ES_NIF, …) as ad-hoc zero-shot labels — wrong scope and slower. The gliner path uses the small spaCy models (*_sm, ~60MB total) purely for tokenization + lemmas so NlpArtifacts/context-boosts for the regex recognizers behave as before (blank pipelines don't work — presidio tries to pip-download them). SpacyRecognizer is removed from the registry so sm-model NER never competes with GLiNER. Fail-fast: invalid PII_ENGINE dies at import; a custom image missing gliner deps dies with an actionable message instead of presidio's silent pip-download fallback. docker/pii.Dockerfile: single linear image. GLiNER weights are baked at build (cached layer) with HF_HUB_OFFLINE=1 so startup never touches the network and a typo'd PII_GLINER_MODEL fails loudly. The GPU variant for the infra follow-up is the same Dockerfile built with --build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu128 (torch pinned to the newest version published on both cpu and cu128 indexes). Bench + tests + pytest ride along in the image. CI: unchanged — same single pii build/tags as before. Helm: pii.engine (spacy|gliner, default spacy) and pii.device render to PII_ENGINE/PII_DEVICE as chart-owned env keys (pii.env can't override them; PII_GLINER_MODEL stays a plain pii.env passthrough). nvidia.com/gpu requests are deliberately not wired — infra follow-up. PII_WORKERS (merged from #5457) note: each uvicorn worker loads its own GLiNER model copy — into GPU memory on cuda — so GPU deployments generally want PII_WORKERS=1 per GPU (documented in Dockerfile + server.py; behavior unchanged). Parity & throughput (spaCy vs GLiNER-CPU) apps/pii/scripts/bench_engines.py runs the same payload through both engines and diffs results; the 32-text multilingual payload (en/es/it/pl/fi with names, locations, dates, NRP, and regex bait: emails, phones, valid-checksum VIN/ES_NIF/IT_FISCAL_CODE/PESEL/HETU) ships in the repo. Numbers below from the CPU (aarch64 docker) run; rerun with docker run --rm python scripts/bench_engines.py: engine throughput p50 / p95 latency spacy (*_lg) ~305 texts/s 2.9ms / 5.8ms gliner (CPU) ~3.7 texts/s 272ms / 355ms CPU-GLiNER is ~80× slower than spaCy — that's the point of this being opt-in now and GPU-bound later. NER agreement (span IoU ≥ 0.5, same type): entity spacy gliner matched PERSON 18 28 17 LOCATION 23 26 19 DATE_TIME 15 24 12 NRP 8 13 6 ORGANIZATION 3 0 — (intentional: not in the app's supported set, no GLiNER mapping) Regex/checksum entities: identical across engines ✓ (the script exits non-zero on any non-NER diff). Qualitative diff highlights: GLiNER has higher recall overall and produces wider (often better) spans (45 Queen Street, Toronto vs just Toronto), but zero-shot eagerness tags pronouns (She, he) and once an email as PERSON; spaCy has its own false positives (quarterly as DATE_TIME, credit-card number as ORGANIZATION) and misses GLiNER catches. GLINER_ENTITY_MAPPING label prompts are the tuning lever; the bench is the harness. Enabling Our fleet: infra sets PII_ENGINE=gliner on the pii task def (same image). Realistically waits for the GPU capacity provider given CPU throughput. Helm: pii.engine: gliner — nothing else. Local: docker run -e PII_ENGINE=gliner .... Validation PII_ENGINE unset ⇒ spaCy, regression-tested /redact_batch en+es byte-identical to today; PII_ENGINE=bogus dies at import with a clear error. PII_ENGINE=gliner masks PERSON/LOCATION/email/phone/VIN/ES_NIF; flipping back to spacy on the same image behaves identically to default; startup is fully offline. Tests: apps/pii/tests — unit suite (mocked GLiNER; shared-model load-once, label restriction, fail-fast) runs model-free; integration suite (RUN_PII_INTEGRATION=1) ran green in-image for both engines. helm unittest 65/65 (incl. new engine/device/override tests), helm lint clean, bun run lint:check green, ruff clean. Pre-existing quirk noted while validating (not addressed here): /analyze with return_decision_process=true 500s on both engines (presidio's AnalysisExplanation isn't JSON-serializable via to_dict()); the app never sends that flag. Follow-ups (infra task) EC2-GPU capacity provider + nvidia.com/gpu requests; build/publish the cu128 image via TORCH_INDEX_URL build-arg; set PII_WORKERS=1 per GPU. 🤖 Generated with Claude Code https://claude.ai/code/session_01Up3F97mjCH9HCj1pX4J8VJ

Open Graph Description: What Adds GLiNER (zero-shot transformer NER) as an opt-in engine for the PII service, selected by PII_ENGINE (spacy | gliner, default spacy). Of the ~40 supported entity types only 4 are NER — PERS...

X Description: What Adds GLiNER (zero-shot transformer NER) as an opt-in engine for the PII service, selected by PII_ENGINE (spacy | gliner, default spacy). Of the ~40 supported entity types only 4 are NER — PERS...

Opengraph URL: https://github.com/simstudioai/sim/pull/5495

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:80724d9e-8640-aa73-5830-728fac248483
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8B6A:223A5F:AEB976:F0D022:6AFB52A7
html-safe-noncebf454ab0d928e6f2a36a1c102b81d73a7453c73c129a989e2daa7c0760e3e99b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjZBOjIyM0E1RjpBRUI5NzY6RjBEMDIyOjZBRkI1MkE3IiwidmlzaXRvcl9pZCI6IjQ4ODM3NTQ2MjM0MTc2NjgyNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb3e99c745d789d6ee8f1e92b3e093fe78847bcb49ed997730d5865fd6673a64b
hovercard-subject-tagpull_request:4010573034
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/5495/files
twitter:imagehttps://avatars.githubusercontent.com/u/19564703?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19564703?s=400&v=4
og:image:altWhat Adds GLiNER (zero-shot transformer NER) as an opt-in engine for the PII service, selected by PII_ENGINE (spacy | gliner, default spacy). Of the ~40 supported entity types only 4 are NER — PERS...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/5495/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F5495%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F5495%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/5495/files
Reloadhttps://github.com/simstudioai/sim/pull/5495/files
Reloadhttps://github.com/simstudioai/sim/pull/5495/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
TheodoreSpeakshttps://github.com/TheodoreSpeaks
staginghttps://github.com/simstudioai/sim/tree/staging
feat/pii-gliner-enginehttps://github.com/simstudioai/sim/tree/feat/pii-gliner-engine
Conversation 6 https://github.com/simstudioai/sim/pull/5495
Commits 3 https://github.com/simstudioai/sim/pull/5495/commits
Checks 18 https://github.com/simstudioai/sim/pull/5495/checks
Files changed https://github.com/simstudioai/sim/pull/5495/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
feat(pii): add opt-in GLiNER NER engine (PII_ENGINE), device-agnostic https://github.com/simstudioai/sim/pull/5495/files#top
Show all changes 3 commits https://github.com/simstudioai/sim/pull/5495/files
4626999 feat(pii): add opt-in GLiNER NER engine (PII_ENGINE), device-agnostic TheodoreSpeaks Jul 7, 2026 https://github.com/simstudioai/sim/pull/5495/commits/4626999f8e9e5104319444b098831317258dbe9b
3309d18 Merge remote-tracking branch 'origin/staging' into feat/pii-gliner-en… TheodoreSpeaks Jul 7, 2026 https://github.com/simstudioai/sim/pull/5495/commits/3309d18cf7902c900665be5507284cedcd42d71a
bff7626 refactor(pii): ship both engines in one image — engine is a pure env … TheodoreSpeaks Jul 8, 2026 https://github.com/simstudioai/sim/pull/5495/commits/bff762688a6874e04762dd687127676b52bc2db9
Clear filters https://github.com/simstudioai/sim/pull/5495/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
.gitignore https://github.com/simstudioai/sim/pull/5495/files#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
engines.py https://github.com/simstudioai/sim/pull/5495/files#diff-fbe90457362e24c1fba550733aa2c5d1f6631f23375e96edae7f41bfceacafc9
requirements-dev.txt https://github.com/simstudioai/sim/pull/5495/files#diff-f7a9125f0a589bcdf4e20571e6a25b1fa37d3fb8ae46981e3e53f0dfd40eddc8
requirements-gliner.txt https://github.com/simstudioai/sim/pull/5495/files#diff-631382ecf2c52bc4c26def2712572b38d746672c578c78d0d053010e00677694
bench_engines.py https://github.com/simstudioai/sim/pull/5495/files#diff-3a91363ef01402ecbacc8ddf5839033857ee2e631352b735772151f790ce2d6e
bench_payload.json https://github.com/simstudioai/sim/pull/5495/files#diff-977273acfc27de3f43322d8f6a02bd63acfb63005ee6c865fd8aa7d5c6cfffdf
server.py https://github.com/simstudioai/sim/pull/5495/files#diff-4447adf1c9c684d32a5fd31a17e05677749ef10d0ca6bce34ac9b6263e781a40
conftest.py https://github.com/simstudioai/sim/pull/5495/files#diff-6ce44a2f7bb2fc4fb40d1f8da636468417def63f018a2adcc0a5bc03ec700aff
test_engines.py https://github.com/simstudioai/sim/pull/5495/files#diff-2a33d1e9ba963e28973549f0bbc17effcfd4ca717d257c2f47e2b6f0de661ebb
test_integration.py https://github.com/simstudioai/sim/pull/5495/files#diff-ca7038f36b80b4066e03e590f590afe3d6915c0d3a9724e44516222c1ba28a1d
pii.Dockerfile https://github.com/simstudioai/sim/pull/5495/files#diff-9ffed6e2379c4cb446d31f12ffaf134779b805cf63f2083664be12267918a8e2
deployment-pii.yaml https://github.com/simstudioai/sim/pull/5495/files#diff-d3d1dde5e4a0eb52d77b759ca172a47fe2daf307769e49edbbbe66a05b2650d7
pii_test.yaml https://github.com/simstudioai/sim/pull/5495/files#diff-cfc33b707268cfa11d88d46284224b5a916982a2804a4c1c2198d0d967cb496b
values.schema.json https://github.com/simstudioai/sim/pull/5495/files#diff-3203678a723acd84dd61f119ae4b9e439b04d35a123c7918821e20c31a72c791
values.yaml https://github.com/simstudioai/sim/pull/5495/files#diff-5586790157aac5be1a3be674910d22e602e8c840abbf289d0ad31ffb5dac5cb1
.gitignorehttps://github.com/simstudioai/sim/pull/5495/files#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
View file https://github.com/simstudioai/sim/blob/bff762688a6874e04762dd687127676b52bc2db9/.gitignore
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5495/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/5495/files#diff-bc37d034bad564583790a46f19d807abfe519c5671395fd494d8cce506c42947
apps/pii/engines.pyhttps://github.com/simstudioai/sim/pull/5495/files#diff-fbe90457362e24c1fba550733aa2c5d1f6631f23375e96edae7f41bfceacafc9
View file https://github.com/simstudioai/sim/blob/bff762688a6874e04762dd687127676b52bc2db9/apps/pii/engines.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5495/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
apps/pii/requirements-dev.txthttps://github.com/simstudioai/sim/pull/5495/files#diff-f7a9125f0a589bcdf4e20571e6a25b1fa37d3fb8ae46981e3e53f0dfd40eddc8
View file https://github.com/simstudioai/sim/blob/bff762688a6874e04762dd687127676b52bc2db9/apps/pii/requirements-dev.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5495/{{ revealButtonHref }}
apps/pii/requirements-gliner.txthttps://github.com/simstudioai/sim/pull/5495/files#diff-631382ecf2c52bc4c26def2712572b38d746672c578c78d0d053010e00677694
View file https://github.com/simstudioai/sim/blob/bff762688a6874e04762dd687127676b52bc2db9/apps/pii/requirements-gliner.txt
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/5495/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/5495/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.