Views
No views yet
| Model | Initialised from | Pre-training | Fine-Tuned | Link |
|---|---|---|---|---|
| roberta_10 | RoBERTa | MathSE (1) | yes, N=10 MathSE | |
| base_10 | ALBERT | MathSE (1) | yes, N=10 MathSE | |
| math_10_add | ALBERT | MathSE (1)-(3) | yes, N=10 MathSE and annotated data | |
| Khan_SE_10 | ALBERT | MathSE (1) | yes, N=10 MathSE | |
| roberta | RoBERTa | MathSE (1) | no | AnReu/math_pretrained_roberta |
| math albert | ALBERT | MathSE (1)-(3) | no | AnReu/math_albert |
| base | ALBERT | MathSE (1) | no | |
| Khan_SE | ALBERT | MathSE (1) mixed with Khan | no |
1# based on https://huggingface.co/docs/transformers/main/en/task_summary#sequence-classification
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4tokenizer = AutoTokenizer.from_pretrained("AnReu/albert-for-arqmath-3")
5
6model = AutoModelForSequenceClassification.from_pretrained("AnReu/albert-for-arqmath-3")
7
8classes = ["non relevant", "relevant"]
9
10sequence_0 = "How can I calculate x in $3x = 5$"
11sequence_1 = "Just divide by 3: $x = \\frac{5}{3}$"
12sequence_2 = "The general rule for squaring a sum is $(a+b)^2=a^2+2ab+b^2$"
13
14# The tokenizer will automatically add any model specific separators (i.e. <CLS> and <SEP>) and tokens to
15# the sequence, as well as compute the attention masks.
16irrelevant = tokenizer(sequence_0, sequence_2, return_tensors="pt")
17relevant = tokenizer(sequence_0, sequence_1, return_tensors="pt")
18
19irrelevant_classification_logits = model(**irrelevant).logits
20relevant_classification_logits = model(**relevant).logits
21
22irrelevant_results = torch.softmax(irrelevant_classification_logits, dim=1).tolist()[0]
23relevant_results = torch.softmax(relevant_classification_logits, dim=1).tolist()[0]
24
25# Should be irrelevant
26for i in range(len(classes)):
27 print(f"{classes[i]}: {int(round(irrelevant_results[i] * 100))}%")
28
29# Should be relevant
30for i in range(len(classes)):
31 print(f"{classes[i]}: {int(round(relevant_results[i] * 100))}%")
32@article{reusch2022transformer,
title={Transformer-Encoder and Decoder Models for Questions on Math},
author={Reusch, Anja and Thiele, Maik and Lehner, Wolfgang},
year={2022},
organization={CLEF}
}