项目内容 Project Scope
FAISS in PostgreSQL
在 PostgreSQL backend 内运行 FAISS ANN 索引,支持 HNSW、IVFFlat、IVFPQ。
Runs FAISS ANN indexes inside a PostgreSQL backend with HNSW, IVFFlat, and IVFPQ.
RRF SQL
融合 pgvector 向量排名与 PostgreSQL tsvector 全文排名。
Fuses pgvector rankings with PostgreSQL tsvector full-text rankings.
Evaluation
离线计算 Recall@K、NDCG@K、P95/P99 latency,用于验证融合效果。
Computes Recall@K, NDCG@K, and P95/P99 latency to validate fusion quality.
Observability
暴露查询调用量、耗时、候选深度、batch 参数和自动调参状态。
Exposes call counts, timings, candidate depth, batch knobs, and autotune state.
快速使用 Quick Usage
CREATE EXTENSION vector;
CREATE EXTENSION pg_retrieval_engine;
SELECT pg_retrieval_engine_index_create(
'docs_hnsw', 768, 'cosine', 'hnsw',
'{"m":32,"ef_construction":200,"ef_search":64}'::jsonb,
'cpu'
);
SELECT *
FROM pg_retrieval_engine_hybrid_search(
'documents'::regclass,
'id',
'embedding',
'search_vector',
'[0.1,0.2,0.3,0.4]'::vector,
plainto_tsquery('simple', 'vector database'),
20,
'{"vector_k":100,"fts_k":100,"rrf_k":60}'::jsonb
);
量化指标 Quantitative Metrics
| Module | Direction | Required metrics | Current target/result |
|---|---|---|---|
| FAISS | ANN | Recall@10, avg latency, P95/P99, speedup | CPU target >= 5x; local HNSW 11.32x, IVFFlat 10.31x |
| RRF SQL | Hybrid fusion | Recall@K, NDCG@K, P95/P99 | Report vector-only, FTS-only, and RRF together |
| Autotune | Runtime tuning | before/after Recall@K, NDCG@K, P95/P99 | Validate with fixed qrels before accepting changes |
性能样例(CPU,批量查询路径) Performance Sample (CPU, batch query path)
实测环境(2026-04-14):20,000 x 128,29 queries,k=10。
Measured on 2026-04-14: 20,000 x 128, 29 queries, k=10.
| Scenario | pgvector avg_ms | pg_retrieval_engine avg_ms | Speedup | Recall@10 |
|---|---|---|---|---|
| HNSW | 1.13 | 0.10 | 11.32x | 1.0000 |
| IVFFlat | 0.76 | 0.07 | 10.31x | 1.0000 |
README (ZH)
项目总览、模块、安装与使用入口
Project overview, modules, install, and usage entry points
README (EN)
英文项目总览
English project overview
Architecture
模块边界与运行架构
Module boundaries and runtime architecture
API
每个接口的参数与语义
Per-function parameter semantics
Usage
安装、建索引、查询与 RRF 示例
Install, indexing, search, and RRF examples
Benchmark
模块量化测试与验收指标
Module-level quantitative tests and acceptance metrics
Design
按模块拆分的设计文档
Module-oriented design documents
Evaluation
Recall@K、NDCG@K、P95/P99 评测协议
Recall@K, NDCG@K, and P95/P99 evaluation protocol