Update README.md
Browse files
README.md
CHANGED
@@ -9,21 +9,6 @@ datasets:
|
|
9 |
metrics:
|
10 |
- exact_match
|
11 |
- rouge
|
12 |
-
model-index:
|
13 |
-
- name: calc-flan-xl
|
14 |
-
results:
|
15 |
-
- task:
|
16 |
-
type: question-answering
|
17 |
-
name: Question Answering
|
18 |
-
dataset:
|
19 |
-
type: gsm8k
|
20 |
-
name: GSM8K
|
21 |
-
split: validation
|
22 |
-
metrics:
|
23 |
-
- type: exact_match
|
24 |
-
value: 0.495
|
25 |
-
- type: rouge
|
26 |
-
value: 0.655
|
27 |
license: apache-2.0
|
28 |
language:
|
29 |
- en
|
@@ -31,15 +16,10 @@ language:
|
|
31 |
|
32 |
# Model Card for calc-flan-xl
|
33 |
|
34 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
35 |
-
|
36 |
This model generates reasoning chains over mathematical questions while **using an external tool: Sympy calculator**.
|
37 |
|
38 |
-
## Model Details
|
39 |
-
|
40 |
-
### Model Description
|
41 |
|
42 |
-
|
43 |
|
44 |
With the idea to offload a symbolic reasoning from the stochastic language model,
|
45 |
we train this model to utilize a calculator **for all applicable numeric operations**.
|
@@ -52,17 +32,19 @@ This is achieved by training the model to construct calls to the tool's API in t
|
|
52 |
where `<gadget>` segment triggers a call of the tool,
|
53 |
which is subsequently served by extending model's decoder input context by adding the output of the tool within the `<output>` segment.
|
54 |
|
55 |
-
- **Developed by:**
|
56 |
- **Model type:** Autoregressive Encoder-Decoder
|
57 |
- **Language(s):** en
|
58 |
- **Finetuned from:** google/flan-t5-xl
|
59 |
|
60 |
-
### Model Sources
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
- **Repository:** https://github.com/emnlp2023sub/gadgets
|
65 |
-
- **Paper:** Stay tuned!
|
66 |
|
67 |
## Usage
|
68 |
|
@@ -71,20 +53,20 @@ Additionally to conventional generation, using Tool-augmented generation require
|
|
71 |
(2) a customization of generate() method augmenting input context on-demand with the outputs of the tools.
|
72 |
|
73 |
You can find these two components implemented in the attached **gadgets/model.py** and **gadgets/gadget.py** in this model's repo
|
74 |
-
and the project's [home repo](https://github.com/
|
75 |
|
76 |
After adding these two scripts to your directory, you can use the model as follows:
|
77 |
|
78 |
-
```
|
79 |
-
|
80 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
81 |
|
82 |
from gadgets.model import gadget_assisted_model
|
83 |
from gadgets.gadget import Calculator
|
84 |
|
85 |
GadgetAssistedT5 = gadget_assisted_model(T5ForConditionalGeneration)
|
86 |
-
|
87 |
-
|
|
|
88 |
|
89 |
model.prepare_for_generate(tokenizer,
|
90 |
enabled_gadgets=[Calculator()],
|
@@ -100,7 +82,9 @@ inputs = tokenizer(query, return_tensors="pt")
|
|
100 |
output_ids = model.generate(**inputs)
|
101 |
tokenizer.decode(output_ids[0], spaces_between_special_tokens=False)
|
102 |
```
|
|
|
103 |
This returns:
|
|
|
104 |
```html
|
105 |
According to the ratio, for every 5 parts that Johnson gets, Mike gets 2 parts Since Johnson got $2500,
|
106 |
each part is therefore $2500/5 = $<gadget id="calculator">2500/5</gadget><output>500</output> 500
|
@@ -109,26 +93,17 @@ After buying the shirt he will have $1000-$200 = $<gadget id="calculator">1000-2
|
|
109 |
Final result is<result>800</result></s>
|
110 |
```
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
115 |
|
116 |
Note that given the limited scope of the exercises' complexity in the training, this model will not work well for tasks requiring
|
117 |
more complex algebraic operations, including equations, variables and operations outside the scope of (+-*/).
|
118 |
|
119 |
|
120 |
-
## Training
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
This model was trained on our Calculator-augmented set of
|
125 |
|
126 |
-
- [Calc Ape210k](https://huggingface.co/datasets/emnlp2023/Calc-ape210k) ([original Ape210k on github](https://github.com/Chenny0808/ape210k))
|
127 |
-
- [Calc MathQA](https://huggingface.co/datasets/emnlp2023/Calc-math_qa) ([original MathQA on HF](https://huggingface.co/datasets/math_qa))
|
128 |
-
- [Calc GSM8K](https://huggingface.co/datasets/emnlp2023/Calc-gsm8k) ([original GSM8K on HF](https://huggingface.co/datasets/gsm8k))
|
129 |
-
- [Calc Aqua-RAT](https://huggingface.co/datasets/emnlp2023/Calc-aqua_rat) ([original Aqua-RAT on HF](https://huggingface.co/datasets/aqua_rat))
|
130 |
-
|
131 |
-
in a standard auto-regressive setup i.e. for a conditional next-token prediction with teacher-forced prefix.
|
132 |
|
133 |
## Cite
|
134 |
|
|
|
9 |
metrics:
|
10 |
- exact_match
|
11 |
- rouge
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
license: apache-2.0
|
13 |
language:
|
14 |
- en
|
|
|
16 |
|
17 |
# Model Card for calc-flan-xl
|
18 |
|
|
|
|
|
19 |
This model generates reasoning chains over mathematical questions while **using an external tool: Sympy calculator**.
|
20 |
|
|
|
|
|
|
|
21 |
|
22 |
+
## Model Description
|
23 |
|
24 |
With the idea to offload a symbolic reasoning from the stochastic language model,
|
25 |
we train this model to utilize a calculator **for all applicable numeric operations**.
|
|
|
32 |
where `<gadget>` segment triggers a call of the tool,
|
33 |
which is subsequently served by extending model's decoder input context by adding the output of the tool within the `<output>` segment.
|
34 |
|
35 |
+
- **Developed by:** Calcformer team
|
36 |
- **Model type:** Autoregressive Encoder-Decoder
|
37 |
- **Language(s):** en
|
38 |
- **Finetuned from:** google/flan-t5-xl
|
39 |
|
|
|
40 |
|
41 |
+
## Sources
|
42 |
+
|
43 |
+
- **Repository:** <https://github.com/prompteus/calc-x>
|
44 |
+
- **Paper:** <https://arxiv.org/abs/2305.15017>
|
45 |
+
- [**Calcformer model family on HF**](https://huggingface.co/collections/MU-NLPC/calcformers-65367392badc497807b3caf5)
|
46 |
+
- [**Calc-X dataset collection on HF**](https://huggingface.co/collections/MU-NLPC/calc-x-652fee9a6b838fd820055483)
|
47 |
|
|
|
|
|
48 |
|
49 |
## Usage
|
50 |
|
|
|
53 |
(2) a customization of generate() method augmenting input context on-demand with the outputs of the tools.
|
54 |
|
55 |
You can find these two components implemented in the attached **gadgets/model.py** and **gadgets/gadget.py** in this model's repo
|
56 |
+
and the project's [home repo](https://github.com/prompteus/calc-x).
|
57 |
|
58 |
After adding these two scripts to your directory, you can use the model as follows:
|
59 |
|
60 |
+
```python3
|
|
|
61 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
62 |
|
63 |
from gadgets.model import gadget_assisted_model
|
64 |
from gadgets.gadget import Calculator
|
65 |
|
66 |
GadgetAssistedT5 = gadget_assisted_model(T5ForConditionalGeneration)
|
67 |
+
model_name = "MU-NLPC/calcformer-flan-xl"
|
68 |
+
model = GadgetAssistedT5.from_pretrained(model_name)
|
69 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
70 |
|
71 |
model.prepare_for_generate(tokenizer,
|
72 |
enabled_gadgets=[Calculator()],
|
|
|
82 |
output_ids = model.generate(**inputs)
|
83 |
tokenizer.decode(output_ids[0], spaces_between_special_tokens=False)
|
84 |
```
|
85 |
+
|
86 |
This returns:
|
87 |
+
|
88 |
```html
|
89 |
According to the ratio, for every 5 parts that Johnson gets, Mike gets 2 parts Since Johnson got $2500,
|
90 |
each part is therefore $2500/5 = $<gadget id="calculator">2500/5</gadget><output>500</output> 500
|
|
|
93 |
Final result is<result>800</result></s>
|
94 |
```
|
95 |
|
96 |
+
## Out-of-Scope Usage
|
|
|
|
|
97 |
|
98 |
Note that given the limited scope of the exercises' complexity in the training, this model will not work well for tasks requiring
|
99 |
more complex algebraic operations, including equations, variables and operations outside the scope of (+-*/).
|
100 |
|
101 |
|
102 |
+
## Training
|
103 |
|
104 |
+
This model was trained on [Calc-X](https://huggingface.co/collections/MU-NLPC/calc-x-652fee9a6b838fd820055483), a collection of math problem datasets which we converted into CoT with calculator interactions.
|
105 |
+
We used a standard auto-regressive transformer training, i.e. a conditional next-token prediction with cross-entropy loss. For more detail about data, training or evaluation, see the [Calc-X and Calcformers paper](https://arxiv.org/abs/2305.15017).
|
|
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
## Cite
|
109 |
|