lance-bundle - Portable Embeddings
Embed Once, Query Forever
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
- Portability: you own your data and embeddings; store and search them forever into the future
- Reusability: stop re-embedding the internet; a shared dataset registry allows compressed and indexed knowledge to be used interchangeably
- 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:
- https://github.com/huggingface/sentence-transformers/issues/3258
- https://sbert.net/docs/sentence_transformer/usage/efficiency.html#onnx
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6b4f41ba02ecfa4bde07d7eeb489a82bad4e77a70ded3aa749e3d1cf2e507c6
|
|
| MD5 |
f1be9c03cba838dc8dd1121d68616a1b
|
|
| BLAKE2b-256 |
a7fa4ed66ed0e544e14151fc5882ea8841989287fe42fde20e8688a876140cc4
|
Provenance
The following attestation bundles were made for lance_bundle-0.0.4.tar.gz:
Publisher:
publish.yml on cloudkj/lance-bundle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lance_bundle-0.0.4.tar.gz -
Subject digest:
f6b4f41ba02ecfa4bde07d7eeb489a82bad4e77a70ded3aa749e3d1cf2e507c6 - Sigstore transparency entry: 2418243984
- Sigstore integration time:
-
Permalink:
cloudkj/lance-bundle@498f332ae0d037793e38090e3f3402e78d2398b0 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/cloudkj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@498f332ae0d037793e38090e3f3402e78d2398b0 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
378191d398bf61977bea0dc6a7ef7c52317e706a6ee9e845be84a4e2b772799b
|
|
| MD5 |
529505883df59689ae5015c87c5c6913
|
|
| BLAKE2b-256 |
05b2affd0f28b0d17795e892519d306d20ba4e9330aa870c1de9c047f39f5b98
|
Provenance
The following attestation bundles were made for lance_bundle-0.0.4-py3-none-any.whl:
Publisher:
publish.yml on cloudkj/lance-bundle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lance_bundle-0.0.4-py3-none-any.whl -
Subject digest:
378191d398bf61977bea0dc6a7ef7c52317e706a6ee9e845be84a4e2b772799b - Sigstore transparency entry: 2418244622
- Sigstore integration time:
-
Permalink:
cloudkj/lance-bundle@498f332ae0d037793e38090e3f3402e78d2398b0 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/cloudkj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@498f332ae0d037793e38090e3f3402e78d2398b0 -
Trigger Event:
release
-
Statement type: