Text Generation
PEFT
Safetensors
lora
finqa
finance
numerical-reasoning
Mr-Rosen commited on
Commit
01aafbb
·
verified ·
1 Parent(s): 98426c1

Initial adapter release

Browse files
LICENSE ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mr-Rosen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Scope note: this license applies to this adapter release. It does not alter or
24
+ replace the license or attribution requirements of Qwen/Qwen2.5-7B-Instruct,
25
+ FinQA, the CC BY 4.0 expanded FinQA dataset, or upstream FinQA code/evaluator
26
+ material.
README.md ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-7B-Instruct
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ license: mit
6
+ datasets:
7
+ - Mr-Rosen/Accuracy-Is-Not-Enough-FinQA-Dataset
8
+ tags:
9
+ - peft
10
+ - lora
11
+ - finqa
12
+ - finance
13
+ - numerical-reasoning
14
+ ---
15
+
16
+ # FinQA Qwen2.5-7B LoRA
17
+
18
+ A LoRA adapter for structured financial question answering over Natively Extended FinQA.
19
+
20
+ Base model:
21
+
22
+ `Qwen/Qwen2.5-7B-Instruct`
23
+
24
+ This repository contains PEFT adapter weights, not a standalone copy of the base model.
25
+
26
+ ## Official Result
27
+
28
+ | Metric | Final Test |
29
+ |---|---:|
30
+ | Execution Accuracy | **66.17%** |
31
+ | Program Accuracy | **61.64%** |
32
+ | Parse Success | **97.82%** |
33
+ | Average Latency | 0.4793 s/example |
34
+
35
+ Selected checkpoint:
36
+
37
+ `epoch_1_adapter`
38
+
39
+ The checkpoint was selected using development-set performance before final test evaluation.
40
+
41
+ ## Intended Input
42
+
43
+ This adapter was trained on **full expanded FinQA context**.
44
+
45
+ Training mapping:
46
+
47
+ ```text
48
+ question
49
+ + pre_text
50
+ + table
51
+ + post_text
52
+
53
+ FinQA program
54
+ ````
55
+
56
+ Training target:
57
+
58
+ `qa.program`
59
+
60
+ The selected prompt is included in this repository as:
61
+
62
+ `S2_financial_analyst_operation_reader.json`
63
+
64
+ Do not replace the full-document input with RAG chunks when attempting to reproduce the reported LoRA result.
65
+
66
+ ## Adapter Configuration
67
+
68
+ ```text
69
+ rank: 64
70
+ alpha: 32
71
+ dropout: 0.05
72
+ bias: none
73
+ task type: CAUSAL_LM
74
+ ```
75
+
76
+ Target modules:
77
+
78
+ ```text
79
+ q_proj
80
+ k_proj
81
+ v_proj
82
+ o_proj
83
+ gate_proj
84
+ up_proj
85
+ down_proj
86
+ ```
87
+
88
+ Additional confirmed training settings include:
89
+
90
+ ```text
91
+ learning rate: 1e-4
92
+ effective batch size: 32
93
+ training dtype: bfloat16
94
+ ```
95
+
96
+ ## Official Training Burden
97
+
98
+ For the study's controlled practical comparison:
99
+
100
+ ```text
101
+ Training time: 14.7519 hours
102
+ Training cost: approximately $27.88
103
+ ```
104
+
105
+ ## Installation
106
+
107
+ ```bash
108
+ pip install torch transformers peft accelerate safetensors
109
+ ```
110
+
111
+ ## Load the Adapter
112
+
113
+ ```python
114
+ import torch
115
+ from transformers import AutoModelForCausalLM, AutoTokenizer
116
+ from peft import PeftModel
117
+
118
+ BASE_MODEL = "Qwen/Qwen2.5-7B-Instruct"
119
+ ADAPTER = "Mr-Rosen/Accuracy-Is-Not-Enough-FinQA-LoRA"
120
+
121
+ tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
122
+
123
+ base_model = AutoModelForCausalLM.from_pretrained(
124
+ BASE_MODEL,
125
+ torch_dtype=torch.bfloat16,
126
+ device_map="auto",
127
+ )
128
+
129
+ model = PeftModel.from_pretrained(
130
+ base_model,
131
+ ADAPTER,
132
+ )
133
+
134
+ model.eval()
135
+ ```
136
+
137
+ ## Prepare the Input
138
+
139
+ Use the exact released `S2_financial_analyst_operation_reader` prompt.
140
+
141
+ The prompt should receive:
142
+
143
+ ```text
144
+ qa.question
145
+ pre_text
146
+ table
147
+ post_text
148
+ ```
149
+
150
+ Do not expose:
151
+
152
+ ```text
153
+ qa.program
154
+ qa.exe_ans
155
+ qa.gold_inds
156
+ ```
157
+
158
+ during normal dev or test inference.
159
+
160
+ ## Generate
161
+
162
+ Once `rendered_prompt` has been constructed with the official prompt:
163
+
164
+ ```python
165
+ inputs = tokenizer(
166
+ rendered_prompt,
167
+ return_tensors="pt",
168
+ ).to(model.device)
169
+
170
+ with torch.no_grad():
171
+ output = model.generate(
172
+ **inputs,
173
+ max_new_tokens=256,
174
+ do_sample=False,
175
+ )
176
+
177
+ generated = output[0, inputs["input_ids"].shape[-1]:]
178
+
179
+ text = tokenizer.decode(
180
+ generated,
181
+ skip_special_tokens=True,
182
+ )
183
+
184
+ print(text)
185
+ ```
186
+
187
+ ## Expected Output
188
+
189
+ ```json
190
+ ["subtract(", "5829", "5735", ")", "EOF"]
191
+ ```
192
+
193
+ ## Evaluation
194
+
195
+ Parsed predictions should be converted to:
196
+
197
+ ```json
198
+ [
199
+ {
200
+ "id": "example-id",
201
+ "predicted": [
202
+ "subtract(",
203
+ "5829",
204
+ "5735",
205
+ ")",
206
+ "EOF"
207
+ ]
208
+ }
209
+ ]
210
+ ```
211
+
212
+ Then evaluate them with the original FinQA evaluator.
213
+
214
+ ## Related Repositories
215
+
216
+ Dataset:
217
+
218
+ `Mr-Rosen/Accuracy-Is-Not-Enough-FinQA-Dataset`
219
+
220
+ Prompts, evaluator, results, and paper materials:
221
+
222
+ `MarkPaulRosenthal/Accuracy-Is-Not-Enough-Practical-Financial-QA`
223
+
224
+ ## Limitations
225
+
226
+ This adapter was trained specifically for FinQA-style numerical program generation.
227
+
228
+ It is not a general financial-advice model, and its reported accuracy should not be assumed to transfer directly to unrelated financial documents or tasks.
229
+
230
+ ## License
231
+
232
+ The adapter is released under the MIT License.
233
+
234
+ The Qwen base model remains subject to its own license.
235
+
236
+ The FinQA-derived training dataset is separately released under CC BY 4.0.
S2_financial_analyst_operation_reader.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "variant_id": "S2_financial_analyst_operation_reader",
3
+ "family": "S",
4
+ "description": "Prompt S: financial analyst translating questions into FinQA token-list programs.",
5
+ "system_message": "You are a financial analyst that converts financial questions into FinQA calculation programs.",
6
+ "instruction_text": "You are a financial analyst that converts financial questions into calculation programs. Read the context, identify the relevant numbers, and finish the answer after the final program: marker with only the FinQA JSON token list. The two examples show the required pattern.\n\n\nAllowed operation names:\nadd\nsubtract\nmultiply\ndivide\nexp\ngreater\ntable_sum\ntable_average\ntable_max\ntable_min\n\nWhen writing the answer after program:, use a FinQA JSON token list. The operation token includes the opening parenthesis, such as \"divide(\".\n\nExample1 - \"pre_text: shutdown. the customer, which primarily received products from the tonnage gases segment, filed for bankruptcy in may 2012 and announced the mill shutdown in august 2012. pension settlement loss our U.S. supplemental pension plan provides for a lump sum benefit payment option at the time of retirement, or for corporate officers, six months after the retirement date. pension settlements are recognized when cash payments exceed the sum of the service and interest cost components of net periodic pension cost of the plan for the fiscal year. the participant 2019s vested benefit is considered fully settled upon cash payment of the lump sum. we recognized $12.4 of settlement charges in 2013. advisory costs during the fourth quarter of 2013, we incurred legal and other advisory fees of $10.1 ($6.4 after-tax, or $.03 per share) in connection with our response to the rapid acquisition of a large position in shares of our common stock by pershing square capital management llc and its affiliates (pershing square). these fees, which are reflected on the consolidated income statements as 201cadvisory costs, 201d include costs incurred before and after pershing square 2019s disclosure of its holdings and cover advisory services related to the adoption of the shareholders rights plan, preparation for a potential proxy solicitation campaign, and entering into an agreement with pershing square. other income (expense), net items recorded to other income (expense), net arise from transactions and events not directly related to our principal income earning activities. the detail of other income (expense), net is presented in note 23, supplemental information, to the consolidated financial statements. 2013 vs. 2012 other income (expense), net of $70.2 increased $23.1, primarily due to higher gains from the sale of a number of small assets and investments and a favorable commercial contract settlement, partially offset by lower government grants. otherwise, no individual items were significant in comparison to the prior year. 2012 vs. 2011 other income (expense), net of $47.1 increased $5.4, primarily due to favorable foreign exchange and reimbursements from government grants for expense, partially offset by lower gains from the sale of assets. otherwise, no individual items were significant in comparison to the prior year. interest expense. table: 2013 2012 2011 | interest incurred $167.6$ 153.9 $138.2 | less : capitalized interest 25.8 30.2 22.7 | interest expense$ 141.8 $123.7$ 115.5 2013 vs. 2012 interest incurred increased $13.7. the increase was driven primarily by a higher average debt balance for $41, partially offset by a lower average interest rate on the debt portfolio of $24. the change in capitalized interest was driven by a decrease in project spending and a lower average interest rate. 2012 vs. 2011 interest incurred increased $15.7. the increase was driven primarily by a higher average debt balance and debt issuance costs related to the indura s.a. acquisition, partially offset by the impact of a stronger dollar on the translation of foreign currency interest. the change in capitalized interest was driven by an increase in project spending which qualified for capitalization. effective tax rate the effective tax rate equals the income tax provision divided by income from continuing operations before taxes. refer to note 22, income taxes, to the consolidated financial statements for details on factors affecting the effective tax rate. 2013 vs. 2012 on a gaap basis, the effective tax rate was 22.8% (22.8%) and 21.9% (21.9%) in 2013 and 2012, respectively. the current year rate includes income tax benefits of $73.7 related to the business restructuring and cost reduction plans and $3.7 for the advisory costs. the prior year rate includes income tax benefits of $105.0 related to the business restructuring and cost reduction plans, $58.3 related to the second quarter spanish tax ruling, and $3.7 related to the customer. what was the percentual increase of other income due to favorable foreign exchange and reimbursements in 2011? program:[\"divide(\", \"5.4\", \"47.1\", \")\", \"EOF\"]\"\n\nExample2 - \"note 6: inventories we use the last-in, first-out (lifo) method for the majority of our inventories located in the continental U.S. other inventories are valued by the first-in, first-out (fifo) method. fifo cost approximates current replacement cost. inventories measured using lifo must be valued at the lower of cost or market. inventories measured using fifo must be valued at the lower of cost or net realizable value. inventories at december 31 consisted of the following:.table: 2018 2017 | finished products $988.1$ 1211.4 | work in process 2628.2 2697.7 | raw materials and supplies 506.5 488.8 | total ( approximates replacement cost ) 4122.8 4397.9 | increase ( reduction ) to lifo cost -11.0 ( 11.0 ) 60.4 | inventories $4111.8$ 4458.3 inventories valued under the lifo method comprised $1.57 billion and $1.56 billion of total inventories at december 31, 2018 and 2017, respectively. note 7: financial instruments financial instruments that potentially subject us to credit risk consist principally of trade receivables and interest-bearing investments. wholesale distributors of life-science products account for a substantial portion of our trade receivables; collateral is generally not required. we seek to mitigate the risk associated with this concentration through our ongoing credit-review procedures and insurance. a large portion of our cash is held by a few major financial institutions. we monitor our exposures with these institutions and do not expect any of these institutions to fail to meet their obligations. major financial institutions represent the largest component of our investments in corporate debt securities. in accordance with documented corporate risk-management policies, we monitor the amount of credit exposure to any one financial institution or corporate issuer. we are exposed to credit-related losses in the event of nonperformance by counterparties to risk-management instruments but do not expect any counterparties to fail to meet their obligations given their high credit ratings. we consider all highly liquid investments with a maturity of three months or less from the date of purchase to be cash equivalents. the cost of these investments approximates fair value. our equity investments are accounted for using three different methods depending on the type of equity investment: 2022 investments in companies over which we have significant influence but not a controlling interest are accounted for using the equity method, with our share of earnings or losses reported in other-net, (income) expense. 2022 for equity investments that do not have readily determinable fair values, we measure these investments at cost, less any impairment, plus or minus changes resulting from observable price changes in orderly transactions for the identical or similar investment of the same issuer. any change in recorded value is recorded in other-net, (income) expense. 2022 our public equity investments are measured and carried at fair value. any change in fair value is recognized in other-net, (income) expense. we review equity investments other than public equity investments for indications of impairment on a regular basis. our derivative activities are initiated within the guidelines of documented corporate risk-management policies and are intended to offset losses and gains on the assets, liabilities, and transactions being hedged. management reviews the correlation and effectiveness of our derivatives on a quarterly basis.. what was the percent of the finished products to the total inventory? program:[\"divide(\", \"988.1\", \"4111.8\", \")\", \"EOF\"]\"\n\ninput:\n{passage}\n\nquestion: {question}\n\n program:"
7
+ }
adapter_config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": null,
6
+ "base_model_name_or_path": "Qwen/Qwen2.5-7B-Instruct",
7
+ "bias": "none",
8
+ "corda_config": null,
9
+ "ensure_weight_tying": false,
10
+ "eva_config": null,
11
+ "exclude_modules": null,
12
+ "fan_in_fan_out": false,
13
+ "inference_mode": true,
14
+ "init_lora_weights": true,
15
+ "layer_replication": null,
16
+ "layers_pattern": null,
17
+ "layers_to_transform": null,
18
+ "loftq_config": {},
19
+ "lora_alpha": 32,
20
+ "lora_bias": false,
21
+ "lora_dropout": 0.05,
22
+ "lora_ga_config": null,
23
+ "megatron_config": null,
24
+ "megatron_core": "megatron.core",
25
+ "modules_to_save": null,
26
+ "peft_type": "LORA",
27
+ "peft_version": "0.19.1",
28
+ "qalora_group_size": 16,
29
+ "r": 64,
30
+ "rank_pattern": {},
31
+ "revision": null,
32
+ "target_modules": [
33
+ "o_proj",
34
+ "v_proj",
35
+ "down_proj",
36
+ "gate_proj",
37
+ "q_proj",
38
+ "k_proj",
39
+ "up_proj"
40
+ ],
41
+ "target_parameters": null,
42
+ "task_type": "CAUSAL_LM",
43
+ "trainable_token_indices": null,
44
+ "use_bdlora": null,
45
+ "use_dora": false,
46
+ "use_qalora": false,
47
+ "use_rslora": false
48
+ }
adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00789b410b40ad248c50ad012fe14c497758539af56322f8118bd64330f61fb0
3
+ size 645975704