oobabooga / text-generation-webui

A Gradio web UI for Large Language Models.
GNU Affero General Public License v3.0
39.62k stars 5.21k forks source link

Difficulty in rendering numerical values or special characters #6048

Open Opensourcestreamingclient opened 3 months ago

Opensourcestreamingclient commented 3 months ago

Describe the bug

It appears that the issue lies with the most recent iterations of Oobabooga. Notably, examining the two images provided below reveals that the latest version fails to accurately render the same paragraph, whereas the older version from approximately 2 months ago successfully renders it correctly.

Is there an existing issue for this?

Reproduction

Ask any model to write a shell script that prints: "The Tier 3 plan, designed for 1440p gaming, is priced at $19.95 per month. Additionally, you have the option to purchase extra hours at $0.75 per hour if you need more gaming time beyond the included daily allocation."

Screenshot

model2 model1

Logs

No errors.

System Info

AMD 7900XTX with an 7800X3D CPU.
Alkohole commented 3 months ago

It's a math renderer, I can suggest a temporary solution: just exclude the search for the single "$" character.

./text-generation-webui/js/main.js line 230

function doSyntaxHighlighting() {
  const indexes = getVisibleMessagesIndexes();
  const elements = document.querySelectorAll(".message-body");

  if (indexes.length > 0) {
    observer.disconnect();

    indexes.forEach((index) => {
      const element = elements[index];

      // Tag this element to prevent it from being highlighted twice
      element.setAttribute("data-highlighted", "true");

      // Perform syntax highlighting
      const codeBlocks = element.querySelectorAll("pre code");

      codeBlocks.forEach((codeBlock) => {
        hljs.highlightElement(codeBlock);
      });

      renderMathInElement(element, {
        delimiters: [
          { left: "$$", right: "$$", display: true },
          { left: "$", right: "$", display: false }, // Delete this line
          { left: "\\(", right: "\\)", display: false },
          { left: "\\[", right: "\\]", display: true },
        ],
      });

    });

    observer.observe(targetElement, config);
  }
}

I'm not a mathematician and not a nuclear physicist to chatter with LLM on such topics, so I can painlessly delete { left: "$", right: "$", display: false },

Opensourcestreamingclient commented 3 months ago

I'd like to express my gratitude, as the issue seems to have been resolved and we're primarily utilizing it for sales and technical inquiries related to our RAG FAQ. We anticipate this solution won't pose any future problems