Skip to content

Commit

Permalink
added evaluation module using llama_index for graph_rag
Browse files Browse the repository at this point in the history
  • Loading branch information
debrupf2946 committed Aug 14, 2024
1 parent 9cf1b43 commit db2a529
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions graph_rag/evalution/evaluation_llama_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from llama_index.core import SimpleDirectoryReader
from llama_index.core.llama_dataset import LabelledRagDataset
from llama_index.core.llama_dataset import download_llama_dataset
from llama_index.core.llama_pack import download_llama_pack
from llama_index.core import VectorStoreIndex
from llama_index.llms.ollama import Ollama
from llama_index.embeddings.huggingface import HuggingFaceEmbedding

RAG_DATASET="./data/rag_dataset.json"

RagEvaluatorPack = download_llama_pack(
"RagEvaluatorPack", "./rag_evaluator_pack"
)
def evaluate(RAG_DATASET: str,query_engine: object,ollama_model: str="llama3",embedd_model: str="microsoft/codebert-base"):
rag_dataset = LabelledRagDataset.from_json(RAG_DATASET)
rag_evaluator_pack = RagEvaluatorPack(
rag_dataset=rag_dataset,
query_engine=query_engine,
judge_llm=Ollama(base_url="http://localhost:11434", model=ollama_model),
embed_model=HuggingFaceEmbedding(model_name=embedd_model),
)
benchmark_df = await rag_evaluator_pack.arun(
batch_size=5, # batches the number of openai api calls to make
sleep_time_in_seconds=1, # seconds to sleep before making an api call
)
return benchmark_df

0 comments on commit db2a529

Please sign in to comment.