AGPL-3.0🖥️ Self-hostable

Lantern

Lantern

Lantern is an open-source PostgreSQL extension that adds vector storage, embedding generation and fast approximate nearest-neighbour search to a database you already run. It introduces the lantern_hnsw index type — an HNSW (Hierarchical Navigable Small World) implementation built on the usearch library — so ORDER BY … LIMIT queries over vector columns are answered by an index scan instead of a sequential scan. Everything stays in SQL, and the latest release is v0.5.0 (November 2024).

Key Features

  • Vector columns in plain SQL — Store embeddings in real[] or vector columns and query them with the SQL you already write, with no separate query language or client.
  • HNSW index (lantern_hnsw) — Approximate nearest-neighbour search built on usearch, tunable with the M, ef and ef_construction parameters.
  • Three distance operators — <-> for L2 squared, <=> for cosine and <+> for Hamming distance, with matching operator classes for real[], vector and integer[] columns.
  • In-database embedding generation — Helper functions generate embeddings in SQL for CLIP, Hugging Face models and custom models.
  • pgvector interoperability — Shares pgvector’s data types, so an existing pgvector setup can move across without rewriting its schema.
  • Parallel and out-of-database indexing — An external indexer builds the HNSW graph in parallel, and indexes can be built outside the database server so indexing does not interrupt normal workflows.
  • Standard PostgreSQL tooling — Keeps the normal PostgreSQL interface, so psql, pgAdmin, ORMs, backups and replication keep working as they did.

Why Use Lantern?

Adding a second datastore for similarity search means syncing data, keeping two systems consistent and running two sets of infrastructure. Lantern puts vector search inside PostgreSQL: embeddings sit next to the rows they describe, vectors can be joined with relational data in a single statement, and your existing backup, monitoring and access-control setup keeps working. It covers the same ground as pgvector, with an HNSW index and helpers for generating embeddings in-database.

Use Cases

  • Semantic search and retrieval-augmented generation (RAG) over documents already stored in PostgreSQL.
  • Image or audio similarity search using CLIP embeddings generated by Lantern’s helper functions.
  • “More like this” recommendations powered by nearest-neighbour queries.
  • Adding vector search to an existing PostgreSQL application without introducing a separate vector database.

Platform

Self-hosted PostgreSQL extension — PostgreSQL 11, 12, 13, 14, 15 and 16 on Linux and macOS, installed with the official Docker image, Homebrew, precompiled binaries or a source build.

Licence

AGPL-3.0 (GNU Affero General Public License v3.0) — source at github.com/lanterndata/lantern

Website

lantern.dev

Explore More Categories

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.