01. Synthetic test dataset generation (RAGAS)

Why Synthetic Test Dataset?

It is very important to evaluate the performance of RAG (Search Enhancement Generation) augmented pipline.

However, manually generating hundreds of QA (question-context-response) samples in a document can be time consuming and labor consuming. In addition, man-made questions can be difficult to reach the level of complexity required for a thorough evaluation, ultimately affecting the quality of the evaluation.

Using synthetic data generation, in the data aggregation process Developer time 90% Can be reduced to

After uncommenting below, run it and proceed after installing the package.

Copy

# !pip install -qU ragas

Copy

# Configuration file for managing API KEY as environment variable
from dotenv import load_dotenv

# Load API KEY information
load_dotenv()

Copy

 True 

Copy

# Set up LangSmith tracking. https://smith.langchain.com
# !pip install -qU langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("CH16-Evaluations")

Copy

Documents utilized for practice

Software Policy Institute (SPRi)-December 2023

  • Author: Jaeheung Lee (AI Policy Institute Office Liability Institute), Lee Ji-soo (AI Policy Lab Yi Phyang Institute)

  • Link: https://spri.kr/posts/view/23669

  • File name: SPRI_AI_Brief_2023년12월호_F.pdf

Files downloaded for practice data Please copy to folder

Document pretreatment

Load documents.

Copy

Copy

Each document object metadata Contains a metadata dictionary that can be used to store additional information about documents accessible through.

Metadata dictionary filename Make sure the key is included.

This key will be utilized in the Test datasets creation process. Metadata filename Properties are used to identify chunks belonging to the same document.

Copy

Generate data set

Copy

Initialize DocumentStore. Use custom LLM and embedding.

Copy

Generates TestSet.

Copy

Distribution by type of question

  • simple: simple question

  • reasoning: questions that need reasoning

  • multi_context: questions to consider multiple contexts

  • conditional: conditional question

Copy

  • documents: document data

  • test_size: the number of questions to create

  • distributions: distribution by question type

  • with_debugging_logs: Debugging log output

Copy

Copy

Saves the dataset stored in DataFrame as a csv file

Copy

Copy

Copy

Copy

Copy

Execute evaluation only for specific tags

Tag settings (enter the desired tag)

Edit Rule

You can only evaluate for a specific Tag by setting Tag without Evaluation of all steps.

Tag creation

Save after Grade check

Be sure to check Preview, then turn off Preview mode again to move on to the next step.

caution

Preview ensures that data is entered in the correct place

Last updated