Skip to content

Instantly share code, notes, and snippets.

@shahules786
Created July 4, 2023 07:49
Show Gist options
  • Save shahules786/550049169a2eaa34905a58035902ffbe to your computer and use it in GitHub Desktop.
Save shahules786/550049169a2eaa34905a58035902ffbe to your computer and use it in GitHub Desktop.
from ragas import evaluate
from datasets import Dataset
import os
os.environ["OPENAI_API_KEY"] = "your-openai-key"
# prepare your huggingface dataset in the format
# Dataset({
# features: ['question','contexts','answer'],
# num_rows: 25
# })
dataset: Dataset
results = evaluate(dataset)
# {'ragas_score': 0.860, 'context_relavency': 0.817,
# 'factuality': 0.892, 'answer_relevancy': 0.874}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment