Deterministic identity + privacy layer for LLM applications
Project description
Taivium
Deterministic identity + privacy layer for LLM applications
Sensitive data in → safe prompts out → coherent responses back
Taivium sits between your application and any LLM provider, automatically preventing sensitive data leakage — without breaking reasoning, context, or output quality.
No prompt engineering. No degraded responses. No data exposure.
The Problem
Every LLM call is a potential data leak.
- Support copilots handle customer PII (names, emails, accounts)
- Developers paste secrets (API keys, credentials)
- Healthcare & legal workflows send sensitive records
- RAG pipelines embed confidential company data
Naive redaction breaks AI quality.
"Alice emailed Bob" → "[NAME] emailed [NAME]"
→ Identity is lost → reasoning collapses.
The Solution
Taivium preserves identity and privacy.
"Alice emailed Bob" → "PERSON_a1b2 emailed PERSON_c3d4"
- Identity remains distinguishable
- Context stays intact
- Zero sensitive data reaches the LLM
How It Works
Your App ──► Taivium ──► LLM (OpenAI / Claude / local)
│
┌──────────────────────────────┐
│ Detection Layer │ spaCy · regex · transformer · LLM
│ Span Canonicalization │ one entity per span
│ Identity Engine │ deterministic pseudonyms
│ Policy Engine │ ALLOW · ANONYMIZE · BLOCK
│ Session Store │ memory or Redis
└──────────────────────────────┘
│
Optional response restoration
Key idea:
Each real-world entity gets a stable pseudonymous ID across the session.
Why Taivium Is Different
| Capability | Typical Tools | Taivium |
|---|---|---|
| PII detection | ✔ | ✔ |
| Anonymization | Masking | Semantic preservation |
| Identity tracking | ✗ | Deterministic + persistent |
| Coreference | Weak | Cross-session consistent |
| Utility preservation | ✗ | Primary objective |
Determinism
Taivium is fully deterministic by default:
- Same input → same output
- Reproducible + auditable
- No randomness
Optional layers:
- Transformer → deterministic
- LLM → non-deterministic (opt-in)
Installation
pip install taivium
With Redis:
pip install taivium[redis]
Model Dependency
Taivium uses spaCy for entity detection. You must manually install the English model:
pip install "en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl#sha256=1932429db727d4bff3deed6b34cfc05df17794f4a52eeb26cf8928f7c1a0fb85"
With Transformers (deep learning NER):
pip install taivium[transformers]
With multiple options (e.g., Redis and Transformers and dev tools):
pip install taivium[redis,transformers,dev]
Note: Optional dependencies let you install only what you need. For example, if you want transformer-based NER, use the
transformersextra. If you want Redis-backed session storage, use theredisextra. You can combine extras as needed.
Quick Start
1. Drop-in OpenAI Client
from taivium.client import PrivacyClient
import os
client = PrivacyClient(api_key=os.environ["OPENAI_API_KEY"])
response = client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "user",
"content": "John Doe's email is john@acme.com. Draft a follow-up."
}],
deid_response=True,
)
print(response.choices[0].message.content)
✔ LLM never sees real data
✔ Output still uses real names
2. Sanitize Text Directly
from taivium.engine import Taivium
pipeline = Taivium()
result = pipeline.process(
"Alice Johnson from Acme Corp emailed alice@acme.com"
)
print(result["anonymized"])
Example output:
PERSON_xxxx from ORG_xxxx emailed EMAIL_xxxx
3. Custom Policies
from taivium.engine import (
Taivium, PolicyEngine, PolicyRule, PolicyAction, RiskLevel
)
pipeline = Taivium(
policy_engine=PolicyEngine(policy_table={
"API_KEY": PolicyRule("API_KEY", PolicyAction.BLOCK, RiskLevel.CRITICAL),
"LOCATION": PolicyRule("LOCATION", PolicyAction.ALLOW, RiskLevel.LOW),
})
)
4. Redis Persistence
from taivium.engine import Taivium
from taivium.session_store import RedisSessionStore
store = RedisSessionStore(
session_id="user-123",
redis_url="redis://localhost:6379",
)
pipeline = Taivium(session_store=store)
5. Optional Detection Layers
pipeline = Taivium(
use_transformer=True,
use_llm=True
)
- Transformer → higher recall
- LLM → broader detection
- Both optional
What Gets Detected
| Entity Type | Examples |
|---|---|
| PERSON | Alice Johnson |
| ORG | Acme Corp |
| alice@acme.com | |
| PHONE | +1 415-555-1234 |
| API_KEY | sk-xxxx |
| LOCATION | New York |
Why Not Simple Redaction?
| Redaction | Taivium | |
|---|---|---|
| Identity preserved | ✗ | ✓ |
| Same entity consistency | ✗ | ✓ |
| LLM reasoning intact | ✗ | ✓ |
| Response restoration | ✗ | ✓ |
| Policy control | ✗ | ✓ |
Features
- Multi-layer detection (spaCy + regex + transformer + LLM)
- Deterministic pseudonymous identity
- Policy engine (ALLOW / ANONYMIZE / BLOCK)
- Response restoration
- Redis session persistence
- Audit trail per request
- OpenAI-compatible client
Example Output
result = pipeline.process("Alice emailed alice@acme.com")
{
"original": "Alice emailed alice@acme.com",
"anonymized": "PERSON_xxxx emailed EMAIL_xxxx",
"store_type": "InMemorySessionStore",
"mapping = {
"PERSON_7e4a1c2b3d4e5f6a7b8c9d0e": "Alice",
"EMAIL_1a2b3c4d5e6f7a8b9c0d1e2f": "alice@acme.com"
}": {},
"entities": [
{
"text": "Alice",
"label": "PERSON",
"start": 0,
"end": 5,
"source": "spacy",
"evidence_sources": ["spacy", "regex"],
"confidence": 0.92
},
{
"text": "alice@acme.com",
"label": "EMAIL",
"start": 14,
"end": 28,
"source": "regex",
"evidence_sources": ["regex"],
"confidence": 0.95
}
]
}
Architecture
engine.py
├── collect_evidence()
├── canonicalize_spans()
├── IdentityEngine.resolve()
├── PolicyEngine.evaluate()
├── transform()
└── session_store
Documentation
See docs/ for full design details.
Examples
See examples/:
- privacy pipeline
- OpenAI client
- custom detectors
Contributing
- Fork the repo
- Create a branch
- Add tests
- Open PR
License
MIT — see LICENSE
Support
Open an issue for bugs, questions, or feature requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file taivium-0.1.3.tar.gz.
File metadata
- Download URL: taivium-0.1.3.tar.gz
- Upload date:
- Size: 57.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7163922011bac48d312983914116979ea0d076348c9da87abbc78552e384d865
|
|
| MD5 |
1fe364d9952b3568d007358996bd18ad
|
|
| BLAKE2b-256 |
4eb490c2ebab0d20ed00642f17a3dbc51e96ef6d23c2ab3d9005d8ed01e17457
|
Provenance
The following attestation bundles were made for taivium-0.1.3.tar.gz:
Publisher:
cd.yml on taivium-ai/taivium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taivium-0.1.3.tar.gz -
Subject digest:
7163922011bac48d312983914116979ea0d076348c9da87abbc78552e384d865 - Sigstore transparency entry: 1682325376
- Sigstore integration time:
-
Permalink:
taivium-ai/taivium@419518eae1a79a5f5149d672677b8e66d39f6612 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/taivium-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@419518eae1a79a5f5149d672677b8e66d39f6612 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file taivium-0.1.3-py3-none-any.whl.
File metadata
- Download URL: taivium-0.1.3-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e1b2c0abf11aaf56ceed5218bd4050e06476ee9113d592c732c5aaad092febe
|
|
| MD5 |
5830b6d3243f7c429979fc15ef8ed288
|
|
| BLAKE2b-256 |
b2e726cf2c72452c548cc861b3e62713d2b7e862f51082452a96cd7d976700ea
|
Provenance
The following attestation bundles were made for taivium-0.1.3-py3-none-any.whl:
Publisher:
cd.yml on taivium-ai/taivium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
taivium-0.1.3-py3-none-any.whl -
Subject digest:
2e1b2c0abf11aaf56ceed5218bd4050e06476ee9113d592c732c5aaad092febe - Sigstore transparency entry: 1682325482
- Sigstore integration time:
-
Permalink:
taivium-ai/taivium@419518eae1a79a5f5149d672677b8e66d39f6612 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/taivium-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@419518eae1a79a5f5149d672677b8e66d39f6612 -
Trigger Event:
workflow_dispatch
-
Statement type: