[Paper Review] COS-Mix: Cosine Similarity and Distance Fusion for Improved Information Retrieval
This paper proposes COS-Mix, a hybrid retrieval method that fuses cosine similarity and cosine distance to improve retrieval performance in Retrieval-Augmented Generation (RAG), especially for sparse information in proprietary datasets. By pre-segregating sparse document chunks into a dedicated subset and switching to distance-based retrieval only when similarity-based retrieval fails, the method reduces inference latency and improves answer quality without sacrificing accuracy.
This study proposes a novel hybrid retrieval strategy for Retrieval-Augmented Generation (RAG) that integrates cosine similarity and cosine distance measures to improve retrieval performance, particularly for sparse data. The traditional cosine similarity measure is widely used to capture the similarity between vectors in high-dimensional spaces. However, it has been shown that this measure can yield arbitrary results in certain scenarios. To address this limitation, we incorporate cosine distance measures to provide a complementary perspective by quantifying the dissimilarity between vectors. Our approach is experimented on proprietary data, unlike recent publications that have used open-source datasets. The proposed method demonstrates enhanced retrieval performance and provides a more comprehensive understanding of the semantic relationships between documents or items. This hybrid strategy offers a promising solution for efficiently and accurately retrieving relevant information in knowledge-intensive applications, leveraging techniques such as BM25 (sparse) retrieval , vector (Dense) retrieval, and cosine distance based retrieval to facilitate efficient information retrieval.
Motivation & Objective
- To address the limitation of traditional RAG systems that fail to retrieve relevant context for sparse information in enterprise datasets.
- To improve retrieval reliability and response quality in proprietary knowledge bases where open-source benchmarks do not reflect real-world challenges.
- To reduce inference latency by pre-segregating sparse chunks and applying distance-based retrieval only when necessary.
- To validate that a hybrid approach combining similarity and distance measures outperforms standard RAG pipelines in real-world, non-open-source settings.
- To demonstrate that cosine distance provides a meaningful complement to cosine similarity in capturing semantic relationships in low-frequency or unique content.
Proposed method
- The method begins by crawling and parsing HTML pages from a proprietary source (i-venture.org), extracting and cleaning text content.
- Text chunks are vectorized using OpenAI’s text-embedding-ada-002 model, with chunk size optimized for retrieval performance.
- A hybrid retriever combines BM25 (sparse) and dense vector retrieval, with results re-ranked using the FlashRank library.
- A validation prompt is used to assess whether the initial response from the LLM is satisfactory; if not, the system switches to a distance-based retrieval on a pre-identified subset of sparse chunks.
- Sparse chunks are identified via a function that checks whether information in a chunk appears in no other chunk in the corpus, forming subset S; non-sparse chunks form subset R.
- During inference, the system first retrieves from R using the hybrid retriever; if the response fails validation, it retrieves only from S using the same retriever, significantly reducing search space and latency.
Experimental results
Research questions
- RQ1Does combining cosine similarity and cosine distance improve retrieval performance for sparse information in proprietary RAG systems?
- RQ2Can pre-segregating sparse chunks into a dedicated subset reduce inference latency without degrading retrieval quality?
- RQ3How does the hybrid retrieval strategy compare to standard RAG pipelines when applied to real-world, non-open-source datasets?
- RQ4To what extent does the distance-based approach improve response quality when the similarity-based approach fails?
- RQ5Can a validation prompt effectively trigger a switch to distance-based retrieval only when needed, improving efficiency?
Key findings
- The hybrid retrieval strategy using both cosine similarity and cosine distance significantly improves retrieval performance on proprietary datasets where standard RAG methods often fail.
- The method successfully retrieves relevant context for queries involving sparse or unique information that traditional similarity-based retrieval misses.
- Switching to distance-based retrieval on a pre-identified sparse subset (S) reduces inference time by avoiding full corpus searches, especially when the initial retrieval fails.
- The validation prompt effectively identifies unsatisfactory responses, enabling a reliable and efficient switch to the distance-based retrieval path.
- The approach maintains high response quality, as confirmed by GPT-4-TURBO-based evaluation, demonstrating that distance-based retrieval is a robust complement to similarity-based retrieval.
- Experiments show that the distance approach does not compromise answer quality and is particularly effective in scenarios where standard RAG fails due to sparse or unique content.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.