Instructions to use ozhyhinas/latexgen-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use ozhyhinas/latexgen-models with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-to-text', 'ozhyhinas/latexgen-models');
LatexGen model weights (ONNX)
The three ONNX models that LatexGen serves to the browser. LatexGen converts English math and equation screenshots into LaTeX entirely on-device, with nothing leaving the tab.
They are hosted here rather than in the application repository so a clone does not pull 1.6 GB of weights. Each model ships in several precisions plus pre-compressed .gz copies, so a static host can serve whichever the device can run.
Contents
| directory | model | role in the app | precisions | size |
|---|---|---|---|---|
intellitex/ |
IntelliTeX, CodeT5+ 220M fine-tuned on English→LaTeX pairs | the specialist: single equations from plain English | int8, int4 | 629 MB |
texify/ |
Texify | image OCR fallback for prose mixed with math, and dense equations | int8, int4 | 917 MB |
texo/ |
Texo / FormulaNet, 20M | first-pass image OCR: tiny, fast, robust to small fonts and dark backgrounds | fp32 | 76 MB |
Each directory also carries its tokenizer and config. compressed.json lists which files have a pre-built .gz sibling.
How they are used
LatexGen walks a ladder and only climbs when the previous tier's output fails validation. Texo reads an image first and Texify takes over when Texo's output fails a syntax check or spells out prose. IntelliTeX handles single-line text input before any language model is loaded. Measured on an Apple M5 Pro:
| model | ONNX Runtime Web | via webnn-catalog on Core ML |
|---|---|---|
| Texo | 770 ms | 25.9 ms |
| Texify | 810 ms | 145.7 ms |
| IntelliTeX | 450 ms | 146.2 ms |
The int4 variants are GPU-only: on CPU, int4 measured about ten times slower than int8, so the application selects int8 there.
LatexGen downloads a directory, serves it from its own static host, and loads it with transformers.js as a local model:
import { pipeline, env } from "@huggingface/transformers";
env.allowRemoteModels = false;
env.allowLocalModels = true;
env.localModelPath = "/models/"; // holds intellitex/, texo/, texify/
const specialist = await pipeline("text2text-generation", "intellitex", { dtype: "q8" });
const out = await specialist(
"Convert natural-language math into a STRICT LaTeX equation\nx squared plus one",
{ max_new_tokens: 64 },
);
Use dtype: "q4" for the int4 weights where WebGPU is available.
For the routing rules, the validation and repair loop, and the benchmarks behind every choice: https://github.com/OlehZhyhinas/LatexGen
Published by Oleh Zhyhinas (GitHub, LinkedIn).