Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some math formulas can not be displayed #1019

Open
pixelock opened this issue May 13, 2024 · 1 comment
Open

Some math formulas can not be displayed #1019

pixelock opened this issue May 13, 2024 · 1 comment

Comments

@pixelock
Copy link

What happened?

I published a blog with lots of block math. Strangely, some of them can not be showed properly.

A test blog is published to show this problem: https://pixelock.github.io/p/math-typesetting/

WX20240513-135118

Two blocks are not showed correctly. Details in .md

$$
\begin{aligned}
& \mathbf{q}_t = W_Q \mathbf{h}_t \\
& \mathbf{k}_t = W_K \mathbf{h}_t \\
& \mathbf{v}_t = W_V \mathbf{h}_t
\end{aligned}
$$
在 MHA 中, $\mathbf{q}_t, \mathbf{k}_t, \mathbf{v}_t$ 被拆分为 $n_h$ 个 heads, 然后每个 head 中进行 attention 计算:

$$
\mathbf{q}_t + \mathbf{q}_{1}
$$

每个 head 计算得到的结果再拼接起来, 经过参数矩阵 $W_O \in \mathbb{R}^{d \times d_h n_h}$ 得到 MHA 的输出张量.

$$
\begin{aligned}
& {\left[\mathbf{q}_{t, 1} ; \mathbf{q}_{t, 2} ; \ldots ; \mathbf{q}_{t, n_h}\right]=\mathbf{q}_t,} \\
& {\left[\mathbf{k}_{t, 1} ; \mathbf{k}_{t, 2} ; \ldots ; \mathbf{k}_{t, n_h}\right]=\mathbf{k}_t,} \\
& {\left[\mathbf{v}_{t, 1} ; \mathbf{v}_{t, 2} ; \ldots ; \mathbf{v}_{t, n_h}\right]=\mathbf{v}_t,} \\
& \mathbf{o}_{t, i}=\sum_{j=1}^t \operatorname{Softmax}_j\left(\frac{\mathbf{q}_{t, i}^T \mathbf{k}_{j, i}}{\sqrt{d_h}}\right) \mathbf{v}_{j, i}, \\
& \mathbf{u}_t=W^O\left[\mathbf{o}_{t, 1} ; \mathbf{o}_{t, 2} ; \ldots ; \mathbf{o}_{t, n_h}\right]
\end{aligned}
$$

same latex math code can be show properly in another blog pubulish framework, so the math code itself is correct:

WX20240513-135439

Can you help to find the cause of this problem, thx!

Hugo version

0.125.7

Theme version

3.26.0

What browsers are you seeing the problem on?

Chrome

More information about the browser

No response

Relevant log output

No response

Link to Minimal Reproducible Example

https://github.com/pixelock/blogtest

@pixelock
Copy link
Author

pixelock commented May 13, 2024

I find that either inline math or block math with _{ or \{ will cause this problem. Manually change them into \_{ or \\{ to show properly.

How to fix it in the theme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant