Mask Thai personal data (PII) before sending it to an external AI, then restore the real values locally. Everything runs on your machine — raw PII never leaves the device (PDPA-friendly).
PSU Future Tech Challenge 2026 · AI Innovation for Future Society (Prototype)
- AI Guard — on ChatGPT, Claude, Gemini, Grok, Perplexity, or GLM / Z.ai, replace PII with tokens (
[ชื่อ_1]) or realistic fake data before sending, then restore the real values from the reply. (On any other page, the docked side panel does the same by paste.) - True PDF redaction — black out PII in a PDF (removed from the text layer), returns the redacted file + before/after preview.
- PDPA report — risk score plus Section 26 sensitive-data flags (health, religion, …).
Detection runs locally: regex + checksum (Thai ID mod-11, phone, email, …) and Thai NER (PyThaiNLP). No cloud AI is used to detect.
The recommended way to run AI Guard is the desktop app: a native installer that bundles the backend, so there is no Python setup. A from-source / pip path is also available for developers.
- Download the installer for your platform from the Releases page:
- Windows (tested, primary platform):
AI.Guard_<version>_x64-setup.exe - macOS (experimental — built in CI, not yet verified on real hardware):
AI.Guard_<version>_aarch64.dmg - Linux (experimental — built in CI, not yet verified on real hardware):
AI.Guard_<version>_amd64.deborAI.Guard_<version>_amd64.AppImage
- Windows (tested, primary platform):
- Run the installer and launch AI Guard. The backend is bundled and starts with the app — no Python, no separate install, works offline.
- The app is not code-signed. On first run, Windows SmartScreen may show an "unknown publisher" warning — click More info → Run anyway to continue.
Prerequisites: Python 3.11+ and git.
git clone https://github.com/Teerapat-Vatpitak/thai-pii-redaction.git
cd thai-pii-redaction./run.ps1 # Windows (PowerShell)./run.sh # Linux / macOS / git-bashThe script creates a virtual environment and installs dependencies on first run (a few minutes). The first time Thai NER runs it downloads a ~2 MB model (needs internet once). This starts the same backend the desktop app bundles, at http://localhost:8000 — useful for the browser extension UI below, or for hitting the API directly.
Verify either option: open http://localhost:8000/api/health → you should see {"status":"ok"} with the current version.
The extension talks to the same local backend, so it works with either install option above (desktop app or from-source).
- Open
chrome://extensionsin Chrome / Edge (any Chromium browser). - Turn on Developer mode (top-right).
- Click Load unpacked and select the
extension/folder from this repo (clone or download the repo to get it). - Pin the AI Guard extension so its toolbar icon is handy — clicking it opens the docked side panel. The in-page bar activates on
chatgpt.com,claude.ai,gemini.google.com,grok.com,perplexity.ai, andchat.z.ai/chatglm.cn.
See extension/README.md for details.
Using it:
- Type a prompt containing PII into the chat box.
- Click Mask PII (the floating AI Guard bar) — your text becomes tokens or fake data.
- Send it with the site's normal Send button.
- When the AI replies, click Restore PII to see the real values.
- "Backend offline" in the extension — the backend isn't running. Launch the desktop app, or start it via the
runscript (Option B). - Port 8000 already in use — close whatever is using it, or stop a previous backend instance.
- SmartScreen blocks the installer — expected for an unsigned build; choose More info → Run anyway.
- Extension bar doesn't appear — reload the ChatGPT/Claude tab after loading the extension.
| Mode | Output | Use when |
|---|---|---|
token (default) |
[ชื่อ_1], [โทรศัพท์_1] |
you want masking to be obvious |
surrogate |
realistic fake data (valid checksums) | you want the AI to read it naturally |
Switch in the extension side panel.
In examples/ (all PII is fabricated): three realistic Thai prompts and a sample Thai PDF. Explore the API at http://localhost:8000/docs, or:
curl -X POST http://localhost:8000/api/sanitize \
-H "Content-Type: application/json" \
-d '{"text":"ผมชื่อสมชาย ใจดี โทร 081-234-5678","mode":"surrogate"}'Catches free-form Section 26 content keywords miss (e.g. "ป่วยเป็นเบาหวาน") via a MiniLM model:
pip install -r requirements-ml.txt # large; the feature self-disables if absent
(Not included in the desktop app or the packaged builds.)
The token↔original vault is in memory only — never written to disk or sent over the network. The extension stores only a session_id. The external AI sees only masked text.
PYTHONUTF8=1 python -m pytest
Architecture and module map: CLAUDE.md.
Apache License 2.0 — see LICENSE and NOTICE. PDF handling uses the permissively licensed pypdfium2 / reportlab / pdfplumber (PyMuPDF/AGPL is no longer used).
See desktop/README.md and packaging/README.md for the Tauri build (bundles the backend via desktop/build-sidecar.ps1).

