I'm using ragas for evals, OpenTelemetry (by way of LlamaIndex), and would like to set the ragas output as attributes in Phoenix. Is there a playbook for how to do this so I don't have to fumble through figuring it out? The nuance of course is that to set the attributes in Phoenix, you need to be able to identify the original span the query created, after the fact. LLM Query : creates a span Ragas evals the LLM Query Now set attributes to the original span
There is no official playbook for directly setting Ragas evaluation outputs as attributes on the original Phoenix span after the fact. However, the recommended approach is to log your Ragas evaluation results as Phoenix evaluations (not as span attributes), using the SpanEvaluations class and linking them to the correct span_id鈥攖his is the supported and visible way to annotate spans with evals in Phoenix. You generate a DataFrame with your Ragas scores, ensure it has a span_id column matching the original spans, and then log it via px.Client().log_evaluations(SpanEvaluations(eval_name, evals_df)) (source, source).If you want to set custom attributes on spans after the fact, Phoenix does not support mutating span attributes post-creation; attributes must be set at span creation time (source). The supported workflow is to log evaluations as annotations, not as attributes, and these will appear in the Phoenix UI alongside the relevant spans.Would you like a step-by-step example of how to structure your Ragas eval DataFrame and log it to Phoenix?Sources:
- Ragas Retrieval Evals Tutorial
- Slack: Custom Evaluators and Span Annotation
- https://arize.com/docs/phoenix/cookbook/evaluation/evaluate-rag#芦Rsl38ut1letrnb禄
馃挕聽Hint: Mention RunLLM in the thread for followups.
Hey Kurt T. running into a meeting here so my response might be slightly delayed. Just to understand when you run Ragas, you run it during the execution of a llama-index query is that correct? In general we do need an openTelemetry ID to join things back. Let me get a dev-rel person to help out in your use case. Thanks for the feedback!
I run the query (by way of LlamaIndex) Then I run ragas to evaluate the results of the query.
Then i want to put those ragas results back into Phoenix on the query so we can do all the review, looking at the ragas results and the span details
Per the link above from RunLLM... maybe I'm trying to solve the wrong problem? Let me state the problem itself: I want to easily be able to look at spans, and see what ragas has to say about the query that formed the span. 馃檪 The link above suggests what I'm trying to do isn't even possible.
Let me restate: What I was trying to do was
Run a query by way of LlamaIndex, and set a unique Attribute so I can find that span later
Run Ragas against the query results.
Find the original span and annotate it with the Ragas results.
So:
Is this the right solution to my desire to be able to view Ragas Results and Spans?
If not, what is the right solution?
Is this the right solution to my desire to be able to view Ragas Results and Spans?
The right solution right now is to use something called a SpanQuery to pull the spans that match a specific criteria. (https://arize.com/docs/phoenix/tracing/how-to-tracing/importing-and-exporting-traces/extract-data-from-spans#running-span-queries) You can then log the ragas evaluations back using the annotations API (https://arize.com/docs/phoenix/tracing/how-to-tracing/feedback-and-annotations/capture-feedback) Will get back to you when I'm out of my morning meetings. Thanks for your patience.
Ok, I see how the SpanQuery could work.... But the problem is: What am I supposed to query for?
(there are various sources that say "just grab the last span"... which is not a reasonable solution in anything that is multi-user)
Hey Kurt, back for a breather. It can vary depending on your use-case. You typically have to query for all the data that's needed for the eval. Just grab the last span does seem naive here.
This seems incredibly straight forward: A query happens and it creates a span. How do I get the span_id immediately at the point the query has either started or finished?
this is llama-index created span I presume?
LlamaIndex is driving the queries. It's creating spans via OpenTelemetry
So I guess this is an OpenTelemetry question?
Oh. I may have solved it. How in the Phoenix UI do I find the value for a span_id?
