Skip to main content

lance-bundle - Portable Embeddings

Embed Once, Query Forever

PyPI Version PyPI Python Version

lance-bundle packages embedding vectors and the model that produced them into a single portable file - load it and query it anywhere, with no server, no database to run, and no re-embedding your data on a new machine. Built on LanceDB and ONNX for a minimal dependency footprint, it's equally at home embedded in an app, on the edge, or in a local script.

Usage

Loading Bundles

Install: pip install lance-bundle

If loading bundles from Hugging Face: pip install lance-bundle[hub]

Import and load locally or from readily available embedding datasets (huggingface.co/lance-bundle):

from lance_bundle import load_dataset
bundle = load_dataset("lance-bundle/berkshire-hathaway-letters")
bundle.search("What does Warren Buffett think of Coca-Cola and car insurance?")

Exporting Bundles

Install: pip install lance-bundle[export]

Export documents and embeddings to a local archive file (zip), then load as needed for queries:

from lance_bundle import load, save, ExportDataset
from sentence_transformers import SentenceTransformer
documents = [
    "Quantum mechanics is the foundation of modern physics.",
    "Photosynthesis allows plants to convert sunlight into food.",
    "I love eating pepperoni pizza on Fridays.",
]
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
save(model, ExportDataset(texts=documents, vectors=model.encode(documents)), "bundle.zip")
# ...
bundle = load("bundle.zip")
bundle.search("I'm hungry for some science")

Local RAG Example

Add RAG to a local LLM by loading a precomputed bundled embedding dataset (huggingface.co/lance-bundle). Example using Ollama:

from lance_bundle import load_dataset
import ollama

bundle = load_dataset("lance-bundle/paul-graham-essays")

prompt = "You are a Silicon Valley angel investor and venture capitalist. Provide advice and answers based ONLY on the provided context. If the answer cannot be found in the context, say 'I don't know'. Context: {context} Question: {query}"

while True:
    print("> ", end="")
    query = input()
    context = bundle.search(query, limit=1)[0]['text']
    response = ollama.chat(
        model='llama3.2:1b',
        messages=[{'role': 'user', 'content': prompt.format(context=context, query=query)}]
    )
    print(response.message.content)

CLI

# Download a bundle from the Hugging Face dataset registry
lance-bundle download lance-bundle/berkshire-hathaway-letters -o berkshire.zip

# Inspect a bundle's metadata (model, dataset, provenance)
lance-bundle inspect berkshire.zip

# Search a bundle without writing any Python
lance-bundle search berkshire.zip "What does Buffett think of Coca-Cola?" --limit 10 --json

Design

Goals

  1. Portability: you own your data and embeddings; store and search them forever into the future
  2. Reusability: stop re-embedding the internet; a shared dataset registry allows compressed and indexed knowledge to be used interchangeably
  3. Provenance: each self-contained bundle contains metadata, lineage, and the exact model artifact used for generating the data

Implementation

The initial version of lance-bundle is limited to support for SentenceTransformer embedding models and embedding vectors stored in LanceDB. While these underlying technologies may change in the future, the aim will always be to preserve the spirit of the portable, forwards-compatible design of lance-bundle and allow for supporting new and different ways of computing, storing, and searching embeddings.

Sentence Transformer

By design, the Sentence Transformers models from Hugging Face are exported to ONNX with only the transformers modules. The pooling and normalization modules are not included in the export, and thus need to be applied as a post-processing step; lance-bundle ensures that the post-processing pooling and normalization steps are also included as part of the portable package.

See:

License

MIT

Download files

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

Source Distribution

lance_bundle-0.0.4.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

lance_bundle-0.0.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file lance_bundle-0.0.4.tar.gz.

File metadata

  • Download URL: lance_bundle-0.0.4.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lance_bundle-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f6b4f41ba02ecfa4bde07d7eeb489a82bad4e77a70ded3aa749e3d1cf2e507c6
MD5 f1be9c03cba838dc8dd1121d68616a1b
BLAKE2b-256 a7fa4ed66ed0e544e14151fc5882ea8841989287fe42fde20e8688a876140cc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for lance_bundle-0.0.4.tar.gz:

Publisher: publish.yml on cloudkj/lance-bundle

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

File details

Details for the file lance_bundle-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: lance_bundle-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lance_bundle-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 378191d398bf61977bea0dc6a7ef7c52317e706a6ee9e845be84a4e2b772799b
MD5 529505883df59689ae5015c87c5c6913
BLAKE2b-256 05b2affd0f28b0d17795e892519d306d20ba4e9330aa870c1de9c047f39f5b98

See more details on using hashes here.

Provenance

The following attestation bundles were made for lance_bundle-0.0.4-py3-none-any.whl:

Publisher: publish.yml on cloudkj/lance-bundle

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

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page