This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: example for rag evaluator pack (#882)
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Required Environment Variables: OPENAI_API_KEY | ||
|
||
from llama_index.llama_dataset import download_llama_dataset | ||
from llama_index.llama_pack import download_llama_pack | ||
from llama_index import VectorStoreIndex | ||
|
||
# download a LabelledRagDataset from llama-hub | ||
rag_dataset, documents = download_llama_dataset( | ||
"PaulGrahamEssayDataset", "./paul_graham" | ||
) | ||
|
||
# build a basic RAG pipeline off of the source documents | ||
index = VectorStoreIndex.from_documents(documents=documents) | ||
query_engine = index.as_query_engine() | ||
|
||
# Time to benchmark/evaluate this RAG pipeline | ||
# Download and install dependencies | ||
RagEvaluatorPack = download_llama_pack("RagEvaluatorPack", "./rag_evaluator_pack") | ||
|
||
# construction requires a query_engine, a rag_dataset, and optionally a judge_llm | ||
rag_evaluator_pack = RagEvaluatorPack( | ||
query_engine=query_engine, rag_dataset=rag_dataset | ||
) | ||
|
||
# PERFORM EVALUATION | ||
benchmark_df = rag_evaluator_pack.run() # async arun() also supported | ||
print(benchmark_df) |