README.md 14.7 KB
Newer Older
Michael Chiang's avatar
Michael Chiang committed
1
<div align="center">
Arpit Jain's avatar
Arpit Jain committed
2
 <img alt="ollama" height="200px" src="https://github.com/ollama/ollama/assets/3325447/0d0b44e2-8f4a-4e99-9b52-a5c1c741c8f7">
Michael Chiang's avatar
Michael Chiang committed
3
</div>
Jeffrey Morgan's avatar
Jeffrey Morgan committed
4

Bruce MacDonald's avatar
Bruce MacDonald committed
5
# Ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
6

7
[![Discord](https://dcbadge.vercel.app/api/server/ollama?style=flat&compact=true)](https://discord.gg/ollama)
8

9
Get up and running with large language models locally.
10

11
### macOS
Jeffrey Morgan's avatar
Jeffrey Morgan committed
12

13
[Download](https://ollama.com/download/Ollama-darwin.zip)
14

Michael's avatar
Michael committed
15
### Windows preview
16

Michael's avatar
Michael committed
17
[Download](https://ollama.com/download/OllamaSetup.exe)
18

Michael's avatar
Michael committed
19
### Linux
20
21

```
22
curl -fsSL https://ollama.com/install.sh | sh
23
24
```

25
[Manual install instructions](https://github.com/ollama/ollama/blob/main/docs/linux.md)
26

27
### Docker
28

Jeffrey Morgan's avatar
Jeffrey Morgan committed
29
The official [Ollama Docker image](https://hub.docker.com/r/ollama/ollama) `ollama/ollama` is available on Docker Hub.
30

Jeffrey Morgan's avatar
Jeffrey Morgan committed
31
32
33
34
35
### Libraries

- [ollama-python](https://github.com/ollama/ollama-python)
- [ollama-js](https://github.com/ollama/ollama-js)

36
37
## Quickstart

Michael's avatar
Michael committed
38
To run and chat with [Llama 3](https://ollama.com/library/llama3):
39
40

```
Michael's avatar
Michael committed
41
ollama run llama3
42
43
44
45
```

## Model library

Jeffrey Morgan's avatar
Jeffrey Morgan committed
46
Ollama supports a list of models available on [ollama.com/library](https://ollama.com/library 'ollama model library')
47

Jeffrey Morgan's avatar
Jeffrey Morgan committed
48
Here are some example models that can be downloaded:
49

50
51
| Model              | Parameters | Size  | Download                       |
| ------------------ | ---------- | ----- | ------------------------------ |
Michael's avatar
Michael committed
52
53
| Llama 3            | 8B         | 4.7GB | `ollama run llama3`            |
| Llama 3            | 70B        | 40GB  | `ollama run llama3:70b`        |
Michael's avatar
Michael committed
54
| Phi-3              | 3.8B       | 2.3GB | `ollama run phi3`              |
Jeffrey Morgan's avatar
Jeffrey Morgan committed
55
| Mistral            | 7B         | 4.1GB | `ollama run mistral`           |
Michael's avatar
Michael committed
56
57
| Neural Chat        | 7B         | 4.1GB | `ollama run neural-chat`       |
| Starling           | 7B         | 4.1GB | `ollama run starling-lm`       |
58
59
| Code Llama         | 7B         | 3.8GB | `ollama run codellama`         |
| Llama 2 Uncensored | 7B         | 3.8GB | `ollama run llama2-uncensored` |
Jeffrey Morgan's avatar
Jeffrey Morgan committed
60
| LLaVA              | 7B         | 4.5GB | `ollama run llava`             |
61
62
| Gemma              | 2B         | 1.4GB | `ollama run gemma:2b`          |
| Gemma              | 7B         | 4.8GB | `ollama run gemma:7b`          |
63
| Solar              | 10.7B      | 6.1GB | `ollama run solar`             |
64

Matt Williams's avatar
Matt Williams committed
65
> Note: You should have at least 8 GB of RAM available to run the 7B models, 16 GB to run the 13B models, and 32 GB to run the 33B models.
Jeffrey Morgan's avatar
Jeffrey Morgan committed
66

Jeffrey Morgan's avatar
Jeffrey Morgan committed
67
## Customize a model
Jeffrey Morgan's avatar
Jeffrey Morgan committed
68

69
### Import from GGUF
Michael Yang's avatar
Michael Yang committed
70

71
Ollama supports importing GGUF models in the Modelfile:
Michael Yang's avatar
Michael Yang committed
72

73
1. Create a file named `Modelfile`, with a `FROM` instruction with the local filepath to the model you want to import.
Michael Yang's avatar
Michael Yang committed
74

75
76
77
   ```
   FROM ./vicuna-33b.Q4_0.gguf
   ```
78

79
2. Create the model in Ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
80

81
   ```
82
   ollama create example -f Modelfile
83
   ```
84

85
3. Run the model
Michael Yang's avatar
Michael Yang committed
86

87
   ```
88
   ollama run example
89
   ```
Michael Yang's avatar
Michael Yang committed
90

91
92
93
94
### Import from PyTorch or Safetensors

See the [guide](docs/import.md) on importing models for more information.

95
### Customize a prompt
Michael Yang's avatar
Michael Yang committed
96

Michael's avatar
Michael committed
97
Models from the Ollama library can be customized with a prompt. For example, to customize the `llama3` model:
98
99

```
Michael's avatar
Michael committed
100
ollama pull llama3
101
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
102

103
Create a `Modelfile`:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
104

Jeffrey Morgan's avatar
Jeffrey Morgan committed
105
```
Michael's avatar
Michael committed
106
FROM llama3
107
108
109
110

# set the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 1

111
# set the system message
Jeffrey Morgan's avatar
Jeffrey Morgan committed
112
SYSTEM """
Jeffrey Morgan's avatar
Jeffrey Morgan committed
113
You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.
114
"""
Jeffrey Morgan's avatar
Jeffrey Morgan committed
115
```
Bruce MacDonald's avatar
Bruce MacDonald committed
116

117
Next, create and run the model:
Bruce MacDonald's avatar
Bruce MacDonald committed
118
119

```
120
121
122
123
ollama create mario -f ./Modelfile
ollama run mario
>>> hi
Hello! It's your friend Mario.
Bruce MacDonald's avatar
Bruce MacDonald committed
124
125
```

126
For more examples, see the [examples](examples) directory. For more information on working with a Modelfile, see the [Modelfile](docs/modelfile.md) documentation.
127
128
129
130
131
132

## CLI Reference

### Create a model

`ollama create` is used to create a model from a Modelfile.
133

Matt Williams's avatar
Matt Williams committed
134
135
136
137
```
ollama create mymodel -f ./Modelfile
```

138
### Pull a model
Jeffrey Morgan's avatar
Jeffrey Morgan committed
139

140
```
Michael's avatar
Michael committed
141
ollama pull llama3
142
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
143

144
145
146
> This command can also be used to update a local model. Only the diff will be pulled.

### Remove a model
Jeffrey Morgan's avatar
Jeffrey Morgan committed
147
148

```
Michael's avatar
Michael committed
149
ollama rm llama3
Jeffrey Morgan's avatar
Jeffrey Morgan committed
150
151
```

152
153
154
### Copy a model

```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
155
ollama cp llama3 my-model
156
157
158
159
160
161
162
163
164
165
166
167
168
```

### Multiline input

For multiline input, you can wrap text with `"""`:

```
>>> """Hello,
... world!
... """
I'm a basic program that prints the famous "Hello, world!" message to the console.
```

Jeffrey Morgan's avatar
Jeffrey Morgan committed
169
170
171
172
173
174
175
### Multimodal models

```
>>> What's in this image? /Users/jmorgan/Desktop/smile.png
The image features a yellow smiley face, which is likely the central focus of the picture.
```

Arpit Jain's avatar
Arpit Jain committed
176
### Pass the prompt as an argument
177
178

```
Michael's avatar
Michael committed
179
$ ollama run llama3 "Summarize this file: $(cat README.md)"
180
181
182
183
 Ollama is a lightweight, extensible framework for building and running language models on the local machine. It provides a simple API for creating, running, and managing models, as well as a library of pre-built models that can be easily used in a variety of applications.
```

### List models on your computer
Jeffrey Morgan's avatar
Jeffrey Morgan committed
184

185
186
187
```
ollama list
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
188

189
### Start Ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
190

191
`ollama serve` is used when you want to start ollama without running the desktop application.
Jeffrey Morgan's avatar
Jeffrey Morgan committed
192

Jeffrey Morgan's avatar
Jeffrey Morgan committed
193
194
## Building

195
Install `cmake` and `go`:
Michael Yang's avatar
Michael Yang committed
196

Jeffrey Morgan's avatar
Jeffrey Morgan committed
197
```
James Braza's avatar
James Braza committed
198
brew install cmake go
Jeffrey Morgan's avatar
Jeffrey Morgan committed
199
200
```

201
202
203
204
205
206
Then generate dependencies:

```
go generate ./...
```

207
Then build the binary:
208

209
```
210
go build .
Jeffrey Morgan's avatar
Jeffrey Morgan committed
211
212
```

213
More detailed instructions can be found in the [developer guide](https://github.com/ollama/ollama/blob/main/docs/development.md)
214
215

### Running local builds
216

Jeffrey Morgan's avatar
Jeffrey Morgan committed
217
Next, start the server:
Bruce MacDonald's avatar
Bruce MacDonald committed
218

Jeffrey Morgan's avatar
Jeffrey Morgan committed
219
```
Jeffrey Morgan's avatar
Jeffrey Morgan committed
220
./ollama serve
Jeffrey Morgan's avatar
Jeffrey Morgan committed
221
222
```

Michael Yang's avatar
Michael Yang committed
223
Finally, in a separate shell, run a model:
Jeffrey Morgan's avatar
Jeffrey Morgan committed
224
225

```
Michael's avatar
Michael committed
226
./ollama run llama3
Jeffrey Morgan's avatar
Jeffrey Morgan committed
227
```
228
229
230

## REST API

James Braza's avatar
James Braza committed
231
Ollama has a REST API for running and managing models.
232
233

### Generate a response
234
235

```
236
curl http://localhost:11434/api/generate -d '{
Michael's avatar
Michael committed
237
  "model": "llama3",
238
239
  "prompt":"Why is the sky blue?"
}'
240
```
Nate Sesti's avatar
Nate Sesti committed
241

242
### Chat with a model
Bruce MacDonald's avatar
Bruce MacDonald committed
243
244
245

```
curl http://localhost:11434/api/chat -d '{
Michael's avatar
Michael committed
246
  "model": "llama3",
247
248
  "messages": [
    { "role": "user", "content": "why is the sky blue?" }
Bruce MacDonald's avatar
Bruce MacDonald committed
249
250
251
252
  ]
}'
```

James Braza's avatar
James Braza committed
253
254
See the [API documentation](./docs/api.md) for all endpoints.

255
256
## Community Integrations

Jeffrey Morgan's avatar
Jeffrey Morgan committed
257
### Web & Desktop
258

Bruce MacDonald's avatar
Bruce MacDonald committed
259
260
- [Open WebUI](https://github.com/open-webui/open-webui)
- [Enchanted (macOS native)](https://github.com/AugustDev/enchanted)
Saifeddine ALOUI's avatar
Saifeddine ALOUI committed
261
- [Lollms-Webui](https://github.com/ParisNeo/lollms-webui)
262
- [LibreChat](https://github.com/danny-avila/LibreChat)
263
- [Bionic GPT](https://github.com/bionic-gpt/bionic-gpt)
264
- [HTML UI](https://github.com/rtcfirefly/ollama-ui)
Jikku Jose's avatar
Jikku Jose committed
265
- [Saddle](https://github.com/jikkuatwork/saddle)
266
- [Chatbot UI](https://github.com/ivanfioravanti/chatbot-ollama)
267
- [Chatbot UI v2](https://github.com/mckaywrigley/chatbot-ui)
268
- [Typescript UI](https://github.com/ollama-interface/Ollama-Gui?tab=readme-ov-file)
269
- [Minimalistic React UI for Ollama Models](https://github.com/richawo/minimal-llm-ui)
270
- [Ollamac](https://github.com/kevinhermawan/Ollamac)
271
- [big-AGI](https://github.com/enricoros/big-AGI/blob/main/docs/config-local-ollama.md)
272
- [Cheshire Cat assistant framework](https://github.com/cheshire-cat-ai/core)
273
- [Amica](https://github.com/semperai/amica)
274
- [chatd](https://github.com/BruceMacD/chatd)
275
- [Ollama-SwiftUI](https://github.com/kghandour/Ollama-SwiftUI)
276
- [Dify.AI](https://github.com/langgenius/dify)
277
- [MindMac](https://mindmac.app)
278
- [NextJS Web Interface for Ollama](https://github.com/jakobhoeg/nextjs-ollama-llm-ui)
279
- [Msty](https://msty.app)
280
- [Chatbox](https://github.com/Bin-Huang/Chatbox)
281
- [WinForm Ollama Copilot](https://github.com/tgraupmann/WinForm_Ollama_Copilot)
282
- [NextChat](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web) with [Get Started Doc](https://docs.nextchat.dev/models/ollama)
283
- [Alpaca WebUI](https://github.com/mmo80/alpaca-webui)
284
- [OllamaGUI](https://github.com/enoch1118/ollamaGUI)
285
- [OpenAOE](https://github.com/InternLM/OpenAOE)
286
- [Odin Runes](https://github.com/leonid20000/OdinRunes)
287
- [LLM-X](https://github.com/mrdjohnson/llm-x) (Progressive Web App)
288
- [AnythingLLM (Docker + MacOs/Windows/Linux native app)](https://github.com/Mintplex-Labs/anything-llm)
289
290
- [Ollama Basic Chat: Uses HyperDiv Reactive UI](https://github.com/rapidarchitect/ollama_basic_chat)
- [Ollama-chats RPG](https://github.com/drazdra/ollama-chats)
291
292
293
294
295
296
- [QA-Pilot](https://github.com/reid41/QA-Pilot) (Chat with Code Repository)
- [ChatOllama](https://github.com/sugarforever/chat-ollama) (Open Source Chatbot based on Ollama with Knowledge Bases)
- [CRAG Ollama Chat](https://github.com/Nagi-ovo/CRAG-Ollama-Chat) (Simple Web Search with Corrective RAG)
- [RAGFlow](https://github.com/infiniflow/ragflow) (Open-source Retrieval-Augmented Generation engine based on deep document understanding)
- [StreamDeploy](https://github.com/StreamDeploy-DevRel/streamdeploy-llm-app-scaffold) (LLM Application Scaffold)
- [chat](https://github.com/swuecho/chat) (chat web app for teams)
297
- [Lobe Chat](https://github.com/lobehub/lobe-chat) with [Integrating Doc](https://lobehub.com/docs/self-hosting/examples/ollama)
298
299
- [Ollama RAG Chatbot](https://github.com/datvodinh/rag-chatbot.git) (Local Chat with multiple PDFs using Ollama and RAG)
- [BrainSoup](https://www.nurgo-software.com/products/brainsoup) (Flexible native client with RAG & multi-agent automation)
300

Jeffrey Morgan's avatar
Jeffrey Morgan committed
301
### Terminal
Jeffrey Morgan's avatar
Jeffrey Morgan committed
302

303
304
305
- [oterm](https://github.com/ggozad/oterm)
- [Ellama Emacs client](https://github.com/s-kostyaev/ellama)
- [Emacs client](https://github.com/zweifisch/ollama)
306
- [gen.nvim](https://github.com/David-Kunz/gen.nvim)
307
- [ollama.nvim](https://github.com/nomnivore/ollama.nvim)
308
- [ollero.nvim](https://github.com/marco-souza/ollero.nvim)
309
- [ollama-chat.nvim](https://github.com/gerazov/ollama-chat.nvim)
310
- [ogpt.nvim](https://github.com/huynle/ogpt.nvim)
Bruce MacDonald's avatar
Bruce MacDonald committed
311
- [gptel Emacs client](https://github.com/karthink/gptel)
312
- [Oatmeal](https://github.com/dustinblackman/oatmeal)
313
- [cmdh](https://github.com/pgibler/cmdh)
314
- [ooo](https://github.com/npahlfer/ooo)
reid41's avatar
reid41 committed
315
- [shell-pilot](https://github.com/reid41/shell-pilot)
316
- [tenere](https://github.com/pythops/tenere)
317
- [llm-ollama](https://github.com/taketwo/llm-ollama) for [Datasette's LLM CLI](https://llm.datasette.io/en/stable/).
318
- [typechat-cli](https://github.com/anaisbetts/typechat-cli)
319
- [ShellOracle](https://github.com/djcopley/ShellOracle)
320
- [tlm](https://github.com/yusufcanb/tlm)
Bruce MacDonald's avatar
Bruce MacDonald committed
321
- [podman-ollama](https://github.com/ericcurtin/podman-ollama)
322

Jorge Torres's avatar
Jorge Torres committed
323
324
### Database

325
- [MindsDB](https://github.com/mindsdb/mindsdb/blob/staging/mindsdb/integrations/handlers/ollama_handler/README.md) (Connects Ollama models with nearly 200 data platforms and apps)
326
- [chromem-go](https://github.com/philippgille/chromem-go/blob/v0.5.0/embed_ollama.go) with [example](https://github.com/philippgille/chromem-go/tree/v0.5.0/examples/rag-wikipedia-ollama)
327

Matt Williams's avatar
Matt Williams committed
328
### Package managers
329

Matt Williams's avatar
Matt Williams committed
330
- [Pacman](https://archlinux.org/packages/extra/x86_64/ollama/)
331
- [Helm Chart](https://artifacthub.io/packages/helm/ollama-helm/ollama)
332

333
### Libraries
Jeffrey Morgan's avatar
Jeffrey Morgan committed
334

335
- [LangChain](https://python.langchain.com/docs/integrations/llms/ollama) and [LangChain.js](https://js.langchain.com/docs/modules/model_io/models/llms/integrations/ollama) with [example](https://js.langchain.com/docs/use_cases/question_answering/local_retrieval_qa)
336
- [LangChainGo](https://github.com/tmc/langchaingo/) with [example](https://github.com/tmc/langchaingo/tree/main/examples/ollama-completion-example)
LangChain4j's avatar
LangChain4j committed
337
- [LangChain4j](https://github.com/langchain4j/langchain4j) with [example](https://github.com/langchain4j/langchain4j-examples/tree/main/ollama-examples/src/main/java)
338
- [LlamaIndex](https://gpt-index.readthedocs.io/en/stable/examples/llm/ollama.html)
339
- [LiteLLM](https://github.com/BerriAI/litellm)
340
- [OllamaSharp for .NET](https://github.com/awaescher/OllamaSharp)
341
- [Ollama for Ruby](https://github.com/gbaptista/ollama-ai)
342
- [Ollama-rs for Rust](https://github.com/pepperoni21/ollama-rs)
343
- [Ollama4j for Java](https://github.com/amithkoujalgi/ollama4j)
344
- [ModelFusion Typescript Library](https://modelfusion.dev/integration/model-provider/ollama)
345
- [OllamaKit for Swift](https://github.com/kevinhermawan/OllamaKit)
346
- [Ollama for Dart](https://github.com/breitburg/dart-ollama)
347
- [Ollama for Laravel](https://github.com/cloudstudio/ollama-laravel)
348
- [LangChainDart](https://github.com/davidmigloz/langchain_dart)
349
- [Semantic Kernel - Python](https://github.com/microsoft/semantic-kernel/tree/main/python/semantic_kernel/connectors/ai/ollama)
350
- [Haystack](https://github.com/deepset-ai/haystack-integrations/blob/main/integrations/ollama.md)
351
- [Elixir LangChain](https://github.com/brainlid/langchain)
Maximilian Weber's avatar
Maximilian Weber committed
352
- [Ollama for R - rollama](https://github.com/JBGruber/rollama)
353
- [Ollama for R - ollama-r](https://github.com/hauselin/ollama-r)
354
- [Ollama-ex for Elixir](https://github.com/lebrunel/ollama-ex)
355
- [Ollama Connector for SAP ABAP](https://github.com/b-tocs/abap_btocs_ollama)
356
- [Testcontainers](https://testcontainers.com/modules/ollama/)
357
- [Portkey](https://portkey.ai/docs/welcome/integration-guides/ollama)
358

Jeffrey Morgan's avatar
Jeffrey Morgan committed
359
360
### Mobile

361
- [Enchanted](https://github.com/AugustDev/enchanted)
Dane Madsen's avatar
Dane Madsen committed
362
- [Maid](https://github.com/Mobile-Artificial-Intelligence/maid)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
363

Jeffrey Morgan's avatar
Jeffrey Morgan committed
364
365
### Extensions & Plugins

366
367
368
369
- [Raycast extension](https://github.com/MassimilianoPasquini97/raycast_ollama)
- [Discollama](https://github.com/mxyng/discollama) (Discord bot inside the Ollama discord channel)
- [Continue](https://github.com/continuedev/continue)
- [Obsidian Ollama plugin](https://github.com/hinterdupfinger/obsidian-ollama)
370
- [Logseq Ollama plugin](https://github.com/omagdy7/ollama-logseq)
371
- [NotesOllama](https://github.com/andersrex/notesollama) (Apple Notes Ollama plugin)
372
373
- [Dagger Chatbot](https://github.com/samalba/dagger-chatbot)
- [Discord AI Bot](https://github.com/mekb-turtle/discord-ai-bot)
ruecat's avatar
ruecat committed
374
- [Ollama Telegram Bot](https://github.com/ruecat/ollama-telegram)
375
- [Hass Ollama Conversation](https://github.com/ej52/hass-ollama-conversation)
376
- [Rivet plugin](https://github.com/abrenneke/rivet-plugin-ollama)
377
- [Obsidian BMO Chatbot plugin](https://github.com/longy2k/obsidian-bmo-chatbot)
378
- [Cliobot](https://github.com/herval/cliobot) (Telegram bot with Ollama support)
379
- [Copilot for Obsidian plugin](https://github.com/logancyang/obsidian-copilot)
Pavel Frankov's avatar
Pavel Frankov committed
380
- [Obsidian Local GPT plugin](https://github.com/pfrankov/obsidian-local-gpt)
Jeffrey Morgan's avatar
Jeffrey Morgan committed
381
- [Open Interpreter](https://docs.openinterpreter.com/language-model-setup/local-models/ollama)
382
383
- [Llama Coder](https://github.com/ex3ndr/llama-coder) (Copilot alternative using Ollama)
- [Ollama Copilot](https://github.com/bernardo-bruning/ollama-copilot) (Proxy that allows you to use ollama as a copilot like Github copilot)
384
- [twinny](https://github.com/rjmacarthy/twinny) (Copilot and Copilot chat alternative using Ollama)
385
- [Wingman-AI](https://github.com/RussellCanfield/wingman-ai) (Copilot code and chat alternative using Ollama and HuggingFace)
386
- [Page Assist](https://github.com/n4ze3m/page-assist) (Chrome Extension)
387
- [AI Telegram Bot](https://github.com/tusharhero/aitelegrambot) (Telegram bot using Ollama in backend)
Yaroslav's avatar
Yaroslav committed
388
- [AI ST Completion](https://github.com/yaroslavyaroslav/OpenAI-sublime-text) (Sublime Text 4 AI assistant plugin with Ollama support)
389
- [Discord-Ollama Chat Bot](https://github.com/kevinthedang/discord-ollama) (Generalized TypeScript Discord Bot w/ Tuning Documentation)
390
391

### Supported backends 
392
393
- [llama.cpp](https://github.com/ggerganov/llama.cpp) project founded by Georgi Gerganov.