su77ungr / CASALIOY

♾️ toolkit for air-gapped LLMs on consumer-grade hardware
Apache License 2.0
230 stars 31 forks source link

Crash while generating text that includes some special characters #89

Closed doughn0 closed 1 year ago

doughn0 commented 1 year ago

.env

# Generic
MODEL_N_CTX='2048'
N_GPU_LAYERS=320
TEXT_EMBEDDINGS_MODEL=sentence-transformers/all-MiniLM-L6-v2
TEXT_EMBEDDINGS_MODEL_TYPE=HF  # LlamaCpp or HF
USE_MLOCK=true

# Ingestion
PERSIST_DIRECTORY=db
DOCUMENTS_DIRECTORY=source_documents
INGEST_CHUNK_SIZE=500
INGEST_CHUNK_OVERLAP=50

# Generation
#MODEL_TYPE=LlamaCpp # GPT4All or LlamaCpp
#MODEL_PATH=TheBloke/GPT4All-13B-snoozy-GGML/GPT4All-13B-snoozy.ggml.q4_0.bin
MODEL_TYPE=LlamaCpp # GPT4All or LlamaCpp
MODEL_PATH=eachadea/ggml-vicuna-7b-1.1/ggml-vic7b-q5_1.bin
MODEL_TEMP=0.8
MODEL_N_CTX=2048  # Max total size of prompt+answer
MODEL_MAX_TOKENS=256  # Max size of answer
MODEL_STOP=[STOP]
CHAIN_TYPE=betterstuff
N_RETRIEVE_DOCUMENTS=100
N_FORWARD_DOCUMENTS=100

Python version

Pthon 3.10.6

System

Ubuntu 22.04 WSL

CASALIOY version

e5e8e2b

Information

Related Components

Reproduction

I ingested documentation for some framework I use at work, but generating answers often leads to this error:

\`\`\`java
containerRunner.call().notification("Job updated successfully.");
containerRunner.fullRefresh();
\`\`\`
llama_print_timings:        load time =  5599.29 ms
llama_print_timings:      sample time =    58.62 ms /   146 runs   (    0.40 ms per token)
llama_print_timings: prompt eval time = 10652.43 ms /  1759 tokens (    6.06 ms per token)
llama_print_timings:        eval time = 15696.45 ms /   145 runs   (  108.25 ms per token)
llama_print_timings:       total time = 34172.49 ms
Traceback (most recent call last):
  File "/home/doughno/_dev/CASALIOY/casalioy/utils.py", line 38, in print_HTML
    print_formatted_text(HTML(text).format(**kwargs), style=style)
  File "/home/doughno/_dev/CASALIOY/.venv/lib/python3.10/site-packages/prompt_toolkit/formatted_text/html.py", line 35, in __init__
    document = minidom.parseString(f"<html-root>{value}</html-root>")
  File "/usr/lib/python3.10/xml/dom/minidom.py", line 1998, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python3.10/xml/dom/expatbuilder.py", line 925, in parseString
    return builder.parseString(string)
  File "/usr/lib/python3.10/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 169, column 41

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/doughno/_dev/CASALIOY/casalioy/startLLM.py", line 135, in <module>
    main()
  File "/home/doughno/_dev/CASALIOY/casalioy/startLLM.py", line 131, in main
    qa_system.prompt_once(query)
  File "/home/doughno/_dev/CASALIOY/casalioy/startLLM.py", line 110, in prompt_once
    print_HTML(
  File "/home/doughno/_dev/CASALIOY/casalioy/utils.py", line 40, in print_HTML
    print(text.format(**kwargs))
ValueError: Single '}' encountered in format string

I don't know how to reliably reproduce it, but I would expect that a lot of code related text generation would fail in a similar way.

Expected behavior

The program shouldn't crash when generating text with any special characters.

hippalectryon-0 commented 1 year ago

Yep that's my fault, should have escaped the brackets

su77ungr commented 1 year ago

added escape

doughn0 commented 1 year ago

Yep that's my fault, should have escaped the brackets

Also i did see other characters that did this same error, but I don't know if I can find them all.

(Also sidenote, IDK why I have the close actions available to me as well) image

su77ungr commented 1 year ago

on every issue?

doughn0 commented 1 year ago

on every issue?

Just this one.

@su77ungr: > because you created it. that lets you close it

su77ungr commented 1 year ago

If you come across "Also i did see other characters that did this same error" again, please share them here.

su77ungr commented 1 year ago

should be fixed for now. if you this error persists just ping me here.