EngramEngramDocs

Quick Start

Get from zero to your first semantic query in under 2 minutes.

01
Install

Install the engram-subnet package from PyPI.

bash
pip install engram-subnet
02
Configure (optional)

Copy the example env file and edit it. Defaults work out of the box with a local embedder.

bash
cp .env.example .env
# USE_LOCAL_EMBEDDER=true ← no API key needed
03
Ingest your first text
python
from engram.sdk import EngramClient
client = EngramClient("http://127.0.0.1:8091")
cid = client.ingest("The transformer architecture changed everything.")
print(cid) # v1::a3f2b1...
04
Run a semantic query
python
results = client.query("how does attention work?", top_k=5)
for r in results:
print(f"{r['score']:.4f} {r['cid']}")

Configuration

All config is read from a .env file in the working directory:

.env
# Embedder
USE_LOCAL_EMBEDDER=true # no API key needed
# OPENAI_API_KEY=sk-... # set this if USE_LOCAL_EMBEDDER=false
# Network
SUBTENSOR_NETWORK=test # test | finney | ws://...
NETUID=42
# Wallet (for running a miner/validator)
WALLET_NAME=engram
WALLET_HOTKEY=miner
# Storage
FAISS_INDEX_PATH=./data/engram.index

Ingest text

The SDK embeds the text, assigns a CID, and stores it on the miner's FAISS index.

python
# Basic ingest
cid = client.ingest("BERT uses bidirectional encoder representations.")
# With metadata
cid = client.ingest(
"GPT generates text autoregressively.",
metadata={"source": "arxiv", "year": "2017"}
)
# Batch ingest from JSONL
cids = client.batch_ingest_file("data/corpus.jsonl")
Note
The CID is deterministically derived from the embedding — the same text always produces the same CID regardless of which miner stores it.

Query

python
results = client.query("attention mechanisms", top_k=10)
# [
# {"cid": "v1::a3f2b1...", "score": 0.9821, "metadata": {"source": "arxiv"}},
# {"cid": "v1::b2e8c1...", "score": 0.8847, "metadata": {}},
# ...
# ]

Try the CLI

bash
# Ingest
engram ingest "Some important knowledge"
engram ingest --file corpus.jsonl
# Query
engram query "what is self-attention?"
# Status
engram status
Tip
Run engram demo for a full end-to-end demo — seeds a corpus, ingests it, runs queries, and prints scores.
engram docs · v0.1edit on github →