How one RAG query retrieves (#3022): taken by the RAGQueryOptions overloads of query, queryWithAnswer, queryWithAnswerStreaming and their permission variants, beside the forms that take only a topK.
import org.llm4s.vectorstore.MetadataFilter
val options = RAGQueryOptions()
.withFilter(MetadataFilter.Equals("lang", "en"))
.withMinScore(0.75)
.withTopK(3)
rag.queryWithAnswer("How do refunds work?", options)
Value parameters
- filter
-
a metadata filter every result must match, applied inside the store's search, vector and keyword alike (
HybridSearcher.search's filter,SearchIndex.query'sadditionalFilter) - minScore
-
the lowest vector similarity a result may have, from 0 to 1, on the scale every store scores with since #3006:
(1 + cos) / 2, so 0.5 is an unrelated chunk and 1 the same direction as the query. It is compared with a result'svectorScore, not its fusedscore, whose scale depends on the fusion strategy (RRF's is rank-based) and the reranker: a hit the keyword search found and the vector search did not has no vector score and is dropped. It is applied to the fused candidates before the reranker, so the reranker never orders a chunk below it. AKeywordOnlypipeline has no vector scores, so a minimum score there is aValidationError. - noContextAnswer
-
the answer
queryWithAnswerand its variants return when nothing is retrieved (an empty store, a filter nothing matches, a minimum score nothing reaches) instead of asking the model with no context: the result has no contexts and no usage, and no model call is made - topK
-
how many results to return, at least 1; the config's
topKwhenNone
Attributes
- Companion
- object
- Source
- RAGQueryOptions.scala
- Graph
-
- Supertypes
