lance-format/lance

★ 7,086⑂ 0

Open Lakehouse Format for Multimodal AI. Convert from Parquet in 2 lines of code for 100x faster random access, vector index, and data versioning.

About lance-format/lance

lance-format/lance is an open-source project on GitHub, mainly written in Rust. Open Lakehouse Format for Multimodal AI. Convert from Parquet in 2 lines of code for 100x faster random access, vector index, and data versioning. It currently holds 7,086 stars and 0 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Image Projects board and on the AI AI Image Projects list.

GitHub Repository Details

Repository lance-format/lance · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

https://github.com/lance-format/lance/blob/HEAD/Lance Logo

The Open Lakehouse Format for Multimodal AI
High-performance vector search, full-text search, random access, and feature engineering capabilities for the lakehouse.
Compatible with Pandas, DuckDB, Polars, PyArrow, Ray, Spark, and more integrations on the way.

DocumentationCommunityDiscordMailing List

[CI]: https://github.com/lance-format/lance/actions/workflows/rust.yml [CI Badge]: https://github.com/lance-format/lance/actions/workflows/rust.yml/badge.svg [Docs]: https://lance.org [Docs Badge]: https://img.shields.io/badge/docs-passing-brightgreen [crates.io]: https://crates.io/crates/lance [crates.io badge]: https://img.shields.io/crates/v/lance.svg [Python versions]: https://pypi.org/project/pylance/ [Python versions badge]: https://img.shields.io/pypi/pyversions/pylance

[![CI Badge]][CI] [![Docs Badge]][Docs] [![crates.io badge]][crates.io] [![Python versions badge]][Python versions]


Lance is an open lakehouse format for multimodal AI. It contains a file format, table format, and catalog spec that allows you to build a complete lakehouse on top of object storage to power your AI workflows. Lance is perfect for:

1. Building search engines and feature stores with hybrid search capabilities. 2. Large-scale ML training requiring high performance IO and random access. 3. Storing, querying, and managing multimodal data including images, videos, audio, text, and embeddings.

The key features of Lance include:

For more details, see the full Lance format specification.

[!TIP]
Lance is in active development and we welcome contributions. Please see our contributing guide for more information.

File format stability

Lance releases frequently because the SDKs, integrations, and performance work are moving quickly. This does not mean the Lance file format changes incompatibly in every release. The Lance file format is identified by the data_storage_version stored in each dataset, and stable storage versions are a long-term compatibility contract.

For production, write data with a stable data_storage_version. See the format versioning guide for the current compatibility matrix.

Quick Start

Installation

pip install pylance

To install a preview release:

pip install --pre --extra-index-url https://pypi.fury.io/lance-format pylance
[!TIP]
Preview releases are released more often than full releases and contain the
latest features and bug fixes. They receive the same level of testing as full releases.
We guarantee they will remain published and available for download for at
least 6 months. When you want to pin to a specific version, prefer a stable release.

Converting to Lance

import lance

import pandas as pd import pyarrow as pa import pyarrow.dataset

df = pd.DataFrame({"a": [5], "b": [10]}) uri = "/tmp/test.parquet" tbl = pa.Table.from_pandas(df) pa.dataset.write_dataset(tbl, uri, format='parquet')

parquet = pa.dataset.dataset(uri, format='parquet') lance.write_dataset(parquet, "/tmp/test.lance")

Reading Lance data

dataset = lance.dataset("/tmp/test.lance")
assert isinstance(dataset, pa.dataset.Dataset)

Pandas

df = dataset.to_table().to_pandas()
df

DuckDB

import duckdb

If this segfaults, make sure you have duckdb v0.7+ installed

duckdb.query("SELECT * FROM dataset LIMIT 10").to_df()

Vector search

Download the sift1m subset

wget ftp://ftp.irisa.fr/local/texmex/corpus/sift.tar.gz
tar -xzf sift.tar.gz

Convert it to Lance

import lance
from lance.vector import vec_to_table
import numpy as np
import struct

nvecs = 1000000 ndims = 128 with open("sift/sift_base.fvecs", mode="rb") as fobj: buf = fobj.read() data = np.array(struct.unpack("<128000000f", buf[4 : 4 + 4 nvecs ndims])).reshape((nvecs, ndims)) dd = dict(zip(range(nvecs), data))

table = vec_to_table(dd) uri = "vec_data.lance" sift1m = lance.write_dataset(table, uri, max_rows_per_group=8192, max_rows_per_file=1024*1024)

Build the index

sift1m.create_index("vector",
                    index_type="IVF_PQ",
                    num_partitions=256,  # IVF
                    num_sub_vectors=16)  # PQ

Search the dataset

# Get top 10 similar vectors
import duckdb

dataset = lance.dataset(uri)

Sample 100 query vectors. If this segfaults, make sure you have duckdb v0.7+ installed

sample = duckdb.query("SELECT vector FROM dataset USING SAMPLE 100").to_df() query_vectors = np.array([np.array(x) for x in sample.vector])

Get nearest neighbors for all of them

rs = [dataset.to_table(nearest={"column": "vector", "k": 10, "q": q}) for q in query_vectors]

Directory structure

| Directory | Description | |--------------------|--------------------------| | rust | Core Rust implementation | | python | Python bindings (PyO3) | | java | Java bindings (JNI) | | docs | Documentation source |

Benchmarks

Vector search

We used the SIFT dataset to benchmark our results with 1M vectors of 128D

1. For 100 randomly sampled query vectors, we get <1ms average response time (on a 2023 m2 MacBook Air)

avg_latency.png

2. ANNs are always a trade-off between recall and performance

avg_latency.png

Vs. parquet

We create a Lance dataset using the Oxford Pet dataset to do some preliminary performance testing of Lance as compared to Parquet and raw image/XMLs. For analytics queries, Lance is 50-100x better than reading the raw metadata. For batched random access, Lance is 100x better than both parquet and raw files.

Why Lance for AI/ML workflows?

The machine learning development cycle involves multiple stages:

graph LR
    A[Collection] --> B[Exploration];
    B --> C[Analytics];
    C --> D[Feature Engineer];
    D --> E[Training];
    E --> F[Evaluation];
    F --> C;
    E --> G[Deployment];
    G --> H[Monitoring];
    H --> A;

Traditional lakehouse formats were designed for SQL analytics and struggle with AI/ML workloads that require:

While existing formats (Parquet, Iceberg, Delta Lake) excel at SQL analytics, they require additional specialized systems for AI capabilities. Lance brings these AI-first features directly into the lakehouse format.

A comparison of different formats across ML development stages:

| | Lance | Parquet & ORC | JSON & XML | TFRecord | Database | Warehouse | |---------------------|-------|---------------|------------|----------|----------|-----------| | Analytics | Fast | Fast | Slow | Slow | Decent | Fast | | Feature Engineering | Fast | Fast | Decent | Slow | Decent | Good | | Training | Fast | Decent | Slow | Fast | N/A | N/A | | Exploration | Fast | Slow | Fast | Slow | Fast | Decent | | Infra Support | Rich | Rich | Decent | Limited | Rich | Rich |

GitHub Stars & Activity

7,086Stars
0Forks
0Open issues
RustLanguage

GitHub Popularity

GitHub stars7,086
Forks0
Open issues0
Primary languageRust
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

screenpipe / screenpipe

Rust★ 21,590⑂ 0
2

rerun-io / rerun

Rust★ 11,457⑂ 0
3

opencv / opencv

C++★ 90,853⑂ 0
4
5

d2l-ai / d2l-zh

Python★ 80,716⑂ 0
6

microsoft / AI-For-Beginners

Jupyter Notebook★ 68,541⑂ 0
7

ultralytics / ultralytics

Python★ 61,651⑂ 0
8

ultralytics / yolov5

Python★ 58,015⑂ 0

More AI Rankings