> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bespokelabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama

> Generate data with a local model served by Ollama.

You can use a model served by [Ollama](https://ollama.com) with Curator. This guide asks for the capital of each country in a list.

## Prerequisites

* Python 3.10 or later.
* Curator, installed with `pip install bespokelabs-curator`.
* Ollama, from the [Ollama download page](https://ollama.com/download).

**1. Create an LLM subclass**

```python theme={null}
from bespokelabs import curator


class CapitalGenerator(curator.LLM):
    def prompt(self, input: dict) -> str:
        return f"What is the capital of {input['country']}? Answer with only the city name."

    def parse(self, input: dict, response: str) -> dict:
        return {"country": input["country"], "capital": response.strip()}
```

**2. Start Ollama**

Pull a model and start the server.

```bash theme={null}
ollama pull llama3.1:8b
ollama serve
```

**3. Connect Curator to Ollama**

Add the `ollama/` prefix to the model name, and set `base_url` to your Ollama server.

```python theme={null}
llm = CapitalGenerator(
    model_name="ollama/llama3.1:8b",
    backend_params={"base_url": "http://localhost:11434"},
)
```

Curator sends Ollama requests through the LiteLLM backend.

**4. Generate the data**

```python theme={null}
countries = [{"country": c} for c in ["France", "Japan", "Germany", "India", "Brazil"]]
capitals = llm(countries)
print(capitals.dataset.to_pandas())
```

The output looks like this.

| country | capital |
| - | - |
| France | Paris |
| Japan | Tokyo |
| Germany | Berlin |
| India | New Delhi |
| Brazil | Brasília |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.