AnReu commited on
Commit
6b6511c
1 Parent(s): ce61465

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +63 -0
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - retrieval
6
+ - math-retrieval
7
+ datasets:
8
+ - MathematicalStackExchange
9
+ - ARQMath
10
+ ---
11
+
12
+ # ALBERT for ARQMath 3
13
+
14
+ This repository contains our best model for ARQMath 3, the math_10 model. It was initialised from ALBERT-base-v2 and further pre-trained on Math StackExchange in three different stages. We also added more LaTeX tokens to the tokenizer to enable a better tokenization of mathematical formulas. math_10 was fine-tuned on a classification task to determine whether a given question (sequence 1) matches a given answer (sequence 2). The classification output can be used for ranking the best answers. For further details, please read our paper: http://ceur-ws.org/Vol-3180/paper-07.pdf. We plan on also publishing the other fine-tuned models as well as the base models. Links to these repositories will be added here soon.
15
+
16
+ # Usage
17
+
18
+ ```python
19
+ # based on https://huggingface.co/docs/transformers/main/en/task_summary#sequence-classification
20
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
21
+
22
+ tokenizer = AutoTokenizer.from_pretrained("AnReu/albert-for-arqmath-3")
23
+
24
+ model = AutoModelForSequenceClassification.from_pretrained("AnReu/albert-for-arqmath-3")
25
+
26
+ classes = ["non relevant", "relevant"]
27
+
28
+ sequence_0 = "How can I calculate x in $3x = 5$"
29
+ sequence_1 = "Just divide by 3: $x = \\frac{5}{3}$"
30
+ sequence_2 = "The general rule for squaring a sum is $(a+b)^2=a^2+2ab+b^2$"
31
+
32
+ # The tokenizer will automatically add any model specific separators (i.e. <CLS> and <SEP>) and tokens to
33
+ # the sequence, as well as compute the attention masks.
34
+ irrelevant = tokenizer(sequence_0, sequence_2, return_tensors="pt")
35
+ relevant = tokenizer(sequence_0, sequence_1, return_tensors="pt")
36
+
37
+ irrelevant_classification_logits = model(**irrelevant).logits
38
+ relevant_classification_logits = model(**relevant).logits
39
+
40
+ irrelevant_results = torch.softmax(irrelevant_classification_logits, dim=1).tolist()[0]
41
+ relevant_results = torch.softmax(relevant_classification_logits, dim=1).tolist()[0]
42
+
43
+ # Should be irrelevant
44
+ for i in range(len(classes)):
45
+ print(f"{classes[i]}: {int(round(irrelevant_results[i] * 100))}%")
46
+
47
+ # Should be relevant
48
+ for i in range(len(classes)):
49
+ print(f"{classes[i]}: {int(round(relevant_results[i] * 100))}%")
50
+
51
+ ```
52
+
53
+ # Citation
54
+
55
+ If you find this model useful, consider citing our paper:
56
+ ```
57
+ @article{reusch2022transformer,
58
+ title={Transformer-Encoder and Decoder Models for Questions on Math},
59
+ author={Reusch, Anja and Thiele, Maik and Lehner, Wolfgang},
60
+ year={2022},
61
+ organization={CLEF}
62
+ }
63
+ ```