EricAI03 commited on
Commit
968748e
·
verified ·
1 Parent(s): 2e201a8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -41
README.md CHANGED
@@ -1,61 +1,95 @@
1
  ---
2
- library_name: transformers
3
  license: mit
4
- base_model: roberta-base
5
  tags:
6
- - generated_from_trainer
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  model-index:
8
  - name: math_token_classification
9
- results: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- <!-- This model card has been generated automatically according to the information the Trainer had access to. You
13
- should probably proofread and complete it, then remove this comment. -->
14
-
15
- # math_token_classification
16
-
17
- This model is a fine-tuned version of [roberta-base](https://huggingface.co/roberta-base) on an unknown dataset.
18
- It achieves the following results on the evaluation set:
19
- - Loss: 0.2459
20
-
21
- ## Model description
22
 
23
- More information needed
24
 
25
- ## Intended uses & limitations
 
 
 
 
 
26
 
27
- More information needed
 
 
 
 
 
 
 
 
 
28
 
29
- ## Training and evaluation data
 
30
 
31
- More information needed
 
 
32
 
33
- ## Training procedure
 
 
 
34
 
35
- ### Training hyperparameters
 
 
 
 
 
 
36
 
37
- The following hyperparameters were used during training:
38
- - learning_rate: 3e-05
39
- - train_batch_size: 16
40
- - eval_batch_size: 16
41
- - seed: 42
42
- - optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
43
- - lr_scheduler_type: linear
44
- - num_epochs: 3
45
- - mixed_precision_training: Native AMP
46
 
47
- ### Training results
48
 
49
- | Training Loss | Epoch | Step | Validation Loss |
50
- |:-------------:|:-----:|:----:|:---------------:|
51
- | 1.4177 | 1.0 | 83 | 0.3656 |
52
- | 0.4853 | 2.0 | 166 | 0.2629 |
53
- | 0.2995 | 3.0 | 249 | 0.2459 |
54
 
 
 
 
55
 
56
- ### Framework versions
57
 
58
- - Transformers 5.16.1
59
- - Pytorch 2.11.0+cu128
60
- - Datasets 4.8.5
61
- - Tokenizers 0.23.1
 
1
  ---
2
+ language: en
3
  license: mit
 
4
  tags:
5
+ - token-classification
6
+ - ner
7
+ - math
8
+ - mathematics
9
+ - equations
10
+ base_model: roberta-base
11
+ datasets:
12
+ - lighteval/MATH-Hard
13
+ metrics:
14
+ - precision
15
+ - recall
16
+ - f1
17
+ - accuracy
18
+ pipeline_tag: token-classification
19
  model-index:
20
  - name: math_token_classification
21
+ results:
22
+ - task:
23
+ type: token-classification
24
+ name: Named Entity Recognition
25
+ dataset:
26
+ name: lighteval/MATH-Hard
27
+ type: lighteval/MATH-Hard
28
+ split: train
29
+ metrics:
30
+ - name: Accuracy
31
+ type: accuracy
32
+ value: 0.0
33
+ - name: F1
34
+ type: f1
35
+ value: 0.0
36
  ---
37
 
38
+ # Math Token Classification (RoBERTa-base)
 
 
 
 
 
 
 
 
 
39
 
40
+ 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.
41
 
42
+ ## Target Domains & Labels
43
+ The model uses a **BIO (Beginning, Inside, Outside)** tagging schema across 4 distinct mathematical disciplines:
44
+ - `ALGEBRA` (e.g., linear equations, polynomials, systems of equations)
45
+ - `CALCULUS` (e.g., integrals, derivatives, limits)
46
+ - `GEOMETRY` (e.g., shapes, coordinate planes, geometric theorems)
47
+ - `TRIGONOMETRY` (e.g., sine, cosine, identity equations)
48
 
49
+ ### Label Mapping Indices
50
+ ```json
51
+ {
52
+ "0": "O",
53
+ "1": "B-ALGEBRA", "2": "I-ALGEBRA",
54
+ "3": "B-CALCULUS", "4": "I-CALCULUS",
55
+ "5": "B-GEOMETRY", "6": "I-GEOMETRY",
56
+ "7": "B-TRIGONOMETRY", "8": "I-TRIGONOMETRY"
57
+ }
58
+ ```
59
 
60
+ ## Intended Uses & Limitations
61
+ This model is intended for educational tools, math tutoring software, or documentation engines to help parse, analyze, or visually highlight mathematical syntax automatically.
62
 
63
+ ### Limitations
64
+ - **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.
65
+ - **Context Dependence:** The expression classification depends heavily on the context words around the formula in the prompt sentence.
66
 
67
+ ## Training Data & Methodology
68
+ 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).
69
+ - **Sequence Preprocessing:** Regular expressions isolated math spans wrapped in standard delimiters (`$...$`, `$$...$$`, `\[...\]`, `\(...\)`).
70
+ - **Subword Alignment:** Character boundaries were aligned to RoBERTa token vectors via structural sequence index matching (`char_to_token`).
71
 
72
+ ### Training Hyperparameters
73
+ - **Base Architecture:** RoBERTa-base (~125M parameters)
74
+ - **Learning Rate:** 3e-5
75
+ - **Batch Size:** 8
76
+ - **Epochs:** 3
77
+ - **Optimizer:** AdamW with weight decay (0.01)
78
+ - **Precision:** Mixed Precision (FP16) where available
79
 
80
+ ## How to Use
 
 
 
 
 
 
 
 
81
 
82
+ You can run inference using the Hugging Face `pipeline` API:
83
 
84
+ ```python
85
+ from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification
 
 
 
86
 
87
+ model_id = "EricAI03/math_token_classification"
88
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
89
+ model = AutoModelForTokenClassification.from_pretrained(model_id)
90
 
91
+ nlp_ner = pipeline("token-classification", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
92
 
93
+ text = "Find the derivative of \(\int x^2\) dx and then solve the linear equation \(y = 2x + 3\)."
94
+ print(nlp_ner(text))
95
+ ```