RAGQueryOptions

org.llm4s.rag.RAGQueryOptions
See theRAGQueryOptions companion object
@Experimental
final case class RAGQueryOptions

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's additionalFilter)

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's vectorScore, not its fused score, 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. A KeywordOnly pipeline has no vector scores, so a minimum score there is a ValidationError.

noContextAnswer

the answer queryWithAnswer and 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 topK when None

Attributes

Companion
object
Source
RAGQueryOptions.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Only results whose metadata matches filter.

Only results whose metadata matches filter.

Attributes

Source
RAGQueryOptions.scala

Only results whose metadata matches filter, or every result for None.

Only results whose metadata matches filter, or every result for None.

Attributes

Source
RAGQueryOptions.scala

Only results with a vector similarity of at least score, from 0 to 1 (see the class).

Only results with a vector similarity of at least score, from 0 to 1 (see the class).

Attributes

Source
RAGQueryOptions.scala

Only results with a vector similarity of at least score, or no minimum for None.

Only results with a vector similarity of at least score, or no minimum for None.

Attributes

Source
RAGQueryOptions.scala

The answer returned without a model call when nothing is retrieved.

The answer returned without a model call when nothing is retrieved.

Attributes

Source
RAGQueryOptions.scala

Returns at most k results, at least 1.

Returns at most k results, at least 1.

Attributes

Source
RAGQueryOptions.scala

Returns at most k results, or the config's topK for None.

Returns at most k results, or the config's topK for None.

Attributes

Source
RAGQueryOptions.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product