## 3 Model Design and Implementation
### Pre-Processing
\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline
**Model Name** & **Total EX** & **Total F1 Score** & **Total VES** & **P Value of EX** & **P Value of F1** & **P Value of VES** \\ \hline NL2 PY2 SQL & 59.97 & 63.57 & 65.54 & - & - & - \\ \hline SuperSQL & 57.24 & 60.1 & 59.2 & 0.1249 & 0.0480 & 0.0003 \\ \hline SFT\_CodeS\_15B\_EK & 56.52 & 59.27 & 58.46 & 0.0528 & 0.0145 & 0.0001 \\ \hline SFT\_CodeS\_7B\_EK & 54.89 & 56.89 & 57.84 & 0.0044 & 0.0002 & 0.0000 \\ \hline DAILSQL\_SC & 54.63 & 57.27 & 55.73 & 0.0028 & 0.0004 & 0.0000 \\ \hline SFT\_CodeS\_3B\_EK & 53.46 & 56.21 & 56.05 & 0.0003 & 0.0000 & 0.0000 \\ \hline DAILSQL & 52.87 & 55.2 & 53.83 & 0.0001 & 0.0000 & 0.0000 \\ \hline SFT\_CodeS\_1B\_EK & 48.7 & 50.98 & 49.72 & 0.0000 & 0.0000 & 0.0000 \\ \hline C3\_SQL & 48.37 & 51.04 & 48.7 & 0.0000 & 0.0000 & 0.0000 \\ \hline RESDSQL\_3B\_EK & 42.37 & 44.62 & 43 & 0.0000 & 0.0000 & 0.0000 \\ \hline RESDSQL\_Large\_EK & 36.83 & 39.01 & 37.43 & 0.0000 & 0.0000 & 0.0000 \\ \hline RESDSQL\_Base\_EK & 31.16 & 33.12 & 30.88 & 0.0000 & 0.0000 & 0.0000 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Significance test results. ### Ablation Experiment Prediction Results

From the ablation comparison results of EX, removing CoT has the greatest impact on the results, causing an accuracy decrease of 11.27%. In fact, removing NL2 PY leads to a decrease in accuracy of 1.95%. From the ablation comparison results of F1, removing CoT also has the greatest impact, resulting in an F1 score decrease of 11.94%. The next largest impact comes from removing Revise SQL, which decreases F1 by 1.47%. From the ablation comparison results of VES, removing CoT again has the greatest impact, causing a VES decrease of 12.01%. In contrast, removing NL2 PY results in a decrease of 2.6% in VES. The analysis above shows that CoT and NL2 PY significantly affect the entire process, suggesting that further research can be conducted on these two components. As shown in Figure 9, the Chain Thinking (CoT) and NL2 PY each have their unique contributions to results in NL2 SQL, and their synergy can significantly improve the accuracy and logic of query generation. CoT (Chain of Thought) uses step-by-step reasoning to help the model handle complex logic and conditions more accurately when generating SQL queries. It breaks down the problem and gradually expands thinking to avoid jumping directly to the final answer, thereby reducing the possibility of errors. For example, when processing complex multi-table joins or nested queries, CoT helps the model clarify the reasoning process at each step, making the final SQL query more interpretable and accurate. NL2 PY further clarifies the query logic by converting natural language into Python code. As an intermediate expression form, Python code makes the execution of query steps more controllable and precise and provides a more accurate basis for subsequent SQL conversion. Through this step-by-step transformation, NL2 PY reduces the complexity of natural language understanding, allowing the model to generate SQL queries more accurately. Combining the two, CoT is responsible for the refined reasoning process, while NL2 PY ensures the logical operability of queries, thus improving the overall performance and accuracy of the NL2 SQL system. The method proposed in this article first converts natural language to Python and then to SQL, which can flexibly implement complex transaction logic and risk models in the financial field and use Python data analysis and modeling to process large-scale data efficiently, thus significantly improving the accuracy and reliability of queries. Interpretabil

Figure 9: Comparison of ablation experiment prediction results on BIRD dataset. Multiple ablation experiments were conducted, during which COT, NL2 PY, SQL Iteration, and PY Iteration were removed. ity and decision-making efficiency significantly reduce maintenance costs. In the medical and legal fields, the method of NL2 PY combined with PY2 SQL has demonstrated strong adaptability.