Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:24kchengYe MemoMind Fact Extraction

From Leeroopedia
Knowledge Sources
Domains NLP, Information_Extraction
Last Updated 2026-10-28 00:00 GMT

Overview

Technique that uses large language models to extract structured factual statements from unstructured text, classifying each fact by type and capturing temporal, entity, and causal metadata.

Description

Fact extraction is the process of transforming free-form text (conversations, documents, event logs) into discrete, typed factual units suitable for storage in a knowledge graph. Traditional information extraction relied on rule-based systems and supervised NER models. LLM-based extraction replaces this pipeline with a single generative model that can understand context, infer fact types (world facts vs. personal experiences), detect entities, and identify causal relationships—all from a prompt.

The key problem solved is semantic normalization: raw text is ambiguous, verbose, and unstructured. Fact extraction distills it into atomic units ("Alice works at Acme Corp", "Alice enjoys hiking") that can be individually embedded, linked, and retrieved. Without extraction, retrieval would operate on coarse document chunks with poor precision.

Usage

Use this principle when building memory systems that ingest heterogeneous text sources and need fine-grained, per-fact retrieval. It is the entry point of any "retain" pipeline where raw text must become queryable knowledge.

Theoretical Basis

The extraction prompt instructs the LLM to:

  1. Segment input text into chunks (preserving ordering)
  2. Classify each extracted fact by type (world, experience, opinion)
  3. Extract entities mentioned in each fact
  4. Detect temporal markers (occurred_start, occurred_end, mentioned_at)
  5. Identify causal relations between facts (causes, enables, prevents)

The LLM returns structured JSON conforming to a Pydantic schema. Each fact is an atom with:

# Abstract fact structure (not real implementation)
fact = {
    "fact_text": "Alice works at Acme Corp",
    "fact_type": "world",           # world | experience | opinion
    "entities": ["Alice", "Acme Corp"],
    "occurred_start": "2024-01-15",
    "occurred_end": None,
    "mentioned_at": "2024-01-15",
    "causal_relations": [...]
}

Practical Guide

  • Prompt design is critical: the system prompt must enforce fact atomicity (one fact per statement), type classification, and entity extraction in a single LLM call.
  • Temporal offsets are added post-extraction to ensure unique timestamps across facts from the same content, enabling time-aware retrieval.
  • Batch routing: when enabled, extraction delegates to a batch API mode for state persistence and crash recovery.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment