talira

VectorChord-bm25

Native BM25 ranking index in PostgreSQL

open sourceAGPL-3.0 OR Elastic-2.0self-hostablefree

VectorChord-bm25 is a PostgreSQL extension from TensorChord that ranks documents by BM25 with a Block-WeakAnd index it implemented from scratch. Text is turned into a bm25vector (a sparse vector of token IDs and counts) by its companion extension pg_tokenizer, using a pre-trained tokenizer such as BERT's or one trained on your own corpus, then queried with the <&> operator and ORDER BY ... LIMIT. It's dual-licensed under AGPL-3.0 or the Elastic License 2.0, and the easiest way to run it is the vchord-suite Docker image, which bundles it with the VectorChord vector search extension. In 2026 the repository moved from the tensorchord organization to a supervc-stack account, its last release was 0.3.0 in December 2025, and the vectorchord.ai site has lapsed.

Problems it solves

  • BM25 ranking in Postgres with my own tokenizer, such as a BERT vocabulary
  • store each document as a sparse BM25 vector in Postgres next to its embedding
  • train a tokenizer on my own corpus for keyword ranking inside Postgres
  • keyword search over Chinese text in Postgres using jieba word segmentation
  • score my RAG chunks by keyword relevance inside the database, next to their embeddings
  • a Postgres Docker image with vector search and BM25 keyword ranking ready to use

Features

  • bm25vector type: token IDs and frequencies stored as a sparse vector
  • bm25 index with the Block-WeakAnd algorithm and a negative-score <&> operator for ascending ORDER BY
  • tokenizers from pg_tokenizer: pre-trained models (BERT, llmlingua2, gemma2b) or custom models trained on your corpus
  • text analyzers with Unicode segmentation, stopwords and Porter2 stemming
  • jieba pre-tokenizer for Chinese
  • triggers that keep the bm25vector column in step with the source text
  • vchord-suite Docker image for PostgreSQL 17 and 18 with VectorChord and pg_tokenizer

Limitations

  • Doesn't return more than bm25_catalog.bm25_limit results from an index scan (100 by default): raise it for larger LIMITs or strict filters1
  • Doesn't come tested beyond English: its makers have only tested English, and other languages need a tokenizer with a larger vocabulary1

Alternatives

The same job

These do what VectorChord-bm25 does.

  1. pg_textsearch PostgreSQL extension for BM25 relevance-ranked full-text search
  2. ParadeDB Postgres for full-text search, vector retrieval and aggregations, as an extension (pg_search)

Compare VectorChord-bm25 with the top 3