Compliance-to-Code: Enhancing Financial Compliance Checking via Code Generation

Siyuan Li, Jian Chen, Rui Yao, Xuming Hu, Peilin Zhou, Weihua Qiu, Simin Zhang, Chucheng Dong, Zhiyao Li, Qipeng Xie, Zixuan Yuan · OpenReview

Abstract

Nowadays, regulatory compliance has become a cornerstone of corporate governance, ensuring adherence to systematic legal frameworks. At its core, financial regulations often comprise highly intricate provisions, layered logical structures, and numerous exceptions, which inevitably result in labor-intensive or comprehension challenges. To mitigate this, recent Regulatory Technology (RegTech) and Large Language Models (LLMs) have gained significant attention in automating the conversion of regulatory text into executable compliance logic. However, their performance remains suboptimal particularly when applied to Chinese-language financial regulations, due to three key limitations: (1) incomplete domain-specific knowledge representation, (2) insufficient hierarchical reasoning capabilities, and (3) failure to maintain temporal and logical coherence. One promising solution is to develop a domain specific and code-oriented datasets for model training. Existing datasets such as LexGLUE, LegalBench, and CODE-ACCORD are often English-focused, domain-mismatched, or lack fine-grained granularity for compliance code generation. To fill these gaps, we present Compliance-to-Code, the first large-scale Chinese dataset dedicated to financial regulatory compliance. Covering 1,159 annotated clauses from 361 regulations across ten categories, each clause is modularly structured with four logical elements-subject, condition, constraint, and contextual information-along with regulation relations. We provide deterministic Python code mappings, detailed code reasoning, and code explanations to facilitate automated auditing. To demonstrate utility, we present FinCheck: a pipeline for regulation structuring, code generation, and report generation.

Introduction

Financial regulations are notoriously "dense"—filled with nested logic, quantitative thresholds, and complex cross-references. Traditionally, ensuring company compliance requires extensive manual labor by legal and audit experts, making the process slow, expensive, and prone to human error. While Large Language Models (LLMs) excel at text summarization, they often struggle with the "hard logic" required for financial law, frequently hallucinating details or failing to maintain consistency across complex documents. Furthermore, the lack of high-quality, Chinese-centric legal AI benchmarks has hindered progress in the Chinese financial market. This paper aims to bridge the gap between natural language law and executable code to make auditing automated and transparent.

The FinCheck Framework

To implement automated auditing, we introduce FinCheck, a modular pipeline that decomposes the process into four distinct stages:

  1. Structure Predictor: An LLM parses raw regulatory text into structured "Compliance Units" (CUs).
  2. Code Generator: A specialized Structured Synthesis LLM (SS-LLM) transforms these CUs into deterministic Python code.
  3. Information Retriever: The system fetches real-world company data from financial databases.
  4. Report Generator: The generated code is executed against the retrieved data, and the results are summarized into human-readable compliance reports.
The FinCheck pipeline for automated compliance auditing.

Compliance Units and Dataset

The core innovation of this work is the "atomization" of legal text into Compliance Units (CUs). Each CU is defined by four logical elements:

  • Subject: The entity to which the rule applies (e.g., "Listed companies").
  • Condition: The specific trigger scenario (e.g., "If net profit decreased by >50%").
  • Constraint: The mandatory requirement or prohibition (e.g., "Shall not disclose a high bonus plan").
  • Contextual Information: Necessary definitions or calculation methodologies.

Additionally, we define four Inter-Unit Relations—refer to, exclude, only include, and should include—to manage complex dependencies between different regulatory clauses. The resulting Compliance-to-Code Dataset includes 1,159 annotated clauses from 361 authoritative Chinese financial regulations, along with 307 executable Python tasks featuring human-validated Chain-of-Thought reasoning.

Results and Analysis

Our evaluation demonstrates that modularity is a powerful antidote to LLM hallucination. By requiring the model to structure the text into CUs before generating code, the system's reliability increases significantly.

Performance metrics for regulation structuring across various models.

As shown in the performance metrics, GLM-4-9B-0414 excelled at the initial regulation structuring task (71.68% F1 score), while DeepSeek-R1-0528 achieved the highest performance in subsequent code generation tasks (73.67% Pass@1). We also observed that incorporating explicit Chain-of-Thought reasoning boosted the code generation success rate from approximately 52% to over 78%.

A critical finding in our study is the phenomenon of "Upstream Error Propagation": if the model fails to correctly identify a condition or constraint during the structuring phase, the resulting code is almost inevitably incorrect. Furthermore, we noted that excessive Supervised Fine-Tuning (SFT) can lead to "catastrophic forgetting" of logical reasoning; while CodeBLEU scores might improve as the model mimics human coding style, its ability to solve the underlying legal logic (Pass@1) can actually decrease.

Conclusion and Future Work

Compliance-to-Code provides a path toward transparent and verifiable financial oversight. While the current framework handles intra-regulation relations effectively, future work will address cross-document complexity—such as reasoning across disparate legal domains like tax and securities law. Additionally, we aim to automate the updating of code modules as regulations evolve, ensuring the system remains current without requiring full re-training.

Summary updated

Abstract

Nowadays, regulatory compliance has become a cornerstone of corporate governance, ensuring adherence to systematic legal frameworks. At its core, financial regulations often comprise highly intricate provisions, layered logical structures, and numerous exceptions, which inevitably result in labor-intensive or comprehension challenges. To mitigate this, recent Regulatory Technology (RegTech) and Large Language Models (LLMs) have gained significant attention in automating the conversion of regulatory text into executable compliance logic. However, their performance remains suboptimal particularly when applied to Chinese-language financial regulations, due to three key limitations: (1) incomplete domain-specific knowledge representation, (2) insufficient hierarchical reasoning capabilities, and (3) failure to maintain temporal and logical coherence. One promising solution is to develop a domain specific and code-oriented datasets for model training. Existing datasets such as LexGLUE, LegalBench, and CODE-ACCORD are often English-focused, domain-mismatched, or lack fine-grained granularity for compliance code generation. To fill these gaps, we present Compliance-to-Code, the first large-scale Chinese dataset dedicated to financial regulatory compliance. Covering 1,159 annotated clauses from 361 regulations across ten categories, each clause is modularly structured with four logical elements-subject, condition, constraint, and contextual information-along with regulation relations. We provide deterministic Python code mappings, detailed code reasoning, and code explanations to facilitate automated auditing. To demonstrate utility, we present FinCheck: a pipeline for regulation structuring, code generation, and report generation.
BibTeX
@inproceedings{li2026compliance,
  author = {Siyuan Li and Jian Chen and Rui Yao and Xuming Hu and Peilin Zhou and Weihua Qiu and Simin Zhang and Chucheng Dong and Zhiyao Li and Qipeng Xie and Zixuan Yuan},
  title = {{Compliance-to-Code: Enhancing Financial Compliance Checking via Code Generation}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2026},
  doi = {10.1145/3770854.3785703},
}
Figure