Skip to content

Weirdy output with llama-cpp-python and create_chat_completion function #1118

@particitae

Description

@particitae

I tried to run the llama-cpp-python's tutorial but i got weirdy output

Configuration:
Package Version
black 23.12.1
click 8.1.7
diskcache 5.6.3
Jinja2 3.1.3
llama_cpp_python 0.2.29
MarkupSafe 2.1.3
mypy-extensions 1.0.0
numpy 1.26.3
packaging 23.2
pathspec 0.12.1
pip 23.0.1
platformdirs 4.1.0
setuptools 66.1.1
typing_extensions 4.9.0

python3 --version
Python 3.11.2
uname -a
Linux 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux

llm = llama_cpp.Llama(
model_path="/home/jacques/Model/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q5_0.gguf", n_gpu_layers=35, chat_format="llama-2",)
output = llm.create_chat_completion(
      messages = [
          {"role": "system", "content": "You are an assistant who perfectly describes images."},
          {
              "role": "user",
              "content": "Describe this image in detail please."
          }
      ]
)
print(output)

llama_print_timings: load time = 174.28 ms
llama_print_timings: sample time = 195.21 ms / 475 runs ( 0.41 ms per token, 2433.29 tokens per second)
llama_print_timings: prompt eval time = 174.15 ms / 37 tokens ( 4.71 ms per token, 212.46 tokens per second)
llama_print_timings: eval time = 32596.57 ms / 474 runs ( 68.77 ms per token, 14.54 tokens per second)
llama_print_timings: total time = 34265.68 ms / 511 tokens
{'id': 'chatcmpl-9ef3679d-b74e-4280-aa6e-cac06a30d7e3', 'object': 'chat.completion', 'created': 1705583449, 'model': '/home/jacques/Model/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q5_0.gguf', 'choices': [{'index': 0, 'message': {'role': 'assistant', 'content': '###########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################'}, 'finish_reason': 'length'}], 'usage': {'prompt_tokens': 37, 'completion_tokens': 475, 'total_tokens': 512}}

My output seems weirdy, fulled with #.
Any ideas ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions