Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix passing of chat_format to llamacpp ms #531

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/model_servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
branches:
- main
paths:
- ./model_servers/**
- 'model_servers/**'
- .github/workflows/model_servers.yaml
push:
branches:
- main
paths:
- ./model_servers/
- 'model_servers/**'
- .github/workflows/model_servers.yaml

workflow_dispatch:
Expand Down
13 changes: 11 additions & 2 deletions model_servers/common/Makefile.common
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
REGISTRY ?= quay.io
REGISTRY_ORG ?= ai-lab
COMPONENT ?= model_servers
CHAT_FORMAT ?=

BIND_MOUNT_OPTIONS := ro
OS := $(shell uname -s)
Expand All @@ -10,7 +11,7 @@ endif

.PHONY: build
build:
podman build --squash-all --build-arg PORT=$(PORT) -t $(IMAGE) . -f base/Containerfile
podman build --squash-all $(CHAT_FORMAT:%=--build-arg CHAT_FORMAT=%) --build-arg PORT=$(PORT) -t $(IMAGE) . -f base/Containerfile

.PHONY: install
install:
Expand All @@ -35,7 +36,15 @@ clean:
.PHONY: run
run:
cd ../../models && \
podman run -it -d -p $(PORT):$(PORT) -v ./$(MODEL_NAME):$(MODELS_PATH)/$(MODEL_NAME):$(BIND_MOUNT_OPTIONS) -e MODEL_PATH=$(MODELS_PATH)/$(MODEL_NAME) -e HOST=0.0.0.0 -e PORT=$(PORT) $(IMAGE)
podman run -it \
-d \
-p $(PORT):$(PORT) \
-v ./$(MODEL_NAME):$(MODELS_PATH)/$(MODEL_NAME):$(BIND_MOUNT_OPTIONS) \
-e MODEL_PATH=$(MODELS_PATH)/$(MODEL_NAME) \
-e HOST=0.0.0.0 \
-e PORT=$(PORT) \
$(CHAT_FORMAT:%=-e CHAT_FORMAT=${CHAT_FORMAT}) \
$(IMAGE)

.PHONY: podman-clean
podman-clean:
Expand Down
2 changes: 1 addition & 1 deletion model_servers/llamacpp_python/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APP := llamacpp_python
PORT ?= 8001
CHAT_FORMAT ?= openchat
CHAT_FORMAT ?= llama-2

include ../common/Makefile.common

Expand Down
1 change: 1 addition & 0 deletions model_servers/llamacpp_python/base/Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM registry.access.redhat.com/ubi9/python-311:1-62.1716478620
ENV CHAT_FORMAT=llama-2
WORKDIR /locallm
COPY src .
USER root
Expand Down
9 changes: 8 additions & 1 deletion model_servers/llamacpp_python/src/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ if [ ${CONFIG_PATH} ] || [[ ${MODEL_PATH} && ${CONFIG_PATH} ]]; then
fi

if [ ${MODEL_PATH} ]; then
python -m llama_cpp.server --model ${MODEL_PATH} --host ${HOST:=0.0.0.0} --port ${PORT:=8001} --n_gpu_layers ${GPU_LAYERS:=0} --clip_model_path ${CLIP_MODEL_PATH:=None} --chat_format ${MODEL_CHAT_FORMAT:="llama-2"} --interrupt_requests ${INTERRUPT_REQUESTS:=False}
python -m llama_cpp.server \
--model ${MODEL_PATH} \
--host ${HOST:=0.0.0.0} \
--port ${PORT:=8001} \
--n_gpu_layers ${GPU_LAYERS:=0} \
--clip_model_path ${CLIP_MODEL_PATH:=None} \
--chat_format ${CHAT_FORMAT:="llama-2"} \
--interrupt_requests ${INTERRUPT_REQUESTS:=False}
exit 0
fi

Expand Down
2 changes: 1 addition & 1 deletion model_servers/llamacpp_python/tooling_options.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n",
"\n",
"\n",
"llm = OpenAI(temperature=0.9,model_name=\"llama2\", base_url=\"http://localhost:8000/v1\", \n",
"llm = OpenAI(temperature=0.9,model_name=\"instructlab/granite-7b-lab\", base_url=\"http://localhost:8000/v1\", \n",
" openai_api_key=\"sk-no-key-required\", streaming=True,\n",
" callbacks=[StreamingStdOutCallbackHandler()])\n",
"text = \"What would be a good company name for a company that makes colorful socks?\"\n",
Expand Down