Skip to content

How do I put ragas outputs into a clean JSON, like the JSON that I can get from the dashboard? #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AmirPoursaberi opened this issue Apr 9, 2025 · 1 comment
Labels
question Further information is requested

Comments

@AmirPoursaberi
Copy link

Hi.
I want to extract the output results from the Ragas result object on my local machine. How do I do that?

@AmirPoursaberi AmirPoursaberi added the question Further information is requested label Apr 9, 2025
@sahusiddharth
Copy link
Collaborator

Hi @AmirPoursaberi, you can convert the evaluation result to pandas then can convert them to dict.

from ragas.dataset_schema import EvaluationDataset
from ragas import evaluate 
from ragas.dataset_schema import SingleTurnSample
from ragas.metrics import AnswerAccuracy

from langchain_openai import ChatOpenAI
from ragas.llms import LangchainLLMWrapper

sample = SingleTurnSample(
    user_input="When was Einstein born?",
    response="Albert Einstein was born in 1879.",
    reference="Albert Einstein was born in 1879."
)

dataset = EvaluationDataset(samples=[sample])

llm = ChatOpenAI(model="gpt-4o-mini")
evaluator_llm = LangchainLLMWrapper(langchain_llm=llm)

result = evaluate(dataset=dataset, metrics=[AnswerAccuracy(llm=evaluator_llm)])
result.to_pandas().to_dict()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants