Galileo Datasets allow you to create, manage, and version collections of data for testing and evaluating your LLM applications.

Creating and Using Datasets

You can create and use datasets for experimentation:

import { createDataset, getDataset } from 'galileo';

// Create a dataset from a file path
const datasetFromFile = await createDataset('/path/to/dataset.csv', 'my-dataset-name');

// Create a dataset from an array of objects
const datasetFromArray = await createDataset([
  { name: 'John' },
  { name: 'Jane' },
  { name: 'Bob' },
  { name: 'Alice' }
], 'names-dataset');

// Create a dataset from a dictionary of arrays
const datasetFromDict = await createDataset({
  name: ['John', 'Jane', 'Bob', 'Alice'],
  age: ['30', '25', '40', '35']
}, 'people-dataset');

// Get a dataset by name
const dataset = await getDataset({name: 'names'}); 

Using Datasets in Experiments

Datasets can be used in experiments to evaluate your LLM applications:

import { runExperiment } from 'galileo';
import { OpenAI } from 'openai';

async function runDatasetExperiment() {
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

  const runner = async (input) => {
    const result = await openai.chat.completions.create({
      model: 'gpt-3.5-turbo',
      messages: [{ content: `Say hello ${input['name']}!`, role: 'user' }]
    });
    return result;
  };

  await runExperiment({
    name: `Test Experiment`,
    datasetName: 'names',
    function: runner,
    metrics: ['toxicity'],
    projectName: 'my-project'
  });
}

// Run the experiment
runDatasetExperiment(); 

Using Custom Datasets

You can also use locally generated datasets for experiments:

import { runExperiment } from 'galileo';
import { OpenAI } from 'openai';

async function runCustomDatasetExperiment() {
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

  const dataset = [
    { name: 'John' },
    { name: 'Jane' },
    { name: 'Bob' },
    { name: 'Alice' }
  ];

  const runner = async (input) => {
    const result = await openai.chat.completions.create({
      model: 'gpt-3.5-turbo',
      messages: [{ content: `Say hello ${input['name']}!`, role: 'user' }]
    });
    return result;
  };

  await runExperiment({
    name: `Test Experiment`,
    dataset: dataset,
    function: runner,
    metrics: ['tox'],
    projectName: 'my-project'
  });
}

// Run the experiment
runCustomDatasetExperiment();