← 开源
lanterndata

lantern

PostgreSQL vector database extension for building AI applications

InfrastructureData systemsRust
在 GitHub 打开
增长势头
+024 小时新增 Star0.0%
895
Star
67
Fork
+0
本周
13
贡献者
创建于 2023-07-11 · 更新于 2026-10-15 · 今日第 12835 名
主要开发者

lanterndata/lantern 排名第 12,835,有 895 个星标。

同类别比较

lanterndata/lantern 排名第 12,835,此处有 8 个同类条目;kendryte/nncase 排名第 12,815。

同类别比较
名称排名指标
mosecorg/mosec12,790
语言:
Python
星标数:
901
分叉数:
77
简介:
A high-performance ML model serving framework, offers dynamic batching and CPU/GPU pipelines to fully exploit your compute machine
IST-DASLab/sparsegpt12,791
语言:
Python
星标数:
900
分叉数:
127
简介:
Code for the ICML 2023 paper "SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shot".
nikolaypavlov/MLPNeuralNet12,806
语言:
Objective-C
星标数:
898
分叉数:
208
简介:
Fast multilayer perceptron neural network library for iOS and Mac OS X
kendryte/nncase12,815
语言:
C#
星标数:
897
分叉数:
211
简介:
Open deep learning compiler stack for Kendryte AI accelerators ✨
SoftInstigate/restheart12,855
语言:
Java
星标数:
892
分叉数:
177
简介:
A backend for web, mobile, AI and IoT apps. Built on MongoDB
Meterless/genai-agentos12,864
语言:
Python
星标数:
890
分叉数:
282
简介:
GenAI infrastructure
gety-ai/apple-on-device-openai12,868
语言:
Swift
星标数:
890
分叉数:
66
简介:
OpenAI-compatible API server for Apple on-device models
spiritbuun/buun-llama-cpp12,887
语言:
C++
星标数:
888
分叉数:
94
简介:
Experimental llama.cpp fork for inference research and development
关键参数与规格
关键参数与规格
参数值
语言Rust
类别Infrastructure
子类别Data systems
星标数895
分叉数67
贡献者13
创建日期2023-07-11
更新日期2026-10-15
1 天星标数0
7 天星标数0
排名12,835
上次排名12,736
排名变化-99
7 天星标排名13,626
上次 7 天星标排名13,641
7 天星标排名变化15
总星标排名12,150
上次总星标排名12,131
总星标排名变化-19
国家USA
README 摘录

💡 Lantern Lantern is an open-source PostgreSQL database extension to store vector data, generate embeddings, and handle vector search operations. It provides a new index type for vector columns called which speeds up queries. Lantern builds and uses usearch, a single-header state-of-the-art HNSW implementation. 🔧 Quick Install If you don’t have PostgreSQL already, use Lantern with Docker to get started quickly: Then, you can connect to the database via . To install Lantern using : You can also

install Lantern on top of PostgreSQL from our precompiled binaries via a single . Alternatively, you can use Lantern in one click using Replit. 🔧 Build Lantern from source code on top of your existing PostgreSQL Prerequisites: To build Lantern on new hardware or with CPU-specific vectorization: To build portable Lantern binaries: 📖 How to use Lantern Lantern retains the standard PostgreSQL interface, so it is compatible with all of your favorite tools in the PostgreSQL ecosystem. via shell) Note: After running

the above, lantern extension is only available on the current postgres DATABASE (single postgres instance may have multiple such DATABASES). When connecting to a different DATABASE, make sure to run the above command for the new one as well. For example: Create a table with a vector column and add your data Create an hnsw index on the table via : Customize index parameters depending on your vector data, such as the distance function (e. , ), index construction parameters, and index search

parameters. Start querying data A note on operators and operator classes Lantern supports several distance functions in the index There are 3 operators available (l2sq), (cosine), (hamming). There are four defined operator classes that can be employed during index creation: ** **: Default for the type ** **: Default for the type ** **: Applicable to the type ** **: Applicable to the type ** **: Applicable to the type Index Construction Parameters The , , and parameters control the performance of the HNSW algorithm for your use case. In general, lower

and speed up index creation at the cost of recall. Lower and improve search speed and result in fewer shared buffer hits at the cost of recall. Tuning these parameters will require experimentation for your specific use case. Miscellaneous If you have previously cloned Lantern and would like to update run ⭐️ Features Embedding generation for popular use cases (CLIP model, Hugging Face models, custom model) Interoperability with pgvector's data type, so anyone using pgvector can switch to Lantern Parallel index

creation via an external indexer Ability to generate the index graph outside of the database server Support for creating the index outside of the database and inside another instance allows you to create an index without interrupting database workflows. See all of our helper functions to better enable your workflows 🏎️ Performance Important takeaways: There's three key metrics we track. We match or outperform pgvector and pg_embedding (Neon) on all of these metrics. We plan to continue to make performance

improvements to ensure we are the best performing database. 🗺️ Roadmap Cloud-hosted version of Lantern - Sign up here Hardware-accelerated

常见问题

记录了多少星标和分叉?

lanterndata/lantern 有 895 个星标和 67 个分叉。

仓库排名是多少?

lanterndata/lantern 排名第 12,835。

记录的语言和类别是什么?

lanterndata/lantern 有 895 个星标,语言为 Rust,类别为 Infrastructure。

哪个仓库排名最接近?

lanterndata/lantern 与 kendryte/nncase 比较,后者排名第 12,815,有 897 个星标。

README

💡 Lantern

Lantern is an open-source PostgreSQL database extension to store vector data, generate embeddings, and handle vector search operations.

It provides a new index type for vector columns called lantern_hnsw which speeds up ORDER BY ... LIMIT queries.

Lantern builds and uses usearch, a single-header state-of-the-art HNSW implementation.

🔧 Quick Install

If you don’t have PostgreSQL already, use Lantern with Docker to get started quickly:

docker run --pull=always --rm -p 5432:5432 -e "POSTGRES_USER=$USER" -e "POSTGRES_PASSWORD=postgres" -v ./lantern_data:/var/lib/postgresql/data lanterndata/lantern:latest-pg15

Then, you can connect to the database via postgresql://$USER:postgres@localhost/postgres.

To install Lantern using homebrew:

brew tap lanterndata/lantern
brew install lantern && lantern_install

You can also install Lantern on top of PostgreSQL from our precompiled binaries via a single make install.

Alternatively, you can use Lantern in one click using Replit.

🔧 Build Lantern from source code on top of your existing PostgreSQL

Prerequisites:

cmake version: >=3.3
gcc && g++ version: >=11 when building portable binaries, >= 12 when building on new hardware or with CPU-specific vectorization
PostgreSQL 11, 12, 13, 14, 15 or 16
Corresponding development package for PostgreSQL (postgresql-server-dev-$version)

To build Lantern on new hardware or with CPU-specific vectorization:

git clone --recursive https://github.com/lanterndata/lantern.git
cd lantern
cmake -DMARCH_NATIVE=ON -S lantern_hnsw -B build
make -C build install -j

To build portable Lantern binaries:

git clone --recursive https://github.com/lanterndata/lantern.git
cd lantern
cmake -DMARCH_NATIVE=OFF -S lantern_hnsw -B build
make -C build install -j

📖 How to use Lantern

Lantern retains the standard PostgreSQL interface, so it is compatible with all of your favorite tools in the PostgreSQL ecosystem.

First, enable Lantern in SQL (e.g. via psql shell)

CREATE EXTENSION lantern;

Note: After running the above, lantern extension is only available on the current postgres DATABASE (single postgres instance may have multiple such DATABASES). When connecting to a different DATABASE, make sure to run the above command for the new one as well. For example:

CREATE DATABASE newdb;
\c newdb
CREATE EXTENSION lantern;

Create a table with a vector column and add your data

CREATE TABLE small_world (id integer, vector real[3]);
INSERT INTO small_world (id, vector) VALUES (0, '{0,0,0}'), (1, '{0,0,1}');

Create an hnsw index on the table via lantern_hnsw:

CREATE INDEX ON small_world USING lantern_hnsw (vector);

Customize lantern_hnsw index parameters depending on your vector data, such as the distance function (e.g., dist_l2sq_ops), index construction parameters, and index search parameters.

CREATE INDEX ON small_world USING lantern_hnsw (vector dist_l2sq_ops)
WITH (M=2, ef_construction=10, ef=4, dim=3);

Start querying data

SET enable_seqscan = false;
SELECT id, l2sq_dist(vector, ARRAY[0,0,0]) AS dist
FROM small_world ORDER BY vector <-> ARRAY[0,0,0] LIMIT 1;

A note on operators and operator classes

Lantern supports several distance functions in the index

There are 3 operators available <-> (l2sq), <=> (cosine), <+> (hamming).

There are four defined operator classes that can be employed during index creation:

  • dist_l2sq_ops: Default for the type real[]
  • dist_vec_l2sq_ops: Default for the type vector
  • dist_cos_ops: Applicable to the type real[]
  • dist_vec_cos_ops: Applicable to the type vector
  • dist_hamming_ops: Applicable to the type integer[]

Index Construction Parameters

The M, ef, and ef_construction parameters control the performance of the HNSW algorithm for your use case.

  • In general, lower M and ef_construction speed up index creation at the cost of recall.
  • Lower M and ef improve search speed and result in fewer shared buffer hits at the cost of recall. Tuning these parameters will require experimentation for your specific use case.

Miscellaneous

  • If you have previously cloned Lantern and would like to update run git pull && git submodule update --recursive

⭐️ Features

  • Embedding generation for popular use cases (CLIP model, Hugging Face models, custom model)
  • Interoperability with pgvector's data type, so anyone using pgvector can switch to Lantern
  • Parallel index creation via an external indexer
  • Ability to generate the index graph outside of the database server
  • Support for creating the index outside of the database and inside another instance allows you to create an index without interrupting database workflows.
  • See all of our helper functions to better enable your workflows

🏎️ Performance

Important takeaways:

  • There's three key metrics we track. CREATE INDEX time, SELECT throughput, and SELECT latency.
  • We match or outperform pgvector and pg_embedding (Neon) on all of these metrics.
  • We plan to continue to make performance improvements to ensure we are the best performing database.

🗺️ Roadmap

  • Cloud-hosted version of Lantern - Sign up here
  • Hardware-accelerated distance metrics, tailored for your CPU, enabling faster queries
  • Templates and guides for building applications for different industries
  • More tools for generating embeddings (support for third party model API’s, more local models)
  • Support for version control and A/B test embeddings
  • Autotuned index type that will choose appropriate creation parameters
  • Support for 1 byte and 2 byte vector elements, and up to 8000 dimensional vectors (PR #19)
  • Request a feature at support@lantern.dev

📚 Resources

  • GitHub issues: report bugs or issues with Lantern
  • Need support? Contact support@lantern.dev. We are happy to troubleshoot issues and advise on how to use Lantern for your use case
  • We welcome community contributions! Feel free to open an issue or a PR. If you contact support@lantern.dev, we can find an open issue or project that fits you
排名相邻
同类项目