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

This paper introduces Compliance-to-Code, a framework and dataset designed to automate financial auditing by transforming complex, natural-language regulations into executable Python code. By modularizing legal text into structured "Compliance Units," the authors provide a path toward transparent, verifiable, and automated financial oversight.

TL;DR

The authors present the first large-scale Chinese dataset for financial compliance, featuring 1,159 annotated clauses mapped to deterministic Python code. They also introduce FinCheck, a modular pipeline that uses Large Language Models (LLMs) to structure regulations, generate audit code, and produce human-readable compliance reports.

What Problem Does This Paper Address?

Financial regulations are notoriously "dense"—filled with nested logic, quantitative thresholds, and cross-references. Traditionally, checking if a company complies with these rules requires armies of lawyers and auditors, making it slow and expensive.

While LLMs are great at summarizing text, they struggle with the "hard logic" of financial law. They often hallucinate details, miss subtle "if-then" conditions, or fail to maintain consistency across long documents. Furthermore, most existing legal AI benchmarks are English-centric, leaving a significant gap in the Chinese financial market. The authors aim to bridge the gap between "natural language law" and "executable code" to make auditing automated and transparent.

Methods

The core innovation lies in how the authors "atomize" legal text. They decompose regulations into Compliance Units (CUs), each containing four logical elements:

  1. Subject: Who the rule applies to (e.g., "Listed companies").
  2. Condition: The trigger scenario (e.g., "If net profit decreased by >50%").
  3. Constraint: The mandatory requirement (e.g., "Shall not disclose a high bonus plan").
  4. Contextual Information: Definitions or calculation methodologies.

The authors also define four Inter-Unit Relations (refer to, exclude, only include, should include) to handle complex dependencies between different rules.

To implement this, they developed the FinCheck pipeline:

  • Structure Predictor: An LLM that parses raw text into structured CUs.
  • Code Generator: A "Structured Synthesis LLM" (SS-LLM) that turns CUs into Python code.
  • Information Retriever: Fetches real-world company data (e.g., from financial databases).
  • Report Generator: Executes the code against the data and summarizes the findings for human auditors.

Datasets

The paper introduces the Compliance-to-Code Dataset, which includes:

  • 361 authoritative Chinese financial regulations across 10 categories (e.g., Insider Information, Share Repurchases).
  • 1,159 annotated clauses broken down into CUs.
  • 307 executable Python tasks with human-validated "Chain-of-Thought" reasoning and unit tests.

This differs from existing datasets like LexGLUE or LegalBench by focusing specifically on fine-grained, executable code generation rather than just classification or question answering.

Key Insights and Ideas

  • Modularity is the Antidote to Hallucination: By forcing the LLM to first structure the text into CUs before writing code, the system becomes much more reliable. This "intermediate representation" acts as a guardrail.
  • The "Catastrophic Forgetting" of SFT: In a fascinating finding (Table 4), the authors noted that while Supervised Fine-Tuning (SFT) improves the style of the code (higher CodeBLEU scores), too many training epochs actually degraded the model's logical reasoning (lower Pass@1 scores). The model started mimicking human coding patterns but lost the "thread" of the underlying legal logic.
  • Upstream Error Propagation: The biggest bottleneck isn't writing the code; it's the initial structuring. If the model fails to correctly identify a "Condition" or "Constraint" in Task 1, the resulting code in Task 2 is almost guaranteed to be wrong.

Key Results

  • Top Performers: DeepSeek-R1-0528 achieved the best performance in code generation tasks (73.67% Pass@1), while GLM-4-9B-0414 excelled at the initial regulation structuring (71.68% F1 score).
  • Reasoning Matters: Incorporating explicit "Chain-of-Thought" reasoning steps into the prompt boosted the code generation success rate (Pass@1) from ~52% to over 78%.
  • Human-AI Alignment: Expert evaluations gave the FinCheck-generated explanations a score of 4.5/5.0, significantly higher than standard prompt-engineered baselines.

Limitations and Future Work

  • The Annotation Bottleneck: Creating the dataset required a multidisciplinary team of legal and audit experts. Scaling this to every global jurisdiction remains a massive manual undertaking.
  • Cross-Document Complexity: While the system handles relations between units within a regulation well, reasoning across entirely different sets of laws (e.g., tax law vs. securities law) remains a challenge.
  • Dynamic Regulations: Laws change. The authors suggest that future work should focus on how to automatically update the code modules when a specific clause in a regulation is amended, without needing to re-train the entire system.

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},
}

Loading related content...

Figure