Using Ollama with Curator
Prerequisites
Steps
1. Create a curator.LLM subclass
from bespokelabs import curator
from pydantic import BaseModel, Field
class Location(BaseModel):
country: str = Field(description="The name of the country")
capital: str = Field(description="The name of the capital city")
class LocationList(BaseModel):
locations: list[Location] = Field(description="A list of locations")
class SimpleOllamaGenerator(curator.LLM):
response_format = LocationList
def prompt(self, input: dict) -> str:
return "Return five countries and their capitals."
def parse(self, input: dict, response: str) -> dict:
return [{"country": output.country, "capital": output.capital} for output in response.locations]2. Configure the Ollama Backend
3. Generate Data
Example Output
Country
Capital
Ollama Configuration
Last updated