TL;DR
This paper introduces QuackIR, a toolkit that enables retrieval-augmented generation (RAG) directly within existing relational databases (RDBMS) like DuckDB, SQLite, and PostgreSQL. By leveraging RDBMS for information retrieval, organizations can simplify their AI infrastructure and avoid the need for separate, dedicated vector databases. The authors demonstrate that RDBMS can achieve retrieval effectiveness comparable to established IR toolkits, with DuckDB showing particular promise.
What Problem Does This Paper Address?
The current trend in building applications with Large Language Models (LLMs) often involves Retrieval-Augmented Generation (RAG). This typically requires integrating specialized vector databases to perform efficient similarity searches on text embeddings. However, many enterprises already have extensive investments in traditional relational database management systems (RDBMS) as part of their data lakes. The problem this paper addresses is the complexity and overhead associated with introducing and managing separate vector databases when existing RDBMS could potentially fulfill the retrieval needs for RAG. The authors propose using RDBMS as a simpler, more integrated alternative.
Methods
The core contribution is QuackIR, an information retrieval (IR) toolkit designed to work with RDBMS. QuackIR provides a unified Python interface that mirrors popular IR toolkits like Anserini and Pyserini, abstracting away the SQL complexities of different RDBMS.
Key methodological aspects include:
- Support for Multiple RDBMS: QuackIR integrates with DuckDB, SQLite, and PostgreSQL, allowing for evaluation across different database architectures and capabilities.
- Sparse and Dense Retrieval: The toolkit supports both sparse retrieval (keyword-based, e.g., BM25) and dense retrieval (vector-based similarity search).
- Hybrid Retrieval: QuackIR implements reciprocal rank fusion (RRF) to combine results from sparse and dense retrieval for potentially improved effectiveness.
- Pre-processing and Indexing: QuackIR handles text pre-processing (tokenization, stemming, stopword removal) and indexing for both sparse and dense data within the RDBMS.
- Benchmarking: The paper focuses on evaluating the retrieval effectiveness (using nDCG@10) and latency (queries per second) of these RDBMS against established IR baselines.
Datasets
The experiments were conducted on the BEIR dataset (Thakur et al., 2021). BEIR is a widely adopted benchmark comprising a diverse set of real-world retrieval tasks across multiple domains. The paper notes that the "flat" variant of the BEIR dataset was used, where fields are concatenated prior to indexing.
Key Insights and Ideas
- RDBMS as a Viable Alternative: The most significant insight is that existing relational databases can serve as effective and simpler alternatives to dedicated vector databases for RAG scenarios. This challenges the dominant narrative that specialized vector stores are always necessary.
- DuckDB's Strong Performance: DuckDB emerges as a particularly promising candidate, showing effectiveness close to baselines in sparse retrieval and competitive performance in dense retrieval, often with better speed than PostgreSQL. Its flexible configuration options for text processing are also highlighted as a key advantage.
- SQLite's Speed Advantage: SQLite demonstrates excellent efficiency, being the fastest among the evaluated RDBMS for sparse retrieval, especially on smaller datasets.
- PostgreSQL's Trade-offs: While PostgreSQL offers dense retrieval capabilities via pgvector, its performance in sparse retrieval is noted to be lower than baselines, and its latency can be a significant bottleneck for larger datasets.
- Bridging the Gap: QuackIR's design aims to bridge the gap between academic IR research toolkits and practical industry applications by providing a familiar interface and leveraging existing infrastructure.
Key Results
- Effectiveness:
- DuckDB and SQLite achieved sparse retrieval effectiveness very close to the Anserini baseline, with differences generally less than 0.01 nDCG@10.
- PostgreSQL's sparse retrieval, using its "simple" configuration, was about 0.1–0.15 lower than baseline, but improved with the "modified" configuration to be around 0.04 lower on average.
- For dense retrieval, DuckDB and PostgreSQL matched the Anserini baseline exactly.
- Hybrid retrieval results were generally close to the baseline, indicating that the effectiveness of the individual retrieval methods translated well.
- Latency:
- SQLite was the fastest for sparse retrieval, followed by DuckDB.
- PostgreSQL was considerably slower, especially for larger datasets, making it impractical for evaluation on medium and large corpora in terms of speed.
- For dense retrieval, PostgreSQL was initially faster on the smallest datasets but DuckDB showed better performance as dataset size increased.
Limitations and Future Work
- Indexing Cost: The paper did not consider the cost of indexing in its evaluation, assuming a static corpus. Future work could explore efficient indexing strategies for frequently updated collections.
- Scaling: Query latency increased significantly for larger datasets across all RDBMS, particularly for dense retrieval. Improving speed and efficiency for large-scale deployments is a key area for future work.
- Extensions: The authors acknowledge that they only explored "flat" dense indexes and did not investigate more advanced extensions like HNSW indexes (available in DuckDB and PostgreSQL via pgvector) or specialized RDBMS extensions like ParadeDB. Exploring these could further enhance performance.
- Vector Encoding: QuackIR currently lacks its own vector encoding capabilities. Future work could integrate LLM capabilities and retrieval-augmented generation more deeply, potentially through extensions like FlockMTL.
- Learned Sparse Retrieval: The paper suggests exploring learned sparse retrieval methods (e.g., SPLADE) for term expansion and reweighting, which could be incorporated into QuackIR's pipeline.
Summary updated