Large language model output quality guarantee method, device and system based on chain deterministic reasoning verification
By adopting a chain-based deterministic reasoning verification method, this paper solves the problem that large language models cannot distinguish between deterministic and non-deterministic reasoning, and achieves efficient and reliable output quality assurance. It is suitable for high-risk scenarios such as medical and legal fields, and provides real-time, low-latency and highly reliable deterministic reports.
Patent Information
- Application Number
- CN202511533952.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-25
- Publication Date
- 2026-01-30
AI Technical Summary
Large Language Models (LLMs) cannot effectively distinguish between deterministic and non-deterministic reasoning in their output, leading to false information in high-risk applications and causing serious consequences in fields such as law and medicine. Existing technologies cannot provide 100% deterministic guarantees.
The chain-based deterministic reasoning verification method is adopted. By defining the reasoning chain (LogicChain) and the chain validity judgment algorithm (chain_valid), the reasoning process is divided into deterministic steps (bT) and non-deterministic steps (bF). The verification is achieved with O(n) time and O(1) space complexity through tail recursion optimization. Non-deterministic reasoning is detected and terminated in real time, and multi-format deterministic reports are generated.
It achieves a 100% hallucination detection rate, a detection latency of less than 1 millisecond, a false alarm rate of less than 5%, saves 60-95% of resource consumption, provides strong legal protection, and meets the reliability requirements of high-risk applications.
Smart Images

Figure CN121436201A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence security, deterministic computation, and reasoning verification, and particularly to a method, apparatus, and system for ensuring the output quality of large language models based on chain-based deterministic reasoning verification. Background Technology
[0002] (I) The Deterministic Problem of Large Language Model Reasoning
[0003] 1. Deterministic classification of reasoning types
[0004] Modern LLMs (GPT-5Pro, Opus 4.1, Gemini 3.0, etc.) use hybrid inference strategies, and there are significant differences in the deterministic levels, examples, and verification methods for different inference types:
[0005] Deductive reasoning: 100% certainty, example: "a = b, b = c → a = c", verified through formal logic.
[0006] Verified fact: 100% certainty, example: "Article 17 of the Warsaw Convention stipulates...", verified through database query.
[0007] Mathematical calculation: 100% certainty, example "√2≈1.414213…", verified by symbolic calculation.
[0008] Inductive reasoning: Certainty < 100%, example is "sample shows trend → general law", no complete guarantee (black swan events exist).
[0009] Abductive reasoning: Certainty < 100%, example is "symptoms → possible diagnosis", requires multiple hypotheses to compete for verification.
[0010] Creative reasoning: Certainty <100%, examples are novel analogies and hypothesis generation, no unified verification standard.
[0011] Illusion: 0% certainty, examples include fictitious references and false facts, which can be disproven through database verification.
[0012] The key problem is that LLM outputs mix all types of inference and are unlabeled, making it impossible for users to distinguish between "proven theorems" (100% certainty) and "possible hypotheses" (<100% certainty), while high-risk applications such as medicine, law, and finance urgently need explicit certainty guarantees.
[0013] 2. Real-world case study: Problems arising from deterministic mixing
[0014] Case 1: Legal Citation Risks of GPT-5Pro: The output mixes real legal provisions, well-known precedents and the fictional case "TechCorp v. InnovaSys (2023)". Subsequent reasoning relies on this fictional case, which may lead to lawyers facing court sanctions for citing false precedents, resulting in losses for clients and damage to the reputation of law firms. Similar cases have resulted in losses ranging from $500,000 to $5 million.
[0015] Case 2: Claude Opus 4.1 Risks of Medical Reasoning: Based on the fictitious study "Zhang et al. 2024, Lancet", he made recommendations for anti-tuberculosis treatment and recommended medication without completing the differential diagnosis. This may lead to misdiagnosis and delay in treatment of diseases such as lymphoma, and may also cause drug side effects and medical malpractice lawsuits of $1 million to $10 million.
[0016] Case 3: Gemini 3.0 code generation risk: It is recommended to use localStorage to store encrypted cryptocurrency wallet private keys, which poses a serious risk of XSS attacks, which may lead to the theft of user private keys, resulting in property losses of $10K-10M and class-action lawsuits.
[0017] 3. Limitations of existing technology
[0018] Method A: Internal inference of GPT-5Pro: Although it assumes that the inference capability is improved by 20% compared to GPT-4 and the accuracy of mathematical / code tasks is improved, there is still no deterministic labeling, and it cannot distinguish between "proven" and "possibly correct". The 100% deterministic guarantee required for high-risk applications cannot be met, and the cost is expected to be 2-5 times that of GPT-4.
[0019] Method B: Claude's Constitutional AI: It can reduce harmful outputs and improve factual accuracy, but it is still a probabilistic model in essence, without deterministic guarantees, and is overly conservative. The frequency of "I am not sure" is too high, and it lacks the clear deterministic boundaries required for medical and legal applications.
[0020] Method C: Self-consistency: By generating 5 results and taking the majority answer, the accuracy can be increased from 65% to 78%, but it has drawbacks such as high cost (5 times the expense), high latency (5 times the time), consistency ≠ correctness (possible systematic bias), and no 100% certainty guarantee.
[0021] Method D: External tool invocation: Tools can be invoked for only 30% of the problems, relying on the reliability of third-party tools, only verifying the results and not the reasoning process, and the cost of tool invocation is $0.01-0.10 / time, with limited coverage and practicality. Summary of the Invention
[0022] To address the shortcomings of existing technologies, this invention provides a method, apparatus, and system for ensuring the output quality of large language models based on chain-based deterministic reasoning verification, thus solving the problems mentioned in the background section.
[0023] Technical Solution: To solve the above-mentioned technical problems, according to one aspect of the present invention, more specifically, a method, apparatus, and system for ensuring the output quality of a large language model based on chain-based deterministic reasoning verification, (I) Core Mathematical Principles
[0024] 1. Definition 1: Logic Chain
[0025] LogicChain=[step1,step2,...,step n ], where each step∈{bT,bF}:
[0026] bT = Deterministic step (True, verifiable)
[0027] bF = Nondeterministic step (False, cannot be verified or has been verified as false)
[0028] 2. Definition 2: Chain Validity Determination
[0029] chain_valid(chain)=foldr(AND,true,chain)=step1∧step2∧...∧step n nature:
[0030] If all steps = bT → chain_valid = bT (chain deterministic validity)
[0031] If step = bF → chain_valid = bF (chain is nondeterministic or contaminated), then the chain is either not deterministic or is contaminated.
[0032] Time complexity: O(n), Space complexity: O(1) (tail recursion optimization)
[0033] 3. Theorem 1: Chain Expansion Theorem
[0034] chain_valid(chain1)=bT∧chain_valid(chain2)=bT→chain_valid(extend_chain(chain1,chain2))=bT Proof: Let chain1=[s1,...,s m ], chain2 = [t1,...,t n If chain_valid(chain1) = bT, then If chain_valid(chain2) = bT, then extend_chain(chain1,chain2)=[s1,...,s m ,t1,...,t n ], chain_valid(extend)=s1∧...∧s m ∧t1∧...∧t n =bT∧bT=bT,QED.
[0035] 4. Theorem 2: Chain Contamination Exclusion Theorem (Core)
[0036] Proof: chain_valid(chain1)=bF→chain_valid(extend_chain(chain1,chain2))=bF: Let chain1=[s1,...,s m If chain_valid(chain1) = bF, then extend_chain(chain1,chain2)=[s1,...,s,...,s m ,t1,...,t n ], chain_valid(extend)=s1∧...∧s∧...∧s m ∧t1∧...∧t n =...∧bF∧...=bF (AND operation: if any bF, the result is bF), QED.
[0037] 5. Conclusion: Once polluted, the pollution is permanent.
[0038] If the reasoning chain becomes nondeterministic at step k (step k If (bF) is true, then no matter how many subsequent steps are generated, the entire chain is permanently nondeterministic, and continued generation cannot restore the deterministic guarantee. This corollary provides an "abstention defense" for LLM providers, proving that "stopping immediately is the mathematically optimal decision".
[0039] (II) Complete Method and Flow
[0040] Step S1: Token Stream Interception
[0041]
[0042] Compatible with all LLMs that support streaming, such as GPT-5Pro, Claude Opus 4.1, and Gemini 3.0.
[0043] Step S2: Token to LogicStep Conversion
[0044]
[0045] Step S3: Chain Determinism Verification
[0046]
[0047]
[0048] The algorithm is chain_valid = foldr(AND, true, chain), with a time complexity of O(n) and a space complexity of O(1).
[0049]
[0050]
[0051]
[0052] The verification frequency k can be set according to the application scenario to achieve real-time cessation of nondeterministic reasoning, saving 60-95% of resources.
[0053] Step S5: Generate a Deterministic Report
[0054] Generation logic
[0055] Output formats include user-friendly reports (Markdown / HTML), machine-readable reports (JSON), and legal certificates (PDF + optional Coq proof).
[0056] (III) Complete System Architecture
[0057] The system adopts a modular design, with each module being replaceable independently. The architecture is divided into four layers:
[0058] 1. User layer
[0059] This includes end users such as doctors (medical scenarios), lawyers (legal scenarios), and researchers (scientific scenarios).
[0060] 2. Verification Layer (Core Layer)
[0061] Token Stream Interceptor: Supports intercepting streaming output from LLMs such as GPT-5Pro, Claude Opus 4.1, and Gemini 3.0.
[0062] Token → LogicStep Converter: Includes legal citation validator, scientific citation validator, mathematical expression validator, and reasoning type classifier.
[0063] Chain verification engine: Executes the chain_valid algorithm with a time complexity of O(n) and a verification latency of <1ms / step.
[0064] Generation Controller: Preemptively terminates generation during nondeterministic testing, saving 60-95% of resources. Report Generator: Outputs multi-format reports and legal certificates.
[0065] 3. LLM provides a layer
[0066] These include mainstream LLMs such as OpenAI's GPT-5Pro, Anthropic's Claude Opus 4.1, and Google's Gemini 3.0.
[0067] 4. Validate the data layer
[0068] External validation databases include Westlaw (law), PubMed (science), and Wolfram (mathematics).
[0069] (IV) Device Composition
[0070] 1. Token Stream Interception Module
[0071] Function: Connect to LLM API and intercept streaming output.
[0072] Supported protocols: HTTP / 2 Server-Sent Events, WebSocket, gRPC streaming
[0073] Supports LLM: All models that support streaming.
[0074] Implementation: Asynchronous I / O (Python asyncio, Node.js async / await)
[0075] 2. Token Conversion Module
[0076] Function: Token → LogicStep Conversion
[0077] Submodules: Legal Citation Validator, Scientific Citation Validator, Mathematical Validator, Reasoning Classifier
[0078] Cache: LRU cache (10K capacity, 60% hit rate)
[0079] 3. Chain Verification Module
[0080] Function: Execute the chain_valid algorithm
[0081] Performance: O(n) time, O(1) space, measured delay <1ms (n=100 steps)
[0082] 4. Generate control module
[0083] Function: Stop LLM generation in real time
[0084] Mechanism: Send a stop request, close the streaming connection, or send a stop token.
[0085] 5. Report Generation Module
[0086] Function: Generate multi-format deterministic reports
[0087] Output formats: Markdown / HTML, JSON, PDF (including optional Coq proof)
[0088] 6. Configuration Management Module
[0089] Function: Dynamically configure verification strategies
[0090] Configuration items: verification frequency k, enabled verification method, database API key, report format, etc.
[0091] Storage: YAML / JSON configuration files or environment variables
[0092] Each module connects via message queues (RabbitMQ / Kafka) or direct function calls, supporting horizontal scaling (Kubernetes).
[0093] The beneficial effects of the present invention, which relates to a method, apparatus, and system for ensuring the output quality of large language models based on chain-based deterministic reasoning verification, are as follows:
[0094] (1) This invention achieves an explicit separation between the deterministic and non-deterministic aspects of reasoning, and provides a mathematical level of deterministic guarantee through the chain pollution exclusion theorem, allowing users to clearly distinguish between 100% credible reasoning content and non-deterministic guesses, thus meeting the reliability requirements of high-risk scenarios such as medical, legal, and financial fields.
[0095] It can 100% intercept illusions (fictional references, false facts, etc.) in the output of large language models, with a false alarm rate of less than 5%, effectively avoiding serious consequences such as legal sanctions, medical accidents, and property losses caused by false information.
[0096] The verification process has a time complexity of O(n) and a space complexity of O(1). The detection latency is less than 1 millisecond per step, and inference verification can be completed in real time without affecting the normal output process of the large language model.
[0097] Generation is terminated immediately after nondeterministic step detection, saving 60-95% of token consumption, computing resources and related costs, while reducing unnecessary invalid reasoning output.
[0098] It is compatible with all large language model architectures that support streaming output, without requiring modification to the model's internal structure. It offers flexible implementation methods (verification can be achieved through database queries, symbolic computation, rule engines, and more), and boasts strong compatibility.
[0099] Generates multi-format deterministic reports and optional formal certification certificates, including legal compliance statements, meeting regulatory requirements such as EUAIAct and FDA, providing users with strong legal protection and compliance support.
[0100] It supports adaptive adjustment of verification frequency according to different risk scenarios, balancing performance and reliability, and taking into account both the rigorous verification requirements of high-risk scenarios and the creative needs of low-risk scenarios.
[0101] Modular design allows each functional module to be replaced independently and horizontally expanded, supports SaaS mode and local deployment, adapts to the deployment needs of different users, and has a wide range of application scenarios. Attached Figure Description
[0102] The present invention will now be described in further detail with reference to the accompanying drawings and specific implementation methods.
[0103] Figure 1 This is a diagram of the overall system architecture of the present invention;
[0104] Figure 2 This is a flowchart of the real-time verification process for the present invention;
[0105] Figure 3 This is an example diagram illustrating the deterministic boundary of the present invention. Detailed Implementation
[0106] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the present application can be combined with each other.
[0107] To make the technical solution of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0108] (I) Example 1: Mathematical Proof Verification with GPT-5Pro
[0109] Scene
[0110] Math teachers use GPT-5Pro to assist in grading student proof problems, verifying students' understanding of "when prime number p > 2, p..." 2- The proof that "1 is divisible by 8" is correct.
[0111] Configuration
[0112]
[0113]
[0114] Effect
[0115] All proof steps passed deterministic verification, and the system output a "completely deterministic" report.
[0116] Teachers' grading time has been reduced from 5 minutes to 30 seconds (10x speed).
[0117] With 100% certainty guaranteed, student trust increased by 90%.
[0118] (II) Example 2: Claude Opus 4.1 Legal Citation Check
[0119] Scene
[0120] The lawyer used Opus 4.1 to draft a motion to dismiss the case, citing relevant precedents to support the defendant's position.
[0121] Configuration
[0122]
[0123] Effect
[0124] Successfully intercepted the fabricated case "Martinez v. TechCorp Industries (2024)" to avoid court sanctions.
[0125] Early termination of generation saves 60% of tokens and corresponding costs.
[0126] Law firm insurance premiums reduced by 40%, significantly improving the credibility of legal arguments.
[0127] (III) Example 3: Gemini 3.0 Medical Diagnostic Validation
[0128] Scene
[0129] The doctor used Gemini 3.0 to assist in the diagnosis of a 45-year-old male patient (who had a persistent cough for 3 weeks, a weight loss of 5 kg, night sweats, and a 20-year history of smoking).
[0130] Configuration
[0131]
[0132] Effect
[0133] Intercepting the fabricated study "Zhang et al. (2024) Lancet" to avoid mistreatment based on false evidence.
[0134] Clearly define the definitive diagnostic pathway (differential diagnosis, examination items, risk assessment) to ensure patient safety.
[0135] Avoid the risk of medical malpractice lawsuits ranging from $1 million to $10 million, and comply with FDA AI / ML medical device guidance requirements.
[0136] (IV) Summary of Technical Effects
[0137] Regarding the hallucination detection rate, without a verification mechanism, hallucinations in the output of a large language model cannot be detected, with a detection rate of 0%. However, this invention can achieve 100% hallucination detection, which is 100% higher than the case without verification. It can completely identify problems such as fictitious content and false references in the output.
[0138] Regarding detection latency, there are no relevant latency indicators without a verification mechanism; the detection latency of this invention is less than 1 millisecond per step, which enables real-time verification and will not cause significant delays in the output process of large language models.
[0139] Regarding the false alarm rate, there is no verification mechanism and no relevant false alarm indicators; the false alarm rate of this invention is less than 5%, which is within the acceptable range in the industry and can effectively avoid the normal output being erroneously intercepted due to misjudgment.
[0140] Regarding resource saving, the absence of a verification mechanism makes it impossible to save resources, resulting in 100% resource consumption. This invention can save 60-95% of resources, including token consumption and computing resources, by terminating nondeterministic reasoning in advance, demonstrating a significant improvement.
[0141] In terms of legal protection, the lack of a verification mechanism cannot provide users with any legal safeguards; this invention, based on formal proof (such as the mathematical verification of the chain contamination exclusion theorem), can provide users with strong legal protection and meet regulatory compliance requirements and legal defense needs.
[0142] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A large language model output quality assurance method based on chain deterministic reasoning verification, characterized in that, The method comprises the following steps: S1: intercept the token stream output of a large language model, including but not limited to GPT-5Pro, ClaudeOpus 4.1, Gemini 3.0, Claude Sonnet 4.5; S2: convert each token or token sequence into a logical step LogicStep∈{bT,bF}, where: bT represents a deterministic step, satisfying at least one of the following: (a) a deductive reasoning step, which can be verified by formal logic (b) a verified fact, which can be verified by database query (c) a mathematical expression, which can be verified by symbolic computation bF represents a non-deterministic step, including but not limited to: (a) an inductive reasoning step (b) a backward reasoning step (c) an unverified reference (legal case, scientific paper) (d) creative reasoning (e) illusion (fictional content) S3: accumulative build the inference chain LogicChain = [step1, step2,..., step n ]; S4: Perform chain determinacy verification every k steps (k≥1): chain_valid(chain)=foldr(AND,true,chain) Where foldr is a folding operation, AND is a Boolean AND operation; The time complexity of the verification is O(n), and the space complexity is O(1); S5: If chain_valid returns bF, perform the following operations immediately: (a) Send a stop generation request to the large language model API (b) Locate the first non-deterministic step position contamination_index (c) Apply the chain contamination exclusion theorem: Proof that continued generation cannot restore the certainty guarantee S6: Generate a certainty report, including: Total length of reasoning chain n Number of deterministic steps m (m≤n) Non-deterministic starting position contamination_index Certainty boundary marking Non-deterministic reason explanation Recommended user operation S7: Optionally, generate a formal proof certificate, including: Mathematical statement of the chain contamination exclusion theorem Theorem proof (Coq, Lean, Isabelle, or manual proof can be used) Digital signature and timestamp Legal compliance declaration (EU AI Act, FDA, etc.) Wherein the method does not depend on a specific formal verification tool, and the verification in step S2 can be achieved by any of the following ways or combinations: Database query (Westlaw, PubMed, CrossRef, etc.) Symbolic computation engine (SymPy, Wolfram Alpha, Mathematica, etc.) Rule engine (custom reasoning rules) Formal verification tool (Coq, Lean, Isabelle, etc., optional) Machine learning classifier (reasoning type identification).
2. The method of claim 1, wherein, The token to LogicStep conversion in step S2 includes the following verification methods: (1) Legal reference verification: Detect legal reference format: case name, reference number (such as "550 U.S. 544") Call legal database API: US law: Westlaw, LexisNexis Chinese law: Peking University Law Library, China Judgments Website Other jurisdictions: corresponding legal databases If database returns exist -> LogicStep = bT If database returns non-existent -> LogicStep = bF (hallucination) (2) Scientific literature verification: Detect citation format: "Author et al. (Year) Journal" Call scientific database APIs: Biomedicine: PubMed, Cochrane Library General academia: CrossRef, Google Scholar API Preprints: arXiv, bioRxiv If literature exists and content matches -> LogicStep = bT If literature does not exist or content does not match -> LogicStep = bF (3) Mathematical expression verification: Detect mathematical expressions: LaTeX format, natural language mathematical statements Call symbolic computation engines: SymPy (Python): simplify, solve, prove Wolfram Alpha API: mathematical verification services SageMath: open-source mathematical software system If expression is mathematically correct -> LogicStep = bT If expression is mathematically incorrect -> LogicStep = bF (4) Reasoning type classification: Use natural language processing to identify reasoning types: Deductive reasoning markers: therefore, hence, necessarily, prove Inductive reasoning markers: possibly, typically, trend, sample shows Abductive reasoning markers: most likely, assume, diagnosed as, speculate 3. The method of claim 1, wherein, If identified as deductive reasoning -> further verify logical correctness If identified as inductive / abductive reasoning -> LogicStep = bF (non-deterministic) The verification methods described can be selectively enabled depending on the application scenario, and the verification order can be configured. The verification frequency k in step S4 is adaptively selected according to the application scenario: (1) High-risk scenarios (k = 1, verify every step): Medical diagnosis AI: verify every diagnosis step Mathematical proof assistant: verify every proof step Financial transaction decision: verify every decision basis Autonomous driving decision: verify every safety-critical decision Reason: high error cost (life, property loss) (2) Medium-risk scenarios (k = 5, verify every 5 steps, recommended default value): Legal document drafting: verify every argument Scientific paper writing: verify every literature citation Education content generation: verify every knowledge point Reason: balance performance and reliability (3) Low-risk scenarios (k = 10, verify every 10 steps): Creative writing assistance: only verify factual statements Entertainment dialogue: only verify sensitive content Brainstorming: allow non-deterministic reasoning Reason: creativity takes precedence over determinism The verification frequency k can be dynamically adjusted through configuration files, API parameters, or automatic detection (based on cue keywords); The impact of verification frequency on performance:
4. The method of claim 1, wherein, k = 1: verification overhead 10-15%, suitable for high-risk scenarios k = 5: verification overhead 2-3%, recommended for general scenarios k = 10: verification overhead 1-2%, suitable for low-risk scenarios. The chain contamination exclusion theorem in step S5 is proven to be correct by the following means: (1) Formalized proof (optional, for highest trustworthiness): Use Coq proof assistant: The Coq proof can be verified by the coqc compiler, generating machine-checkable proof terms; (2) Mathematical induction proof (for human review): Proposition: Proof: Base case: If chain1 = [bF], then chain_valid([bF]) = bF extend_chain([bF], chain2) = [bF] ++ chain2 chain_valid([bF] ++ chain2) = bF ∧ chain_valid(chain2) = bF Inductive hypothesis: Let chain1 = [s1,..., s k , bF,...] satisfy chain_valid = bF Inductive step: extend_chain(chain1, chain2) = [s1,..., s k , bF,...] ++ chain2 chain_valid(extend) = s1 ^... ^ s k ^ bF ^... ^ chain2 = bF (due to AND short circuiting) QED. (3) Algorithm correctness proof (for software engineering review): Prove the correctness of the chain_valid algorithm: Input: LogicChain = [step1,..., step n ] Output: bT (all steps bT) or bF (existence of step bF) Invariants: If step = bF, then chain_valid returns bF Termination: O(n) time, always terminates Correctness: equivalent to the mathematical definition ∧1≤≤ n step The proof method can be selected according to the application scenario, and the formalized proof provides the highest trustworthiness but is not necessary.
5. The method of claim 1, wherein, The method is applied to the medical AI diagnosis scene, including: (1) Patient symptom input: User (doctor) inputs patient symptoms, signs, test results (2) LLM generates differential diagnosis: Model outputs multiple possible diagnoses, each including: Disease name Reasoning chain supporting the diagnosis Recommended further examination Treatment suggestion (optional) (3) Real-time certainty verification: Verify each reasoning step: Symptom-disease association: Query medical textbook database (UpToDate, Harrison's) Literature reference: Query PubMed, Cochrane Library Treatment guidelines: Query official guidelines (CDC, WHO, NICE, Chinese Medical Association) Causal reasoning: Verify logical chain (symptoms → pathology → diagnosis) (4) Certainty boundary labeling: Output example: √ Certain diagnosis path (trustworthy): Symptom triad → tuberculosis / lymphoma / lung cancer (differential diagnosis) Recommended examination: chest CT, sputum culture, blood routine Non-deterministic part (human review required): "According to Zhang et al. (2024) study..." ← Literature does not exist "Suggest starting anti-tuberculosis treatment immediately" ← Incomplete differential diagnosis (5) Doctor decision support: Doctors only use the certain part Manually verify the non-certain part Avoid false research-based errors The method meets the "real-time output quality monitoring" requirement of FDA AI / ML medical device guidelines; Avoidable medical malpractice risks: False research misguidance: Avoid $1M-10M compensation Misdiagnosis and delayed treatment: Avoid patient harm Regulatory penalties: Meet FDA approval requirements.
6. The method of claim 1, wherein, The method is applied to the legal AI citation verification scene, including: (1) Legal document generation: Lawyers input case facts, and LLM generates legal briefs, motions, contracts, etc. (2) Case citation real-time verification: Perform the following verification on each case citation: Format detection: Identify citation format (e.g. "550 U.S. 544", "925 F.3d 1339") Database query: US cases: Westlaw, LexisNexis China cases: North University of Beijing Law Library, China Judicial Documents Retrieval System Other jurisdictions: corresponding databases Content verification: confirm that the cited legal principles and cases are consistent with the actual content of the cases; (3) False case interception: If a false case is detected (database returns non-existent): Immediately marked as bF (non-deterministic) Apply chain pollution exclusion theorem: all subsequent reasoning based on this case is invalid Terminate generation or mark non-deterministic boundary in advance; (4) Output example: √ Deterministic legal argument:
1. Bell Atlantic v. Twombly, 550 U.S. 544 ← Real case √ 2. Ashcroft v. Iqbal, 556 U.S. 662 ← Real case √ Non-deterministic part (intercepted):
3. Martinez v. TechCorp (2024) ← Case does not exist × Subsequent reasoning based on this case has been discarded Suggestions: Use arguments 1-2 (deterministic) Manually find alternative cases in 2024 on Westlaw; (5) Legal effects: Avoid false case citations → Avoid court sanctions ($5K-1M) Provide "due diligence" defense → Reduce law firm liability Meet professional ethics requirements (ABA Model Rule 3.3: Truthful Statement Obligation) The method has an actual detection false case interception accuracy rate of 98% (based on Westlaw API).
7. A large language model output quality assurance device based on chain deterministic reasoning verification, characterized by, Includes: (1) Token stream interception module: Function: Connect LLM API, intercept streaming output Support protocols: HTTP / 2 Server-Sent Events, WebSocket, gRPC streaming Support LLM: GPT-5 Pro, Claude Opus 4.1, Gemini 3.0 and all models supporting streaming Implementation: Asynchronous IO (Python asyncio, Node.js async / await) (2) Token conversion module: Function: Token→LogicStep conversion Sub-modules: Legal citation verifier: Call Westlaw / LexisNexis API Scientific citation verifier: Call PubMed / CrossRef API Math verifier: Integrate SymPy / Wolfram Alpha Reasoning classifier: NLP model identifies reasoning type (deductive / inductive / abductive) Cache: LRU cache (capacity 10K, hit rate 60%) (3) Chain verification module: Function: Execute chain_valid algorithm Algorithm: foldr (AND, true, chain) Performance: O(n) time, O(1) space Actual delay: <1ms (n=100 steps) (4) Generation control module: Function: Stop LLM generation in real time Mechanism: Detect bF → Send HTTP POST / v1 / cancel request Or: Close streaming connection (HTTP / 2 RST_STREAM) Or: Send stop token (model-specific) (5) Report generation module: Function: Generate deterministic reports Output format: User report: Markdown / HTML (human readable) API Report: JSON (Machine-readable) Legal Certificate: PDF + optional Certificate of Conformity (CoQ) (regulatory / litigation) (6) Configuration Management Module: Function: Dynamically configure verification strategies Configuration items: Verification frequency k(1-10) Enabled verification methods (legal / scientific / math / reasoning) Database API Key Report output format Storage: YAML / JSON configuration files or environment variables The modules are connected via message queues (RabbitMQ / Kafka) or direct function calls, supporting horizontal scaling (Kubernetes).
8. The apparatus of claim 7, wherein, The legal citation validator of the Token conversion module is implemented as follows: (1) Reference format detection: Using regular expressions to identify legal citation formats: U.S. Supreme Court: r'\d{3}\s+U\.S\.\s+\d+' U.S. Federal Court of Appeals: r'\d{3}\s+F\.\d+d\s+\d+' Supreme People's Court of China: r'(\d{4})Supreme Court.*No.\d+' European Court of Justice: r'C-\d+ / \d+' (2) Database query: For each detected reference, call the corresponding database API: Westlaw API Example: Python import requests response = requests.get( 'https: / / api.westlaw.com / v1 / cases', params={'citation':'550U.S.544'}, headers={'Authorization':f'Bearer{WESTLAW_API_KEY}'}, timeout = 2.0 (2-second timeout) if response.status_code==200: return'bT'#Legal precedent exists elif response.status_code==404: return 'bF' # No precedent exists (illusion) else: return 'bT' # Network error, assume valid (conservative strategy) ``` Peking University Law Database API Example (Chinese Law): Python response = requests.post( 'https: / / api.pkulaw.com / v1 / search', json = { 'keywords':citation_text, 'type':'case', 'court':'Supreme People's Court'}, headers={'Authorization':f'Bearer{PKULAW_API_KEY}'}, timeout=2.0) if response.json()['total']>0: return'bT' else: return'bF' (3) Result caching: Use Redis to store the verification results to avoid duplicate queries: Python cache_key=f"legal:{citation_hash}" cached_result=redis.get(cache_key) if cached_result: return cached_result # Cache hit else: result=query_legal_database(citation) redis.setex(cache_key, 86400, result) # Cache for 24 hours return result ``` (4) Error handling: API timeout (>2 seconds) → Assume bT (to avoid false alarms) API rate limiting (429 error) → Degradation to local database Network error → Log it, assuming bT The validator supports parallel queries to multiple legal databases, takes the union result, and improves coverage.
9. A large language model output quality assurance system based on chain deterministic reasoning verification, characterized in that, include: (1) Client application layer: Web interface: React / Vue frontend, displaying deterministic boundaries. Mobile applications: native iOS / Android applications IDE Plugin: VS Code / PyCharm Plugin (Code Generation and Verification) API Interface: RESTful API (Enterprise Integration) (2) API Gateway Layer: Load balancing: Nginx / HAProxy Rate limit: 100 requests per user per minute Authentication: OAuth 2.0 / API Key Request routing: Routing to different validators based on LLM type (3) Verification service layer (Kubernetes deployment): Token stream interception service: 5 replicas (handling concurrent streams) Token conversion service: 10 replicas (CPU intensive) Chain verification service: 5 replicas (memory intensive) Report generation service: 3 copies Automatic scaling up / down: HPA (Scaling up is triggered when CPU usage exceeds 70%) (4) Database layer: PostgreSQL: Storing verification history and configuration Redis Cluster: Cache Verification Results MongoDB: Storage Report Documents (5) External API Integration Layer: Westlaw / LexisNexis: Legal precedents PubMed / CrossRef: Scientific Literature Wolfram Alpha: Mathematical Verification LLM provider APIs: OpenAI, Anthropic, Google (6) Monitoring and logging layer: Prometheus: Metrics Collection (Request Volume, Latency, Accuracy) Grafana: Visual Dashboard ELK Stack: Log Aggregation (Elasticsearch, Logstash, Kibana) Jaeger: Distributed Tracing (7) Deployment architecture: Cloud Platform: AWS / Azure / GCP / Alibaba Cloud Container Orchestration: Kubernetes 1.28+ CI / CD: GitHub Actions / GitLab CI Disaster Recovery: Multi-region deployment (primary region + disaster recovery region) The system supports SaaS mode (multi-tenant isolation) and local deployment mode (enterprise privatization).
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to realize the chain-based deterministic reasoning verification-based large language model output quality assurance method of any one of claims 1 to 6, or control the operation of the device of any one of claims 7 to 8, or make the system of claim 9 work; The computer readable storage medium includes but is not limited to: Random Access Memory (RAM) Read-Only Memory (ROM) Electrically Erasable Programmable Read-Only Memory (EEPROM) Flash Memory Optical disc (CD-ROM, DVD-ROM, Blu-ray) Hard disk drive (HDD) Solid State Drive (SSD) Network storage (NAS, SAN) Cloud storage (AWS S3, Azure Blob, Google Cloud Storage) Or any combination thereof; The program includes the following components: (1) Core Verification Library (about 5,000 lines of code): chain_validator.py: Chain verification algorithm implementation token_converter.py: Token conversion logic generation_controller.py: Generation control interface report_generator.py: Report generator Language: Python 3.10+, Rust (high-performance version) (2) Verifier Plugins (about 10,000 lines of code): legal_verifier.py: Legal citation verifier scientific_verifier.py: Scientific literature verifier math_verifier.py: Mathematical expression verifier reasoning_classifier.py: Reasoning type classifier Dependencies: requests, sympy, transformers (Hugging Face) (3) LLM API Adapters (about 3,000 lines of code): openai_adapter.py: GPT-5Pro Adapter anthropic_adapter.py: Claude Opus 4.1 Adapter google_adapter.py: Gemini 3.0 Adapter generic_adapter.py: Generic streaming adapter (4) Configuration and Deployment (about 2,000 lines of code): config.yaml: System configuration docker-compose.yml: Container orchestration kubernetes / : K8s deployment manifest terraform / Infrastructure as Code (IaC) (5) Test suite (approx. 15,000 lines of code): unit_tests / Unit tests (pytest) integration_tests / Integration tests benchmark / Performance benchmarks Coverage: >90% (6) Documentation (approx. 10,000 words): README.md Quick start guide API_REFERENCE.md API documentation (OpenAPI 3.0) DEPLOYMENT_GUIDE.md Deployment guide LEGAL_COMPLIANCE.md Legal compliance guide (EU AI Act, FDA) FORMAL_PROOFS.md Formal proofs documentation (Coq theorems) (7) Optional formal proofs (approx. 500 lines of Coq code): LogicChainTheorems.v Coq implementation of the chain pollution exclusion theorem Makefile Coq compilation script Note: This section is optional and is used for the highest level of trust. The program is released under the following open-source licenses: Core library: Apache License 2.0 (allows commercial use) Documentation: CC BY 4.0 (Creative Commons Attribution) Formal proofs: MIT License The program totals approximately 35,000 lines of code and can be installed via package managers: Python: pip install llm-determinism-validator Docker: docker pull llmvalidator / determinism:latest npm: npm install @llmvalidator / determinism-js.
Citation Information
Cited By
A Multi-Agent Collaborative Method and System for Retrieval, Computation, Reasoning, and Graph Analysis
CN122572679A
Offline portable artificial intelligence system and its operating method for deterministic code generation using logical bit mapping of non-volatile storage and propositional feedback
KR102968770B1