jan icon indicating copy to clipboard operation
jan copied to clipboard

bug: LaTeX rendering issue

Open thethinkmachine opened this issue 1 year ago • 1 comments

Describe the bug Jan has issues with properly displaying mathematical content. When inline mathematical statements (enclosed within single $ delimiters) are used, the output duplicates the expression alongside the rendered LaTeX expression. Additionally, matrices enclosed within double $$ delimiters are not displayed correctly, with the application using small, fixed sized curved braces instead of the appropriate larger square brackets. Furthermore, rendering larger matrices, such as an n x n Jacobian (a matrix containing partials), is sometimes a hit or a miss, sometimes it fails to display the matrix completely.

Steps to reproduce

  1. Launch the Jan application and load a model (e.g., Llama 3 8B Q6).
  2. Ask it to print an inline mathematical expression (e.g., $E = mc^2$), it'll get duplicated next to the latex expression in the output.
  3. Ask it to print a matrix enclosed within $$ delimiters (e.g., $$\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$$), it uses small, curved braces instead of larger square braces to enclose the matrix.
  4. Ask it to print the following LaTeX syntax.
$$\frac{\partial \nabla\phi}{\partial \mathbf{x}} = \begin{bmatrix}
\frac{\partial \nabla_x \phi}{\partial x} & \frac{\partial \nabla_x \phi}{\partial y} & \frac{\partial \nabla_x \phi}{\partial z} \\
\frac{\partial \nabla_y \phi}{\partial x} & \frac{\partial \nabla_y \phi}{\partial y} & \frac{\partial \nabla_y \phi}{\partial z} \\
\frac{\partial \nabla_z \phi}{\partial x} & \frac{\partial \nabla_z \phi}{\partial y} & \frac{\partial \nabla_z \phi}{\partial z}
\end{bmatrix}$$

It renders the provided text as is.

Expected behavior The expected behavior can be observed by copying and pasting the above LaTeX syntax into Obsidian, a note-taking application with proper LaTeX rendering capabilities. In Obsidian, the inline mathematical statements should be rendered correctly without duplication, and the matrices should be displayed using the appropriate square brackets and formatting. The larger, more complex matrices should also be rendered correctly, displaying the content in a visually appealing and mathematically accurate manner.

Screenshots

  • Not required (The bug is reproducible).

Environment details

  • Operating System: Windows 11
  • Jan Version: 0.4.12
  • Processor: AMD Ryzen 5 3600
  • RAM: 16GB
  • GPU: NVIDIA RTX 2070 Super (8 GB DDR6 VRAM)
  • System prompt: You are a helpful assistant designed to assist reasoning in mathematical tasks & subjects.

thethinkmachine avatar May 04 '24 02:05 thethinkmachine

The issue is reproducible :x: image image

Van-QA avatar May 06 '24 04:05 Van-QA

The issue is resolved in Jan v0.5.2-619

Van-QA avatar Aug 29 '24 04:08 Van-QA

Jan 0.5.3 is released to stable version of Jan app: https://github.com/janhq/jan/releases/tag/v0.5.3, feel free to get back to us if any concern

Van-QA avatar Aug 30 '24 02:08 Van-QA

Sure, thank you very much.

thethinkmachine avatar Aug 30 '24 11:08 thethinkmachine