Skip to content

Quick Start

Rishu edited this page Oct 21, 2026 · 1 revision

Quick Start

This page takes you from install to retrieved context. See Installation first.

1. Compress a piece of text

import noema

result = noema.compress("Larry Page founded Google in 1998. Sundar Pichai is the CEO of Google.")

print(result.notation)         # compact logical form
print(result.saved_percent)    # token reduction versus the original text
print(result.confidence)       # round-trip validation score, 0 to 1
print(noema.decode(result.notation))

Short, fact-sparse text can produce notation that is longer than the original. In that case saved_percent is 0, not negative. See Compressing Text.

2. Build a knowledge base

kb = noema.KnowledgeBase()
report = kb.ingest([
    "Larry Page founded Google in 1998.",
    "Sundar Pichai is the CEO of Google.",
])

print(report.entities_after, report.relations_after, report.entities_merged)
kb.save("company_kb.noema")

ingest() accepts a string, a Document, or a list of either. Entities that refer to the same thing, such as "Google" and "Google Inc.", are merged into one node. See Knowledge Bases.

3. Retrieve context for a question

kb = noema.KnowledgeBase.load("company_kb.noema")

context = kb.retrieve("Who is Google's CEO?", max_tokens=200)

print(context.text)           # notation, ready for a prompt
print(context.token_count)    # tokens used
print(context.truncated)      # True if the budget cut facts

4. Use it in a prompt

question = "Who is Google's CEO?"
prompt = f"Use these facts:\n{context.text}\n\nQuestion: {question}"

The notation is compact but readable by an LLM. To give the model plain sentences instead, pass format="natural_language" to retrieve(). See Retrieval.

5. Add more documents later

kb.ingest("Google acquired YouTube in 2006.")
kb.save("company_kb.noema")

New facts merge into the existing graph, and the retrieval index is rebuilt on the next retrieve() call.

From the command line

noema build-graph docs/a.txt docs/b.txt --output company_kb.noema
noema query company_kb.noema "Who is Google's CEO?"

See CLI Reference.

Next

Clone this wiki locally