Feature: span-level evaluation metrics for RAG pipelines in Weave traces
Background
I'm using Weave to trace multi-step RAG pipelines where each span corresponds to a different stage: retrieval, reranking, context compression, and LLM generation. Weave's tracing is excellent for observability, but I'm missing built-in evaluation hooks that fire at the span level, not just on the final output.
Problem
Right now, I can attach evaluations at the top-level op, but there's no clean way to:
- Define per-span evaluators that run when a specific span type completes (e.g., evaluate retrieval quality right after the retrieval span)
- Aggregate span-level metrics across a trace to understand where quality drops
- Compare span-level metrics across runs to attribute regressions to a specific pipeline stage
Proposed Feature
A span_evaluators parameter (or similar) on @weave.op that lets you attach evaluators to specific spans within a traced call:
import weave
from weave.evaluators import ContextRelevanceEvaluator, AnswerCorrectnessEvaluator
@weave.op()
def retrieve(query: str) -> list[str]:
# ... retrieval logic
pass
@weave.op(
span_evaluators=[
ContextRelevanceEvaluator(), # fires after this span
]
)
def rag_pipeline(query: str) -> str:
context = retrieve(query)
answer = generate(query, context)
return answer
# After a run, metrics visible in Weave UI per span:
# retrieve span: context_relevance=0.85
# generate span: answer_correctness=0.79
Why This Matters
For production RAG systems, overall quality is a product of multiple stages. Without span-level eval, you can see that the final answer is wrong but can't tell if it's a retrieval failure, a reranking issue, or a generation problem.
Having span-level evaluators would:
- Make it easy to attribute regressions to specific pipeline stages
- Enable per-component A/B testing (e.g., compare two retrievers while keeping the rest fixed)
- Align evaluation granularity with trace granularity (which Weave already does beautifully for observability)
Happy to prototype a small example demonstrating this pattern if it would help scope the implementation.
This would be very useful for reliability work.
The key value is not just running evaluators at span level, but preserving stage attribution over time. If a release changes retrieval, reranking, compression, and generation together, a final-answer score cannot tell which component introduced the regression. Span-level evals would let teams build release gates like: retrieval relevance must not drop, compression must preserve key entities, generation must stay grounded in retrieved spans, and latency/cost must stay within budget.
Totally agree with the release-gate framing @andrewclayman — that's exactly the use case that motivated this.
To make it concrete: in my RAG pipeline I have 4 stages (retrieval → reranking → compression → generation). When I push a new reranker model, the final answer score might stay the same or even improve slightly — but the compression and generation stages are now working much harder to compensate for weaker reranked context. Without span-level evals, that "silent regression" in the reranker is invisible until it compounds.
The release gates I'd want:
retreval_relevance >= 0.75 # per retrieval span
reranking_precision_delta >= -0.05 # reranker didn't lose top-k quality
compression_coverage >= 0.80 # compressed context preserves key facts
generation_groundedness >= 0.85 # final answer grounded in context
If the Weave team is open to it, I'm happy to draft a RFC-style design doc showing how span_evaluators could hook into the existing @weave.op decorator and trace schema. That might help move this from enhancement to scoped implementation. @wandb/weave — is there a preferred format for feature proposals like this?