Using Ollama with Curator
Last updated
Last updated
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.
Python 3.10+
Curator: Install via pip install bespokelabs-curator
Ollama: Download via
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:
Start Ollama server with llama3.1:8b
model.
Initialize your generator with Ollama configuration:
Generate the structured data and output the results as a pandas DataFrame:
Using the above example, the output might look like this:
France
Paris
Japan
Tokyo
Germany
Berlin
India
New Delhi
Brazil
Brasília
Use base_url
in the backend_params
to specify the connection URL.
Example: