2023-04-15 23:39:07 +00:00
GOCMD = go
GOTEST = $( GOCMD) test
GOVET = $( GOCMD) vet
2023-04-19 16:43:10 +00:00
BINARY_NAME = local-ai
2023-05-04 10:26:59 +00:00
2023-07-04 17:02:02 +00:00
# llama.cpp versions
# Temporarly pinned to https://github.com/go-skynet/go-llama.cpp/pull/124
2023-07-04 16:56:45 +00:00
GOLLAMA_VERSION ?= cb8d7cd4cb95725a04504a9e3a26dd72a12b69ac
2023-07-04 17:02:02 +00:00
2023-07-04 16:56:45 +00:00
# Temporary set a specific version of llama.cpp
2023-07-04 17:02:02 +00:00
# containing: https://github.com/ggerganov/llama.cpp/pull/1773 and
# rebased on top of master.
# This pin can be dropped when the PR above is merged, and go-llama has merged changes as well
# Set empty to use the version pinned by go-llama
2023-07-04 16:56:45 +00:00
LLAMA_CPP_REPO ?= https://github.com/mudler/llama.cpp
LLAMA_CPP_VERSION ?= 48ce8722a05a018681634af801fd0fd45b3a87cc
2023-07-04 17:02:02 +00:00
# gpt4all version
2023-06-14 16:07:05 +00:00
GPT4ALL_REPO ?= https://github.com/nomic-ai/gpt4all
2023-06-30 08:30:39 +00:00
GPT4ALL_VERSION ?= 70cbff70cc2a9ad26d492d44ab582d32e6219956
2023-07-04 17:02:02 +00:00
# go-ggml-transformers version
2023-06-27 21:54:51 +00:00
GOGGMLTRANSFORMERS_VERSION ?= 8e31841dcddca16468c11b2e7809f279fa76a832
2023-07-04 17:02:02 +00:00
# go-rwkv version
2023-06-04 15:25:35 +00:00
RWKV_REPO ?= https://github.com/donomii/go-rwkv.cpp
2023-06-21 06:57:15 +00:00
RWKV_VERSION ?= f5a8c45396741470583f59b916a2a7641e63bcd0
2023-07-04 17:02:02 +00:00
# whisper.cpp version
2023-06-28 21:42:57 +00:00
WHISPER_CPP_VERSION ?= 85ed71aaec8e0612a84c0b67804bde75aa75a273
2023-07-04 17:02:02 +00:00
# bert.cpp version
2023-06-09 22:09:14 +00:00
BERT_VERSION ?= 6069103f54b9969c02e789d0fb12a23bd614285f
2023-07-04 17:02:02 +00:00
# go-piper version
2023-06-22 15:53:10 +00:00
PIPER_VERSION ?= 56b8a81b4760a6fbee1a82e62f007ae7e8f010a7
2023-07-04 17:02:02 +00:00
# go-bloomz version
2023-05-29 21:09:42 +00:00
BLOOMZ_VERSION ?= 1834e77b83faafe912ad4092ccf7f77937349e2f
2023-07-04 17:02:02 +00:00
# stablediffusion version
STABLEDIFFUSION_VERSION ?= d89260f598afb809279bc72aa0107b4292587632
2023-06-05 12:26:20 +00:00
export BUILD_TYPE ?=
2023-05-16 14:26:25 +00:00
CGO_LDFLAGS ?=
CUDA_LIBPATH ?= /usr/local/cuda/lib64/
2023-05-16 17:32:53 +00:00
GO_TAGS ?=
2023-05-23 15:12:48 +00:00
BUILD_ID ?= git
2023-06-26 13:12:43 +00:00
2023-07-02 09:14:09 +00:00
VERSION ?= $( shell git describe --always --tags || echo "dev" )
2023-06-26 13:12:43 +00:00
# go tool nm ./local-ai | grep Commit
2023-06-22 15:53:10 +00:00
LD_FLAGS ?=
2023-06-26 13:12:43 +00:00
o v e r r i d e LD_FLAGS += -X " github.com/go-skynet/LocalAI/internal.Version= $( VERSION) "
o v e r r i d e LD_FLAGS += -X " github.com/go-skynet/LocalAI/internal.Commit= $( shell git rev-parse HEAD) "
2023-05-16 17:32:53 +00:00
OPTIONAL_TARGETS ?=
2023-06-22 15:53:10 +00:00
ESPEAK_DATA ?=
2023-05-03 09:45:22 +00:00
2023-05-23 15:12:48 +00:00
OS := $( shell uname -s)
ARCH := $( shell uname -m)
2023-04-15 23:39:07 +00:00
GREEN := $( shell tput -Txterm setaf 2)
YELLOW := $( shell tput -Txterm setaf 3)
WHITE := $( shell tput -Txterm setaf 7)
CYAN := $( shell tput -Txterm setaf 6)
RESET := $( shell tput -Txterm sgr0)
2023-05-23 19:47:47 +00:00
C_INCLUDE_PATH = $( shell pwd ) /go-llama:$( shell pwd ) /go-stable-diffusion/:$( shell pwd ) /gpt4all/gpt4all-bindings/golang/:$( shell pwd ) /go-ggml-transformers:$( shell pwd ) /go-rwkv:$( shell pwd ) /whisper.cpp:$( shell pwd ) /go-bert:$( shell pwd ) /bloomz
2023-06-22 15:53:10 +00:00
LIBRARY_PATH = $( shell pwd ) /go-piper:$( shell pwd ) /go-llama:$( shell pwd ) /go-stable-diffusion/:$( shell pwd ) /gpt4all/gpt4all-bindings/golang/:$( shell pwd ) /go-ggml-transformers:$( shell pwd ) /go-rwkv:$( shell pwd ) /whisper.cpp:$( shell pwd ) /go-bert:$( shell pwd ) /bloomz
2023-04-21 22:29:32 +00:00
2023-05-16 14:26:25 +00:00
i f e q ( $( BUILD_TYPE ) , o p e n b l a s )
CGO_LDFLAGS += -lopenblas
2023-04-21 22:29:32 +00:00
e n d i f
2023-05-16 14:26:25 +00:00
i f e q ( $( BUILD_TYPE ) , c u b l a s )
CGO_LDFLAGS += -lcublas -lcudart -L$( CUDA_LIBPATH)
2023-05-19 15:11:28 +00:00
export LLAMA_CUBLAS = 1
2023-04-21 22:29:32 +00:00
e n d i f
2023-06-05 12:26:20 +00:00
i f e q ( $( BUILD_TYPE ) , m e t a l )
CGO_LDFLAGS += -framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders
export LLAMA_METAL = 1
e n d i f
2023-05-29 13:17:38 +00:00
i f e q ( $( BUILD_TYPE ) , c l b l a s )
CGO_LDFLAGS += -lOpenCL -lclblast
e n d i f
2023-05-24 14:42:24 +00:00
# glibc-static or glibc-devel-static required
i f e q ( $( STATIC ) , t r u e )
LD_FLAGS = -linkmode external -extldflags -static
e n d i f
2023-06-22 15:53:10 +00:00
i f e q ( $( findstring stablediffusion ,$ ( GO_TAGS ) ) , s t a b l e d i f f u s i o n )
2023-05-16 17:32:53 +00:00
OPTIONAL_TARGETS += go-stable-diffusion/libstablediffusion.a
e n d i f
2023-06-22 15:53:10 +00:00
i f e q ( $( findstring tts ,$ ( GO_TAGS ) ) , t t s )
OPTIONAL_TARGETS += go-piper/libpiper_binding.a
OPTIONAL_TARGETS += backend-assets/espeak-ng-data
e n d i f
2023-04-15 23:39:07 +00:00
.PHONY : all test build vendor
all : help
2023-05-11 12:31:19 +00:00
## GPT4ALL
gpt4all :
git clone --recurse-submodules $( GPT4ALL_REPO) gpt4all
cd gpt4all && git checkout -b build $( GPT4ALL_VERSION) && git submodule update --init --recursive --depth 1
2023-04-21 22:29:32 +00:00
# This is hackish, but needed as both go-llama and go-gpt4allj have their own version of ggml..
2023-06-01 21:38:52 +00:00
@find ./gpt4all -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_gpt4all_/g' { } +
@find ./gpt4all -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_gpt4all_/g' { } +
2023-06-14 11:24:53 +00:00
@find ./gpt4all -type f -name "*.m" -exec sed -i'' -e 's/ggml_/ggml_gpt4all_/g' { } +
2023-06-01 21:38:52 +00:00
@find ./gpt4all -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_gpt4all_/g' { } +
2023-06-05 12:26:20 +00:00
@find ./gpt4all -type f -name "*.c" -exec sed -i'' -e 's/llama_/llama_gpt4all_/g' { } +
@find ./gpt4all -type f -name "*.cpp" -exec sed -i'' -e 's/llama_/llama_gpt4all_/g' { } +
@find ./gpt4all -type f -name "*.h" -exec sed -i'' -e 's/llama_/llama_gpt4all_/g' { } +
@find ./gpt4all/gpt4all-backend -type f -name "llama_util.h" -execdir mv { } "llama_gpt4all_util.h" \;
@find ./gpt4all -type f -name "*.cmake" -exec sed -i'' -e 's/llama_util/llama_gpt4all_util/g' { } +
@find ./gpt4all -type f -name "*.txt" -exec sed -i'' -e 's/llama_util/llama_gpt4all_util/g' { } +
2023-06-01 21:38:52 +00:00
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.cpp" -exec sed -i'' -e 's/load_model/load_gpt4all_model/g' { } +
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.go" -exec sed -i'' -e 's/load_model/load_gpt4all_model/g' { } +
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.h" -exec sed -i'' -e 's/load_model/load_gpt4all_model/g' { } +
2023-07-02 22:17:48 +00:00
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.h" -exec sed -i'' -e 's/set_numa_thread_affinity/gpt4all_set_numa_thread_affinity/g' { } +
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.c" -exec sed -i'' -e 's/set_numa_thread_affinity/gpt4all__set_numa_thread_affinity/g' { } +
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.c" -exec sed -i'' -e 's/clear_numa_thread_affinity/gpt4all__clear_numa_thread_affinity/g' { } +
@find ./gpt4all/gpt4all-bindings/golang -type f -name "*.h" -exec sed -i'' -e 's/clear_numa_thread_affinity/gpt4all__clear_numa_thread_affinity/g' { } +
2023-06-01 21:38:52 +00:00
2023-06-22 15:53:10 +00:00
## go-piper
go-piper :
git clone --recurse-submodules https://github.com/mudler/go-piper go-piper
cd go-piper && git checkout -b build $( PIPER_VERSION) && git submodule update --init --recursive --depth 1
2023-04-19 15:10:29 +00:00
2023-05-10 13:20:21 +00:00
## BERT embeddings
go-bert :
git clone --recurse-submodules https://github.com/go-skynet/go-bert.cpp go-bert
cd go-bert && git checkout -b build $( BERT_VERSION) && git submodule update --init --recursive --depth 1
@find ./go-bert -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_bert_/g' { } +
@find ./go-bert -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_bert_/g' { } +
@find ./go-bert -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_bert_/g' { } +
2023-05-16 17:32:53 +00:00
## stable diffusion
go-stable-diffusion :
git clone --recurse-submodules https://github.com/mudler/go-stable-diffusion go-stable-diffusion
cd go-stable-diffusion && git checkout -b build $( STABLEDIFFUSION_VERSION) && git submodule update --init --recursive --depth 1
go-stable-diffusion/libstablediffusion.a :
$( MAKE) -C go-stable-diffusion libstablediffusion.a
2023-05-03 09:45:22 +00:00
## RWKV
go-rwkv :
git clone --recurse-submodules $( RWKV_REPO) go-rwkv
cd go-rwkv && git checkout -b build $( RWKV_VERSION) && git submodule update --init --recursive --depth 1
2023-05-05 09:20:06 +00:00
@find ./go-rwkv -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_rwkv_/g' { } +
@find ./go-rwkv -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_rwkv_/g' { } +
@find ./go-rwkv -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_rwkv_/g' { } +
2023-05-03 09:45:22 +00:00
go-rwkv/librwkv.a : go -rwkv
2023-06-02 06:53:57 +00:00
cd go-rwkv && cd rwkv.cpp && cmake . -DRWKV_BUILD_SHARED_LIBRARY= OFF && cmake --build . && cp librwkv.a ..
2023-05-03 09:45:22 +00:00
2023-05-10 23:12:58 +00:00
## bloomz
bloomz :
git clone --recurse-submodules https://github.com/go-skynet/bloomz.cpp bloomz
@find ./bloomz -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_bloomz_/g' { } +
@find ./bloomz -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_bloomz_/g' { } +
@find ./bloomz -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_bloomz_/g' { } +
@find ./bloomz -type f -name "*.cpp" -exec sed -i'' -e 's/gpt_/gpt_bloomz_/g' { } +
@find ./bloomz -type f -name "*.h" -exec sed -i'' -e 's/gpt_/gpt_bloomz_/g' { } +
2023-05-29 13:17:38 +00:00
@find ./bloomz -type f -name "*.cpp" -exec sed -i'' -e 's/void replace/void json_bloomz_replace/g' { } +
@find ./bloomz -type f -name "*.cpp" -exec sed -i'' -e 's/::replace/::json_bloomz_replace/g' { } +
2023-05-10 23:12:58 +00:00
bloomz/libbloomz.a : bloomz
cd bloomz && make libbloomz.a
2023-05-10 13:20:21 +00:00
go-bert/libgobert.a : go -bert
$( MAKE) -C go-bert libgobert.a
2023-06-01 21:38:52 +00:00
backend-assets/gpt4all : gpt 4all /gpt 4all -bindings /golang /libgpt 4all .a
mkdir -p backend-assets/gpt4all
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.so backend-assets/gpt4all/ || true
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dylib backend-assets/gpt4all/ || true
@cp gpt4all/gpt4all-bindings/golang/buildllm/*.dll backend-assets/gpt4all/ || true
2023-06-22 15:53:10 +00:00
backend-assets/espeak-ng-data :
mkdir -p backend-assets/espeak-ng-data
i f d e f E S P E A K _ D A T A
@cp -rf $( ESPEAK_DATA) /. backend-assets/espeak-ng-data
e l s e
@touch backend-assets/espeak-ng-data/keep
e n d i f
2023-05-11 12:31:19 +00:00
gpt4all/gpt4all-bindings/golang/libgpt4all.a : gpt 4all
2023-05-16 14:26:25 +00:00
$( MAKE) -C gpt4all/gpt4all-bindings/golang/ libgpt4all.a
2023-04-15 23:39:07 +00:00
2023-05-03 09:45:22 +00:00
## CEREBRAS GPT
2023-06-26 20:34:03 +00:00
go-ggml-transformers :
2023-05-23 19:47:47 +00:00
git clone --recurse-submodules https://github.com/go-skynet/go-ggml-transformers.cpp go-ggml-transformers
cd go-ggml-transformers && git checkout -b build $( GOGPT2_VERSION) && git submodule update --init --recursive --depth 1
2023-04-21 22:29:32 +00:00
# This is hackish, but needed as both go-llama and go-gpt4allj have their own version of ggml..
2023-05-23 19:47:47 +00:00
@find ./go-ggml-transformers -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_gpt2_/g' { } +
@find ./go-ggml-transformers -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_gpt2_/g' { } +
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_gpt2_/g' { } +
@find ./go-ggml-transformers -type f -name "*.cpp" -exec sed -i'' -e 's/gpt_print_usage/gpt2_print_usage/g' { } +
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/gpt_print_usage/gpt2_print_usage/g' { } +
@find ./go-ggml-transformers -type f -name "*.cpp" -exec sed -i'' -e 's/gpt_params_parse/gpt2_params_parse/g' { } +
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/gpt_params_parse/gpt2_params_parse/g' { } +
@find ./go-ggml-transformers -type f -name "*.cpp" -exec sed -i'' -e 's/gpt_random_prompt/gpt2_random_prompt/g' { } +
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/gpt_random_prompt/gpt2_random_prompt/g' { } +
@find ./go-ggml-transformers -type f -name "*.cpp" -exec sed -i'' -e 's/json_/json_gpt2_/g' { } +
2023-07-02 22:17:48 +00:00
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/set_numa_thread_affinity/transformers_set_numa_thread_affinity/g' { } +
@find ./go-ggml-transformers -type f -name "*.c" -exec sed -i'' -e 's/set_numa_thread_affinity/transformers_set_numa_thread_affinity/g' { } +
@find ./go-ggml-transformers -type f -name "*.c" -exec sed -i'' -e 's/clear_numa_thread_affinity/transformers_clear_numa_thread_affinity/g' { } +
@find ./go-ggml-transformers -type f -name "*.h" -exec sed -i'' -e 's/clear_numa_thread_affinity/transformers_clear_numa_thread_affinity/g' { } +
2023-05-23 19:47:47 +00:00
go-ggml-transformers/libtransformers.a : go -ggml -transformers
$( MAKE) -C go-ggml-transformers libtransformers.a
2023-04-20 17:33:36 +00:00
2023-05-09 09:43:50 +00:00
whisper.cpp :
git clone https://github.com/ggerganov/whisper.cpp.git
cd whisper.cpp && git checkout -b build $( WHISPER_CPP_VERSION) && git submodule update --init --recursive --depth 1
2023-05-14 23:00:16 +00:00
@find ./whisper.cpp -type f -name "*.c" -exec sed -i'' -e 's/ggml_/ggml_whisper_/g' { } +
@find ./whisper.cpp -type f -name "*.cpp" -exec sed -i'' -e 's/ggml_/ggml_whisper_/g' { } +
@find ./whisper.cpp -type f -name "*.h" -exec sed -i'' -e 's/ggml_/ggml_whisper_/g' { } +
2023-05-09 09:43:50 +00:00
whisper.cpp/libwhisper.a : whisper .cpp
cd whisper.cpp && make libwhisper.a
2023-04-15 23:39:07 +00:00
go-llama :
2023-05-04 09:55:14 +00:00
git clone --recurse-submodules https://github.com/go-skynet/go-llama.cpp go-llama
cd go-llama && git checkout -b build $( GOLLAMA_VERSION) && git submodule update --init --recursive --depth 1
2023-07-04 16:56:45 +00:00
i f n e q ( $( LLAMA_CPP_REPO ) , )
cd go-llama && rm -rf llama.cpp && git clone $( LLAMA_CPP_REPO) llama.cpp && cd llama.cpp && git checkout -b build $( LLAMA_CPP_VERSION) && git submodule update --init --recursive --depth 1
e n d i f
2023-04-19 15:10:29 +00:00
2023-06-26 20:34:03 +00:00
go-llama/libbinding.a : go -llama
2023-05-16 14:26:25 +00:00
$( MAKE) -C go-llama BUILD_TYPE = $( BUILD_TYPE) libbinding.a
2023-04-19 15:10:29 +00:00
2023-06-22 15:53:10 +00:00
go-piper/libpiper_binding.a :
$( MAKE) -C go-piper libpiper_binding.a example/main
2023-06-26 20:34:03 +00:00
get-sources : go -llama go -ggml -transformers gpt 4all go -piper go -rwkv whisper .cpp go -bert bloomz go -stable -diffusion
touch $@
2023-04-20 17:33:36 +00:00
replace :
2023-04-19 15:10:29 +00:00
$( GOCMD) mod edit -replace github.com/go-skynet/go-llama.cpp= $( shell pwd ) /go-llama
2023-05-16 17:32:53 +00:00
$( GOCMD) mod edit -replace github.com/nomic-ai/gpt4all/gpt4all-bindings/golang= $( shell pwd ) /gpt4all/gpt4all-bindings/golang
2023-05-23 19:47:47 +00:00
$( GOCMD) mod edit -replace github.com/go-skynet/go-ggml-transformers.cpp= $( shell pwd ) /go-ggml-transformers
2023-05-03 09:45:22 +00:00
$( GOCMD) mod edit -replace github.com/donomii/go-rwkv.cpp= $( shell pwd ) /go-rwkv
2023-05-09 09:43:50 +00:00
$( GOCMD) mod edit -replace github.com/ggerganov/whisper.cpp= $( shell pwd ) /whisper.cpp
2023-05-10 13:20:21 +00:00
$( GOCMD) mod edit -replace github.com/go-skynet/go-bert.cpp= $( shell pwd ) /go-bert
2023-05-10 23:12:58 +00:00
$( GOCMD) mod edit -replace github.com/go-skynet/bloomz.cpp= $( shell pwd ) /bloomz
2023-05-16 17:32:53 +00:00
$( GOCMD) mod edit -replace github.com/mudler/go-stable-diffusion= $( shell pwd ) /go-stable-diffusion
2023-06-22 15:53:10 +00:00
$( GOCMD) mod edit -replace github.com/mudler/go-piper= $( shell pwd ) /go-piper
2023-04-20 17:33:36 +00:00
2023-06-26 20:34:03 +00:00
prepare-sources : get -sources replace
2023-04-29 18:38:37 +00:00
$( GOCMD) mod download
2023-05-03 09:45:22 +00:00
## GENERIC
rebuild : ## Rebuilds the project
2023-07-05 16:24:55 +00:00
$( GOCMD) clean -cache
2023-04-29 18:38:37 +00:00
$( MAKE) -C go-llama clean
2023-05-11 12:31:19 +00:00
$( MAKE) -C gpt4all/gpt4all-bindings/golang/ clean
2023-05-23 19:47:47 +00:00
$( MAKE) -C go-ggml-transformers clean
2023-05-03 09:45:22 +00:00
$( MAKE) -C go-rwkv clean
2023-05-09 09:43:50 +00:00
$( MAKE) -C whisper.cpp clean
2023-05-16 17:32:53 +00:00
$( MAKE) -C go-stable-diffusion clean
2023-05-10 13:20:21 +00:00
$( MAKE) -C go-bert clean
2023-05-10 23:12:58 +00:00
$( MAKE) -C bloomz clean
2023-06-22 15:53:10 +00:00
$( MAKE) -C go-piper clean
2023-04-29 18:38:37 +00:00
$( MAKE) build
2023-06-01 21:38:52 +00:00
prepare : prepare -sources backend -assets /gpt 4all $( OPTIONAL_TARGETS ) go -llama /libbinding .a go -bert /libgobert .a go -ggml -transformers /libtransformers .a go -rwkv /librwkv .a whisper .cpp /libwhisper .a bloomz /libbloomz .a ## Prepares for building
2023-06-26 20:34:03 +00:00
touch $@
2023-04-19 15:10:29 +00:00
2023-04-15 23:39:07 +00:00
clean : ## Remove build related file
2023-07-05 16:24:55 +00:00
$( GOCMD) clean -cache
2023-04-15 23:39:07 +00:00
rm -fr ./go-llama
2023-05-11 12:31:19 +00:00
rm -rf ./gpt4all
2023-05-30 11:01:55 +00:00
rm -rf ./go-gpt2
2023-05-16 17:32:53 +00:00
rm -rf ./go-stable-diffusion
2023-05-23 19:47:47 +00:00
rm -rf ./go-ggml-transformers
2023-06-01 21:38:52 +00:00
rm -rf ./backend-assets
2023-05-03 09:45:22 +00:00
rm -rf ./go-rwkv
2023-05-10 13:20:21 +00:00
rm -rf ./go-bert
2023-05-10 23:12:58 +00:00
rm -rf ./bloomz
2023-05-16 17:32:53 +00:00
rm -rf ./whisper.cpp
2023-06-22 15:53:10 +00:00
rm -rf ./go-piper
2023-04-19 15:10:29 +00:00
rm -rf $( BINARY_NAME)
2023-05-23 15:12:48 +00:00
rm -rf release/
2023-04-15 23:39:07 +00:00
2023-05-03 09:45:22 +00:00
## Build:
build : prepare ## Build the project
$( info ${ GREEN } I local-ai build info:${ RESET } )
$( info ${ GREEN } I BUILD_TYPE: ${ YELLOW } $( BUILD_TYPE) ${ RESET } )
2023-05-16 17:32:53 +00:00
$( info ${ GREEN } I GO_TAGS: ${ YELLOW } $( GO_TAGS) ${ RESET } )
2023-06-26 13:12:43 +00:00
$( info ${ GREEN } I LD_FLAGS: ${ YELLOW } $( LD_FLAGS) ${ RESET } )
2023-05-28 20:59:25 +00:00
CGO_LDFLAGS = " $( CGO_LDFLAGS) " C_INCLUDE_PATH = ${ C_INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } $( GOCMD) build -ldflags " $( LD_FLAGS) " -tags " $( GO_TAGS) " -o $( BINARY_NAME) ./
2023-06-10 23:07:39 +00:00
i f e q ( $( BUILD_TYPE ) , m e t a l )
cp go-llama/build/bin/ggml-metal.metal .
e n d i f
2023-05-03 09:45:22 +00:00
2023-05-23 15:12:48 +00:00
dist : build
mkdir -p release
cp $( BINARY_NAME) release/$( BINARY_NAME) -$( BUILD_ID) -$( OS) -$( ARCH)
2023-05-03 09:45:22 +00:00
generic-build : ## Build the project using generic
BUILD_TYPE = "generic" $( MAKE) build
## Run
run : prepare ## run local-ai
2023-06-02 07:57:01 +00:00
CGO_LDFLAGS = " $( CGO_LDFLAGS) " C_INCLUDE_PATH = ${ C_INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } $( GOCMD) run ./
2023-04-15 23:39:07 +00:00
2023-04-21 22:44:52 +00:00
test-models/testmodel :
mkdir test-models
2023-05-12 08:04:20 +00:00
mkdir test-dir
2023-05-23 19:47:47 +00:00
wget https://huggingface.co/nnakasato/ggml-model-test/resolve/main/ggml-model-q4.bin -O test-models/testmodel
2023-05-12 08:04:20 +00:00
wget https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.en.bin -O test-models/whisper-en
2023-05-12 15:16:49 +00:00
wget https://huggingface.co/skeskinen/ggml/resolve/main/all-MiniLM-L6-v2/ggml-model-q4_0.bin -O test-models/bert
2023-05-12 08:04:20 +00:00
wget https://cdn.openai.com/whisper/draft-20220913a/micro-machines.wav -O test-dir/audio.wav
2023-05-28 20:59:25 +00:00
wget https://huggingface.co/mudler/rwkv-4-raven-1.5B-ggml/resolve/main/RWKV-4-Raven-1B5-v11-Eng99%2525-Other1%2525-20230425-ctx4096_Q4_0.bin -O test-models/rwkv
2023-05-15 06:15:01 +00:00
wget https://raw.githubusercontent.com/saharNooby/rwkv.cpp/5eb8f09c146ea8124633ab041d9ea0b1f1db4459/rwkv/20B_tokenizer.json -O test-models/rwkv.tokenizer.json
2023-05-18 13:59:03 +00:00
cp tests/models_fixtures/* test-models
2023-04-21 22:44:52 +00:00
test : prepare test -models /testmodel
2023-06-05 07:42:50 +00:00
cp -r backend-assets api
2023-05-18 13:59:03 +00:00
cp tests/models_fixtures/* test-models
2023-06-07 22:36:11 +00:00
C_INCLUDE_PATH = ${ C_INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } TEST_DIR = $( abspath ./) /test-dir/ FIXTURES = $( abspath ./) /tests/fixtures CONFIG_FILE = $( abspath ./) /test-models/config.yaml MODELS_PATH = $( abspath ./) /test-models $( GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --label-filter= "!gpt4all && !llama" --flake-attempts 5 -v -r ./api ./pkg
2023-06-05 07:42:50 +00:00
C_INCLUDE_PATH = ${ C_INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } TEST_DIR = $( abspath ./) /test-dir/ FIXTURES = $( abspath ./) /tests/fixtures CONFIG_FILE = $( abspath ./) /test-models/config.yaml MODELS_PATH = $( abspath ./) /test-models $( GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --label-filter= "gpt4all" --flake-attempts 5 -v -r ./api ./pkg
2023-06-07 22:36:11 +00:00
C_INCLUDE_PATH = ${ C_INCLUDE_PATH } LIBRARY_PATH = ${ LIBRARY_PATH } TEST_DIR = $( abspath ./) /test-dir/ FIXTURES = $( abspath ./) /tests/fixtures CONFIG_FILE = $( abspath ./) /test-models/config.yaml MODELS_PATH = $( abspath ./) /test-models $( GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --label-filter= "llama" --flake-attempts 5 -v -r ./api ./pkg
2023-04-15 23:39:07 +00:00
## Help:
help : ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk ' BEGIN { FS = ":.*?## " } { \
if ( /^[ a-zA-Z_-] +:.*?##.*$$ /) { printf " ${ YELLOW } %-20s ${ GREEN } %s ${ RESET } \n " , $$ 1, $$ 2} \
else if ( /^## .*$$ /) { printf " ${ CYAN } %s ${ RESET } \n " , substr( $$ 1,4) } \
2023-04-17 19:34:02 +00:00
} ' $( MAKEFILE_LIST)