import os
import tempfile
import jammi
import jammi_native # noqa: F401 -- the engine the [embedded] extra installed
from jammi_cookbook import fixtures2 5-minute quickstart
Go from pip install "jammi-ai[embedded]" to a vector search over your own data in five minutes: install, connect, register a source, embed it, search it. quickstart.py is the program, one step per cell. It is also the cookbook’s first chapter, where every step runs in Colab.
The program is cookbook/quickstart/quickstart.py; its steps run here in order.
2.1 1. Install
pip install "jammi-ai[embedded]"jammi-ai is the client (import jammi). The [embedded] extra adds the engine itself, jammi-ai-native, so the client can run it in your process; without it the client only reaches a remote jammi-server, and a file:// target raises NoEmbeddedEngineError. On an NVIDIA GPU of compute capability 8.0 or newer (A100, L4, RTX 30-series and later), install the CUDA engine in place of the CPU one: pip install jammi-ai jammi-ai-native-cu12. It carries its CUDA libraries as pip dependencies; the host needs only the NVIDIA driver.
Jammi runs on Python 3.9 or newer, on Linux (x86_64 or aarch64, glibc 2.28+) and macOS (Apple Silicon or Intel); the CUDA engine is Linux x86_64. Windows is not supported: the storage layer uses POSIX memory mapping.
Both imports succeed once the engine is installed. jammi_cookbook holds the small datasets and models the cookbook runs on.
2.2 2. Connect
jammi.connect(target) is the one front door. A file:// target runs the engine in this process, with its catalog and every result table kept under that directory; a grpc://host:8081 or https://host target opens a session against a remote jammi-server instead, with the same methods.
Device and batch size are engine configuration, read from the environment (or a JAMMI_CONFIG TOML file) when the engine starts, so they apply the same way in your process or behind a server. JAMMI_GPU__DEVICE=-1 forces the CPU and 0 pins a device; without it the engine takes GPU 0 when there is one. JAMMI_ENGINE__BATCH_SIZE sets the batch size, here small for a 20-row corpus.
os.environ.setdefault("JAMMI_GPU__DEVICE", "-1")
os.environ.setdefault("JAMMI_ENGINE__BATCH_SIZE", "8")
db = jammi.connect(f"file://{tempfile.mkdtemp()}")2.3 3. Register a source
add_source registers a file so SQL and embedding jobs can name it. The url is a local path, or s3://bucket/key, gs://bucket/key or azure://container/blob for object storage; format is parquet, csv or json. This corpus is 20 short paper abstracts with an id, a title, the content, a year and a category.
db.add_source("corpus", url=str(fixtures.path("tiny_corpus.parquet")), format="parquet")A registered file is a table in SQL, named <source>.public.<table>, where the table is the file’s name without its extension: corpus.public.tiny_corpus here. Every query returns a pyarrow.Table.
for row in db.sql("SELECT id, title, year FROM corpus.public.tiny_corpus LIMIT 3").to_pylist():
print(row){'id': 1, 'title': 'Quantum error correction in superconducting qubits', 'year': 2021}
{'id': 2, 'title': 'Deep reinforcement learning for robotic manipulation', 'year': 2022}
{'id': 3, 'title': 'CRISPR-Cas9 gene editing for sickle cell disease', 'year': 2020}
2.4 4. Embed the corpus and search it
generate_embeddings runs an encoder over every row of corpus, writes the vectors and the key column to a Parquet result table, and builds an ANN index beside it. The job is checkpointed: interrupted and run again, it picks up where it left off.
model is a Hugging Face Hub id or a local directory (local:/path, holding config.json, model.safetensors and tokenizer.json). The quickstart uses tiny_bert, a 32-dimensional single-layer model that needs no network. A real workload would name a Hub model such as sentence-transformers/all-MiniLM-L6-v2 (384 dimensions), and nothing else changes.
MODEL = fixtures.model("tiny_bert")
db.generate_embeddings(
source="corpus",
model=MODEL,
columns=["content"],
key="id",
modality="text",
)2026-10-03T07:44:20.678195Z WARN jammi_kernels::admission: fused-kernel domain check failed; falling back to the eager composition op="attention_block_fused" predicate="head_dim_is_attention_block_fixed_head_dim"
'corpus__text_embedding_____w_jammi-ai_jammi-ai_cookbook_book_jammi_cookbook__fixtures_ti__20261003T074420668081157_e0593dc7'
The query is encoded by the model that built the index, so its vector has the index’s dimension. search returns the k nearest rows as a pyarrow.Table: the source’s columns, _row_id, and similarity (cosine, 1.0 for identical). filter="year > 2020" ranks only the rows a predicate selects, and select=[...] picks the columns; joining sources, or running a model over the results, is SQL through db.sql(...).
query = db.encode_query(model=MODEL, query="how does quantum computing work?")
results = db.search("corpus", query=query, k=3)
assert results.num_rows == 3
for row in results.to_pylist():
print(f"{row['_row_id']:<8} {row['similarity']:>9.4f} {row['title']}")15 0.9354 Organocatalytic asymmetric synthesis of chiral amines
11 0.9293 Quantum key distribution over metropolitan fiber networks
1 0.9263 Quantum error correction in superconducting qubits
An embedded engine holds its catalog until the session closes. A session is also a context manager: with jammi.connect(...) as db: closes it when the block ends.
db.close()