Page content
For Hugo blogs with MathJax, here’s how to properly format your mathematical formulas:
🛠️ Hugo MathJax Setup
1. Add MathJax to your Hugo config
In your config.toml or config.yaml:
[params.math]
enable = true
use = "mathjax" # or "katex" if you prefer
2. Add MathJax to your theme
In your theme’s layouts/partials/head.html or similar:
{{ if or .Params.math .Section "math" }}
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$','$'], ['\\(','\\)']],
displayMath: [['$$','$$']],
processEscapes: true,
processEnvironments: true
},
"HTML-CSS": { linebreaks: { automatic: true } },
"SVG": { linebreaks: { automatic: true } }
});
</script>
{{ end }}
3. Format your math properly
Here’s your research summary with properly formatted math:
## 1. Objective
Given two reasoning systems $A$ and $B$ evaluated on the **same** conversation hypotheses, we:
1. construct a **canonical alignment** of their scores across dimensions $$D=\{\text{reasoning, knowledge, clarity, faithfulness, coverage}\}$$;
2. compute the **gap field** $$\Delta = A - B$$;
3. show $\Delta$ exhibits **non-trivial topology** (e.g., Betti-1 loops) that is **stable** under resampling and **replicates** across implementations (Local HRM/Tiny and HF hf_hrm/hf_mistral);
4. attribute gap structure to **feature families** (content-latents vs process diagnostics) and make the pipeline fully **provenanced** and **portable**.
---
## 2. Data & Inputs
**Unit of analysis**: a *hypothesis* $h_i$ is a short conversation (goal + turns).
**Scoring dimensions**: $D$ as above; each scorer returns a map $s(h_i): D \rightarrow [0,1]$ (normalize if not).
**Corpora**: your curated chat hypotheses ($N$ up to the per-dim cap).
**Stacks**:
* **Local**: `hrm`, `tiny`
* **HF**: `hf_hrm`, `hf_mistral` (mirrors Local)
**Provenance keys**: `goal_id`, `hypothesis_id`, `scorer_name`, `scorer_version`, `dims_hash`, `run_key`.
---
## 3. Canonical Alignment
### 3.1 Score normalization
For any scorer $S$, dimension $d \in D$, hypothesis $h$:
$$\tilde s_S(h,d) = \frac{s_S(h,d)-\mu_{S,d}}{\sigma_{S,d}+\epsilon}$$
then
$$\hat s_S(h,d) = \Phi\left(\tilde s_S(h,d)\right) \in (0,1)$$
where $\mu_{S,d}, \sigma_{S,d}$ are computed on the joint set of hypotheses for $S$; $\Phi$ is standard normal CDF.
**Tip**: If original ranges are already $[0,1]$ and calibrated, set $\hat s_S \equiv s_S$.
### 3.2 Canonical vector & Δ-field
Define the canonical score vector $x_S(h) \in \mathbb{R}^{|D|}$ by ordering dimensions deterministically (e.g., `[reasoning, knowledge, clarity, faithfulness, coverage]`) and stacking $\hat s_S(h,d)$.
Then the **gap vector**:
$$\Delta(h) = x_A(h) - x_B(h)$$
---
## 4. Metrics
* **Δ-mass** (signed magnitude bias):
$$M_{\Delta} = \frac{1}{N}\sum_{i=1}^N \mathbf{1}^\top \Delta(h_i)$$
* **Overlap** (cosine between distributions of $x_A$ and $x_B$):
$$\text{Overlap} = \frac{\langle X_A, X_B\rangle}{\|X_A\|_F \|X_B\|_F}, \quad X_S \in \mathbb{R}^{N\times |D|}$$
* **Hotspot score** per hypothesis $h$:
$$H(h) = \|\Delta(h)\|_1 \quad\text{(or } \|\Delta(h)\|_2\text{)}$$
Top-$k$ by $H(h)$ define **Δ-hotspots** (targets for distillation / audit).
---
## 5. Topological Analysis (Δ-field)
We embed $\{\Delta(h_i)\}$ into $\mathbb{R}^m$ (often $m=|D|$ is enough; optional UMAP to $m=2$ for visualization). Build a Vietoris–Rips filtration with radius parameter $r$, compute persistent homology (PH):
* **Homology groups** $H_k$ via PH → **Betti numbers** $b_k$
* We report $b_1$ (loops) and **persistence** (lifespan of features)
**Pipeline**:
1. Compute pairwise distances $d_{ij} = \|\Delta(h_i)-\Delta(h_j)\|_2$
2. Build filtration $\mathcal{F}(r)$ over $r \in R$
3. Run PH (e.g., `ripser`/`gudhi`) to obtain barcodes/diagrams
4. Summarize: $b_0, b_1$, mean persistence of $H_1$, top loops
**Interpretation**: Non-trivial $H_1$ indicates **structured disagreement manifolds** (e.g., persistent loops) rather than random scatter.
---
## 6. Statistical Validation
### 6.1 Bootstrap stability
* Resample hypotheses with replacement $B$ times (e.g., $B=20$)
* Recompute $b_1$ and mean persistence
* **Stability**: proportion of runs retaining top $H_1$ features within tolerance
### 6.2 Null controls
* **Permutation null**: shuffle dimension columns independently in $x_A$ or permute hypothesis IDs before differencing
* **Noise null**: replace $\Delta$ with i.i.d. Gaussian matched to empirical covariance
**Significance**:
Let $T$ be the observed mean persistence for $H_1$; compute p-value
$$p = \frac{1 + \sum_{b=1}^{B_\text{null}} \mathbf{1}_{T_b \ge T}}{1+B_\text{null}}$$
Benjamini–Hochberg for multiple features if reporting several loops.
---
## 7. Semantic Attribution
Partition features into **families**:
* **Content/Latent** (e.g., HRM latent magnitudes $z_L, z_H$, content-aligned heads)
* **Process Diagnostics** (uncertainty, OOD score, sensitivity)
Compute per-family contribution to $H(h)$:
$$H_f(h) = \| \Delta(h)_{d\in f}\|_1$$
and aggregate across hotspots or across the full set. Consistent dominance of a family across stacks implies **architectural role** (e.g., HRM→content, Tiny→process).
---
## 8. Cross-Implementation Parity (Local ↔ HF)
Replicate Sections 3–7 on **HF stack** with **identical seeds, caps, and normalization**. Compare:
* $M_\Delta$ difference $|\Delta M| < \epsilon$
* Overlap difference $|\Delta \text{Overlap}| < \epsilon$
* Jaccard of top-$k$ hotspots ≥ threshold
* Barcode similarity (e.g., Bottleneck/Wasserstein distance) within tolerance
**Conclusion**: parity indicates **architecture-independent** structure.
---
## Key Formatting Rules for Hugo MathJax:
1. **Inline math**: `$...$` or `\(...\)`
2. **Display math**: `$$...$$` or `\[...\]`
3. **Escape underscores**: Use `\_` instead of `_` in regular text
4. **Use proper brackets**: `\{...\}` for sets, `[...]` for arrays
5. **Special characters**: `\mathbb{R}`, `\mathbf{1}`, `\langle`, `\rangle`
## Alternative: KaTeX (Faster)
If you prefer KaTeX (faster rendering), use this instead:
```html
{{ if or .Params.math .Section "math" }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"
onload="renderMathInElement(document.body, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
]
});">
</script>
{{ end }}
Testing Your Setup
Create a test post with:
---
title: "Math Test"
math: true
---
Here's inline math: $E = mc^2$
And display math:
$$\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}$$
This should render your mathematical formulas beautifully in your Hugo blog!