Downloads · 30 days
44
47% of all-time downloads
piyushgupta53/smollm2-135m-english-to-latex-notation-lora
smollm2-135m-english-to-latex-notation-lora is a text generation model from piyushgupta53. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A rank-32 rsLoRA adapter for HuggingFaceTB/SmolLM2-135M-Instruct that converts a precise English description of mathematical notation into one standalone LaTeX expression.
Downloads · 30 days
44
47% of all-time downloads
All-time downloads
93
Public
Repo size
39.1 MB
Likes
0
Public
Click a slice to open those files.
.safetensors39.1 MB · 92%
From the Hugging Face model README
A rank-32 rsLoRA adapter for HuggingFaceTB/SmolLM2-135M-Instruct that converts a precise English description of mathematical notation into one standalone LaTeX expression.
This model writes notation; it is not intended to solve, calculate, prove, derive, or explain mathematics.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
adapter_id = "piyushgupta53/smollm2-135m-english-to-latex-notation-lora"
base_id = "HuggingFaceTB/SmolLM2-135M-Instruct"
system_prompt = (
"Convert the user's English description of mathematical notation into LaTeX. "
"Return exactly one standalone LaTeX expression. Do not include dollar signs, "
"code fences, explanations, or any other text."
)
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_id,
torch_dtype="auto",
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": "Write the second derivative with respect to g of the fourth power of q evaluated at g."},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
generated = model.generate(
inputs,
max_new_tokens=96,
do_sample=False,
pad_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(generated[0, inputs.shape[-1]:], skip_special_tokens=True).strip())
Expected form:
\frac{d^2}{dg^2}q\left(g\right)^{4}
HuggingFaceTB/SmolLM2-135M-Instruct2e-40.0120260818bb8086d19ef704e4d195ea4125ea800edb1a9623a7fd49b3472904c500cba60aThe 24,956-row training corpus combines deterministic formal targets with audited English paraphrases.
The checkpoint was evaluated greedily with the system prompt above and max_new_tokens=96. Both evaluation sets were frozen and excluded from training.
| Evaluation | Rows | Normalized exact | Compiles | Complete semantic pass |
|---|---|---|---|---|
| Held-out benchmark | 200 | 44 (22.0%) | 197 (98.5%) | 131 (65.5%) |
| Distribution-gap diagnostic | 200 | 116 (58.0%) | 198 (99.0%) | 134 (67.0%) |
Diagnostic semantic pass by arm:
Non-exact predictions were screened with DeepSeek V4 Flash and then every non-exact row was adjudicated with DeepSeek V4 Pro. Compilation and semantic correctness were measured separately: compilable LaTeX can still express the wrong meaning.
This is a narrow 135M-parameter model and is not reliable enough for unreviewed high-stakes use. It still fails many hard or unfamiliar structures. In the structural diagnostic it scored 0/10 on augmented matrices and 0/10 on indexed piecewise expressions with an otherwise branch. Always validate syntax and meaning when correctness matters.
The model may also produce a valid expression that is equivalent to, but textually different from, a reference. Exact match alone is therefore insufficient for comprehensive evaluation.
Apache-2.0, consistent with the base model. See the base model card for its terms and limitations.