PRISM: Predicting Response Intent from Session Memory
Project description
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
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 prism_intent-0.1.1.tar.gz.
File metadata
- Download URL: prism_intent-0.1.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d07c5b2939f5421e6fa7486d64ba6edc2af7c75861d7b576968450f396cb1f07
|
|
| MD5 |
b2f850a4fbfa4beeb190ffe550c18ec4
|
|
| BLAKE2b-256 |
9436b7c5d505a19c180bbfd8db5e6a947919103c86405ddf14d3f89bdd04f71a
|
Provenance
The following attestation bundles were made for prism_intent-0.1.1.tar.gz:
Publisher:
python-publish.yml on AlfaPankaj/prism-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prism_intent-0.1.1.tar.gz -
Subject digest:
d07c5b2939f5421e6fa7486d64ba6edc2af7c75861d7b576968450f396cb1f07 - Sigstore transparency entry: 1615870761
- Sigstore integration time:
-
Permalink:
AlfaPankaj/prism-ai@a08155db8b5bb4df848ca25e82c08f70d18a3fed -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AlfaPankaj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a08155db8b5bb4df848ca25e82c08f70d18a3fed -
Trigger Event:
push
-
Statement type:
File details
Details for the file prism_intent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: prism_intent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.0 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 |
eee468534c4dadcd889df545be8f885946c9ab33c4627c490a51d35c83f17e63
|
|
| MD5 |
2ef8335067d6291c66c985c98d87aa6e
|
|
| BLAKE2b-256 |
48ef228a0f67d54020cdddb8ba67a5c9dce76990f037d269015971be0c0e48a7
|
Provenance
The following attestation bundles were made for prism_intent-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on AlfaPankaj/prism-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prism_intent-0.1.1-py3-none-any.whl -
Subject digest:
eee468534c4dadcd889df545be8f885946c9ab33c4627c490a51d35c83f17e63 - Sigstore transparency entry: 1615870764
- Sigstore integration time:
-
Permalink:
AlfaPankaj/prism-ai@a08155db8b5bb4df848ca25e82c08f70d18a3fed -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/AlfaPankaj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a08155db8b5bb4df848ca25e82c08f70d18a3fed -
Trigger Event:
push
-
Statement type: