Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# numbers_gcd
|
| 2 |
+
---
|
| 3 |
+
language: en
|
| 4 |
+
datasets:
|
| 5 |
+
- numbers_gcd
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
This is a [t5-small](https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html) fine-tuned version on the [math_dataset/numbers_gcd](https://www.tensorflow.org/datasets/catalog/math_dataset#mathdatasetnumbers_gcd) for solving **greatest common divisor** mission.
|
| 9 |
+
|
| 10 |
+
To load the model:
|
| 11 |
+
(necessary packages: !pip install transformers sentencepiece)
|
| 12 |
+
```python
|
| 13 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 14 |
+
tokenizer = AutoTokenizer.from_pretrained("dbernsohn/t5_numbers_gcd")
|
| 15 |
+
model = AutoModelWithLMHead.from_pretrained("dbernsohn/t5_numbers_gcd")
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
You can then use this model to solve algebra 1d equations into numbers.
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
query = "What is the highest common factor of 4210884 and 72?"
|
| 22 |
+
input_text = f"{query} </s>"
|
| 23 |
+
features = tokenizer([input_text], return_tensors='pt')
|
| 24 |
+
model.to('cuda')
|
| 25 |
+
output = model.generate(input_ids=features['input_ids'].cuda(),
|
| 26 |
+
attention_mask=features['attention_mask'].cuda())
|
| 27 |
+
|
| 28 |
+
tokenizer.decode(output[0])
|
| 29 |
+
# <pad> 36</s>
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
Another examples:
|
| 33 |
+
|
| 34 |
+
+ Calculate the greatest common factor of 3470 and 97090.
|
| 35 |
+
+ Answer: 10 Pred: 10
|
| 36 |
+
----
|
| 37 |
+
+ Calculate the highest common factor of 3480 and 775431.
|
| 38 |
+
+ Answer: 87 Pred: 87
|
| 39 |
+
----
|
| 40 |
+
+ What is the highest common divisor of 26 and 88049?
|
| 41 |
+
+ Answer: 13 Pred: 13
|
| 42 |
+
----
|
| 43 |
+
+ Calculate the highest common factor of 1416 and 24203688.
|
| 44 |
+
+ Answer: 1416 Pred: 1416
|
| 45 |
+
----
|
| 46 |
+
+ Calculate the highest common divisor of 124 and 69445828.
|
| 47 |
+
+ Answer: 124 Pred: 124
|
| 48 |
+
----
|
| 49 |
+
+ What is the greatest common factor of 657906 and 470?
|
| 50 |
+
+ Answer: 94 Pred: 94
|
| 51 |
+
----
|
| 52 |
+
+ What is the highest common factor of 4210884 and 72?
|
| 53 |
+
+ Answer: 36 Pred: 36
|
| 54 |
+
|
| 55 |
+
The whole training process and hyperparameters are in my [GitHub repo](https://github.com/DorBernsohn/CodeLM/tree/main/MathLM)
|
| 56 |
+
> Created by [Dor Bernsohn](https://www.linkedin.com/in/dor-bernsohn-70b2b1146/)
|