LiveKnowledge

engineering knowledge, not just storing it

LiveKnowledge is a CLI tool that closes the loop between unstructured text and structured, verifiable knowledge. It combines LLM reasoning with Answer Set Programming (Clingo) to extract, verify, and query facts in an evolving knowledge base.


How it works

You feed it a question and a knowledge base (ASP facts and rules). It:

  1. Generates a candidate answer using an LLM, grounded in the KB
  2. Verifies the answer against the KB (LLM-backed for text, Clingo-backed for coherence)
  3. Abduces & Revises — if verification fails, the LLM explains why and rewrites the candidate
  4. Commits a verified answer or identifies knowledge gaps

Those gaps become actionable gap reports — structured JSON files listing the specific predicates the KB is missing. You then:

  1. Learn from a source text (learn --fill-gap) — the LLM extracts facts targeting the exact missing predicates
  2. Verify coherence — Clingo checks that the new facts don't contradict the existing KB
  3. Resolve gaps — a deterministic scan checks whether the targeted predicates now exist in the KB

The gap report tracks arity drift too — if you asked for profit/2 but the KB learned profit/3 (a richer schema), the system reports it rather than silently accepting or rejecting.


Why ASP?

Most knowledge tools treat knowledge as bags of vectors. LiveKnowledge treats it as logic programs — facts and rules that a solver can check for consistency. This means:


Get started

git clone ...
python3 -m venv .venv
.venv/bin/pip install clingo openai python-dotenv pydantic

# ask a question
python main.py ask --kb /path/to/kb.lp \
  --question "What factors drive profit margins?"

# generate a gap report
python main.py ask --kb /path/to/kb.lp \
  --question "What are the most profitable items?" \
  --gap-report gaps.json

# fill those gaps with a source text
python main.py learn --kb /path/to/kb.lp \
  --fill-gap gaps.json \
  --unstructured source.txt \
  --question "What are the most profitable items?"
  

Full docs in the README.


Stack