PRISM: Predicting Response Intent from Session Memory
PRISM is a model-agnostic Python library and research framework designed to eliminate the "Intent Alignment Tax" in AI conversations. By analyzing past chat history, PRISM builds a User Intent Vector (UIV) that predicts a user's preferred style, format, and complexity, allowing LLMs to provide the perfect response on the first try.
🚀 Key Features
- Clarification Detection: Automatically identify when users are frustrated by misaligned AI responses.
- Dynamic User Profiling: Build long-term memory of user preferences (e.g., "likes bullet points", "prefers simple analogies").
- Seamless Integration: Optimized for Llama 3.2:3b via Ollama, but works with OpenAI, Anthropic, and other LLMs.
- Interactive Web UI: Real-time visualization of intent extraction and prompt adaptation using Gradio.
- Research Framework: Tools to evaluate intent alignment on the OpenAssistant/oasst1 dataset.
📦 Installation
# Install core dependencies
pip install datasets pandas ollama gradio
🧩 CLI Plugin (OpenAI/Claude/Gemini)
The CLI generates provider-ready payloads with PRISM injection so you can plug it into any API client.
# Install the package locally to get the `prism` command
pip install -e .
# Create an OpenAI-ready payload from a single user message
prism adapt --provider openai --message "Explain vector databases"
# Use a history file and output only the provider payload JSON
prism adapt --provider anthropic --history examples/history.json --message "Summarize in bullets" --payload-only
Notes
- Defaults: OpenAI
gpt-4o-mini, Anthropicclaude-3-5-sonnet-latest, Geminigemini-1.5-flash(override with--model). - Disable injection globally with
PRISM_DISABLE_PERSONALIZATION=1. - Output JSON includes the UIV and confidence unless you pass
--payload-only.
CLI Demo (Before/After)
| Before | After |
|---|---|
🔌 Provider Integration
PRISM outputs provider-ready payloads. Pipe them into your own API client.
# Create a payload JSON for any provider
prism adapt --provider gemini --history examples/history.json --message "Summarize in bullets" --payload-only > payload.json
🏷️ Recommended GitHub Topics
llm · personalization · prompt-engineering · nlp · rag · chatbots · gradio · ollama · gemini · claude · openai · ai-tools
🎥 Demo in Action: Visual Tour
PRISM eliminates the "Intent Alignment Tax" in 6 clear steps:
| Step 1: The Problem | Step 2: The Correction | Step 3: PRISM Analysis |
|---|---|---|
| User receives a generic, long response | User provides a stylistic correction | PRISM extracts the Intent Vector (UIV) |
| Step 4: Persistence | Step 5: The Solution | Step 6: Local Integration |
|---|---|---|
| Preferences saved to JSON Profile Store | New queries get the right style immediately | Fully powered by Local Llama 3.2:3b |
The "Intent Alignment" Workflow:
- User: "Explain Quantum Computing" -> AI: [Long Technical Paragraph]
- User: "Too complex, use bullets" -> PRISM: Detects intent and updates UIV to
{'complexity': 'simple', 'format': 'bullets'}. - User: "What is a Qubit?" -> AI (via PRISM): [Automatically provides a simple, bulleted explanation on the first try].
🏗️ Architecture
PRISM sits between the User and the LLM (Ollama/Llama 3.2), acting as a persistent memory and intent-alignment layer.
graph LR
A[User] --> B[PRISM Intent Detector]
B --> C[UIV Builder]
C --> D[Local Profile Store]
D --> E[Ollama Llama 3.2]
E --> A
📄 Research Paper
This project implements the methodology described in the PRISM Research Paper.
✅ Production Readiness v1 (Implemented)
PRISM now includes a full production-hardening pass across six engineering phases:
- Hybrid Intent Inference Core
- Weighted hybrid signals (regex + multi-turn preference scoring)
- Confidence estimation + abstain gating
- Temporal decay blending with prior profile
- Profile Lifecycle Controls
- Profile schema v2 (
uiv, confidence metadata, source, override) - View/edit/reset support in storage APIs
- Temporary override with TTL
- Profile schema v2 (
- Observability
- Structured runtime event logging (
data/metrics/events.jsonl) - Decision counters (
data/metrics/counters.json) - Wrong-personalization signal tracking
- Structured runtime event logging (
- Evaluation Upgrade
- Production metrics tracker (
clarification_rate,first_response_acceptance_rate,wrong_personalization_rate, etc.) - Extended research pipeline output to
research\outputs\evaluation_metrics.json
- Production metrics tracker (
- Storage Hardening
- Profile versioning and metadata normalization
- Export/delete profile methods for privacy workflows
- Retention policy hook (
apply_retention_policy) - Store abstraction interface for DB migration path
- Release Guardrails
- Rollback switch: set
PRISM_DISABLE_PERSONALIZATION=1to disable injection globally - Drift checks via runtime counters (correction/abstain rate alerts)
- Rollback switch: set
Updated Runtime Architecture
graph LR
A[User] --> B[Hybrid Intent Inference]
B --> C[Confidence + Abstain Gate]
C --> D[Profile Store v2]
D --> E[Prompt Adapter]
E --> F[LLM]
F --> A
E --> G[Telemetry + Drift Monitor]
Running Research Evaluation
python research/01_evaluate_lmsys.py --num-samples 10000 --dataset-name OpenAssistant/oasst1
📄 License
MIT
Metadata
Release files for prism-intent 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prism_intent-0.1.1.tar.gz | 21.2 kB | With provenance | Details for prism_intent-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prism_intent-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for prism_intent-0.1.1-py3-none-any.whl |
Total release size: 42.2 kB
Release files / prism_intent-0.1.1.tar.gz
| Download URL | prism_intent-0.1.1.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d07c5b2939f5421e6fa7486d64ba6edc2af7c75861d7b576968450f396cb1f07
|
|
BLAKE2b-256 checksum How to use checksums |
9436b7c5d505a19c180bbfd8db5e6a947919103c86405ddf14d3f89bdd04f71a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logRelease files / prism_intent-0.1.1-py3-none-any.whl
| Download URL | prism_intent-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eee468534c4dadcd889df545be8f885946c9ab33c4627c490a51d35c83f17e63
|
|
BLAKE2b-256 checksum How to use checksums |
48ef228a0f67d54020cdddb8ba67a5c9dce76990f037d269015971be0c0e48a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logSecurity for prism-intent 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for prism_intent-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.