diff --git a/Makefile b/Makefile index 97e9d8a..3b9092b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BINARY_NAME=local-ai # renovate: datasource=github-tags depName=go-skynet/go-llama.cpp GOLLAMA_VERSION?=llama.cpp-7f15c5c # renovate: datasource=git-refs packageNameTemplate=https://github.com/go-skynet/go-gpt4all-j.cpp currentValueTemplate=master depNameTemplate=go-gpt4all-j.cpp -GOGPT4ALLJ_VERSION?=1f7bff57f66cb7062e40d0ac3abd2217815e5109 +GOGPT4ALLJ_VERSION?=d57834a2d24e8be64c78b9496a870d18393066fd # renovate: datasource=git-refs packageNameTemplate=https://github.com/go-skynet/go-gpt2.cpp currentValueTemplate=master depNameTemplate=go-gpt2.cpp GOGPT2_VERSION?=245a5bfe6708ab80dc5c733dcdbfbe3cfd2acdaa @@ -58,7 +58,7 @@ go-gpt4all-j: @find ./go-gpt4all-j -type f -name "*.cpp" -exec sed -i'' -e 's/::replace/::json_gptj_replace/g' {} + go-gpt4all-j/libgptj.a: go-gpt4all-j - $(MAKE) -C go-gpt4all-j $(GENERIC_PREFIX)libgptj.a + $(MAKE) -C go-gpt4all-j $(GENERIC_PREFIX)libgptj.a example # CEREBRAS GPT go-gpt2: diff --git a/api/prediction.go b/api/prediction.go index 65cfce9..393c7de 100644 --- a/api/prediction.go +++ b/api/prediction.go @@ -37,7 +37,7 @@ func ModelInference(s string, loader *model.ModelLoader, c Config) (func() (stri // TODO: this is ugly, better identifying the model somehow! however, it is a good stab for a first implementation.. model, llamaerr = loader.LoadLLaMAModel(modelFile, llamaOpts...) if llamaerr != nil { - gptModel, gptjerr = loader.LoadGPTJModel(modelFile) + gptModel, gptjerr = loader.LoadGPTJModel(modelFile, gptj.SetThreads(c.Threads)) if gptjerr != nil { gpt2Model, gpt2err = loader.LoadGPT2Model(modelFile) if gpt2err != nil { @@ -108,17 +108,12 @@ func ModelInference(s string, loader *model.ModelLoader, c Config) (func() (stri gptj.SetTopP(c.TopP), gptj.SetTopK(c.TopK), gptj.SetTokens(c.Maxtokens), - gptj.SetThreads(c.Threads), } if c.Batch != 0 { predictOptions = append(predictOptions, gptj.SetBatch(c.Batch)) } - if c.Seed != 0 { - predictOptions = append(predictOptions, gptj.SetSeed(c.Seed)) - } - return gptModel.Predict( s, predictOptions..., diff --git a/go.mod b/go.mod index da59e65..f450534 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/go-skynet/go-gpt2.cpp v0.0.0-20230422085954-245a5bfe6708 - github.com/go-skynet/go-gpt4all-j.cpp v0.0.0-20230422090028-1f7bff57f66c + github.com/go-skynet/go-gpt4all-j.cpp v0.0.0-20230501160437-8417608f0e94 github.com/go-skynet/go-llama.cpp v0.0.0-20230430075552-377fd245eae2 github.com/gofiber/fiber/v2 v2.44.0 github.com/jaypipes/ghw v0.10.0 diff --git a/go.sum b/go.sum index ce69a46..06aa68d 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,7 @@ github.com/go-skynet/go-gpt2.cpp v0.0.0-20230422085954-245a5bfe6708 h1:cfOi4TWvQ github.com/go-skynet/go-gpt2.cpp v0.0.0-20230422085954-245a5bfe6708/go.mod h1:1Wj/xbkMfwQSOrhNYK178IzqQHstZbRfhx4s8p1M5VM= github.com/go-skynet/go-gpt4all-j.cpp v0.0.0-20230422090028-1f7bff57f66c h1:48I7jpLNGiQeBmF0SFVVbREh8vlG0zN13v9LH5ctXis= github.com/go-skynet/go-gpt4all-j.cpp v0.0.0-20230422090028-1f7bff57f66c/go.mod h1:5VZ9XbcINI0XcHhkcX8GPK8TplFGAzu1Hrg4tNiMCtI= +github.com/go-skynet/go-gpt4all-j.cpp v0.0.0-20230501160437-8417608f0e94/go.mod h1:5VZ9XbcINI0XcHhkcX8GPK8TplFGAzu1Hrg4tNiMCtI= github.com/go-skynet/go-llama.cpp v0.0.0-20230428071219-3d084e4299e9 h1:N/0SBefkMFao6GiGhIF7+5EdYOMHn4KnCG2AFcIXPt0= github.com/go-skynet/go-llama.cpp v0.0.0-20230428071219-3d084e4299e9/go.mod h1:35AKIEMY+YTKCBJIa/8GZcNGJ2J+nQk1hQiWo/OnEWw= github.com/go-skynet/go-llama.cpp v0.0.0-20230429125915-9bf702fe56b9 h1:20/tdOA4+b7Y7lCob+q2sczfOSz0pp+14L32adYJ+uQ= diff --git a/pkg/model/loader.go b/pkg/model/loader.go index 6b1539c..0468a54 100644 --- a/pkg/model/loader.go +++ b/pkg/model/loader.go @@ -193,7 +193,7 @@ func (ml *ModelLoader) LoadGPT2Model(modelName string) (*gpt2.GPT2, error) { return model, err } -func (ml *ModelLoader) LoadGPTJModel(modelName string) (*gptj.GPTJ, error) { +func (ml *ModelLoader) LoadGPTJModel(modelName string, opts ...gptj.ModelOption) (*gptj.GPTJ, error) { ml.mu.Lock() defer ml.mu.Unlock() @@ -222,7 +222,7 @@ func (ml *ModelLoader) LoadGPTJModel(modelName string) (*gptj.GPTJ, error) { modelFile := filepath.Join(ml.ModelPath, modelName) log.Debug().Msgf("Loading model in memory from file: %s", modelFile) - model, err := gptj.New(modelFile) + model, err := gptj.New(modelFile, opts...) if err != nil { return nil, err }