From 78e362268363b87829731611a1c2644f14175b07 Mon Sep 17 00:00:00 2001 From: Jeffrey Ip Date: Sun, 24 Nov 2024 11:51:11 +0800 Subject: [PATCH] Updated docs again --- deepeval/dataset/dataset.py | 6 ++---- docs/docs/evaluation-datasets.mdx | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/deepeval/dataset/dataset.py b/deepeval/dataset/dataset.py index 284b464d..939d5617 100644 --- a/deepeval/dataset/dataset.py +++ b/deepeval/dataset/dataset.py @@ -420,9 +420,7 @@ def get_column_data(df: pd.DataFrame, col_name: str, default=None): else [default] * len(df) ) - df = pd.read_csv(file_path) - # Convert np.nan (default for missing values in pandas) to None for compatibility with Python and Pydantic - df = df.astype(object).where(pd.notna(df), None) + df = pd.read_csv(file_path).astype(object).where(pd.notna(pd.read_csv(file_path)), None) inputs = get_column_data(df, input_col_name) actual_outputs = get_column_data(df, actual_output_col_name) @@ -552,7 +550,7 @@ def add_goldens_from_json_file( retrieval_context=retrieval_context, tools_called=tools_called, expected_tools=expected_tools, - source_file=file_path, + source_file=source_file, ) ) diff --git a/docs/docs/evaluation-datasets.mdx b/docs/docs/evaluation-datasets.mdx index cce8ee4b..5a8bf36e 100644 --- a/docs/docs/evaluation-datasets.mdx +++ b/docs/docs/evaluation-datasets.mdx @@ -70,19 +70,26 @@ A `Golden` and `LLMTestCase` contains almost an identical class signature, so te ## Generate An Evaluation Dataset +:::caution +We highly recommend you to checkout the [`Synthesizer`](synthesizer-introduction) page to see the customizations available and how data synthesization work in `deepeval`. All methods in an `EvaluationDataset` that can be used to generate goldens uses the `Synthesizer` under the hood and has exactly the same function signature as corresponding methods in the `Synthesizer`. +::: + `deepeval` offers anyone the ability to easily generate synthetic datasets from documents locally on your machine. This is especially helpful if you don't have an evaluation dataset prepared beforehand. ```python from deepeval.dataset import EvaluationDataset dataset = EvaluationDataset() -dataset.generate_goldens_from_docs( - document_paths=['example.txt', 'example.docx', 'example.pdf'], - max_goldens_per_document=2 -) +dataset.generate_goldens_from_docs(document_paths=['example.txt', 'example.docx', 'example.pdf']) ``` -Under the hood, an `EvaluationDataset` generates goldens using to `deepeval`'s `Synthesizer`. You can customize the `Synthesizer` used to generate goldens within an `EvaluationDataset`. +In this example, we've used the `generate_goldens_from_docs` method, which one one of the three generation methods offered by `deepeval`'s `Synthesizer`. The three methods include: + +- [`generate_goldens_from_docs()`](synthesizer-generate-from-docs): useful for generating goldens to evaluate your LLM application based on contexts extracted from your knowledge base in the form of documents. +- [`generate_goldens_from_contexts()`](synthesizer-generate-from-contexts): useful for generating goldens to evaluate your LLM application based on a list of prepared context. +- [`generate_goldens_from_scratch()`](synthesizer-generate-from-scratch): useful for generating goldens to evaluate your LLM application without relying on contexts from a knowledge base. + +Under the hood, these 3 methods calls the corresponding methods in `deepeval`'s `Synthesizer` with the exact same parameters, with an addition of a `synthesizer` parameter for you to customize your generation pipeline. ```python from deepeval.dataset import EvaluationDataset @@ -99,7 +106,7 @@ dataset.generate_goldens_from_docs( ``` :::info -`deepeval`'s `Synthesizer` uses a series of evolution techniques to complicate and make generated goldens more realistic to human prepared data. For more information on how `deepeval`'s `Synthesizer` works, visit the [synthesizer section.](evaluation-datasets-synthetic-data) +`deepeval`'s `Synthesizer` uses a series of evolution techniques to complicate and make generated goldens more realistic to human prepared data. For more information on how `deepeval`'s `Synthesizer` works, visit the [synthesizer section.](synthesizer-introduction#how-does-it-work) ::: ## Load an Existing Dataset