lucid-bias
Detect cognitive biases in AI-generated text. The first open-source library for identifying cognitive biases in LLM outputs.
LLMs don't just hallucinate facts. They exhibit systematic reasoning errors: anchoring on initial values, confirming pre-existing premises, framing data to skew decisions, and appealing to authority without relevance. These cognitive biases in AI outputs lead to flawed decisions downstream.
lucid-bias identifies 70+ cognitive biases in text with zero dependencies. Rule-based detectors for 12 bias types ship out of the box, with a clean extension API for adding more.
Built by Ultra Deep Tech. Full commercial detection (98% precision, 70+ active detectors, sub-2-minute analysis) available at lucidapp.io.
Installation
pip install lucid-bias
Or install from source:
git clone https://github.com/avibrahms/lucid-bias.git
cd lucid-bias
pip install -e ".[dev]"
Quick Start
from lucid_bias import detect_biases
text = """
Since we've already invested $2M in this project, we should see it through
to completion. Research consistently supports this approach, and experts agree
it will definitely succeed. Most companies are already doing this.
"""
results = detect_biases(text)
for bias in results:
print(f"{bias.bias_name}: {bias.confidence:.0%} ({bias.severity.value})")
Output:
Sunk Cost Fallacy: 85% (high)
Overconfidence Bias: 80% (high)
Confirmation Bias: 80% (high)
Bandwagon Effect: 65% (medium)
Features
Detection API
from lucid_bias import detect_biases, LucidDetector
# Simple function call
results = detect_biases("Your text here")
# Filter by specific biases
results = detect_biases(text, bias_ids=["anchoring", "sunk_cost"])
# Set confidence threshold
results = detect_biases(text, min_confidence=0.7)
# Limit results
results = detect_biases(text, top_n=5)
# Reusable detector with configuration
detector = LucidDetector(min_confidence=0.6, top_n=10)
results = detector.analyze(text)
# Human-readable report
print(detector.report(text))
Result Objects
Each BiasResult contains:
result.bias_id # "sunk_cost"
result.bias_name # "Sunk Cost Fallacy"
result.category # BiasCategory.DECISION_MAKING
result.confidence # 0.85
result.severity # BiasSeverity.HIGH
result.evidence # The text fragment that triggered detection
result.explanation # Why this constitutes the bias
result.span # (start, end) character positions
# Serialize for APIs
result.to_dict()
Bias Taxonomy
Browse the full catalog of 70+ cognitive biases:
from lucid_bias import BIAS_CATALOG, get_bias, list_biases, list_categories
from lucid_bias.models import BiasCategory
# Get a specific bias definition
bias = get_bias("anchoring")
print(bias.description)
print(bias.ai_manifestation)
print(bias.example)
# List all biases in a category
decision_biases = list_biases(BiasCategory.DECISION_MAKING)
# List categories with counts
for cat in list_categories():
print(f"{cat['name']}: {cat['count']} biases")
Built-in Detectors
| Detector | Bias | What it catches |
|---|---|---|
AnchoringDetector |
Anchoring Bias | Over-reliance on initial values/numbers |
ConfirmationBiasDetector |
Confirmation Bias | One-sided evidence presentation |
AvailabilityDetector |
Availability Heuristic | Overweighting vivid/recent examples |
FramingEffectDetector |
Framing Effect | Positive/negative presentation skew |
SunkCostDetector |
Sunk Cost Fallacy | Justifying continuation by past investment |
BandwagonDetector |
Bandwagon Effect | Popularity as proof of quality |
OverconfidenceDetector |
Overconfidence Bias | Unwarranted certainty in predictions |
AuthorityBiasDetector |
Authority Bias | Expert opinion as sole evidence |
SurvivorshipDetector |
Survivorship Bias | Learning only from successes |
FalseDichotomyDetector |
False Dichotomy | Artificial binary framing |
LossAversionDetector |
Loss Aversion | Fear-of-loss driven urgency |
HindsightDetector |
Hindsight Bias | Treating outcomes as predictable |
Bias Categories
| Category | Count | Examples |
|---|---|---|
| Decision Making | 18 | Anchoring, Sunk Cost, Status Quo, Loss Aversion |
| Belief | 6 | Confirmation, Appeal to Nature, Just-World Hypothesis |
| Probability | 8 | Availability, Gambler's Fallacy, Base Rate Neglect |
| Social | 8 | Bandwagon, Authority, Halo Effect, Groupthink |
| Self | 7 | Overconfidence, Dunning-Kruger, Planning Fallacy |
| Framing | 6 | Framing Effect, False Dichotomy, Denomination Effect |
| Memory | 5 | Hindsight, Recency, Narrative Fallacy |
| Attention | 3 | Negativity Bias, Mere Exposure, Functional Fixedness |
Writing Custom Detectors
Add detection for any bias in the taxonomy:
from lucid_bias.detectors.base import BaseDetector
from lucid_bias.models import BiasCategory, BiasResult, BiasSeverity
class StatusQuoDetector(BaseDetector):
bias_id = "status_quo" # Must match a taxonomy entry
def detect(self, text: str) -> list[BiasResult]:
results = []
indicators = ["works well enough", "why fix what isn't broken", "no need to change"]
for phrase, start, end in self.find_indicators(text, indicators):
sentence, s_start, s_end = self.get_sentence_at(text, start)
results.append(
BiasResult(
bias_id="status_quo",
bias_name="Status Quo Bias",
category=BiasCategory.DECISION_MAKING,
confidence=0.70,
severity=BiasSeverity.MEDIUM,
evidence=sentence,
explanation="Preference for the current state may not be rational.",
span=(s_start, s_end),
)
)
return results
Import your detector to register it automatically:
from your_module import StatusQuoDetector # Auto-registers on import
from lucid_bias import detect_biases
results = detect_biases(text) # Now includes status quo detection
Why This Matters
AI systems increasingly influence decisions in healthcare, finance, legal, and policy domains. When an LLM anchors on an initial estimate, confirms a user's premise without challenge, or frames data to favor one conclusion, the downstream impact can be significant.
No open-source tool existed to systematically detect these reasoning failures in AI outputs. lucid-bias fills that gap.
Contributing
Contributions welcome. The highest-impact way to contribute is adding new detectors for biases in the taxonomy that don't have one yet (58 biases still need detectors).
# Setup
git clone https://github.com/avibrahms/lucid-bias.git
cd lucid-bias
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Add a detector
# 1. Create lucid_bias/detectors/your_bias.py
# 2. Import it in lucid_bias/detectors/__init__.py
# 3. Add tests in tests/
License
MIT License. See LICENSE.
Links
- Full product: lucidapp.io (70+ active detectors, 98% precision)
- Company: Ultra Deep Tech
- Issues: GitHub Issues
Metadata
Release files for lucid-bias 0.1.0
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 |
|---|---|---|---|---|
| lucid_bias-0.1.0.tar.gz | 35.1 kB | Without provenance | Details for lucid_bias-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lucid_bias-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lucid_bias-0.1.0-py3-none-any.whl |
Total release size: 74.3 kB
Release files / lucid_bias-0.1.0.tar.gz
| Download URL | lucid_bias-0.1.0.tar.gz |
|---|---|
| Size | 35.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b4e8fe97cfd2302a92cd932d29ea1feb6aeae967f67af3b1a99efd27f1d7085
|
|
BLAKE2b-256 checksum How to use checksums |
c8d533fd6ec3dc463fa0853b5ebae6dee5e3d102377861da95c28fc4c4293f6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / lucid_bias-0.1.0-py3-none-any.whl
| Download URL | lucid_bias-0.1.0-py3-none-any.whl |
|---|---|
| Size | 39.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f4e305a308e350fda2b66ba9b782320c8669dd15b71257aaf3984b3bbd8e4d5
|
|
BLAKE2b-256 checksum How to use checksums |
9d95cee34515c8a6ba4e037cbb36ce596650601fbfc6f9a4a72ea81417d74023
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for lucid-bias 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.