RAGQueryMetrics

org.llm4s.rag.RAGQueryMetrics
See theRAGQueryMetrics companion object
@Experimental
final case class RAGQueryMetrics

What one RAG query cost, stage by stage (#2734): on every RAGAnswerResult as metrics, and in the TraceEvent.RAGOperationCompleted a traced RAG emits, so an application gets them with or without a tracer.

Value parameters

answerDuration

generating the answer, for a query that answers

candidatesRetrieved

how many results the search returned (rerankTopK of them with a reranker)

chunksUsed

how many results were kept: the contexts the answer was generated from

completionTokens

the answer's completion tokens, when the provider reports them

costUsd

the answer's estimated cost, when known. The rewrite and LLM-rerank calls are not in these totals: with a tracer they are traced on their own, tagged rag.rewrite and rag.rerank.

embeddingDuration

embedding the query

embeddingTokens

the query embedding's tokens, when the provider reports them

promptTokens

the answer's prompt tokens, when the provider reports them

rerankDuration

the reranker, when one is configured

rewriteDuration

the configured query transformers (zero with none)

searchDuration

the vector and keyword search and their fusion, not the embedding or the reranking

totalDuration

the whole call, from the query to the answer

Attributes

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

Members list

Value members

Concrete methods

The stage durations by name - rewrite, embedding, search, and rerank and answer where they ran.

The stage durations by name - rewrite, embedding, search, and rerank and answer where they ran.

Attributes

Source
RAGQueryMetrics.scala

These metrics as the RAGOperationCompleted event of operation (query or answer).

These metrics as the RAGOperationCompleted event of operation (query or answer).

Attributes

Source
RAGQueryMetrics.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product