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
|
2023-07-30 07:48:10 +00:00
|
|
|
GOLLAMA_VERSION?=8c51308e42d79e8de2553747b23e74f444b02ae2
|
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-07-31 22:48:10 +00:00
|
|
|
GPT4ALL_VERSION?=cbdcde8b75868e145b973725c7c18970091a7f2f
|
2023-07-04 17:02:02 +00:00
|
|
|
|
|
|
|
# go-ggml-transformers version
|
2023-07-16 07:57:16 +00:00
|
|
|
GOGGMLTRANSFORMERS_VERSION?=ffb09d7dd71e2cbc6c5d7d05357d230eea6f369a
|
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-07-15 20:52:45 +00:00
|
|
|
RWKV_VERSION?=c898cd0f62df8f2a7830e53d1d513bef4f6f792b
|
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-07-17 21:58:25 +00:00
|
|
|
BERT_VERSION?=6abe312cded14042f6b7c3cd8edf082713334a4d
|
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-07-14 23:19:43 +00:00
|
|
|
# Go-ggllm
|
|
|
|
GOGGLLM_VERSION?=862477d16eefb0805261c19c9b0d053e3b2b684b
|
|
|
|
|
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
|
|
|
override LD_FLAGS += -X "github.com/go-skynet/LocalAI/internal.Version=$(VERSION)"
|
|
|
|
override 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-07-14 23:19:43 +00:00
|
|
|
ifndef UNAME_S
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# workaround for rwkv.cpp
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
CGO_LDFLAGS += -lcblas -framework Accelerate
|
|
|
|
endif
|
|
|
|
|
2023-05-16 14:26:25 +00:00
|
|
|
ifeq ($(BUILD_TYPE),openblas)
|
|
|
|
CGO_LDFLAGS+=-lopenblas
|
2023-04-21 22:29:32 +00:00
|
|
|
endif
|
|
|
|
|
2023-05-16 14:26:25 +00:00
|
|
|
ifeq ($(BUILD_TYPE),cublas)
|
|
|
|
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
|
|
|
endif
|
|
|
|
|
2023-06-05 12:26:20 +00:00
|
|
|
ifeq ($(BUILD_TYPE),metal)
|
|
|
|
CGO_LDFLAGS+=-framework Foundation -framework Metal -framework MetalKit -framework MetalPerformanceShaders
|
|
|
|
export LLAMA_METAL=1
|
|
|
|
endif
|
|
|
|
|
2023-05-29 13:17:38 +00:00
|
|
|
ifeq ($(BUILD_TYPE),clblas)
|
|
|
|
CGO_LDFLAGS+=-lOpenCL -lclblast
|
|
|
|
endif
|
|
|
|
|
2023-05-24 14:42:24 +00:00
|
|
|
# glibc-static or glibc-devel-static required
|
|
|
|
ifeq ($(STATIC),true)
|
|
|
|
LD_FLAGS=-linkmode external -extldflags -static
|
|
|
|
endif
|
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
ifeq ($(findstring stablediffusion,$(GO_TAGS)),stablediffusion)
|
2023-07-14 23:19:43 +00:00
|
|
|
# OPTIONAL_TARGETS+=go-stable-diffusion/libstablediffusion.a
|
2023-07-14 23:19:43 +00:00
|
|
|
OPTIONAL_GRPC+=backend-assets/grpc/stablediffusion
|
2023-05-16 17:32:53 +00:00
|
|
|
endif
|
|
|
|
|
2023-06-22 15:53:10 +00:00
|
|
|
ifeq ($(findstring tts,$(GO_TAGS)),tts)
|
2023-07-14 23:19:43 +00:00
|
|
|
# OPTIONAL_TARGETS+=go-piper/libpiper_binding.a
|
|
|
|
# OPTIONAL_TARGETS+=backend-assets/espeak-ng-data
|
2023-07-14 23:19:43 +00:00
|
|
|
OPTIONAL_GRPC+=backend-assets/grpc/piper
|
2023-06-22 15:53:10 +00:00
|
|
|
endif
|
|
|
|
|
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-06-01 21:38:52 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
## go-ggllm
|
|
|
|
go-ggllm:
|
|
|
|
git clone --recurse-submodules https://github.com/mudler/go-ggllm.cpp go-ggllm
|
|
|
|
cd go-ggllm && git checkout -b build $(GOGGLLM_VERSION) && git submodule update --init --recursive --depth 1
|
|
|
|
|
|
|
|
go-ggllm/libggllm.a: go-ggllm
|
|
|
|
$(MAKE) -C go-ggllm BUILD_TYPE=$(BUILD_TYPE) libggllm.a
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2023-07-14 23:19:43 +00:00
|
|
|
cd bloomz && git checkout -b build $(BLOOMZ_VERSION) && git submodule update --init --recursive --depth 1
|
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: gpt4all/gpt4all-bindings/golang/libgpt4all.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
|
|
|
|
ifdef ESPEAK_DATA
|
|
|
|
@cp -rf $(ESPEAK_DATA)/. backend-assets/espeak-ng-data
|
|
|
|
else
|
2023-07-14 23:19:43 +00:00
|
|
|
@echo "ESPEAK_DATA not set, skipping tts. Note that this will break the tts functionality."
|
2023-06-22 15:53:10 +00:00
|
|
|
@touch backend-assets/espeak-ng-data/keep
|
|
|
|
endif
|
|
|
|
|
2023-05-11 12:31:19 +00:00
|
|
|
gpt4all/gpt4all-bindings/golang/libgpt4all.a: gpt4all
|
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
|
|
|
|
|
|
|
|
go-ggml-transformers/libtransformers.a: go-ggml-transformers
|
2023-07-18 17:04:19 +00:00
|
|
|
$(MAKE) -C go-ggml-transformers BUILD_TYPE=$(BUILD_TYPE) 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
|
|
|
|
|
|
|
|
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-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-07-25 17:05:27 +00:00
|
|
|
get-sources: go-llama go-ggllm go-ggml-transformers gpt4all go-piper go-rwkv whisper.cpp go-bert bloomz go-stable-diffusion
|
2023-06-26 20:34:03 +00:00
|
|
|
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-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) mod edit -replace github.com/mudler/go-ggllm.cpp=$(shell pwd)/go-ggllm
|
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-07-14 23:19:43 +00:00
|
|
|
$(MAKE) -C go-ggllm clean
|
2023-04-29 18:38:37 +00:00
|
|
|
$(MAKE) build
|
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
prepare: prepare-sources $(OPTIONAL_TARGETS)
|
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-07-25 21:02:46 +00:00
|
|
|
rm -f prepare
|
|
|
|
rm -rf ./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-07-14 23:19:43 +00:00
|
|
|
rm -rf ./go-ggllm
|
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:
|
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
build: grpcs prepare ## Build the project
|
2023-05-03 09:45:22 +00:00
|
|
|
$(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-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o $(BINARY_NAME) ./
|
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
|
|
|
## Run
|
|
|
|
run: prepare ## run local-ai
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" $(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
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
prepare-test: grpcs
|
2023-07-14 23:19:43 +00:00
|
|
|
cp -rf backend-assets api
|
2023-05-18 13:59:03 +00:00
|
|
|
cp tests/models_fixtures/* test-models
|
2023-07-14 23:19:43 +00:00
|
|
|
|
|
|
|
test: prepare test-models/testmodel grpcs
|
|
|
|
@echo 'Running tests'
|
|
|
|
export GO_TAGS="tts stablediffusion"
|
|
|
|
$(MAKE) prepare-test
|
2023-07-20 20:10:42 +00:00
|
|
|
HUGGINGFACE_GRPC=$(abspath ./)/extra/grpc/huggingface/huggingface.py TEST_DIR=$(abspath ./)/test-dir/ FIXTURES=$(abspath ./)/tests/fixtures CONFIG_FILE=$(abspath ./)/test-models/config.yaml MODELS_PATH=$(abspath ./)/test-models \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) run github.com/onsi/ginkgo/v2/ginkgo --label-filter="!gpt4all && !llama" --flake-attempts 5 -v -r ./api ./pkg
|
|
|
|
$(MAKE) test-gpt4all
|
|
|
|
$(MAKE) test-llama
|
|
|
|
$(MAKE) test-tts
|
|
|
|
$(MAKE) test-stablediffusion
|
|
|
|
|
|
|
|
test-gpt4all: prepare-test
|
|
|
|
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
|
|
|
|
|
|
|
|
test-llama: prepare-test
|
|
|
|
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
|
|
|
|
|
|
|
|
test-tts: prepare-test
|
|
|
|
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="tts" --flake-attempts 1 -v -r ./api ./pkg
|
|
|
|
|
|
|
|
test-stablediffusion: prepare-test
|
|
|
|
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="stablediffusion" --flake-attempts 1 -v -r ./api ./pkg
|
|
|
|
|
|
|
|
test-container:
|
|
|
|
docker build --target requirements -t local-ai-test-container .
|
2023-07-20 20:10:42 +00:00
|
|
|
docker run -ti --rm --entrypoint /bin/bash -ti -v $(abspath ./):/build local-ai-test-container
|
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)
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-20 20:10:42 +00:00
|
|
|
protogen: protogen-go protogen-python
|
|
|
|
|
|
|
|
protogen-go:
|
2023-07-14 23:19:43 +00:00
|
|
|
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
2023-07-14 23:19:43 +00:00
|
|
|
pkg/grpc/proto/backend.proto
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-20 20:10:42 +00:00
|
|
|
protogen-python:
|
|
|
|
python -m grpc_tools.protoc -Ipkg/grpc/proto/ --python_out=extra/grpc/huggingface/ --grpc_python_out=extra/grpc/huggingface/ pkg/grpc/proto/backend.proto
|
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
## GRPC
|
|
|
|
|
|
|
|
backend-assets/grpc:
|
|
|
|
mkdir -p backend-assets/grpc
|
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/falcon: backend-assets/grpc go-ggllm/libggllm.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggllm LIBRARY_PATH=$(shell pwd)/go-ggllm \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/falcon ./cmd/grpc/falcon/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/llama: backend-assets/grpc go-llama/libbinding.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-llama LIBRARY_PATH=$(shell pwd)/go-llama \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/llama ./cmd/grpc/llama/
|
2023-07-20 20:00:07 +00:00
|
|
|
# TODO: every binary should have its own folder instead, so can have different metal implementations
|
|
|
|
ifeq ($(BUILD_TYPE),metal)
|
|
|
|
cp go-llama/build/bin/ggml-metal.metal backend-assets/grpc/
|
|
|
|
endif
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/gpt4all: backend-assets/grpc backend-assets/gpt4all gpt4all/gpt4all-bindings/golang/libgpt4all.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/ LIBRARY_PATH=$(shell pwd)/gpt4all/gpt4all-bindings/golang/ \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt4all ./cmd/grpc/gpt4all/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/dolly: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/dolly ./cmd/grpc/dolly/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/gpt2: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gpt2 ./cmd/grpc/gpt2/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/gptj: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptj ./cmd/grpc/gptj/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/gptneox: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/gptneox ./cmd/grpc/gptneox/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/mpt: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/mpt ./cmd/grpc/mpt/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/replit: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/replit ./cmd/grpc/replit/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-14 23:19:43 +00:00
|
|
|
backend-assets/grpc/falcon-ggml: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
2023-07-14 23:19:43 +00:00
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
2023-07-14 23:19:43 +00:00
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/falcon-ggml ./cmd/grpc/falcon-ggml/
|
|
|
|
|
|
|
|
backend-assets/grpc/starcoder: backend-assets/grpc go-ggml-transformers/libtransformers.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-ggml-transformers LIBRARY_PATH=$(shell pwd)/go-ggml-transformers \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/starcoder ./cmd/grpc/starcoder/
|
|
|
|
|
|
|
|
backend-assets/grpc/rwkv: backend-assets/grpc go-rwkv/librwkv.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-rwkv LIBRARY_PATH=$(shell pwd)/go-rwkv \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/rwkv ./cmd/grpc/rwkv/
|
|
|
|
|
|
|
|
backend-assets/grpc/bloomz: backend-assets/grpc bloomz/libbloomz.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/bloomz LIBRARY_PATH=$(shell pwd)/bloomz \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/bloomz ./cmd/grpc/bloomz/
|
|
|
|
|
|
|
|
backend-assets/grpc/bert-embeddings: backend-assets/grpc go-bert/libgobert.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-bert LIBRARY_PATH=$(shell pwd)/go-bert \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/bert-embeddings ./cmd/grpc/bert-embeddings/
|
|
|
|
|
|
|
|
backend-assets/grpc/langchain-huggingface: backend-assets/grpc
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/langchain-huggingface ./cmd/grpc/langchain-huggingface/
|
|
|
|
|
|
|
|
backend-assets/grpc/stablediffusion: backend-assets/grpc go-stable-diffusion/libstablediffusion.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/go-stable-diffusion/ LIBRARY_PATH=$(shell pwd)/go-stable-diffusion/ \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/stablediffusion ./cmd/grpc/stablediffusion/
|
|
|
|
|
|
|
|
backend-assets/grpc/piper: backend-assets/grpc backend-assets/espeak-ng-data go-piper/libpiper_binding.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" LIBRARY_PATH=$(shell pwd)/go-piper \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/piper ./cmd/grpc/piper/
|
|
|
|
|
|
|
|
backend-assets/grpc/whisper: backend-assets/grpc whisper.cpp/libwhisper.a
|
|
|
|
CGO_LDFLAGS="$(CGO_LDFLAGS)" C_INCLUDE_PATH=$(shell pwd)/whisper.cpp LIBRARY_PATH=$(shell pwd)/whisper.cpp \
|
|
|
|
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/whisper ./cmd/grpc/whisper/
|
2023-07-14 23:19:43 +00:00
|
|
|
|
2023-07-25 17:05:27 +00:00
|
|
|
grpcs: prepare backend-assets/grpc/langchain-huggingface backend-assets/grpc/falcon-ggml backend-assets/grpc/bert-embeddings backend-assets/grpc/falcon backend-assets/grpc/bloomz backend-assets/grpc/llama backend-assets/grpc/gpt4all backend-assets/grpc/dolly backend-assets/grpc/gpt2 backend-assets/grpc/gptj backend-assets/grpc/gptneox backend-assets/grpc/mpt backend-assets/grpc/replit backend-assets/grpc/starcoder backend-assets/grpc/rwkv backend-assets/grpc/whisper $(OPTIONAL_GRPC)
|