from factoid import Document, Entity, Fact
class SourceContract(Document):
"""Domain document representing source text."""
pass
class Counterparty(Entity):
"""Domain entity referenced across documents."""
pass
class ContractualObligation(Fact):
"""Self-contained fact extracted from a specific document location."""
pass
Factoid Framework
Factoid is an open-source Python framework that turns Documents into short, self-contained Facts and Entities, each tied to an exact location in the source document.
Factoid is early software (version 0.1.29), requires Python 3.13+, and uses the MIT license.
Domain Modeling and Extraction Pipeline
Factoid is a configurable framework where you map it to your domain by extending the Document, Fact, and Entity base classes.
Documents in
Source text feeds into the domain-configured Document models for ingestion and coordinate tracking.
Extract facts and link entities
Extract explicit, pronoun-free facts tied to exact source locations, and link affected Entities.
Update the fact set
Update the fact set as new documents arrive—retire outdated facts, merge duplicate facts, and flag facts that disagree.
Access Paths
People, agents, and data pipelines use these paths to query facts with semantic, BM25, and hybrid-reranked search, including "as of" queries for a past date.
CLI
Direct terminal access for engineers and automated shell scripts. Search the fact database interactively or emit structured JSON streams for shell pipelines.
Query capabilities:
- Semantic vector retrieval
- Exact BM25 keyword matching
- Hybrid-reranked query mode
- "as of" queries for past dates
factoid query "payment terms" --as-of 2024-01-01 --hybrid
HTTP API
Standard REST API for backend services and data pipelines. Provides endpoints for ingestion, fact retrieval, entity graph traversal, and temporal status filters.
Query capabilities:
- Semantic vector retrieval
- Exact BM25 keyword matching
- Hybrid-reranked query mode
- "as of" queries for past dates
POST /v1/facts/search
{"query": "...", "as_of": "2024-01-01"}
MCP
Model Context Protocol server integration for AI assistants and autonomous agents. Gives language models native access to inspect cited facts and entities.
Query capabilities:
- Semantic vector retrieval
- Exact BM25 keyword matching
- Hybrid-reranked query mode
- "as of" queries for past dates
mcp://factoid/query_facts?rerank=hybrid&as_of=...
Fact Lifecycle and Statuses
Every fact is a short, self-contained sentence devoid of filler and explicit in its language (no pronouns), linked to its exact source location and affected entities.
| Status | Lifecycle Meaning and Role | Fact Set Behavior |
|---|---|---|
| current | Active, verified fact that reflects the latest valid state extracted from source documents. | Active in default queries |
| superseded | Replaced by newer information introduced in a subsequent document. | Historical queries only |
| ended | The stated event, condition, or period has concluded according to source documents. | Historical queries only |
| corrected | Modified to resolve an extraction error or erratum identified in the source text. | Archived with correction link |
| contradicted | Conflicts with another recorded fact in the repository and has been flagged for disagreement. | Flagged in query results |
| replaced | Substituted due to structural changes, schema updates, or entity consolidation. | Substituted by replacement fact |
| retracted | Explicitly withdrawn by the publisher or author of the source document. | Excluded from active state |
Sentence Structure Mandate
In Factoid, each fact is recorded as an explicit, pronoun-free statement. Facts carry coordinate pointers back to the original source text alongside bidirectional links to all affected Entities. When new documents arrive, Factoid retires outdated facts, merges duplicate facts, and flags facts that disagree.
News Transcripts Evaluation and Example Applications
Empirical evaluation results demonstrate retrieval efficiency and precision on news transcripts.
News Transcripts (200 Questions)
On 200 questions about news transcripts, facts read at 512 tokens answered 0.92 right, plain chunks read at 2,048 tokens answered 0.87 right, and at 8,192 tokens the two are even.
| Representation Method | Token Budget | Correct Answers |
|---|---|---|
| Facts (Factoid) | 512 tokens | 0.92 |
| Plain chunks | 2,048 tokens | 0.87 |
| Facts and plain chunks | 8,192 tokens | Even (0.92) |
Example Applications
Example apps for legal contracts, NBA playoffs, and news transcripts publish their evaluation results in the repo.
-
Legal Contracts
Subclasses contracts into obligations, parties, and effective dates. Evaluation results published in repository.
-
NBA Playoffs
Extracts series outcomes, player statistics, and game sequences with temporal validity. Evaluation results published in repository.
-
News Transcripts
Extracts verifiable statements from broadcast reporting transcripts across 200 benchmark questions. Evaluation results published in repository.
Research Papers
Theoretical foundation, empirical methodology, and citation mechanics behind the Factoid framework.
arXiv:2608.20845
Foundational research on fine-grained fact extraction, coordinate citations, and pronoun-free knowledge representation from unstructured documents.
arXiv:2609.29661
Evaluation methodology, lifecycle reconciliation of contradictory statements, and retrieval comparisons between dense chunks and structured facts.