Manuscript Offprint
arXiv:2608.27919From Documents to Reasoning: A Validated Synthetic Data Pipeline and Semantic-Aware Fine-Tuning for Financial Numerical Reasoning
Lokendra Birla
Accenture Labs
Bengaluru, India
Milind Savagaonkar
Accenture Labs
Bengaluru, India
milind.savagaonkar@accenture.com
Visnu Srinivasan
Accenture Labs
Bengaluru, India
visnu.srinivasan@accenture.com
Sowmya Rasipuram†
Accenture Labs
Bengaluru, India
Abstract
Financial question answering (QA) has emerged as a key benchmark for evaluating the performance of Large Language Models (LLMs) on domain-specific tasks involving complex data formats such as tables, charts, and rich textual narratives. While recent advancements have enabled models to reason across modalities and perform multi-step arithmetic operations, limitations remain in performance consistency, and evaluation reliability. In particular, standard evaluation metrics like Exact Match (EM) often fail to account for minor variations such as differences in units or formats, misleading performance assessments.
In this work, we propose a comprehensive pipeline for improving financial QA systems through high-quality synthetic data generation and fine-tuning of smaller language models (SLMs) using Quantized Low-Rank Adaptation (QLoRA). Our pipeline includes aggressive data validation for synthetic question answer generation to ensure the relevance and correctness of synthetic question-answer pairs. We introduce a novel evaluation metric that matches answers computed from arithmetic expressions rather than ground-truth answers; providing a more accurate reflection of model reasoning capability. Furthermore, we propose a modified loss function that aligns predicted and reference expressions using semantic similarity, our novel evaluation metric and standard cross-entropy, resulting in improved performance. Experimental results on benchmark datasets, ConvFinQA demonstrate significant gains in QA accuracy after fine-tuning using synthetic dataset and proposed loss function.
Keywords
Synthetic Data Generation, LLM Evaluation, Finetuning, Financial Question-Answering, QLoRA
Shubhashis Sengupta
Accenture Labs
Bengaluru, India
shubhashis.sengupta@accenture.com
and graphs with lot of numerical content. Development of Machine Learning (ML) systems capable of handling such varied form of data involving multi-step reasoning, and precise arithmetic calculation at each step is very challenging. In recent years, many open source benchmark datasets have been made available for financial question answering. Some of the data sets that contain hybrid forms of data with both tabular and textual content include FinQA [4], ConvFinQA [5], TATQA [26]. Few-shot prompting technique on these kinds of complex tasks often result in poor model performance [10]. Moreover, most commonly used evaluation metric for assessing the performance of LLMs in these datasets is Exact Match (EM). LLM generated answer is compared against ground truth answer at the character level, assigning a binary score of 1 or 0 based on whether there is an exact match or not. But often this method fails due to discrepancies present in the denomination of one of the answers, which results in lower accuracy. Hence, designing a new metric that accounts for these variations is essential.
State-of-the-art LLMs have good reasoning capability and perform well for diverse set of reasoning tasks such as code writing, math problem solving, common sense reasoning and symbolic reasoning. However, one of the major drawbacks is that these models are enormous in size with billions of parameters. Although models like GPT-4V [2] perform well for these tasks, they are very expensive to deploy at scale. To overcome this challenge, recent research has explored the use of large language models (LLMs) to generate training samples with reasoning demonstrations, which are then used to fine-tune smaller language models (SLMs) for domain-specific tasks. Although this approach is successful on many tasks, its applicability to domain-specific tasks such as answering financial questions is limited [14], [23]. Often, data used to fine-tune are insufficient, and smaller models need to look at more reasoning demonstrations to learn better, thereby requiring construction of large number of question-answer pairs for training by hand. This manual annotation process comes with higher costs [23] as it demands the presence of skilled annotators requiring to meticulously read and perform complex numeric reasoning across multiple reports. Thus, automated generation of QA pairs synthetically is a plausible solution to the shortage of high-quality training corpus.
*Lokendra contributed to this work when he was part of Accenture Labs, Bengaluru. †Sowmya contributed to this work when she was part of Accenture Labs, Bengaluru.
The generation of synthetic data has been previously explored in the context of QA. There are frameworks like LIQUID [9], DeepEval , LangChain , and Meta Synthetic Data Kit which support the generation of synthetic data from textual documents. However, there are limited studies focusing on QA generation from numerical data with high accuracy and that capture relationships between text and table data. Studies reporting high-quality synthetic data suitable for real-life applications are also limited. In this paper, we mitigate these limitations by proposing an end-to-end pipeline for generating high-quality synthetic data with multi-step validation. In our work, we do not direct LLMs to generate answers; instead, we instruct LLMs to generate the set of arithmetic expressions because LLMs failed to compute the direct numerical answers. Furthermore, EM does not work well because it only performs a one-to-one match between two answers and fails in the case of mathematically equivalent answers; additionally, it fails when special characters such as currency symbols, commas, and percentages are present in the answers. To mitigate these limitations, we used a novel metric, Expression Match Accuracy (EMA), that compares the numerical answers computed between the ground truth and predicted expressions.
Typically for complex numerical tasks, few-shot prompt based approaches have been used [3], [13]. But the output of the LLMs is very sensitive to the few shot samples used in the ordering of these samples [10]. Models do not exhibit consistent performance with few-shot training [13]. Hence, it is required to perform domain-adaptation on the data that is required. We perform fine-tuning of SLMs with high-quality data generated using our synthetic data generation pipeline and proposed custom loss function. In summary, we solve a range of problems related to question-answering in the finance domain. The main contributions of this paper are:
-
The task of Numerical reasoning is generally evaluated using EM criterion. In this paper, we are proposing a new evaluation metric, EMA that compares the arithmetic expressions of the ground truth with the arithmetic expression of the LLM generated output. This method demonstrated an overall improvement in model performance.
-
We present a synthetic data generation pipeline that ingests financial PDFs, renders and parses tables via vision-language and PDF parsing tools, aligns them with surrounding context such as pre-text and post-text, and employs structured prompts, multi-stage LLM refinement, synthesis of arithmetic reasoning and strict validation to produce high-quality, diverse, and fully verified question-answer pairs.
-
We also proposed a modified loss function using cross-entropy for comparing the predicted arithmetic expressions with ground truth expression to fine tune the SLMs. In this loss function, we are adding two losses: loss computed using EMA and semantic similarity between the predicted and ground truth expressions.
-
We further evaluate the performance of the fine-tuned model on available open-source datasets; and compare performance before and after fine-tuning along with synthetic dataset and our custom loss function. Our approach demonstrates improved performance after fine-tuning.
2 Related Work
Recent benchmarks have advanced financial QA by introducing diverse datasets and evaluation settings. FinanceBench [7] focuses on multi-modal reasoning over text, tables, and charts on open-book financial question-answering. FinQA [4] emphasizes numerical reasoning and multi-step arithmetic over financial reports. FinBen [21] is a comprehensive benchmark specifically designed to evaluate LLMs for diverse set containing 24 different financial tasks. PIXIU [22] introduces a large-scale instruction dataset enabling multi-turn dialogues and complex reasoning but relies heavily on synthetic data, raising concerns about real-world fidelity. Despite these contributions, existing benchmarks do not fully address fine-grained reasoning and dynamic financial scenarios, motivating the need for more comprehensive evaluation frameworks.
Most of these benchmarks consistently adopt EM or Execution Accuracy as a primary evaluation metric to ensure precise numerical reasoning. For instance, the foundational FinQA dataset [4] evaluates model performance using execution accuracy, which measures whether the generated arithmetic program yields the exact ground truth answer. Subsequent improvements, such as the DeBERTa-based model by Wang et al. [19], also use this metric, achieving 68.99% execution accuracy in the FinQA Challenge. The PIXIU [22] financial instruction set further employs EM to assess whether LLM responses exactly match expected results, focusing on final answers regardless of intermediate steps. Additionally, FinQAPT [16] continues this practice, using execution accuracy to report state-of-the-art module-level performance on the FinQA dataset.
Recent studies have shown that pre-trained large language models (LLMs) can achieve remarkable results on reasoning-centric tasks when augmented with specific prompting strategies. For instance, Wei et al. [20] introduced a chain-of-thought prompting approach that enables LLMs to break down complex problems into intermediate reasoning steps using a few illustrative examples. Building on this, Chen et al. [3] proposed a few-shot Program of Thought (PoT) prompting technique where the LLM generates a program representation of the solution, which is then executed externally to obtain the final answer. While these methods effectively leverage the reasoning capabilities of LLMs, their dependencies on large pre-trained models poses challenges for practical deployment, particularly in cost-sensitive and resource-constrained environments. To mitigate these limitations, recent works have explored generation of synthetic data and adaptation of smaller LMs to domain-specific tasks, aiming to reduce data scarcity and resource costs.
Vulic et al. [18] demonstrated a two-stage fine-tuning procedure for effective domain specialization with small amounts of data. The FinLLMs framework by Yuan et al. [23] proposed a framework that achieved high accuracy in generated questions and answers by deriving them directly from common financial formulas and
https://github.com/meta-llama/synthetic-data-kit
From Documents to Reasoning: A Validated Synthetic Data Pipeline and Semantic-Aware Fine-Tuning for Financial Numerical Reasoning
employing a graph-traversal technique to augment the formula set, thereby reducing the need for expensive manual annotation. Phogat et al. [14] explored a "teacher-student" approach for financial question answering, where a larger teacher model (GPT-4) generates synthetic Python code exemplars that encapsulate the necessary financial reasoning and calculations. This approach successfully fine-tunes smaller language models (e.g., Phi [1], Mistral [8], ORCA-2 [12]) to achieve performance comparable to the teacher model. The ELTEX framework in [15] is proposed as a domain-driven solution for generating high-quality synthetic training data in highly specialized fields.
In our paper, we overcome some of these limitations by generating an arithmetic expression containing a set of mathematical operations and devise Expression Match Accuracy (EMA) metric to overcome the shortcomings of the strict exact match criteria. We also show that the evaluation is aligned with the new metric for the fine-tuning process. To the best of our knowledge, this kind of metric-driven loss optimization is unexplored for financial question-answering using a novel synthetic data generation technique.
3 Proposed Methodology
In this section, we delve into the details of the business problems that we are solving. First, we present details about the new metric EMA that is extremely useful in the context of numerical reasoning. Next, we present our multi-step validation pipeline to generate high-quality synthetic data. Further, we perform improved domain-adaptation with the new EMA metric and modified cross-entropy loss function using high-quality synthetic data generated by our technique.
3.1 Problem Formulation for EMA
The limitation of the EM metric is that LLMs are not good in arithmetic calculations [24], and EM is also sensitive to small tolerances, such as currency symbols in the answers or percentages in the answers that result in incorrect matches. For example, relaxed EM which provide numerical tolerance to EM, also comes with limitations when the measurement unit of the ground truth is not same as the llm-generated output. For example, LLM-generated output can be while the ground-truth answer can be 1000000 in which case both EM and relaxed EM criteria will fail. In such cases, the expression match metric performs reliably.
To mitigate these limitations, we proposed EMA to generate a set of arithmetic expressions from LLMs to avoid computational problems of LLMs. We are crafting prompts in a way to generate the arithmetic steps by LLMs and use these arithmetic steps to compute the answer. However, we are not directly comparing the predicted answer computed from the predicted arithmetic expression to ground truth answer. We are computing the answer from the ground truth expression and predicted expression, and then comparing these two answers. Our goal is to compare the answers computed from ground truth arithmetic expression with predicted arithmetic expression .
Each expression step is a computational operation applied on numbers or intermediate results. For example: sum(4,5); multiply(#0, 4); divide(#1, 6) where #k refers to the intermediate result, i.e.; outcome of the kth step.
A single arithmetic operation step
where a, b are two numeric constants or values from intermediate steps. The expression is evaluated using DSPy ReAct Agent and Python Interpreter . The final numerical answer of the entire response is
Instead of exact text matching, EMA compares the numerical answers computed between ground truth and predicted expressions:
if the final computed answers match exactly then it is 1, otherwise 0.
3.2 Financial Reasoning Synthetic Dataset Generation
Some of the financial tables may demonstrate more complex layouts with nested rows/columns which makes difficult for the model to clearly partition the rows and columns. For such complex structures, we use a specific pipeline presented here to first convert document to images to perform structured table and text extraction using a collection of state-of-the-art methods. This method can handle numeric QA, textual QA and visual QA tasks. The following figure shows our qa-pair generation and multi-step validation of generated questions.
-
Document Image Conversion: In this step, we convert the financial PDF documents into high-resolution image formats to facilitate subsequent information extraction. In this step, PyMuPDF (fitz) library is utilized to parse PDF files and render each page as an image. Each page is rendered at 300 DPI to ensure high visual fidelity. This preprocessing step forms the foundation for robust image-based extraction of structured information like tables and graphs from unstructured financial documents.
-
Visual-table Extraction: In this step, we encode each image into a base64 binary stream to support multi-modal input formatting required by Claude’s inference pipeline. This binary representation is combined with natural language prompt that instructs the model to: (1) detect all distinct tables present in the image; (2) preserve structural
https://github.com/stanfordnlp/dspy/tree/main/docs/docs/api/tools
https://pymupdf.readthedocs.io/en/latest/

Figure 1: Overall Architecture
properties including headers, rows, and columns, and (3) output the content of each table using Markdown syntax for downstream compatibility. The prompt strictly emphasizes alignment to ensure the resulting output is structurally rich with minimal error.
• Structured text extraction from PDF: In the third stage of the pipeline, we are again extracting structured textual content from the original PDF. To achieve this, we employ PDFPlumber , a PDF parsing library that enables precise text and table extraction from PDF files. The goal is to retrieve tables along with their surrounding narrative—termed as pre-context and post-context to ensure semantic consistency and alignment across modalities. For each page in the PDF, the algorithm extracts all visible lines of text and identifies tables using PDFPlumber's built-in structure detection. Each table is parsed into a structured DataFrame, and its location within the surrounding textual content with table headers and other content rows below tables. Once identified, a configurable number of lines before and after each table are extracted as pre-context and post-context respectively. This step helpful for cross-validation of tables extracted using image-based extraction (via VLLMs) and text-based extraction (via PDFPlumber) in the next steps.
• Cross-table Validation: To ensure the reliability and consistency of extracted structured data, the next step in our synthetic data generation pipeline involves validation of tables via comparing tables extracted via Claude’s Sonnet3.5 model from document images with those extracted via PDF-Plumber from PDF content. This dual-source approach enables us to reconcile discrepancies between image-rendered and text-native representations of financial tables, while also getting the pre-context and post-context surrounding each table.
For this task, we implement a robust comparison mechanism, which combines semantic similarity and embedding-based matching. To assess alignment between tables, we compute two complementary similarity measures: (1) semantic similarity, based on numerical proximity, range overlap, and pattern type (e.g., "flat", "to", "approximate"); and (2) a sentence-level cosine semilairty computed using embeddings from a pretrained model (all-MiniLM-L6-v2 ). The comparison process computes pairwise similarity between rows of the VLLM-extracted and PDFPlumber extracted tables. Tables with high alignment (above a defined similarity threshold) are retained as validated entries. For these aligned pairs, the system also retrieves their corresponding pre-context and post-context passages from the structured text extracted in step 3, thereby enriching each table with its narrative grounding.
• Question Generation: In this step, we are generating high-quality synthetic questions using pre-context, post-context and tables extracted and validated in above steps. This step leverages a prompt-engineered approach to interact with a Large Language Model (LLM), wherein prompts are carefully crafted to elicit a diverse set of numeric, and reasoning-based questions from each structured data instance pre-context, table and post-context.
The prompt emphasizes to generate question types, including (i) direct retrieval questions, (ii) basic arithmetic operations, (iii) intermediate multi-row/multi-column computations, and (iv) complex reasoning that synthesizes cross-row insights using formulas such as average, percentage change, or compound operations. This step generates multigranular questions supports supervised fine-tuning of models for numerical reasoning in the financial domain.
• Quality Assessment of generated question: To assess the synthetically generated financial questions, we implemented a structured question evaluation approach that
https://pypi.org/project/pdfplumber/
https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
From Documents to Reasoning: A Validated Synthetic Data Pipeline and Semantic-Aware Fine-Tuning for Financial Numerical Reasoning

Figure 2: Distribution analysis of generated questions into the direct retrieval, single operation, multi operation category
systematically filters out erroneous or low-quality questions. The evaluation framework leverages a prompt-based LLM technique designed to assess each question with respect to a provided financial context (pre-context, table and post-context). • The first step of evaluation is to verifying whether the input is a well-formed question and whether it pertains to the financial domain. If the input fails to qualify as a legitimate or grammatically natural question, it is flagged accordingly. For questions passing the initial check, the system computes three core quality metrics: relevance, coherence, and factual Coverage, where each rated on a 1 to 5 scale. These metrics were selected because they represent the minimal set of independent and complementary criteria required to assess the usefulness of a question in financial QA tasks. Relevance measures how closely the question targets significant elements from the context; Coherence evaluates the structural and logical flow of the question; and Factual Coverage assesses the extent to which the question aligns with key facts in the context. If score is 1, which means the question fails the criterion almost completely (e.g., irrelevant to context, grammatically broken, or factually incorrect), if score is 3, which means, the question partially satisfies the criterion but exhibits noticeable issues (e.g., only loosely related to the context, mildly ambiguous, or only partially fact-based), whereas if score is more than 3, which means, the question fully satisfies the criterion with no detectable issues (highly relevant, coherent, and fully grounded in the provided financial data).
This step serves as a crucial quality control mechanism in the synthetic data generation pipeline, ensuring only high-quality and contextually grounded questions are retained for subsequent usage in model finetuning or evaluation.
• Iterative question refinement: This step is refinement module to enhance the quality of questions that failed in previous step. This refinement process consists of three core quality dimensions: contextual coverage, logical coherence, and answer-ability from the given context. We design the prompt in such a way that the context based refinement enforces clear referencing of all available context elements and ensures the refined question remains concise and answerable. The reasoning variant is intended to promote multi-hop reasoning and logical dependencies across different data fields, while the hypothetical variant stimulates counterfactual or speculative question formulation within the bounds of the provided context.
• Program Generation: In this stage of the synthetic question-answer pipeline, we introduce a arithmetic reasoning module designed to address a critical limitation of large language models (LLMs) that unable performance in precise numerical computation. Rather than relying on LLMs to directly compute answers, we instruct LLMs to generate structured arithmetic programs that outline the exact sequence of operations needed to compute the answer. This design enhances both transparency and correctness in financial reasoning tasks.
The prompt design explicitly guides the model to extract numerical values from the context, including financial tables and surrounding textual data and to generate a sequence of arithmetic operations using a predefined set of functions: add, subtract, multiply, divide, exp, greater, table_max, table_min, table_sum, and table_average. These operations are used in a sequential manner, referencing intermediate results using #n notation to prevent nested expressions. This step bridges the gap between natural language questions and executable programs for answer computation, enabling robust handling of tasks such as calculating year-over-year revenue change, computing average profit margins, comparing financial ratios, and identifying trends. To compute the answer from the generated program, we are using DSPy React agent and a LLM which support external tools likes python interpreter .
• Answer Validation: In this final stage, we design a prompt that instructs the model to take on the role of a financial analyst. The model is provided with the full context—comprising
https://github.com/stanfordnlp/dspy/tree/main/docs/docs/api/tools the pre-text, tabular data, and post-text—along with the generated question, arithmetic expression and computed answer. The task is to independently analyze this information and determine whether the arithmetic expression and computed answer are correct for question based on the context, without relying on prior knowledge.
This step includes multiple validation dimensions: question understanding, where the model articulates the intended meaning of the question; relevant data points, identifying specific entries from the table or text used in reasoning; derived approach, outlining the mathematical steps necessary to solve the question independently; expected answer, which is the answer computed using the derived steps; answer verification, a binary assessment with justification for whether the computed answer aligns with the expected value; final assessment, a higher-level summary determining the overall correctness with rationale.
This pipeline is unique with its multi-step validation and the ability to handle multiple document types. By generating data based on this kind of multi-step validation, we ensure that the generated data exhibits the following features: Accuracy of Questions: Since questions generated are validated against the context at multiple steps using LLMs, and are answerable within the context. This multi-step validation reduces the occurrence of invalid or unanswerable questions in the dataset. It is also proved from experimental analysis that our pipeline generate qualitative QA pairs.
3.3 Semantic-Aware EMA Customized Loss for Improved Domain-adaptation
Domain-adaptation of LLMs is the process of customizing general purpose LLMs according to a specific domain-context data, optimized by domain-specific objectives. In this paper, we use a semantic-aware expression generation loss for numerical question-answering in finance-domain.
3.3.1 Motivation and Limitations of Existing Approaches. Symbolic expression generation plays a critical role in financial question answering, program synthesis, and arithmetic reasoning tasks. Conventionally, models are fine-tuned using the standard token-level Cross Entropy (CE) loss. While effective for general sequence modeling, this approach exhibits several key limitations in the context of structured symbolic outputs:
• Lack of Global Semantic Alignment: Token-level loss penalizes differences at individual token positions, but fails to capture the structural similarity between two expressions that may be semantically equivalent.
• Sensitivity to Token Order: Expressions such as sum(2, 5) and sum(5, 2) are penalized despite being semantically identical in commutative operations.
• Limited Structural Understanding: The model may generate syntactically correct but structurally invalid or semantically incorrect programs due to overfitting on local token-level patterns.
3.3.2 Semantic-Aware EMA (SA-EMA) Loss Function. To address the aforementioned issues, we propose a Semantic-Aware EMA Expression Generation Loss, which combines the standard Cross Entropy loss [25] with a string-level semantic dissimilarity component along with the loss computed using the proposed EMA metric. The total loss function is defined as:
where:
• is the token-level Cross Entropy loss:
• is the semantic dissimilarity loss (SD Loss), computed as:
- Sim( , ) is a normalized similarity score between the predicted expression and the ground-truth y, computed using a string-matching metric such as SequenceMatcher.
• is loss computed using EMA metric (EMA Loss) proposed in section 3.1
• , and are scalar hyperparameters that balance losses. This method offers many advantages:
• Structure-Aware Supervision: By considering the overall similarity between expressions, the model learns to produce semantically aligned outputs.
• Robustness to Token-Level Variations: Minor syntactic differences that do not affect semantic meaning are tolerated.
• Improved Generalization: Better performance in low-data regimes and structurally compositional tasks such as program induction.
3.4 Limitations and Future Work
-
The semantic similarity metric is computed post-hoc and is not differentiable, limiting end-to-end learning.
-
The loss does not account for operator-specific semantics such as commutativity or associativity.
-
The decoding step must produce valid token sequences; invalid expressions may propagate errors into the semantic component.
4 Experiments
4.1 Experimental Design
Datasets: For our experiments, we utilized two widely recognized open-source benchmarks in the domain of financial question answering: FinQA [4], and ConvFinQA [5]. These datasets are designed to evaluate a system's ability to perform complex numerical reasoning over financial documents that combine both textual and tabular information.
In the FinQA dataset, the model is required to extract relevant information from heterogeneous sources (table+text) and perform multi-step arithmetic computations to arrive at the correct answer. The ConvFinQA dataset extends this task into a conversational setting. Here, the model is presented with a sequence of interdependent questions and answers that build context incrementally.
From Documents to Reasoning: A Validated Synthetic Data Pipeline and Semantic-Aware Fine-Tuning for Financial Numerical Reasoning
Table 1: Comparative analysis of out finetuning results of open source models with other Models given in [17]. Mistral-V0.3-7B [8] (Our-M-7B), Llama3.1-8B [6] (Our-L-8B), Phi4-14B [1] (Our-P-14B)
| Models | GPT-4 [17] | GPT-3.5-T [17] | Llama2-13B [17] | Mistral-7B [17] | Our-M-7B | Our-L-8B | Our-P-14B |
|---|---|---|---|---|---|---|---|
| Accuracy | 78.81 | 61.19 | 29.92 | 14.48 | 79.15 | 56.09 | 70.85 |
The goal is to answer the final question in the conversation accurately, leveraging both the cumulative conversational history and the associated financial text and tables.
Implementation details: All experiments were conducted on a server equipped with two NVIDIA A100-SXM4 GPUs, each with 80 GB of memory. Our foundational large language model, utilizing the Unsloth library's optimized 4-bit quantization implementation. We implement 4-bit NormalFloat (NF4) quantization. We implement Quantized Low-Rank Adaptation (QLoRA) with hyperparameter configurations optimized through systematic grid search across multiple dimensions. The rank values explored include 8, 16, 32, and 64, 128 and 256 representing the dimensionality of the low-rank decomposition matrices. The alpha scaling parameters range from 16 to 128, controlling the magnitude of the learned adaptations. Dropout rates of 0.0, 0.05, and 0.1 are evaluated to prevent overfitting in the adaptation layers. The target modules for LoRA adaptation encompass all attention projection layers including query, key, value, and output projections, all feed-forward network components including gate, up, and down projections, and the language modeling head. The training protocol employs a learning rate of 2e-4 with linear scheduling, ensuring stable convergence throughout the training process. The effective batch size is 8, achieved through a per-device batch size of 2 with gradient accumulation over 4 steps. Our optimization step utilizes AdamW with 8-bit precision to reduce memory consumption while maintaining optimization effectiveness. Weight decay of 0.01 provides regularization, and 5 warmup steps ensure smooth training initiation.
4.2 Evaluation of Benchmarks with Expression Match Accuracy (EMA) Metric:
We perform evaluation of models on ConvFinQA dataset using EM and EMA. ConvFinQA dataset consisted of 3965 samples in training set and 542 samples in development set. We performed our experiments on development set as the test set did not have ground truth labels. As we can observe from the following table 2, models show an improvement in accuracy using the EMA metric.
4.3 Comparative Analysis
We compare the results of our method with results proposed in [17], and from the table 1, we analyzed that our SMLs are perform comparable to the LLMs and better than the SMLs proposed in the [17]. Experiment Our-M-7B depicts the results of finetuned Mistral-V0.3-7B models using custom loss function and synthetic data proposed in section 3. Likewise, experiment Our-L-BB depicts the results of finetune LLama3.1-8B models and Our-P-14B depicts the results of Phi4-14B Model.
Table 2: Accuracy of models on ConvFinQA using EM and EMA
| Model | EM | EMA |
|---|---|---|
| Sonnet3.5 | 61.25 | 68.63 |
| Haiku | 56.45 | 57.93 |
| Llama3.1-8B [6] | 32.84 | 44.09 |
| Llama3.1-70B [6] | 53.50 | 57.01 |
| Llama3.1-405B [6] | 57.19 | 62.17 |
| Llama3.2-11B [11] | 31.92 | 38.00 |
| Llama3.2-90B [11] | 37.82 | 40.59 |
| Mistral7B v0.2 [8] | 11.80 | 15.68 |
| Mistral 7B v0.3 [8] | 31.26 | 48.71 |
| Mistral Large 2407 | 56.27 | 61.07 |
| Mixtral8*7B | 30.26 | 35.05 |
Table 3: Qualitative assessment of generated synthetic data with existing frameworks
| Framework | TTR | Cosine Similarity |
|---|---|---|
| DeepEval | 0.35% | 0.38% |
| Meta | 0.23% | 0.60% |
| Our Method | 0.37% | 0.68% |
4.4 Qualitative Assessment of the Synthetic Generated Question-answers
We compare the quality of generated synthetic data with the dataset generated from two frameworks: DeepEval and Meta. We employ two measures namely Type-Token-Ratio (TTR) and Cosine Similarity. For numerical reasoning, we divide the questions into three categories and compare to reference datasets to check how complex questions are generated by our framework. From the table 3, we observed that our question-answer generation framework perform better than the other frameworks.
4.4.1 Type-Token-Ratio (TTR). : The ratio of unique words (types) to total words (tokens) in the dataset.
It will be helpful for measuring lexical diversity. A high TTR indicates rich vocabulary, while a low TTR suggests repetitive language. We computed the TTR for questions generated by frameworks and compare the scores.
4.4.2 Cosine Similarity Using TF-IDF. Measures how similar two TF-IDF vectors are by comparing the angle between them. It first converts the datasets into vector space models and measures their similarity in terms of frequency-weighted word importance. It approximates semantic similarity rather than just word overlap. More
Table 4: Finetuning results of SLMs using EM, proposed EMA loss, SD Loss, and Semantic aware EMA (SA-EMA) Loss Function
| Model | EM | EMA loss | SD Loss Function | SA-EMA Loss Function |
|---|---|---|---|---|
| MistralV0.3-7B [8] | 47.42 | 69.74 | 75.28 | 79.15 |
| Phi4-14B [1] | 58.30 | 63.28 | 67.90 | 70.85 |
| Llama3.1-8B [6] | 37.08 | 50.74 | 48.71 | 56.09 |
robust than set-based methods. We computed the similarity scores between the questions generated by the framework and the context passed while generating the questions.
4.4.3 Question Categories. For numerical reasoning, we classify questions into different categories like direct retrieval questions, single operations required to compute the answers, multiple operations required to compute the answer. From the figure 2 we observe that our framework generates more complex questions than the reference datasets.
4.5 Fine-tuning Results
In our experiments, we adopt the Quantized Low Rank Adaptation (QLoRA) technique to fine-tune open source family of smaller language models: Mistral-v0.3-7B [8], Phi-4-14B [1] and Llama3.1-8B [6]. In table 4, column EM, denotes the finetune models evaluated using EM metric, column EMA, denotes the finetune models evaluated using EMA loss given in equation 7, column SD-LossFunction, denotes the finetune models using SD Loss function given in equation 6 and evaluated using EMA metric, whereas last column denotes models finetuned using SA-EMALossFunction given in equation 4 and evaluated using EMA metric. From table 4, we analyze that our proposed EMA metric performed better than EM. We observe that the Semantic Loss Function performs better than cross-entropy function. One interesting analysis of the proposed semantic loss function is that it does not perform well for Llama models. It is because Mistral and Phi models are trained and work better for mathematical problems, while Llama models was trained and open for generic tasks. Furthermore, one more experiment performed by combining the real datasets FinQA, CFinQA with synthetic data generated via our technique as shown in the last column of table. It is observed that the performance is better than other experimental settings and it is one of the novel approaches of generating synthetic data, which is improving the performance of small language models.
5 Conclusion and Future Work
In this work, we introduced the EMA metric for evaluating numerical question answering tasks, which serves as a foundational component of our synthetic data generation framework and domain adaptation strategy via fine-tuning with a tailored loss function. The EMA metric effectively captures model reasoning, even when arithmetic step formats vary, leading to improved performance. Our synthetic data pipeline produced high-quality question-answer pairs, and fine-tuning smaller language models (SLMs) with the custom loss function resulted in significant gains on financial QA benchmarks. We validated our approach on the ConvFinQA dataset, along with synthetic data generated using our pipeline, demonstrating its effectiveness in enhancing numerical reasoning capabilities. Looking ahead, we plan to extend this approach to other NLP tasks such as summarization, sentiment analysis, and descriptive question answering. We are also exploring the integration of Reinforcement Learning from AI Feedback (RLAIF) to further advance numerical reasoning QA. Furthermore, we will extend the cost function for other tasks to improve the answer relevance and coherence.
References
[1] Marah Abdin, Jyoti Aneja, Harkirat Behl, Sébastien Bubeck, Ronen Eldan, Suriya Gunasekar, Michael Harrison, Russell J Hewett, Mojan Javaheripi, Piero Kauffmann, et al. 2024. Phi-4 technical report. arXiv preprint arXiv:2412.08905 (2024).
[2] Josh Achiam, Steven Adler, Sandhini Agarwal, Lama Ahmad, Ilge Akkaya, Florencia Leoni Aleman, Diogo Almeida, Janko Altenschmidt, Sam Altman, Shyamal Anadkat, et al. 2023. Gpt-4 technical report. arXiv preprint arXiv:2303.08774 (2023).
[3] Wenhu Chen, Xueguang Ma, Xinyi Wang, and William W Cohen. 2022. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. arXiv preprint arXiv:2211.12588 (2022).
[4] Zhiyu Chen, Wenhu Chen, Charese Smiley, Sameena Shah, Iana Borova, Dylan Langdon, Reema Moussa, Matt Beane, Ting-Hao Huang, Bryan Routledge, et al. 2021. Finqa: A dataset of numerical reasoning over financial data. arXiv preprint arXiv:2109.00122 (2021).
[5] Zhiyu Chen, Shiyang Li, Charese Smiley, Zhiqiang Ma, Sameena Shah, and William Yang Wang. 2022. Convfinqa: Exploring the chain of numerical reasoning in conversational finance question answering. arXiv preprint arXiv:2210.03849 (2022).
[6] Abhimanyu Dubey, Abhinav Jauhri, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Amy Yang, Angela Fan, et al. 2024. The llama 3 herd of models. arXiv e-prints (2024), arXiv-2407.
[7] Pranab Islam, Anand Kannappan, Douwe Kiela, Rebecca Qian, Nino Scherrer, and Bertie Vidgen. 2023. Financebench: A new benchmark for financial question answering. arXiv preprint arXiv:2311.11944 (2023).
[8] AQ Jiang, A Sablayrolles, A Mensch, C Bamford, DS Chaplot, Ddl Casas, F Bressand, G Lengyel, G Lample, L Saulnier, et al. 2024. Mistral 7B. arXiv 2023. arXiv preprint arXiv:2310.06825 (2024).
[9] Seongyun Lee, Hyunjae Kim, and Jaewoo Kang. 2023. LIQUID: a framework for list question answering dataset generation. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 37. 13014–13024.
[10] Yao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel, and Pontus Stenetorp. 2021. Fantastically ordered prompts and where to find them: Overcoming few-shot prompt order sensitivity. arXiv preprint arXiv:2104.08786 (2021).
[11] AI Meta. 2024. Llama 3.2: Revolutionizing edge ai and vision with open, customizable models. Meta AI Blog. Retrieved December 20 (2024), 2024.
[12] Arindam Mitra, Luciano Del Corro, Shweti Mahajan, Andres Codas, Clarisse Simoes, Sahaj Agarwal, Xuxi Chen, Anastasia Razdaibiedina, Erik Jones, Kriti Aggarwal, et al. 2023. Orca 2: Teaching small language models how to reason. arXiv preprint arXiv:2311.11045 (2023).
[13] Karmvir Singh Phogat, Chetan Harsha, Sridhar Dasaratha, Shashishekar Ramakrishna, and Sai Akhil Puranam. 2023. Zero-shot question answering over financial documents using large language models. arXiv preprint arXiv:2311.14722 (2023).
[14] Karmvir Singh Phogat, Sai Akhil Puranam, Sridhar Dasaratha, Chetan Harsha, and Shashishekar Ramakrishna. 2024. Fine-tuning Smaller Language Models for Question Answering over Financial Documents. arXiv preprint arXiv:2408.12337 (2024).
[15] Arina Razmyslovich, Kseniia Murasheva, Sofia Sedlova, Julien Capitaine, and Eugene Dmitriev. 2025. ELTEX: A Framework for Domain-Driven Synthetic Data Generation. arXiv preprint arXiv:2503.15055 (2025).
[16] Kuldeep Singh, Simerjot Kaur, and Charese Smiley. 2024. Finqapt: Empowering financial decisions with end-to-end llm-driven question answering pipeline. In Proceedings of the 5th ACM International Conference on AI in Finance. 266–273.
[17] Pragya Srivastava, Manuj Malik, Vivek Gupta, Tanuja Ganu, and Dan Roth. 2024. Evaluating LLMs' Mathematical Reasoning in Financial Document Question Answering. arXiv preprint arXiv:2402.11194 (2024).
From Documents to Reasoning: A Validated Synthetic Data Pipeline and Semantic-Aware Fine-Tuning for Financial Numerical Reasoning
[18] Ivan Vulić, Pei-Hao Su, Sam Coope, Daniela Gerz, Pawel Budzianowski, Iñigo Casanueva, Nikola Mrkšić, and Tsung-Hsien Wen. 2021. ConvFiT: Conversational fine-tuning of pretrained language models. arXiv preprint arXiv:2109.10126 (2021).
[19] Yanbo J Wang, Yuming Li, Hui Qin, Yuhang Guan, and Sheng Chen. 2022. A novel deberta-based model for financial question answering task. arXiv preprint arXiv:2207.05875 (2022).
[20] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. 2022. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems 35 (2022), 24824–24837.
[21] Qianqian Xie, Weiguang Han, Zhengyu Chen, Ruoyu Xiang, Xiao Zhang, Yueru He, Mengxi Xiao, Dong Li, Yongfu Dai, Duanyu Feng, et al. 2024. Finben: A holistic financial benchmark for large language models. Advances in Neural Information Processing Systems 37 (2024), 95716–95743.
[22] Qianqian Xie, Weiguang Han, Xiao Zhang, Yanzhao Lai, Min Peng, Alejandro Lopez-Lira, and Jimin Huang. 2023. Pixiu: A large language model, instruction
data and evaluation benchmark for finance. arXiv preprint arXiv:2306.05443 (2023).
[23] Ziqiang Yuan, Kaiyuan Wang, Shoutai Zhu, Ye Yuan, Jingya Zhou, Yanlin Zhu, and Wenqi Wei. 2024. Finllms: A framework for financial reasoning dataset generation with large language models. IEEE Transactions on Big Data (2024).
[24] Zheng Yuan, Hongyi Yuan, Chuanqi Tan, Wei Wang, and Songfang Huang. 2023. How well do large language models perform in arithmetic tasks? arXiv preprint arXiv:2304.02015 (2023).
[25] Zhilu Zhang and Mert Sabuncu. 2018. Generalized cross entropy loss for training deep neural networks with noisy labels. Advances in neural information processing systems 31 (2018).
[26] Fengbin Zhu, Wenqiang Lei, Youcheng Huang, Chao Wang, Shuo Zhang, Jiancheng Lv, Fuli Feng, and Tat-Seng Chua. 2021. TAT-QA: A question answering benchmark on a hybrid of tabular and textual content in finance. arXiv preprint arXiv:2105.07624 (2021).