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 EngramClientclient = 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
# EmbedderUSE_LOCAL_EMBEDDER=true # no API key needed# OPENAI_API_KEY=sk-... # set this if USE_LOCAL_EMBEDDER=false# NetworkSUBTENSOR_NETWORK=test # test | finney | ws://...NETUID=42# Wallet (for running a miner/validator)WALLET_NAME=engramWALLET_HOTKEY=miner# StorageFAISS_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 ingestcid = client.ingest("BERT uses bidirectional encoder representations.")# With metadatacid = client.ingest("GPT generates text autoregressively.",metadata={"source": "arxiv", "year": "2017"})# Batch ingest from JSONLcids = 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
# Ingestengram ingest "Some important knowledge"engram ingest --file corpus.jsonl# Queryengram query "what is self-attention?"# Statusengram 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 →