janhq / jan

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer. Multiple engine support (llama.cpp, TensorRT-LLM)
https://jan.ai/
GNU Affero General Public License v3.0
20.8k stars 1.19k forks source link

bug: LaTeX rendering issue #2865

Open thethinkmachine opened 2 months ago

thethinkmachine commented 2 months ago

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

Environment details

Van-QA commented 2 months ago

The issue is reproducible :x: image image