ollama本机大语言模型


ollama本机大语言模型

下载ollama

1
2
下载地址:
https://ollama.com/download/windows

api调用

1
2
3
4
5
6
7
文档地址:
https://github.com/ollama/ollama/blob/main/docs/api.md

curl -X POST http://localhost:11434/api/generate -d '{
"model": "llama2",
"prompt":"Why is the sky blue?"
}'

语言模型

1
ollama run llama2

识图模型

1
2
3
4
5
6
7
8
ollama run llava "describe this image: ./art.jpg"

./art.jpg是图片地址

有三种型号
ollama run llava:7b
ollama run llava:13b
ollama run llava:34b

代码模型

1
2
3
4
有三种型号
ollama run codellama:7b
ollama run codellama:13b
ollama run codellama:34b

代码纠错

1
2
3
4
5
6
7
8
9
ollama run codellama '
Where is the bug in this code?

def fib(n):
if n <= 0:
return n
else:
return fib(n-1) + fib(n-2)
'

写单元测试

1
2
3
ollama run codellama "write a unit test for this function: $(cat main.go)"

main.go是需要但愿测试的文件

根据已有的代码填充代码

1
2
3
4
5
6
ollama run codellama '<PRE> func getString(x, y string): <SUF>return result <MID>'

以上命令会在<SUF>位置填充根据x,y获取result字符串的代码
类似var result = x + y

响应结束会返回<EOT>标记

数学模型

1
2
3
4
有三种型号
ollama run wizard-math:7b
ollama run wizard-math:13b
ollama run wizard-math:70b

使用

1
ollama run wizard-math 'A right square pyramid has a base with edges each measuring 3 cm and a height twice the perimeter of its base. What is the volume of the pyramid?'