Build an Evaluation DatasetBeta
Keep the conversations that matter to you in a Dataset, so you can reuse them whenever you measure a change.
About This Task
A Dataset holds conversations you want to compare pipeline versions on. It can include conversations from any pipeline in the workspace. To open the Datasets page, open a pipeline's Evaluation tab and choose Datasets from the Resources menu. The list shows the Datasets that have a test case recorded on that pipeline, and each Dataset lists only that pipeline's test cases.
For background, see Datasets. To reuse a Dataset from another workspace, export it there and import it here. For steps, see Import and Export a Dataset. If you have no recorded conversations, you can also build a Dataset from a CSV or XLSX table. See Add Test Cases from a Table.
Ways to Add Test Cases
You can add test cases to a Dataset in these ways:
- Build a new Dataset from a pipeline's Sessions in the Evaluate now dialog. For details, see Sources of an Evaluation Run.
- Copy test cases from another Dataset. For instructions, see Copy Test Cases from Another Dataset.
- Import a Dataset from an archive. For instructions, see Import and Export a Dataset.
- Add rows from a CSV or XLSX table. To learn more, see Add Test Cases from a Table.
Add a Conversation from a Trace
If a trace shows an answer you want to keep as a test case, add its conversation to a Dataset without leaving the trace.
- Open a pipeline, go to Analytics > Traces, and open the trace. For a platform Service, open the trace from the Service's Traces tab.
- Click Add to Dataset in the trace detail header.
- In Add to, choose Existing Dataset and select the Dataset, or choose New Dataset and type a name.
- Click Add. A notification confirms that the test case was added and links to the Dataset.
The test case is the whole conversation the trace belongs to. A trace from a standalone run, outside a chat, is its own conversation. The test case is filed under the trace's pipeline or, for a platform Service, under the Service's source pipeline. The button doesn't appear for an external Service or for a trace written under a previous source pipeline, because there's no pipeline to file the test case under.
Create an Empty Dataset
- Open a pipeline's Evaluation tab, choose Datasets from the Resources menu, and click New Dataset.
- Type a name and click Save. The new Dataset opens with no test cases. Copy test cases from another Dataset to fill it.
Add Test Cases from a Table
To measure your pipeline on questions you keep in a spreadsheet, add them to a Dataset as table-based test cases. Each row of a CSV or XLSX file becomes one test case, and each column is either a pipeline input or expected data that your evaluator reads. For background, see Table-Based Test Cases.
Prepare the File
- Use a CSV or XLSX file with a header row. Each following row is one test case.
- Include a column for each pipeline input you want to send, for example
query. If a pipeline input has another name, name the column after it. - Add a column for each value your evaluator needs to judge the answer, for example
expected_answer. The built-in Answer correctness and Recall Metrics find their expected column by name or content. For how, see Expected Columns for Answer Correctness and Recall. - A Dataset holds at most 100 test cases, so keep the file within the room the Dataset has left. If the file has more rows, split it and add the parts to separate Datasets.
Add the Rows
You can start from two places. On the Datasets list, click Import and drop the file to create a new Dataset from the table. In an existing Dataset, click Add from table to append the rows to it.
-
Drop the CSV or XLSX file in the dialog. The platform reads the file to show a preview of the first rows. It doesn't store the file.
-
If the file is an XLSX workbook with several sheets, choose the sheet to read in Sheet.
-
In Columns, choose a role for each column:
- Input: The column is sent to the pipeline by name. A
querycolumn is sent as the query. - Expected: The column is kept for your evaluators and never sent to the pipeline.
- Ignore: The column is left out.
The platform prefills each role from the column name, for example columns named
expectedorground_truthbecome Expected. So do columns that list documents, such asdocument_ids,doc_ids,documents, andfile_names. Check the roles and change any that are wrong. Make at least one column an input. - Input: The column is sent to the pipeline by name. A
-
Choose a type for each Input and Expected column: String (the default), JSON, Number, or Boolean. The type sets how each cell is read. For example, choose JSON for a column that holds objects or lists. If cells don't match their column's type, the dialog lists them by row and column, and you can't upload until you fix them. Change the column's type or role, or correct the file and drop it again.
-
Optional: In Test case names, choose the column that holds the name of each test case. The platform prefills it with an Ignore ID column whose values repeat, or otherwise with the
queryinput or the first input. To turn rows into multi-turn conversations, see Import Multi-Turn Conversations. -
If you started from the Datasets list, type a name for the new Dataset.
-
Confirm the dialog to create the test cases.
The Dataset opens with one test case per row, unless you grouped rows into conversations. You don't choose a pipeline: a row runs on whichever pipeline an Experiment replays it on.
Import Multi-Turn Conversations
To test a pipeline on conversations instead of single questions, keep each conversation's turns in separate rows that share an ID, and group them with the Test case names column. This lets you check how a pipeline handles follow-up questions.
For example, a file with the columns test_case_id, turn, query, and expected can hold several conversations. Each row is one turn.
- In Columns, set the column that identifies the conversation, for example
test_case_id, to Ignore. - In Test case names, choose that column. Rows with the same value become one test case, named after that value. If you set the column to Input instead, it only names the test cases, even when its values repeat.
- In Turn order, choose a column of numbers that orders the turns of each conversation, for example
turn. If you choose none, the turns follow the order of the rows in the file. Turn order appears only when the name column groups rows. - Set the roles and types of the other columns as usual. Each turn gets its inputs and expected data from them.
A value that appears in only one row stays a one-row test case, and so does a row with no value in the name column. The turn number of a one-row test case isn't checked.
If a turn number is missing, isn't a number, or repeats within a conversation, the dialog lists the cell and you can't upload until you fix it. A conversation can have at most 50 turns. A longer one is rejected when you upload.
The platform stores each conversation as an imported Session, so the Dataset shows it like any other test case with a conversation. To read it, see View an Imported Conversation and Its Traces. Imported conversations hold no recorded replies, so in an Experiment only the Candidate is scored for them.
What Happens When You Replay a Row
A replay of a row sends one request to the pipeline. The query value is sent as the query, and every other input goes to the pipeline input with the same name. If the test case has a setup script, the inputs it returns take precedence over the row's inputs. Your evaluator can read the row's inputs and expected data from session["test_case"].
test_case parameter receives the row's inputs and expected data.Optimization runs don't accept a Dataset that holds table-based test cases yet. To measure a Service on a Dataset, use one with recorded conversations only.
Multi-Turn Test Cases
A test case can be a scripted conversation instead of a single row: an ordered list of user turns, each with its own named pipeline inputs and, optionally, its own expected data. A scripted conversation can have up to 50 turns. The platform stores it as an imported conversation without replies, the same way it stores the conversations of an imported archive. From then on it works like any other conversation test case, and it belongs to no pipeline, so an Experiment can replay it on any pipeline.
A scripted conversation behaves like this:
- Name: Without a name, the test case is named after the query of its first turn.
- Replay: The replay mode of an Experiment decides which turns are sent. First message only sends turn 1. Whole conversation sends every turn, and each request carries the conversation replayed so far. First message, then auto-approve sends turn 1, and the replay guide reads the remaining scripted user messages as hints for what to approve.
- Expected data: The expected data of turn
iis available to your evaluators asexpected["turns"][i], counting from 0. A turn without expected data gets an empty object. You can't also supply anexpected.turnsentry of your own for a scripted conversation. - Baseline: No pipeline has answered a scripted conversation, so it has no recorded replies. An Experiment that uses Recorded conversations as the Baseline doesn't score it as a Baseline. To get a comparison, choose a pipeline version as the Baseline.
- Conversation view: The conversation shows each user turn with no reply.
To change a scripted conversation, import it again. You can't edit its turns in place.
Copy Test Cases from Another Dataset
Copy test cases to reuse them in another Dataset, including test cases recorded on other pipelines, without adding the conversations from search history again.
- Open the Dataset that should receive the test cases and click Copy test cases.
- In From Dataset, choose the source Dataset.
- In Test cases, select the test cases to copy.
- Click Copy. The button shows the number of selected test cases.
Each copy keeps the conversation, its pipeline, name, and scripts. The copy is independent of the original, so editing one leaves the other as it was.
Review and Edit Test Cases
Open a Dataset to see its test cases. The table shows these columns:
- Test case: The name. Click it to edit the test case.
- Conversation: The ID of the conversation.
- Pipeline: The pipeline the conversation was recorded on.
- Scripts: Whether the test case has a Setup script, a Cleanup script, or none.
- Actions: Conversation opens the conversation, Edit opens the test case editor, and Remove deletes the test case after you confirm. Conversation also works for test cases that came from an imported Dataset. For details, see View an Imported Conversation and Its Traces.
For a table-based test case, the table shows the row's inputs instead of a conversation, and Conversation is hidden. When any test case in the Dataset has expected data, an Expected column appears.
To edit a test case, click Edit. You can change its name. You can also write a setup script that runs before every replay, for example to give the replay environment variables or inputs. A cleanup script runs after every replay, even a failed one. A setup script defines one public function that takes no arguments and returns a dictionary with the optional keys env, inputs, and logs. A cleanup script defines one public function that takes the setup result (or None) and returns a dictionary with the optional key logs. Leave a script empty to skip that step. To reuse scripts, click Copy scripts from another test case. Nothing is saved until you click Save.
inputs and expected as JSON.To remove several test cases at once, select them and click Remove selected. Removing a test case doesn't delete the conversation from search history, and Experiments that already ran it keep their results.
To rename a Dataset, click Rename. To delete it, click Delete and confirm. Deleting a Dataset deletes its test cases, but Experiments that already ran it keep their results.
The platform doesn't delete a Dataset that a check in a Service's deployment gate uses. The REST API answers with a 409 error that names the Service. Remove the check from the gate, or change it to use a different Dataset, and then delete the Dataset.
View an Imported Conversation and Its Traces
When you import a Dataset from an archive, each conversation is stored with the Dataset under a new Session ID. Search history doesn't hold these conversations, because they never ran in your workspace. You can still read them, and open the trace of each turn, to check what a test case replays before you run an Experiment.
To view an imported conversation:
- Open the imported Dataset.
- In the row of the test case, click Conversation. The imported conversation drawer opens. It lists each turn with the question and the final answer.
- To see how the pipeline produced an answer, click Go to trace on a turn. The turn opens in the Session inspector, where you can step through its components, inputs, and outputs.
Imported conversations have these limits:
- Archives don't contain retrieved documents, feedback, or logs, so imported turns show none. The drawer tells you this.
- In the Session inspector, actions that apply only to a pipeline are hidden for imported conversations.
- The Session inspector on a scoring run page can't load imported conversations yet.
In an Experiment, the recorded side of an imported test case opens the same imported conversation drawer. Conversations replayed by the Experiment are still read from search history.
What To Do Next
Use your Dataset to compare pipeline versions. For details, see Run an Experiment.
You can also replay a Dataset in a Deployment Gate check to hold a new service revision until it passes. For steps, see Test a Revision Before It Goes Live.
Related Information
Was this page helpful?