Privacy-first tokenization middleware for LLM pipelines. Strip sensitive data before it reaches any API. Restore originals on the way back. Local detection, encrypted vault, zero cloud dependency.
The LLM receives readable context — just not the actual sensitive values.
Everything you need to protect user data in LLM pipelines.
Regex for structured types (cards, IBANs, emails). Local Ollama for contextual types (names, addresses, national IDs). Best of both.
Detection runs on your own infra via Ollama. Raw data never leaves your network — not even for the detection step.
Token↔value mappings stored in AES-256-GCM encrypted SQLite. Keys never leave the process.
Use context_id from your domain (contact_123, zoom_call_789) instead of tracking foreign UUIDs.
Large texts chunked and processed in parallel goroutines. Single-pass Aho-Corasick detokenization.
Run as a standalone HTTP service or import as a Go library. One Docker Compose command to start everything.
Structured and contextual — handled differently, protected equally.
HTTP service or Go library — use whatever fits your architecture.
# 1. Tokenize before sending to LLM resp = requests.post("http://localhost:8080/v1/tokenize", json={ "text": transcript, "context_id": f"zoom_{call_id}" }) tokenized = resp.json() # 2. Send tokenized text to your LLM — real PII never transmitted llm_response = openai.chat.completions.create( messages=[ {"role": "system", "content": "Summarize this call transcript."}, {"role": "user", "content": tokenized["tokenized_text"]} ] ) # 3. Detokenize the response final = requests.post("http://localhost:8080/v1/detokenize", json={ "text": llm_response.choices[0].message.content, "context_id": f"zoom_{call_id}" }) print(final.json()["original_text"])
import "github.com/yemrealtanay/llm-hasher/pkg/hasher" h, err := hasher.New( hasher.WithOllama("http://localhost:11434", "llama3.2:3b"), hasher.WithVault("data/vault.db", ""), ) defer h.Close() // Tokenize result, err := h.Tokenize(ctx, transcript, "zoom_call_789", nil) // result.Text → tokenized transcript, safe to send to any LLM // Detokenize after LLM response original, err := h.Detokenize(ctx, llmResponse, "zoom_call_789")
# Tokenize curl -X POST http://localhost:8080/v1/tokenize \ -H "Content-Type: application/json" \ -d '{"text":"Hi, my card is 4111-1111-1111-1111","context_id":"session_1"}' # Response { "tokenized_text": "Hi, my card is CREDIT_CARD_sess1_4f8a2b", "context_id": "session_1", "entities": [ { "token": "CREDIT_CARD_sess1_4f8a2b", "pii_type": "CREDIT_CARD" } ] } # Detokenize curl -X POST http://localhost:8080/v1/detokenize \ -H "Content-Type: application/json" \ -d '{"text":"CREDIT_CARD_sess1_4f8a2b","context_id":"session_1"}'
Docker Compose handles everything — Ollama, model download, service startup.
Pulls Ollama + llama3.2:3b (~2GB), starts on port 8080.
Returns {"status":"ok"}
Open source, MIT license. Self-hosted. No vendor lock-in.