Compare commits
7 Commits
v0.0.18
...
format-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23481167a7 | ||
|
|
07b4074e7b | ||
|
|
61dda6a5e0 | ||
|
|
e1f9ced568 | ||
|
|
9795b43d93 | ||
|
|
0980d5c7e3 | ||
|
|
0dae34b6a7 |
@@ -1,8 +1,4 @@
|
|||||||
build
|
|
||||||
llama/build
|
|
||||||
.venv
|
|
||||||
.vscode
|
.vscode
|
||||||
ollama
|
ollama
|
||||||
app
|
app
|
||||||
web
|
llm/llama.cpp/ggml
|
||||||
.env
|
|
||||||
|
|||||||
18
Dockerfile
18
Dockerfile
@@ -1,15 +1,21 @@
|
|||||||
FROM golang:1.20
|
FROM golang:alpine
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/jmorganca/ollama
|
WORKDIR /go/src/github.com/jmorganca/ollama
|
||||||
|
RUN apk add --no-cache git build-base cmake
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=1 go build -ldflags '-linkmode external -extldflags "-static"' .
|
RUN go generate ./... && go build -ldflags '-linkmode external -extldflags "-static"' .
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
COPY --from=0 /go/src/github.com/jmorganca/ollama/ollama /bin/ollama
|
ENV OLLAMA_HOST 0.0.0.0
|
||||||
EXPOSE 11434
|
RUN apk add --no-cache libstdc++
|
||||||
|
|
||||||
ARG USER=ollama
|
ARG USER=ollama
|
||||||
ARG GROUP=ollama
|
ARG GROUP=ollama
|
||||||
RUN addgroup -g 1000 $GROUP && adduser -u 1000 -DG $GROUP $USER
|
RUN addgroup $GROUP && adduser -D -G $GROUP $USER
|
||||||
|
|
||||||
|
COPY --from=0 /go/src/github.com/jmorganca/ollama/ollama /bin/ollama
|
||||||
|
|
||||||
USER $USER:$GROUP
|
USER $USER:$GROUP
|
||||||
ENTRYPOINT ["/bin/ollama"]
|
ENTRYPOINT ["/bin/ollama"]
|
||||||
ENV OLLAMA_HOST 0.0.0.0
|
|
||||||
CMD ["serve"]
|
CMD ["serve"]
|
||||||
|
|||||||
@@ -165,10 +165,11 @@ Ollama bundles model weights, configurations, and data into a single package, de
|
|||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Install `cmake`:
|
Install `cmake` and `go`:
|
||||||
|
|
||||||
```
|
```
|
||||||
brew install cmake
|
brew install cmake
|
||||||
|
brew install go
|
||||||
```
|
```
|
||||||
|
|
||||||
Then generate dependencies and build:
|
Then generate dependencies and build:
|
||||||
|
|||||||
@@ -10,15 +10,11 @@ package format
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/ecdsa"
|
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/elliptic"
|
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
)
|
)
|
||||||
@@ -41,25 +37,6 @@ type openSSHPrivateKey struct {
|
|||||||
Rest []byte `ssh:"rest"`
|
Rest []byte `ssh:"rest"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type openSSHRSAPrivateKey struct {
|
|
||||||
N *big.Int
|
|
||||||
E *big.Int
|
|
||||||
D *big.Int
|
|
||||||
Iqmp *big.Int
|
|
||||||
P *big.Int
|
|
||||||
Q *big.Int
|
|
||||||
Comment string
|
|
||||||
Pad []byte `ssh:"rest"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type openSSHECDSAPrivateKey struct {
|
|
||||||
Curve string
|
|
||||||
Pub []byte
|
|
||||||
D *big.Int
|
|
||||||
Comment string
|
|
||||||
Pad []byte `ssh:"rest"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type openSSHEd25519PrivateKey struct {
|
type openSSHEd25519PrivateKey struct {
|
||||||
Pub []byte
|
Pub []byte
|
||||||
Priv []byte
|
Priv []byte
|
||||||
@@ -85,64 +62,6 @@ func OpenSSHPrivateKey(key crypto.PrivateKey, comment string) (*pem.Block, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch k := key.(type) {
|
switch k := key.(type) {
|
||||||
case *rsa.PrivateKey:
|
|
||||||
e := new(big.Int).SetInt64(int64(k.E))
|
|
||||||
|
|
||||||
key := openSSHRSAPrivateKey{
|
|
||||||
N: k.N,
|
|
||||||
E: e,
|
|
||||||
D: k.D,
|
|
||||||
Iqmp: k.Precomputed.Qinv,
|
|
||||||
P: k.Primes[0],
|
|
||||||
Q: k.Primes[1],
|
|
||||||
Comment: comment,
|
|
||||||
}
|
|
||||||
|
|
||||||
pk1.Keytype = ssh.KeyAlgoRSA
|
|
||||||
pk1.Rest = ssh.Marshal(key)
|
|
||||||
|
|
||||||
w.PubKey = ssh.Marshal(struct {
|
|
||||||
KeyType string
|
|
||||||
E *big.Int
|
|
||||||
N *big.Int
|
|
||||||
}{
|
|
||||||
ssh.KeyAlgoRSA, e, k.N,
|
|
||||||
})
|
|
||||||
case *ecdsa.PrivateKey:
|
|
||||||
var curve, keytype string
|
|
||||||
switch name := k.Curve.Params().Name; name {
|
|
||||||
case "P-256":
|
|
||||||
curve = "nistp256"
|
|
||||||
keytype = ssh.KeyAlgoECDSA256
|
|
||||||
case "P-384":
|
|
||||||
curve = "nistp384"
|
|
||||||
keytype = ssh.KeyAlgoECDSA384
|
|
||||||
case "P-521":
|
|
||||||
curve = "nistp521"
|
|
||||||
keytype = ssh.KeyAlgoECDSA521
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("ssh: unknown curve %q", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub := elliptic.Marshal(k.Curve, k.X, k.Y)
|
|
||||||
|
|
||||||
key := openSSHECDSAPrivateKey{
|
|
||||||
Curve: curve,
|
|
||||||
Pub: pub,
|
|
||||||
D: k.D,
|
|
||||||
Comment: comment,
|
|
||||||
}
|
|
||||||
|
|
||||||
pk1.Keytype = keytype
|
|
||||||
pk1.Rest = ssh.Marshal(key)
|
|
||||||
|
|
||||||
w.PubKey = ssh.Marshal(struct {
|
|
||||||
KeyType string
|
|
||||||
Curve string
|
|
||||||
Pub []byte
|
|
||||||
}{
|
|
||||||
keytype, curve, pub,
|
|
||||||
})
|
|
||||||
case ed25519.PrivateKey:
|
case ed25519.PrivateKey:
|
||||||
pub, priv := k[32:], k
|
pub, priv := k[32:], k
|
||||||
key := openSSHEd25519PrivateKey{
|
key := openSSHEd25519PrivateKey{
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ package llm
|
|||||||
//go:generate git -C ggml apply ../ggml_patch/0002-34B-model-support.patch
|
//go:generate git -C ggml apply ../ggml_patch/0002-34B-model-support.patch
|
||||||
//go:generate git -C ggml apply ../ggml_patch/0003-metal-fix-synchronization-in-new-matrix-multiplicati.patch
|
//go:generate git -C ggml apply ../ggml_patch/0003-metal-fix-synchronization-in-new-matrix-multiplicati.patch
|
||||||
//go:generate git -C ggml apply ../ggml_patch/0004-metal-add-missing-barriers-for-mul-mat-2699.patch
|
//go:generate git -C ggml apply ../ggml_patch/0004-metal-add-missing-barriers-for-mul-mat-2699.patch
|
||||||
//go:generate cmake --fresh -S ggml -B ggml/build/cpu -DLLAMA_ACCELERATE=on -DLLAMA_K_QUANTS=on -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11
|
//go:generate cmake --fresh -S ggml -B ggml/build/cpu -DLLAMA_ACCELERATE=on -DLLAMA_K_QUANTS=on -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
|
||||||
//go:generate cmake --build ggml/build/cpu --target server --config Release
|
//go:generate cmake --build ggml/build/cpu --target server --config Release
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ type LayerReader struct {
|
|||||||
type ConfigV2 struct {
|
type ConfigV2 struct {
|
||||||
ModelFamily llm.ModelFamily `json:"model_family"`
|
ModelFamily llm.ModelFamily `json:"model_family"`
|
||||||
ModelType string `json:"model_type"`
|
ModelType string `json:"model_type"`
|
||||||
|
ModelFormat string `json:"model_format"`
|
||||||
FileType string `json:"file_type"`
|
FileType string `json:"file_type"`
|
||||||
RootFS RootFS `json:"rootfs"`
|
RootFS RootFS `json:"rootfs"`
|
||||||
|
|
||||||
@@ -335,6 +336,7 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
|
|||||||
|
|
||||||
config.ModelFamily = ggml.ModelFamily()
|
config.ModelFamily = ggml.ModelFamily()
|
||||||
config.ModelType = ggml.ModelType().String()
|
config.ModelType = ggml.ModelType().String()
|
||||||
|
config.ModelFormat = ggml.Name()
|
||||||
config.FileType = ggml.FileType().String()
|
config.FileType = ggml.FileType().String()
|
||||||
|
|
||||||
// reset the file
|
// reset the file
|
||||||
@@ -366,9 +368,10 @@ func CreateModel(ctx context.Context, name string, path string, fn func(resp api
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// copie the model metadata
|
// copy the model metadata
|
||||||
config.ModelFamily = source.ModelFamily
|
config.ModelFamily = source.ModelFamily
|
||||||
config.ModelType = source.ModelType
|
config.ModelType = source.ModelType
|
||||||
|
config.ModelFormat = source.ModelFormat
|
||||||
config.FileType = source.FileType
|
config.FileType = source.FileType
|
||||||
|
|
||||||
for _, l := range mf.Layers {
|
for _, l := range mf.Layers {
|
||||||
|
|||||||
Reference in New Issue
Block a user