Compare commits

..

No commits in common. "391a633d2f45513c1330ea49c8e5eaefd7e19923" and "58a1de92b8ce93af35bc79c4a78baec82e85197b" have entirely different histories.

26 changed files with 123 additions and 189 deletions

View file

@ -337,8 +337,6 @@ See the [API documentation](./docs/api.md) for all endpoints.
- [Pacman](https://archlinux.org/packages/extra/x86_64/ollama/) - [Pacman](https://archlinux.org/packages/extra/x86_64/ollama/)
- [Helm Chart](https://artifacthub.io/packages/helm/ollama-helm/ollama) - [Helm Chart](https://artifacthub.io/packages/helm/ollama-helm/ollama)
- [Guix channel](https://codeberg.org/tusharhero/ollama-guix) - [Guix channel](https://codeberg.org/tusharhero/ollama-guix)
- [Nix package](https://search.nixos.org/packages?channel=24.05&show=ollama&from=0&size=50&sort=relevance&type=packages&query=ollama)
- [Flox](https://flox.dev/blog/ollama-part-one)
### Libraries ### Libraries

View file

@ -726,17 +726,14 @@ func ShowHandler(cmd *cobra.Command, args []string) error {
} }
func showInfo(resp *api.ShowResponse) { func showInfo(resp *api.ShowResponse) {
arch := resp.ModelInfo["general.architecture"].(string)
modelData := [][]string{ modelData := [][]string{
{"arch", arch},
{"parameters", resp.Details.ParameterSize}, {"parameters", resp.Details.ParameterSize},
{"quantization", resp.Details.QuantizationLevel}, {"quantization", resp.Details.QuantizationLevel},
} {"context length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64))},
if resp.ModelInfo != nil { {"embedding length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64))},
arch := resp.ModelInfo["general.architecture"].(string)
modelData = append(modelData,
[]string{"arch", arch},
[]string{"context length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.context_length", arch)].(float64))},
[]string{"embedding length", fmt.Sprintf("%v", resp.ModelInfo[fmt.Sprintf("%s.embedding_length", arch)].(float64))},
)
} }
mainTableData := [][]string{ mainTableData := [][]string{

View file

@ -128,10 +128,10 @@ Currently supported model architectures:
#### Build from a GGUF file #### Build from a GGUF file
```modelfile ```modelfile
FROM ./ollama-model.gguf FROM ./ollama-model.bin
``` ```
The GGUF file location should be specified as an absolute path or relative to the `Modelfile` location. The GGUF bin file location should be specified as an absolute path or relative to the `Modelfile` location.
### PARAMETER ### PARAMETER
@ -208,7 +208,7 @@ Currently supported Safetensor adapters:
#### GGUF adapter #### GGUF adapter
```modelfile ```modelfile
ADAPTER ./ollama-lora.gguf ADAPTER ./ollama-lora.bin
``` ```
### LICENSE ### LICENSE

View file

@ -30,7 +30,9 @@ func Host() *url.URL {
defaultPort = "443" defaultPort = "443"
} }
hostport, path, _ := strings.Cut(hostport, "/") // trim trailing slashes
hostport = strings.TrimRight(hostport, "/")
host, port, err := net.SplitHostPort(hostport) host, port, err := net.SplitHostPort(hostport)
if err != nil { if err != nil {
host, port = "127.0.0.1", defaultPort host, port = "127.0.0.1", defaultPort
@ -43,13 +45,15 @@ func Host() *url.URL {
if n, err := strconv.ParseInt(port, 10, 32); err != nil || n > 65535 || n < 0 { if n, err := strconv.ParseInt(port, 10, 32); err != nil || n > 65535 || n < 0 {
slog.Warn("invalid port, using default", "port", port, "default", defaultPort) slog.Warn("invalid port, using default", "port", port, "default", defaultPort)
port = defaultPort return &url.URL{
Scheme: scheme,
Host: net.JoinHostPort(host, defaultPort),
}
} }
return &url.URL{ return &url.URL{
Scheme: scheme, Scheme: scheme,
Host: net.JoinHostPort(host, port), Host: net.JoinHostPort(host, port),
Path: path,
} }
} }

View file

@ -13,35 +13,34 @@ func TestHost(t *testing.T) {
value string value string
expect string expect string
}{ }{
"empty": {"", "http://127.0.0.1:11434"}, "empty": {"", "127.0.0.1:11434"},
"only address": {"1.2.3.4", "http://1.2.3.4:11434"}, "only address": {"1.2.3.4", "1.2.3.4:11434"},
"only port": {":1234", "http://:1234"}, "only port": {":1234", ":1234"},
"address and port": {"1.2.3.4:1234", "http://1.2.3.4:1234"}, "address and port": {"1.2.3.4:1234", "1.2.3.4:1234"},
"hostname": {"example.com", "http://example.com:11434"}, "hostname": {"example.com", "example.com:11434"},
"hostname and port": {"example.com:1234", "http://example.com:1234"}, "hostname and port": {"example.com:1234", "example.com:1234"},
"zero port": {":0", "http://:0"}, "zero port": {":0", ":0"},
"too large port": {":66000", "http://:11434"}, "too large port": {":66000", ":11434"},
"too small port": {":-1", "http://:11434"}, "too small port": {":-1", ":11434"},
"ipv6 localhost": {"[::1]", "http://[::1]:11434"}, "ipv6 localhost": {"[::1]", "[::1]:11434"},
"ipv6 world open": {"[::]", "http://[::]:11434"}, "ipv6 world open": {"[::]", "[::]:11434"},
"ipv6 no brackets": {"::1", "http://[::1]:11434"}, "ipv6 no brackets": {"::1", "[::1]:11434"},
"ipv6 + port": {"[::1]:1337", "http://[::1]:1337"}, "ipv6 + port": {"[::1]:1337", "[::1]:1337"},
"extra space": {" 1.2.3.4 ", "http://1.2.3.4:11434"}, "extra space": {" 1.2.3.4 ", "1.2.3.4:11434"},
"extra quotes": {"\"1.2.3.4\"", "http://1.2.3.4:11434"}, "extra quotes": {"\"1.2.3.4\"", "1.2.3.4:11434"},
"extra space+quotes": {" \" 1.2.3.4 \" ", "http://1.2.3.4:11434"}, "extra space+quotes": {" \" 1.2.3.4 \" ", "1.2.3.4:11434"},
"extra single quotes": {"'1.2.3.4'", "http://1.2.3.4:11434"}, "extra single quotes": {"'1.2.3.4'", "1.2.3.4:11434"},
"http": {"http://1.2.3.4", "http://1.2.3.4:80"}, "http": {"http://1.2.3.4", "1.2.3.4:80"},
"http port": {"http://1.2.3.4:4321", "http://1.2.3.4:4321"}, "http port": {"http://1.2.3.4:4321", "1.2.3.4:4321"},
"https": {"https://1.2.3.4", "https://1.2.3.4:443"}, "https": {"https://1.2.3.4", "1.2.3.4:443"},
"https port": {"https://1.2.3.4:4321", "https://1.2.3.4:4321"}, "https port": {"https://1.2.3.4:4321", "1.2.3.4:4321"},
"proxy path": {"https://example.com/ollama", "https://example.com:443/ollama"},
} }
for name, tt := range cases { for name, tt := range cases {
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
t.Setenv("OLLAMA_HOST", tt.value) t.Setenv("OLLAMA_HOST", tt.value)
if host := Host(); host.String() != tt.expect { if host := Host(); host.Host != tt.expect {
t.Errorf("%s: expected %s, got %s", name, tt.expect, host.String()) t.Errorf("%s: expected %s, got %s", name, tt.expect, host.Host)
} }
}) })
} }

View file

@ -87,8 +87,6 @@ apply_patches() {
build() { build() {
cmake -S ${LLAMACPP_DIR} -B ${BUILD_DIR} ${CMAKE_DEFS} cmake -S ${LLAMACPP_DIR} -B ${BUILD_DIR} ${CMAKE_DEFS}
cmake --build ${BUILD_DIR} ${CMAKE_TARGETS} -j8 cmake --build ${BUILD_DIR} ${CMAKE_TARGETS} -j8
# remove unnecessary build artifacts
rm -f ${BUILD_DIR}/bin/ggml-common.h ${BUILD_DIR}/bin/ggml-metal.metal
} }
compress() { compress() {

View file

@ -30,7 +30,7 @@ if grep -i "centos" /etc/system-release >/dev/null; then
dnf install -y rh-git227-git dnf install -y rh-git227-git
ln -s /opt/rh/rh-git227/root/usr/bin/git /usr/local/bin/git ln -s /opt/rh/rh-git227/root/usr/bin/git /usr/local/bin/git
fi fi
dnf install -y devtoolset-10-gcc devtoolset-10-gcc-c++ pigz findutils dnf install -y devtoolset-10-gcc devtoolset-10-gcc-c++ pigz
elif grep -i "rocky" /etc/system-release >/dev/null; then elif grep -i "rocky" /etc/system-release >/dev/null; then
# Temporary workaround until rocky 8 AppStream ships GCC 10.4 (10.3 is incompatible with NVCC) # Temporary workaround until rocky 8 AppStream ships GCC 10.4 (10.3 is incompatible with NVCC)
cat << EOF > /etc/yum.repos.d/Rocky-Vault.repo cat << EOF > /etc/yum.repos.d/Rocky-Vault.repo
@ -45,7 +45,6 @@ EOF
dnf install -y git \ dnf install -y git \
gcc-toolset-10-gcc-10.2.1-8.2.el8 \ gcc-toolset-10-gcc-10.2.1-8.2.el8 \
gcc-toolset-10-gcc-c++-10.2.1-8.2.el8 \ gcc-toolset-10-gcc-c++-10.2.1-8.2.el8 \
findutils \
pigz pigz
else else
echo "ERROR Unexpected distro" echo "ERROR Unexpected distro"

View file

@ -593,9 +593,9 @@ func TestCreateDetectTemplate(t *testing.T) {
checkFileExists(t, filepath.Join(p, "blobs", "*"), []string{ checkFileExists(t, filepath.Join(p, "blobs", "*"), []string{
filepath.Join(p, "blobs", "sha256-0d79f567714c62c048378f2107fb332dabee0135d080c302d884317da9433cc5"), filepath.Join(p, "blobs", "sha256-0d79f567714c62c048378f2107fb332dabee0135d080c302d884317da9433cc5"),
filepath.Join(p, "blobs", "sha256-35360843d0c84fb1506952a131bbef13cd2bb4a541251f22535170c05b56e672"),
filepath.Join(p, "blobs", "sha256-553c4a3f747b3d22a4946875f1cc8ed011c2930d83f864a0c7265f9ec0a20413"), filepath.Join(p, "blobs", "sha256-553c4a3f747b3d22a4946875f1cc8ed011c2930d83f864a0c7265f9ec0a20413"),
filepath.Join(p, "blobs", "sha256-de3959f841e9ef6b4b6255fa41cb9e0a45da89c3066aa72bdd07a4747f848990"), filepath.Join(p, "blobs", "sha256-c608dc615584cd20d9d830363dabf8a4783ae5d34245c3d8c115edb3bc7b28e4"),
filepath.Join(p, "blobs", "sha256-ea34c57ba5b78b740aafe2aeb74dc6507fc3ad14170b64c26a04fb9e36c88d75"),
}) })
}) })

View file

@ -1,2 +1 @@
{{- range .Messages }}<start_{{ .Role }}>{{ .Content }}<end_message> {{ if .System }}<start_system>{{ .System }}<end_message>{{ end }}{{ if .Prompt }}<start_user>{{ .Prompt }}<end_message>{{ end }}<start_assistant>{{ .Response }}<end_message>
{{- end }}<start_assistant>

View file

@ -1,18 +1,8 @@
{{- $system := "" }} {{ if .System }}{{ .System }}
{{- range .Messages }}
{{- if eq .Role "system" }}
{{- if not $system }}{{ $system = .Content }}
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }}
{{- end }}
{{- else if eq .Role "user" }}
{{- if $system }}{{ $system }}
{{ $system = "" }} {{ end }}{{ if .Prompt }}### Instruction:
{{- end }}### Instruction: {{ .Prompt }}
{{ .Content }}
{{ else if eq .Role "assistant" }}### Response: {{ end }}### Response:
{{ .Content }} {{ .Response }}
{{ end }}
{{- end }}### Response:

View file

@ -1,3 +1,6 @@
{{- range .Messages }}<|im_start|>{{ .Role }} {{ if .System }}<|im_start|>system
{{ .Content }}<|im_end|> {{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant {{ end }}<|im_start|>assistant
{{ .Response }}<|im_end|>

View file

@ -1,7 +1,6 @@
{{- range .Messages }} {{ if .System }}System: {{ .System }}
{{- if eq .Role "system" }}System:
{{- else if eq .Role "user" }}User: {{ end }}{{ if .Prompt }}User: {{ .Prompt }}
{{- else if eq .Role "assistant" }}Assistant:
{{- end }} {{ .Content }} {{ end }}Assistant: {{ .Response }}
{{ end }}Assistant:

View file

@ -1,10 +1,10 @@
{{- range .Messages }}Source: {{ if .System }}Source: system
{{- if eq .Role "system" }} system
{{- else if eq .Role "user" }} user {{ .System }} <step> {{ end }}Source: user
{{- else if eq .Role "assistant" }} assistant
{{ .Prompt }} <step> Source: assistant
{{- if not .Response }}
Destination: user
{{- end }} {{- end }}
{{ .Content }} <step> {{ end }}Source: assistant {{ .Response }} <step>
Destination: user

View file

@ -1,8 +1,5 @@
{{- range .Messages }} {{ if .System }}System: {{ .System }}
{{- if eq .Role "system" }}System: {{ .Content }} {{ end }}{{ if .Prompt }}User:
{{ continue }} {{ .Prompt }}
{{- else if eq .Role "user" }}User:
{{- else if eq .Role "assistant" }}Falcon:
{{- end }}
{{ .Content }}
{{ end }}Falcon: {{ end }}Falcon:
{{ .Response }}

View file

@ -1,16 +1,5 @@
{{- $system := "" }} <start_of_turn>user
{{- range .Messages }} {{ if .System }}{{ .System }}
{{- if eq .Role "system" }} {{ end }}{{ .Prompt }}<end_of_turn>
{{- if not $system }}{{ $system = .Content }} <start_of_turn>model
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }} {{ .Response }}<end_of_turn>
{{- end }}
{{- continue }}
{{- else if eq .Role "user" }}<start_of_turn>user
{{- if $system }}
{{ $system }}
{{- $system = "" }}
{{- end }}
{{- else if eq .Role "assistant" }}<start_of_turn>model
{{- end }}
{{ .Content }}<end_of_turn>
{{ end }}<start_of_turn>model

View file

@ -1,8 +1,9 @@
{{- range .Messages }} {{ if .System }}System:
{{- if eq .Role "system" }}System: {{ .System }}
{{- else if eq .Role "user" }}Question:
{{- else if eq .Role "assistant" }}Answer: {{ end }}{{ if .Prompt }}Question:
{{- end }} {{ .Prompt }}
{{ .Content }}
{{ end }}Answer: {{ end }}Answer:
{{ .Response }}

View file

@ -1,14 +1,6 @@
{{- $system := "" }}[INST] {{ range .Messages }} [INST] <<SYS>>
{{- if eq .Role "system" }} {{- if .System }}
{{- if not $system }}{{ $system = .Content }} {{ .System }}
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }} {{ end }}<</SYS>>
{{- end }}
{{- else if eq .Role "user" }}<<SYS>>
{{- if $system }}
{{ $system }}
{{ $system = "" }}
{{- end }}<</SYS>>
{{ .Content }} [/INST] {{ .Prompt }} [/INST] {{ .Response }}</s><s>
{{- else if eq .Role "assistant" }} {{ .Content }}</s><s>[INST] {{ end }}
{{- end }}

View file

@ -1,5 +1,7 @@
{{- range .Messages }}<|start_header_id|>{{ .Role }}<|end_header_id|> {{ if .System }}<|start_header_id|>system<|end_header_id|>
{{ .Content }}<|eot_id|> {{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
{{- end }}<|start_header_id|>assistant<|end_header_id|>
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
{{ .Response }}<|eot_id|>

View file

@ -1,17 +1,8 @@
{{- $system := "" }} {{ if .System }}{{ .System }}
{{- range .Messages }}
{{- if eq .Role "system" }}
{{- if not $system }}{{ $system = .Content }}
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }}
{{- end }}
{{- continue }}
{{- else if eq .Role "user" }}
{{- if $system }}{{ $system }}
{{ $system = "" }} {{ end }}{{ if .Prompt }}@@ Instruction
{{- end }}@@ Instruction {{ .Prompt }}
{{- else if eq .Role "assistant" }}@@ Response
{{- end }}
{{ .Content }}
{{ end }}@@ Response {{ end }}@@ Response
{{ .Response }}

View file

@ -1,6 +1,3 @@
[INST] {{ range $index, $_ := .Messages }} [INST] {{ if .System }}{{ .System }}
{{- if eq .Role "system" }}{{ .Content }}
{{ else if eq .Role "user" }}{{ .Content }}[/INST] {{ end }}{{ .Prompt }}[/INST] {{ .Response }}</s>
{{- else if eq .Role "assistant" }} {{ .Content }}</s>[INST] {{ end }}
{{- end }}

View file

@ -1,6 +1 @@
{{- range .Messages }}GPT4 Correct {{ if .System }}GPT4 Correct System: {{ .System }}<|end_of_turn|>{{ end }}GPT4 Correct User: {{ .Prompt }}<|end_of_turn|>GPT4 Correct Assistant: {{ .Response }}<|end_of_turn|>
{{- if eq .Role "system" }} System:
{{- else if eq .Role "user" }} User:
{{- else if eq .Role "assistant" }} Assistant:
{{- end }} {{ .Content }}<|end_of_turn|>
{{- end }}GPT4 Correct Assistant:

View file

@ -1,3 +1,6 @@
{{- range .Messages }}<|{{ .Role }}|> {{ if .System }}<|system|>
{{ .Content }}<|end|> {{ .System }}<|end|>
{{ end }}{{ if .Prompt }}<|user|>
{{ .Prompt }}<|end|>
{{ end }}<|assistant|> {{ end }}<|assistant|>
{{ .Response }}<|end|>

View file

@ -1,11 +1,9 @@
{{- range .Messages }} {{ if .System }}### System:
{{- if eq .Role "system" }}### System: {{ .System }}
{{- else if eq .Role "user" }}### User:
{{- else if eq .Role "assistant" }}### Assistant:
{{ .Content }}</s>
{{ continue }} {{ end }}{{ if .Prompt }}### User:
{{- end }} {{ .Prompt }}
{{ .Content }}
{{ end }}### Assistant: {{ end }}### Assistant:
{{ .Response }}</s>

View file

@ -1,18 +1,8 @@
{{- $system := "" }} {{ if .System }}{{ .System }}
{{- range .Messages }}
{{- if eq .Role "system" }}
{{- if not $system }}{{ $system = .Content }}
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }}
{{- end }}
{{- else if eq .Role "user" }}
{{- if $system }}{{ $system }}
{{ $system = "" }} {{ end }}{{ if .Prompt }}### Instruction
{{- end }}### Instruction {{ .Prompt }}
{{ .Content }}
{{ else if eq .Role "assistant" }}### Response {{ end }}### Response
{{ .Content }}<|endoftext|> {{ .Response }}<|endoftext|>
{{ end }}
{{- end }}### Response

View file

@ -1,14 +1,4 @@
{{- $system := "" }} {{ if .System }}{{ .System }}
{{- range .Messages }}
{{- if eq .Role "system" }}
{{- if not $system }}{{ $system = .Content }}
{{- else }}{{ $system = printf "%s\n\n%s" $system .Content }}
{{- end }}
{{- else if eq .Role "user" }}
{{- if $system }}{{ $system }}
{{ $system = "" }} {{ end }}{{ if .Prompt }}USER: {{ .Prompt }}
{{- end }}USER: {{ .Content }} {{ end }}ASSISTANT: {{ .Response }}</s>
{{ else if eq .Role "assistant" }}ASSISTANT: {{ .Content }}</s>
{{ end }}
{{- end }}ASSISTANT:

View file

@ -1,3 +1,6 @@
{{- range .Messages }}<|{{ .Role }}|> {{ if .System }}<|system|>
{{ .Content }}</s> {{ .System }}</s>
{{ end }}{{ if .Prompt }}<|user|>
{{ .Prompt }}</s>
{{ end }}<|assistant|> {{ end }}<|assistant|>
{{ .Response }}</s>