text-generation-webui icon indicating copy to clipboard operation
text-generation-webui copied to clipboard

Markdown crashes when LaTeX output for GALACTICA contains special characters

Open nerdyrodent opened this issue 2 years ago • 13 comments

Hi. I'm getting issues most of the time with Galactica. Any ideas?

/home/nerdy/anaconda3/envs/text-gen-webui/lib/python3.10/site-packages/gradio/utils.py:872: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
  fig = plt.figure(figsize=(0.01, 0.01))
 15%|███████████████████████████████████▍                                                                                                                                                                                                  | 4/26 [00:01<00:08,  2.46it/s]Exception ignored in: <function Image.__del__ at 0x7fbc53128700>
Traceback (most recent call last):
  File "/home/nerdy/anaconda3/envs/text-gen-webui/lib/python3.10/tkinter/__init__.py", line 4056, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop

nerdyrodent avatar Mar 10 '23 09:03 nerdyrodent

Something looks wrong. This project does not use matplotlib.

oobabooga avatar Mar 10 '23 14:03 oobabooga

I've run into the the same problem, it has something to do with the characters type Galacitca is trying to push out. Like if it spits out an equation it will give you the error.

RandomInternetPreson avatar Mar 10 '23 15:03 RandomInternetPreson

I guess gradio's markdown widget uses matplotlib to render LaTeX equations, and it crashes if the equation to be rendered contains special characters.

It also crashes if the equation is invalid in any way, like containing a \begin{itemize} that it doesn't recognize, which is annoying.

oobabooga avatar Mar 10 '23 15:03 oobabooga

Hi, My problem was not crashes with math rendering using Galactica, but that $whatever$ simply weren't rendered in the markdown tab. I've been copying the raw answer to other programs to render the math.

I thought I was running a perfect total up to date vanilla conda installation, but when creating a new environment I now get the same "Starting a Matplotlib GUI outside..." crashes - and upgrading to Gradio 1.1.9 (which has some LaTeX fixes) didn't help.

Been looking around for a solution. It seems that Matplotlib is very fuzzy when there is errors or unsupported LaTeX codes in the input. I can't figure out if our problem is Mathplotlib or the way Gradio handles the errors - or something else for that matter?? I don't know enough to file a decent bug report with Gradio (or Mathplotlib?), hope someone else can.

The crashes makes it more or less impossible to use Galactica for anything math/physics/chemistry related.

May I suggest that the Markdown tab is disabled until a solution is found - or just the LaTeX rendering if possible.

CreativeFriday avatar Mar 14 '23 13:03 CreativeFriday

So you can't see any equation at all? It works for me (see the screenshot in the README).

oobabooga avatar Mar 14 '23 19:03 oobabooga

Until this morning I have never had it rendering any equations - it just stripped out any $whatever$ in the the markdown tab, all other markdown formatting was rendered. In trying to fix that I made a new conda environment following the readme. Using the new environment it now does render the equation but I now get the "Starting a Matplotlib GUI outside..." error and it crashes more or less every time the answer includes equations. It has never crashed before.

I just did a fresh install and created a new environment following the readme(conda).

If I try a prompt that does not return any LaTeX it works just fine, but when trying something like this:

A force of 0.6N is applied to an object, which accelerates at 3m/s. What is its mass?

<work>

It now does render the equations in the markdown tab, but gives me this in the terminal and eventually crashes

Loading galactica-6.7b...
Loading checkpoint shards: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:05<00:00,  2.76s/it]
Loaded the model in 8.74 seconds.
Running on local URL:  http://0.0.0.0:7860

To create a public link, set `share=True` in `launch()`.
/home/svend/anaconda3/envs/textgentest/lib/python3.10/site-packages/gradio/utils.py:877: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
  fig = plt.figure(figsize=(0.01, 0.01))
Exception ignored in: <function Image.__del__ at 0x7fd330f37490>
Traceback (most recent call last):
  File "/home/svend/anaconda3/envs/textgentest/lib/python3.10/tkinter/__init__.py", line 4056, in __del__
    self.tk.call('image', 'delete', self.name)
RuntimeError: main thread is not in main loop
Exception ignored in: <function Variable.__del__ at 0x7fd331357d00>
Traceback (most recent call last):

   
---- Repating the same error MANY MANY times ----


Traceback (most recent call last):
  File "/home/svend/anaconda3/envs/textgentest/lib/python3.10/tkinter/__init__.py", line 388, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Exception ignored in: <function Variable.__del__ at 0x7fd331357d00>
Traceback (most recent call last):
  File "/home/svend/anaconda3/envs/textgentest/lib/python3.10/tkinter/__init__.py", line 388, in __del__
    if self._tk.getboolean(self._tk.call("info", "exists", self._name)):
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread
Aborted (core dumped)
(textgentest) svend@pc-3d:~/github/text-generation-webui$ 

(Pop! OS 22.04, Intel i9-7940X, 64Gb ram, RTX 3090)

CreativeFriday avatar Mar 14 '23 21:03 CreativeFriday

I get the exact same error as yourself when using the same prompt about computing the mass.

I can see the equation in F=ma in the "Markdown" tab, but then it types a little more text and crashes and gives me the same error.

You get a little bit of equations, then for some reason the AI tries to make a plot?! IDK :c

RandomInternetPreson avatar Mar 17 '23 15:03 RandomInternetPreson

Matplotlib is indeed used by gradio to turn the LaTeX code into a svg image for display.

It is working for me without errors (I used the contrastive search preset):

print

oobabooga avatar Mar 17 '23 15:03 oobabooga

Hmm, interesting, I deleted everything and reinstalled oobabooga from scratch. I'm still getting the same error, I've attached two images here. Image 1 has my setup before hitting generate, and image 2 is taken soon after the error occurs.

The terminal will throw the error ending in (figsize=(0.01, 0.,01)) first, then continue to generate a little more output at a much slower pace, and then it will throw the remainder of the error into the terminal.

Image 1 Setup

Image 2 Error Encounter

RandomInternetPreson avatar Mar 17 '23 21:03 RandomInternetPreson

I think that this error may be more of a warning. It seems to not be stopping the text generation.

oobabooga avatar Mar 17 '23 23:03 oobabooga

I can see why why it looks like that, but where the text ouput starts is random and in the example it just happened to end somewhere that looks like an ending (my mistake I should have used a different example).

Often the text will stop half way through a sentence and the last error will keep looping.

I will say that I could not generate any more responses after the error in the screenshot, I had to close Oobabooga and start it up again.

RandomInternetPreson avatar Mar 17 '23 23:03 RandomInternetPreson

For me when I get the " main thread is not in main loop", it just repeats then core dumps after some seconds.

nerdyrodent avatar Mar 18 '23 07:03 nerdyrodent

Dude!! I watched your YouTube video yesterday going over the different code outputs... great stuff!!! Thank you, your videos are some of my favorite ❤️❤️

RandomInternetPreson avatar Mar 18 '23 13:03 RandomInternetPreson

This issue has been closed due to inactivity for 30 days. If you believe it is still relevant, please leave a comment below.

github-actions[bot] avatar Apr 17 '23 23:04 github-actions[bot]