llama-cpp-python icon indicating copy to clipboard operation
llama-cpp-python copied to clipboard

Llama.cpp-python missing words/punctuation, lost of context and weird spelling in output on GGUF model

Open Undi95 opened this issue 3 years ago • 13 comments

Prerequisites

Expected Behavior

Trying to have a normal conversation with the AI using new converted GGUF files from a GGML model.

Current Behavior

When speaking to the IA, some words is missing in the output, some are weirdly replaced ("my" replacing "me" for exemple), verb badly conjugued and lost of context.

Environment and Context

I converted the q4_K_S, q4_K_M, q5_K_S and q5_K_M GGML file of Mythomax-L2-13B to GGUF with convert-llama-ggmlv3-to-gguf.py and convert.py. Since there was an issue in convert.py on llama.cpp repo, I was thinking the issue will be fixed after doing a new conversion with the new convert.py.

While the conversion is now working without issues, the issue of missing word and spelling mistake stayed, darxkies pointed out that it was maybe a llama.cpp-python issue and not a llama.cpp issue, and he was right, all is working correctly on Koboldcpp who use llama.cpp with the converted model.

Steps to Reproduce

  1. Load a fresh converted GGUF model with llama-cpp-python or text-generation-webui gguf branch (maybe try MythoMax since we have issue with it)
  2. Prompt something
  3. The reply should have missing words, punctuations and oddly conjugated verb

Failure Logs

Exemple of failed reply :

  • That's amazing, XXX! new sounds! [<=???] smiles warmly and playfully nudges your arm We could even [missing word] on each other if you wanted. It would be much more fun that way (missing a word)

  • I know how hard it can be for someone like XXX to express himself, but when YYY smiles at him, she sees his true self shining through. She loves every imperfect piece of him - just as he is! (lost context completely, was speaking to the AI here of something)

  • If I manage [missing word?] make five more shapes accurately with my hands, [missing word?] will show some appreciation by giving me one of those heart-shaped pebbles as reward or maybe even [missing word] else in return? (not readable reply)

More informations

I'm running Windows 11, I have an RTX 3060 12GB VRAM, I loaded the model entirely in VRAM and use 2k context to 3k context with q4_K_M and q4_K_S GGUF converted file of Mythomax-L2-13B.

I'm actually uploading them to Huggingface but it will take some time, sorry. If you can convert them yourself and reproduce to have a better understanding I would appreciate it. I report the issue, but I don't know what cause it.

English isn't my first language, I hope what I writed is understandable.

Undi95 avatar Aug 26 '23 21:08 Undi95

Code to reproduce the issue:

from llama_cpp_cuda import Llama
llm = Llama(model_path="MythoMax.gguf")
output = llm("### Instruction: Write a long story about aliens? ### Response: ", max_tokens=300, stop=[], echo=True)
print(output)

Output:

{'id': 'cmpl-c7d5dc40-ed15-47aa-b37c-ed15d23876c7', 'object': 'text_completion', 'created': 1693083790, 'model': 'MythoMax.gguf', 'choices': [{'text': '### Instruction: Write a long story about aliens? ### Response: \n\nOnce upon a time, in a galaxy far away, there was a planet called Zorax. It was inhabited by an civilization of extraterrestrial beings who looked like glowing orbs with tentacles around them. They were peaceful andent creatures, living harmoniously on their lush green planet.\n\nOne day, the Zoraxians a strange object falling from the sky. It was metallic and shaped like an oval, making it unlike they had seen before. As it crash-landed on their planet, sparks flew out from all sides of the object. The Zoraxians cautiously the object to what could have caused such a spectacle.\n\nTo their, the metallic shell opened up revealing a group of humanoid creatures inside. They were small and fragile-looking, with soft skin that was colors like blue, green, and red. The Zoraxians these beings closely as they slowly regainedness after the crash.\n\nAs the humanoids awoke, they started panicking and trying to escape from their confinement. The Zoraxians were shocked at how fearful these creatures were of them despite being peaceful. They triedating with the humans by using telepathy, but it seemed that their bar', 'index': 0, 'logprobs': None, 'finish_reason': 'length'}], 'usage': {'prompt_tokens': 17, 'completion_tokens': 300, 'total_tokens': 317}}

Non-existent words are generated: triedating, regainedness... There are also grammatical errors: "To their, the metallic shell opened..." Missing word(s): "The Zoraxians cautiously the object to what could have caused such a spectacle."

darxkies avatar Aug 26 '23 21:08 darxkies

Another test without CUDA support. Same issues. Tested in Linux.

{'id': 'cmpl-3a8e20c4-2333-4c78-aff8-a49c726d8b5f', 'object': 'text_completion', 'created': 1693085634, 'model': '/workspace/llama.cpp/models/MythoMax.gguf', 'choices': [{'text': "### Instruction: Write a long story about aliens? ### Response: \nOnce upon a time, in the far reaches of the, there was a planet called Zorlon. The of this planet were an species known as the Zorlonians. They were tall, with slender builds and elongated heads, covered in iridescent scales that shimmered in the light. Their was far beyond known on Earth; they had mastered interstellar travel and harnessed energy sources that humans couldn't even begin to comprehend.\nOne day, a Zorlonian scientist named Dr. Xal made a groundbreaking. Through his, he had found of anotherent species in the - humans on Earth. Dr. Xal that it was crucial for these two civilizations to make contact with each other and share and. However, his was met with skepticism by his peers, who were wary of the dangers ofing with such a species.\nDetermined to pursue his vision, Dr. Xal secretly a plan to make first contact without alerting the rest of the Zorlonian. He a small spacecraft for one and set off towards Earth alone. After traveling through the vast emptiness of space for several months, he finally arrived at his.\nUpon landing in the middle of a dense forest, Dr. Xal stepped", 'index': 0, 'logprobs': None, 'finish_reason': 'length'}], 'usage': {'prompt_tokens': 17, 'completion_tokens': 300, 'total_tokens': 317}}

darxkies avatar Aug 26 '23 21:08 darxkies

I have too tried directly with llama.cpp-python with this code (thanks a lot to darxkies for explaining a little) :

llm = Llama(model_path="mythomax-l2-13b.ggmlv3.q4_K_S.GGUF")
output = llm("### Instruction: Write a long story about aliens? ### Response: ", max_tokens=100, stop=[], echo=True)
print(output)
input("Press enter to exit;")

Output: {'id': 'cmpl-03688c42-9337-4538-9d19-4c42d36207da', 'object': 'text_completion', 'created': 1693086710, 'model': 'mythomax-l2-13b.ggmlv3.q4_K_S.GGUF', 'choices': [{'text': "### Instruction: Write a long story about aliens? ### Response: \n\nOnce upon a time, in the distant future, Earth was no longer inhabited by humans. The planet had been ago after a series of catastrophic events led to its. However, little did anyone know that there were still some signs of life lingering beneath the surface.\n\nDeep within an underground bunker, located in what used to be Russia, lived a group of scientists who had been the planet's for years.", 'index': 0, 'logprobs': None, 'finish_reason': 'length'}], 'usage': {'prompt_tokens': 17, 'completion_tokens': 100, 'total_tokens': 117}}

Issues: "The planet had been ago" "of catastrophic events led to its." "who had been the planet's for years"

Undi95 avatar Aug 26 '23 22:08 Undi95

I am also facing this same issue. When I ask the question “Who is the prime minister of India?” It says “The prime of India is Narendra Modi” It misses the word Minister.

Similarly I found it also misses the word “Property”. These words it always misses in response no matter which question it is.

I am using latest converted file in gguf format from just 8 hours back using latest code.

I tried the same exact model file in other libraries it works fine. So I inferred the issue is with llama-cpp-python.

Please help to fix this, thanks in advance.

manasmagdum avatar Aug 27 '23 05:08 manasmagdum

@Undi95 thanks for reporting, I was able to reproduce it so I should have a fix shortly!

abetlen avatar Aug 27 '23 06:08 abetlen

Hi @abetlen I found the issue. I was able to run it successfully after below fix. Screenshot 2023-08-27 at 12 22 20 PM

:) :)

manasmagdum avatar Aug 27 '23 06:08 manasmagdum

I can confirm that @manasmagdum's fix works as intended.

darxkies avatar Aug 27 '23 07:08 darxkies

Thanks @darxkies

I have raised PR. https://github.com/abetlen/llama-cpp-python/pull/644

I request @abetlen to Please approve and Release. I wish to use this library in our company project.

Thanks again!!

manasmagdum avatar Aug 27 '23 07:08 manasmagdum

In the meanwhile you can test like this:

CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 pip install git+https://github.com/manasmagdum/llama-cpp-python@patch-1 -U

avion23 avatar Aug 27 '23 15:08 avion23

@manasmagdum thanks for the fix, yes that seems to work for me, if anyone else can confirm I'll close this issue.

abetlen avatar Aug 27 '23 17:08 abetlen

Thanks for the fix, I had issues with all Code Llama models up until now.

peter-ch avatar Aug 27 '23 17:08 peter-ch

Since it's fixed I close the issue, if it's a bad move don't hesitate to reopen it, I don't use github a lot kek

Undi95 avatar Aug 27 '23 20:08 Undi95

I'm having a similar problem. I use the GGUF model, and I get stuck creating text even though the max context length is very much 32k tokens. How do I fix it?

yuneun92 avatar Apr 26 '24 04:04 yuneun92