abetlen / llama-cpp-python

Python bindings for llama.cpp
https://llama-cpp-python.readthedocs.io
MIT License
8.22k stars 980 forks source link

Docker: Missing library transformers when HF_PRETRAINED_MODEL_NAME_OR_PATH is provided #1355

Open xstrama opened 7 months ago

xstrama commented 7 months ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Expected Behavior

Running Functionary 2.4 Small in docker should work when HF_PRETRAINED_MODEL_NAME_OR_PATH is provided

docker run --rm -it -p 8888:8000 -v /home/xstrama/llm/functionary-small-v2.4-GGUF:/models -e MODEL=/models/functionary-small-v2.4.Q4_0.gguf -e CHAT_FORMAT=functionary-v2 -e HF_PRETRAINED_MODEL_NAME_OR_PATH=/models ghcr.io/abetlen/llama-cpp-python:latest

Current Behavior

docker run --rm -it -p 8888:8000 -v /home/xstrama/llm/functionary-small-v2.4-GGUF:/models -e MODEL=/models/functionary-small-v2.4.Q4_0.gguf -e CHAT_FORMAT=functionary-v2 -e HF_PRETRAINED_MODEL_NAME_OR_PATH=/models ghcr.io/abetlen/llama-cpp-python:latest yields the following error when HF_PRETRAINED_MODEL_NAME_OR_PATH is set

File "/app/llama_cpp/llama_tokenizer.py", line 96, in from_pretrained
    raise ImportError(
ImportError: The `transformers` library is required to use the `HFTokenizer`.You can install it with `pip install transformers`.

Environment and Context

Failure Information (for bugs)

Running Functionary 2.4 Small in docker does not work when HF_PRETRAINED_MODEL_NAME_OR_PATH is provided.

File "/app/llama_cpp/llama_tokenizer.py", line 96, in from_pretrained
    raise ImportError(
ImportError: The `transformers` library is required to use the `HFTokenizer`.You can install it with `pip install transformers`.

Steps to Reproduce

Run docker run --rm -it -p 8888:8000 -v /home/xstrama/llm/functionary-small-v2.4-GGUF:/models -e MODEL=/models/functionary-small-v2.4.Q4_0.gguf -e CHAT_FORMAT=functionary-v2 -e HF_PRETRAINED_MODEL_NAME_OR_PATH=/models ghcr.io/abetlen/llama-cpp-python:latest

axel7083 commented 4 months ago

The compatible version is not specified

https://github.com/abetlen/llama-cpp-python/blob/4bf3b43df95e62ddf74413a22a1df3411d206acc/llama_cpp/llama_tokenizer.py#L97