cognition-horizon
A linter for LLM output quality.
Detects when an AI response drifts from the original intent, hedges instead of answers, or escalates in intensity without adding information.
Install
pip install cognition-horizon
Quick Start
from cognition_horizon.engine import CognitionHorizon
analyzer = CognitionHorizon()
intent = "Explain how to implement rate limiting in a FastAPI application"
output = """
Rate limiting is a crucial concept in modern API design. It's important to
consider various factors when implementing it. There are many approaches
available, and the best one depends on your specific use case. Generally
speaking, you might want to think about using middleware, which can be
quite effective in many scenarios. The implementation details can vary
significantly based on your requirements, and it's worth exploring the
different options available to you.
"""
result = analyzer.reflect(intent=intent, output=output)
print(result.to_dict())
What It Measures
Chi Drift - keyword distance between what was asked and what was answered. A score of 0.0 means the response directly addresses the intent. A score of 1.0 means the response is about something else entirely.
Hedging Density - ratio of qualifying language to total content. "might", "could", "generally speaking", "it depends" - these are hedges. High hedging density means the model is avoiding commitment.
Escalation - language intensity increases in the second half. Models sometimes generate excitement rather than precision. Escalation detection catches this pattern.
Preamble - filler at the start before the actual answer begins. "Great question! I'd be happy to help..." adds no information.
The ?h(t)dt Accumulator
The integral of the cognition horizon accumulates a running score of AI quality across traces, stripping away excess verbiage to surface overlooked insights.
Use Cases
- Automated QA Pipeline: Fail PRs where LLM output drift exceeds 0.4
- Prompt Iteration: Compare hedging density across prompt versions
- RAG Refinement: Detect when a model hallucinates excitement instead of providing facts
API Reference
Start the API:
uvicorn cognition_horizon.app:app --reload
Endpoint: POST /api/v1/reflect
Payload: {"intent": "...", "output": "..."}
Returns: JSON with drift, compression ratio, excess markers, and insights.
Philosophy
"System illuminates. Human recognizes." This package provides the illumination - making the invisible patterns of AI drift visible, so you can recognize when it's failing.
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 cognition_horizon-0.1.0.tar.gz.
File metadata
- Download URL: cognition_horizon-0.1.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acf1cf95018d9da958ad3954c9cad829c6ddace808d26a49dd80cb2952c87cc8
|
|
| MD5 |
63eb584f4e711d541c84af55c3b9d119
|
|
| BLAKE2b-256 |
89edd5da028316fce31e6dd9c8221164ec99625cd075dcbb53baff3a3479235c
|
File details
Details for the file cognition_horizon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cognition_horizon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
302042a14b6991aca5797a5cd050fd9716a63f432fe84c2f5b961d5006042a4b
|
|
| MD5 |
7c0de38d4726269078b1c9928b216977
|
|
| BLAKE2b-256 |
e1e16bd33b945c693944e0625bfa21a8ee067d766f0a85b7443cb96bbe41242d
|