Skip to main content

Python bindings for the Valise single-file AI/retrieval archive format.

Project description

valise

Retrieval in one file.

Your RAG prototype works. Now ship it — and suddenly the corpus isn't a thing you have, it's a thing you operate. A vector database container. An index directory that has to travel with the documents and stay consistent with them. A rebuild step in CI. The most valuable artifact you built is the one piece you can't hand to anyone.

SQLite solved this for relational data. Valise does it for retrieval: documents, a BM25 index, compressed vectors, and the schema describing them, in one .vls file you copy, version, and query in place.

pip install valise
import numpy as np
from valise import Store, Schema, Record, Search, Vector

store = Store.open("kb.vls")                      # open-or-create
store.collection("notes", Schema()
    .text("body")                                 # English BM25 by default
    .vector("dense", Vector(dim=768)))            # cosine, auto-calibrated codec

with store.writer() as w:
    w.put("notes", "doc-1",
          Record().text("body", "portable retrieval capsules")
                  .vector("dense", embedding))    # float32 ndarray
    w.commit()                                    # the durability point

hits = store.search("notes", Search()
    .text("body", "retrieval capsule")
    .vector("dense", query)
    .top_k(10))

print(hits.keys)      # ['doc-1']
print(hits.scores)    # float32 ndarray

The schema lives in the file. A later run, another process, or another machine calls Store.open("kb.vls") and searches immediately — nothing to re-declare, nothing to migrate.

Note that leaving the with block releases the writer lock; it does not commit. commit() is explicit, and it is the only durability point.

Copy it while it's being written

That's the test that matters. Take a copy of a live corpus mid-write, move it to a machine with a different OS and instruction set, open it there. On a 171,000-document hybrid corpus:

Valise Tantivy + USearch SQLite + FTS5 + vec
Mid-write copies that opened correctly 50 / 50 4 / 50 0 / 50
Artifact 239 MB, 1 file 677 MB, 62 files 865 MB

Top-10 results come back identical across macOS/ARM and Linux/x86-64, from the same file, with no reconfiguration.

There is no index to build

Every ANN library builds a graph first, and pays again whenever the corpus changes. Valise builds nothing: vectors are stored only as quantized codes, and the candidate-search sketch is derived from those same codes at open — in memory, never written.

At 100k × 768d against recall-matched baselines: 0.50 s to ingest and commit, versus 50 s for FAISS HNSW, 91 s for USearch, 139 s for hnswlib. 90–310× faster to build, and nothing on disk but your data.

The bill: the scan is linear, so a mature HNSW answers individual queries faster. If you build once and serve a billion queries over a static corpus, use a graph. If your corpus changes, travels, or there are thousands of small ones, this trade is the right way round.

Valise does not generate embeddings — bring your own model.

What you get

  • Hybrid search. Lexical and vector channels fused at query time, with reciprocal-rank fusion as the default. Text scorers include BM25, TF-IDF cosine, count cosine, approximate cosine variants, and Dice / overlap / containment.
  • Compact vectors. QAM Lloyd-Max and UPQ polar codecs at ~5.5 bits per dimension, with NEON and AVX2 kernels. There is no persisted HNSW graph or IVF index — nothing to rebuild, and nothing on disk but the capsule.
  • Crash safety. Commits are footer-rooted and atomic: after a crash a reader sees the previous committed state or the new one, never a mixture. Segment payloads carry BLAKE3 checksums.
  • Time partitions, tombstones with explicit compaction, and recency as either a ranking signal or a hard filter.
  • A typed surface. Full type hints, checked under mypy --strict, with strict enums rather than magic strings. Vectors cross the FFI boundary zero-copy.

Batch ingest

put_many takes a C-contiguous float32 [N, dim] array and ingests the whole batch in one native call, rather than a per-row Python loop:

vectors = np.ascontiguousarray(model.encode(bodies), dtype=np.float32)
with store.writer() as w:
    w.put_many("notes", keys, vectors, texts=bodies)
    w.commit()

Reading everything back

Your data is never locked in. keys() plus get() walks a whole collection:

r = store.reader()
for key in r.keys("notes"):
    print(r.get("notes", key).text)

The valise command-line tool (cargo install valise) does the same from a shell, including valise export kb.vls > kb.jsonl.

Requirements

Python 3.9 or newer, and NumPy. Wheels are published for Linux and macOS on x86-64 and aarch64.

Windows is not supported yet — the commit protocol relies on positional file IO and fcntl advisory locks, and the Windows equivalents are not implemented.

Status

Pre-1.0 and under active development. Below 1.0, minor versions may break both the API and the on-disk format.

Links

  • Documentation — quickstart, concepts, full API reference
  • Source — the Rust engine, the on-disk format specification, and the benchmark methodology
  • Rust crate

Licensed under MPL-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

valise-0.1.2.tar.gz (559.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

valise-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

valise-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

valise-0.1.2-cp39-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

valise-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file valise-0.1.2.tar.gz.

File metadata

  • Download URL: valise-0.1.2.tar.gz
  • Upload date:
  • Size: 559.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for valise-0.1.2.tar.gz
Algorithm Hash digest
SHA256 45dc432ddc0c8055fb2e0e1348ac8420d32fdce5de0ce86f07b0bf94ce42de7c
MD5 95e2e3a1565edc55eefa990010c033ba
BLAKE2b-256 8c8943f2953c041c60585af5082cb94be4f88096d7f06112489d0101fd440812

See more details on using hashes here.

Provenance

The following attestation bundles were made for valise-0.1.2.tar.gz:

Publisher: wheels.yml on white07S/valise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file valise-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for valise-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8dadec2b8fb999171a1bf8ec3d23908ee56c247549949034c48a63816dd25580
MD5 e84e8a4a5563d1006a3ef1cd50667be5
BLAKE2b-256 6aa3b9824d6e73894ded1e397074622ba05a127fb26d85c3df8ec2b54af3309d

See more details on using hashes here.

Provenance

The following attestation bundles were made for valise-0.1.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on white07S/valise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file valise-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for valise-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d149726d8020fc4594d67aa0a0da62eadf24cbd40ebbfdb1a1d96ac73d8c84a1
MD5 597cf087fe11503ec454470f8a773dd2
BLAKE2b-256 5f008c18b7e40d18d3fcae4ff8962d6b42c4681d385f0109e14d5ad06b3033a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for valise-0.1.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on white07S/valise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file valise-0.1.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for valise-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 159a15ee89b940ab5b79fe3537c97612f3345b77cb2315c5e6d3243da1daf615
MD5 3e2256cbb2a25457f96de691f345bb1c
BLAKE2b-256 3ab6224117d95811f0849edaad629bb3d9c37675c565235125f0d3e9b206553d

See more details on using hashes here.

Provenance

The following attestation bundles were made for valise-0.1.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on white07S/valise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file valise-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for valise-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 790d9c8667386b1e4842156b6e9446ae71cd01b1a1b4c4875b8082fb2889debd
MD5 1fbc0e0af932708593827d96fe719190
BLAKE2b-256 6c6f1447457a13b43006f2fc8274fc81f5a6ab700e316feb6386006e4c0e2359

See more details on using hashes here.

Provenance

The following attestation bundles were made for valise-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on white07S/valise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page