File size: 3,587 Bytes
8806a47 968748e 4661832 968748e 4661832 968748e 8806a47 4661832 c0be900 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e 4661832 968748e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | ---
language: en
license: mit
tags:
- token-classification
- ner
- math
- mathematics
- equations
base_model: roberta-base
datasets:
- lighteval/MATH-Hard
metrics:
- precision
- recall
- f1
- accuracy
pipeline_tag: token-classification
model-index:
- name: math_token_classification
results:
- task:
type: token-classification
name: Named Entity Recognition
dataset:
name: lighteval/MATH-Hard
type: lighteval/MATH-Hard
split: train
metrics:
- name: Accuracy
type: accuracy
value: 0.0
- name: F1
type: f1
value: 0.0
---
# FOR TESTING PURPOSES TO SEE IF TOKEN CLASSIFICATION CAN BE USED FOR MATCHING MATH EXPRESSIONS TO MATH FIELDS
# Math Token Classification (RoBERTa-base)
This model is a fine-tuned version of **roberta-base** optimized to perform **Named Entity Recognition (NER) / Token Classification** on mathematical texts. Its primary objective is to detect inline and block LaTeX mathematical expressions within standard English text and classify them into their respective mathematical domains.
## Target Domains & Labels
The model uses a **BIO (Beginning, Inside, Outside)** tagging schema across 4 distinct mathematical disciplines:
- `ALGEBRA` (e.g., linear equations, polynomials, systems of equations)
- `CALCULUS` (e.g., integrals, derivatives, limits)
- `GEOMETRY` (e.g., shapes, coordinate planes, geometric theorems)
- `TRIGONOMETRY` (e.g., sine, cosine, identity equations)
### Label Mapping Indices
```json
{
"0": "O",
"1": "B-ALGEBRA", "2": "I-ALGEBRA",
"3": "B-CALCULUS", "4": "I-CALCULUS",
"5": "B-GEOMETRY", "6": "I-GEOMETRY",
"7": "B-TRIGONOMETRY", "8": "I-TRIGONOMETRY"
}
```
## Intended Uses & Limitations
This model is intended for educational tools, math tutoring software, or documentation engines to help parse, analyze, or visually highlight mathematical syntax automatically.
### Limitations
- **Tokenizer Fragility:** While RoBERTa's Byte-Level BPE tokenizer handles rare math symbols effectively, highly non-standard or custom LaTeX macros not present in standard datasets might fragment predictions.
- **Context Dependence:** The expression classification depends heavily on the context words around the formula in the prompt sentence.
## Training Data & Methodology
The model was fine-tuned on **1,553 highly complex mathematical problems** extracted from the **`lighteval/MATH-Hard`** dataset (specifically Level 5 competition-grade questions).
- **Sequence Preprocessing:** Regular expressions isolated math spans wrapped in standard delimiters (`$...$`, `$$...$$`, `\[...\]`, `\(...\)`).
- **Subword Alignment:** Character boundaries were aligned to RoBERTa token vectors via structural sequence index matching (`char_to_token`).
### Training Hyperparameters
- **Base Architecture:** RoBERTa-base (~125M parameters)
- **Learning Rate:** 3e-5
- **Batch Size:** 8
- **Epochs:** 3
- **Optimizer:** AdamW with weight decay (0.01)
- **Precision:** Mixed Precision (FP16) where available
## How to Use
You can run inference using the Hugging Face `pipeline` API:
```python
from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
model_id = "EricAI03/math_token_classification"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id)
nlp_ner = pipeline("token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
text = "Find the derivative of \(\int x^2\) dx and then solve the linear equation \(y = 2x + 3\)."
print(nlp_ner(text))
```
|