Using Ollama with Curator
You can use Ollama as a backend for Curator to generate structured synthetic data. In this example, we will generate a list of countries and their capitals, but the approach can be adapted for any data generation task.
Prerequisites
Python 3.10+
Curator: Install via
pip install bespokelabs-curator
Ollama: Download via https://ollama.com/download
Steps
1. Create a curator.LLM subclass
Create a class that inherits from curator.LLM
. Implement two key methods:
prompt()
: Generates the prompt for the LLM.parse()
: Processes the LLM's response into your desired format.
Here’s the implementation:
2. Configure the Ollama Backend
Start Ollama server with
llama3.1:8b
model.
Initialize your generator with Ollama configuration:
3. Generate Data
Generate the structured data and output the results as a pandas DataFrame:
Example Output
Using the above example, the output might look like this:
France
Paris
Japan
Tokyo
Germany
Berlin
India
New Delhi
Brazil
Brasília
Ollama Configuration
Use base_url
in the backend_params
to specify the connection URL.
Example:
Last updated