Files
RAG/docs/adr/0001-use-pgvector.md
YoVinchen ec1acb36b5
Some checks failed
secret-scan / scan (push) Has been cancelled
Establish a safe foundation before implementing the geology RAG system
The project begins with architecture, data governance, reproducible evaluation, deployment boundaries, and secret-handling contracts so later code has measurable acceptance criteria.

Constraint: Real provider credentials, workspace identities, and restricted geological data must never enter Git

Rejected: Add placeholder runnable services in the design commit | would imply unverified implementation readiness

Confidence: high

Scope-risk: narrow

Reversibility: clean

Directive: Run make verify before every commit and update ADRs when architecture boundaries change

Tested: Secret scan, Markdown links, YAML parse, shell syntax, and staged diff validation

Not-tested: Application runtime is intentionally deferred to the implementation stage
2026-07-12 14:42:11 +08:00

1.4 KiB
Raw Permalink Blame History

ADR-0001第一版使用 PostgreSQL + pgvector

  • Status: accepted
  • Date: 2026-07-11

Context

系统目标是毕业设计规模的地质文档 RAG并要求 Docker 最简单启动、数据和实验可复现。预计正式语料约 1 万至 30 万切片,默认向量维度为 1024。

Decision

第一版使用 PostgreSQL + pgvector同时存储业务元数据和向量。使用 Cosine 距离并从首个 schema 版本建立 HNSW评测事务通过禁用索引扫描获得同过滤条件的 exact 基线。应用与数据库之外不增加 Qdrant、Milvus、Redis 等基础服务,后台任务使用 PostgreSQL 持久化任务表。

Consequences

  • Docker 长期运行组件减少,备份与事务边界更清晰。
  • 1024 维位于 pgvector HNSW vector 类型 2000 维限制内。
  • 带权限过滤的 ANN 必须使用冗余过滤列、普通索引和 pgvector 0.8.x iterative scan并与 exact filtered Top K 比较召回。
  • 维度变化需要新表、列或索引,不允许把不同维度混写。
  • 当切片达到百万级、过滤复杂度或查询吞吐明显超过单机 PostgreSQL 能力时,重新评估 QdrantMilvus 只在明确需要分布式大规模检索时评估。

Rejected

  • QdrantRAG 能力很好,但第一版会引入第二套持久化系统和双写一致性问题。
  • Milvus组件和运维成本超过当前规模需求。