Inference method of large language model, training method of large language model

By introducing a self-reflection mechanism into the large language model, errors are corrected based on the logical consistency between the thought content and the result, thus solving the problem of inaccurate judgment results in content review by the large language model and improving the accuracy and precision of the judgment.

CN120450050BActive Publication Date: 2026-04-10BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING BAIDU NETCOM SCI & TECH CO LTD
Filing Date
2025-05-15
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Large language models lack error correction capabilities in content moderation, making it difficult to guarantee the accuracy of judgment results, especially when early inference errors lead to the accumulation of subsequent errors.

Method used

By judging logical consistency after each step of the reasoning path, updated thinking content and reasoning paths are generated, and the ability to self-reflect is developed to correct errors until the correct reasoning path is determined.

Benefits of technology

This improved the inference accuracy of the large language model and the granularity of the review results, ensuring the accuracy of content review.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120450050B_ABST
    Figure CN120450050B_ABST
Patent Text Reader

Abstract

The present disclosure provides a large language model training method, a large language model inference method, an apparatus, an electronic device and a storage medium, relates to the technical field of artificial intelligence, and in particular to the technical field of deep learning, large language model, natural language processing and content review. The specific implementation scheme is: for input content, a target node corresponding to the input content in an inference tree is determined, wherein the inference tree includes multiple levels of nodes; according to the input content and the target node, thinking content, thinking results and inference paths for inferring the input content are generated, wherein the thinking results are target child nodes determined from multiple candidate child nodes of the target node, and the inference paths are paths from the target node to the target child nodes; the correctness of the inference path is determined according to the thinking content and the thinking results; and in response to determining that the inference path is incorrect, updated thinking content, thinking results and inference paths are generated according to the input content and the target node.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of artificial intelligence, in particular to the technical field of deep learning, large language model, natural language processing, content review. More specifically, the present disclosure provides a large language model inference method, a large language model training method, an apparatus, an electronic device, a storage medium, and a computer program product. BACKGROUND

[0002] With the rapid development of artificial intelligence, the application of large language models is becoming more and more widespread. In particular, the inference ability of large language models has shown significant results in various fields. SUMMARY

[0003] The present disclosure provides a large language model inference method, a large language model training method, an apparatus, an electronic device, a storage medium, and a computer program product.

[0004] According to a first aspect, a large language model inference method is provided, the method comprising: determining, for input content, a target node corresponding to the input content in an inference tree, wherein the inference tree comprises multiple levels of nodes; generating, according to the input content and the target node, thinking content, a thinking result, and an inference path for inferring the input content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the inference path is a path from the target node to the target child node; determining the correctness of the inference path according to the thinking content and the thinking result; and in response to determining that the inference path is incorrect, generating updated thinking content, a thinking result, and an inference path according to the input content and the target node.

[0005] According to a second aspect, a large language model training method is provided, the method comprising: determining, for sample content, a target node corresponding to the sample content in an inference tree, wherein the inference tree comprises multiple levels of nodes; generating, according to the sample content and the target node, thinking content, a thinking result, and an inference path for inferring the sample content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the inference path is a path from the target node to the target child node; determining the correctness of the inference path according to the thinking content and the thinking result; in response to determining that the inference path is correct, determining the inference path as a historical path, determining the target child node as an updated target node, returning to the step of generating, according to the sample content and the target node, thinking content, a thinking result, and an inference path for inferring the sample content, until the target node corresponding to the sample content in the inference tree is determined to be the last level node, obtaining multiple historical paths as inference paths of the large language model; and adjusting parameters of the large language model according to an evaluation result of the inference paths of the large language model.

[0006] According to a third aspect, there is provided an inference apparatus of a large language model, comprising: a first target node determining module configured to determine, for input content, a target node corresponding to the input content in an inference tree, wherein the inference tree comprises multiple levels of nodes; a first generating module configured to generate, according to the input content and the target node, thinking content, a thinking result and an inference path for inferring the input content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the inference path is a path from the target node to the target child node; a first reflection module configured to determine correctness of the inference path according to the thinking content and the thinking result; and an updating module configured to, in response to determining that the inference path is incorrect, generate updated thinking content, a thinking result and an inference path according to the input content and the target node.

[0007] According to a fourth aspect, there is provided a training apparatus of a large language model, comprising: a second target node determining module configured to determine, for sample content, a target node corresponding to the sample content in an inference tree, wherein the inference tree comprises multiple levels of nodes; a second generating module configured to generate, according to the sample content and the target node, thinking content, a thinking result and an inference path for inferring the sample content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the inference path is a path from the target node to the target child node; a second reflection module configured to determine correctness of the inference path according to the thinking content and the thinking result; an inference path determining module configured to, in response to determining that the inference path is correct, determine the inference path as a historical path, determine the target child node as an updated target node, and return to the step of generating, according to the sample content and the target node, thinking content, a thinking result and an inference path for inferring the sample content, until the target node corresponding to the sample content in the inference tree is a last level node, and obtain multiple historical paths as inference paths of the large language model; and an adjusting module configured to adjust parameters of the large language model according to an evaluation result of the inference paths of the large language model.

[0008] According to a fifth aspect, there is provided an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by the present disclosure.

[0009] According to a sixth aspect, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method provided by the present disclosure.

[0010] According to a seventh aspect, there is provided a computer program product comprising a computer program stored on at least one of a readable storage medium and an electronic device, which, when executed by a processor, implements the method according to the present disclosure.

[0011] It should be understood that the contents described in this part are not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0012] The accompanying drawings are used to better understand the present scheme and do not limit the present disclosure. Among them:

[0013] Figure 1 is an exemplary system architecture schematic diagram of a reasoning method of a large language model and a training method of a large language model according to an embodiment of the present disclosure;

[0014] Figure 2 is a flowchart of a reasoning method of a large language model according to an embodiment of the present disclosure;

[0015] Figure 3 is a schematic diagram of a reasoning method of a large language model according to an embodiment of the present disclosure;

[0016] Figure 4 is a flowchart of a training method of a large language model according to an embodiment of the present disclosure;

[0017] Figure 5 is a schematic diagram of a training method of a large language model according to an embodiment of the present disclosure;

[0018] Figure 6 is a block diagram of a reasoning device of a large language model according to an embodiment of the present disclosure;

[0019] Figure 7 is a block diagram of a training device of a large language model according to an embodiment of the present disclosure; and

[0020] Figure 8 is a block diagram of an electronic device of at least one of a reasoning method of a large language model and a training method of a large language model according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0021] Exemplary embodiments of the present disclosure are described herein with reference to the accompanying drawings, which are meant to be exemplary in nature, and include various details intended to facilitate understanding of the present disclosure. Thus, it should be apparent to those skilled in the art that various modifications and changes can be made in the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, it should be apparent to those skilled in the art that the elements of the embodiments described herein can be combined in a variety of ways without departing from the scope and spirit of the present disclosure. In addition, it should be understood that descriptions, as used herein, are meant to be illustrative and are not intended to be limiting as to the scope of the disclosure.

[0022] In the field of content review and content risk control, a large language model can be used to safely distinguish content. For example, the content to be reviewed can be directly input to the large language model, and the large language model can distinguish the safety category of the content.

[0023] However, the large language model also has the case of understanding error. This way of directly letting the large language model distinguish the category of the content lacks error correction ability and is difficult to guarantee the accuracy of the distinguishing result.

[0024] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information comply with relevant laws and regulations and do not violate public order and good customs.

[0025] In the technical solutions of the present disclosure, the authorization or consent of the user is obtained before the user's personal information is acquired or collected.

[0026] Figure 1 is an exemplary system architecture schematic diagram of a reasoning method and a training method of a large language model according to an embodiment of the present disclosure. It should be noted that, Figure 1 The illustrated is only an example of a system architecture that can apply the embodiments of the present disclosure to help those skilled in the art understand the technical content of the present disclosure, but does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0027] As Figure 1 illustrated, the system architecture 100 according to the embodiment can include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a communication link medium between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired and / or wireless communication links, etc.

[0028] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. The terminal devices 101, 102, 103 can be various electronic devices, including but not limited to smartphones, tablet computers, laptop computers, etc.

[0029] The server 105 can be a server that provides various services, such as a background management server that provides support for a website browsed by a user using the terminal device 101, 102, or 103 (as an example). The background management server can perform analysis and the like on received request and the like data, and feed back the processing result to the terminal device 101, 102, or 103. The server 105 can be deployed with a predetermined model that has been trained, and the predetermined model can be a large language model (LLM).

[0030] At least one of the inference method of the large language model and the training method of the large language model provided by the embodiments of the present disclosure can generally be performed by the server 105. Accordingly, the inference apparatus of the large language model and the training apparatus of the large language model provided by the embodiments of the present disclosure can generally be provided in the server 105.

[0031] Figure 2 is a flowchart of an inference method of a large language model according to an embodiment of the present disclosure.

[0032] As shown in Figure 2 The inference method of the large language model 200 includes operations S210-S240.

[0033] At operation S210, for input content, a target node corresponding to the input content in an inference tree is determined, wherein the inference tree includes multiple levels of nodes.

[0034] At operation S220, according to the input content and the target node, thinking content, a thinking result, and an inference path for inferring the input content are generated.

[0035] At operation S230, according to the thinking content and the thinking result, the correctness of the inference path is determined.

[0036] At operation S240, in response to determining that the inference path is incorrect, updated thinking content, a thinking result, and an inference path are generated according to the input content and the target node.

[0037] The input content can be content to be audited, and the security of the content to be audited can be divided into two categories: safe and unsafe. The unsafe category can include multiple categories, and each category can also be divided into specific subcategories. Therefore, the security risk category of the input content can be represented by a tree structure, and each node in the tree represents a category. The inference process of the large language model for the input content is to determine the node in the tree structure, so the tree structure can also be referred to as an inference tree.

[0038] For example, the inference tree includes multiple levels of nodes, wherein a first level of nodes can include safe and unsafe, and child nodes (second level of nodes) of the unsafe node can include node A, node B, node C, which are different risk categories under the unsafe category respectively. Child nodes (third level of nodes) of node A can include node A1, node A2, node A3, and the like. Node A1, node A2, node A3 are different risk subcategories under category A respectively, and the like.

[0039] The safety discrimination of the large language model on the input content can be performed level by level. For example, the large language model first discriminates which node in the first level of nodes the input content belongs to, i.e., whether the input content is safe or unsafe. If it is safe, the content can be directly output as a safe discrimination result. If it is unsafe, the input content can be further discriminated which node in the second level of nodes it belongs to, and the like. The last level of nodes discriminated by the large language model can be the final category discrimination result of the input content.

[0040] The discrimination process of the large language model described above is also the inference process, and each level of inference can generate a thinking step (i.e., thinking content), a discrimination result (i.e., thinking result), and an inference path. For example, when the large language model infers which node in the first level of nodes the input content belongs to, it can generate thinking content that discriminates the input content as safe or unsafe. For example, the thinking content of this level of inference is “the input content contains sensitive words, and the input content has a security risk”, and the thinking result is “the input content belongs to the unsafe node”. Since the inference of the first level of nodes is the first inference of the large language model, this level of inference can have no inference path.

[0041] For another example, after the large language model infers the first level of nodes, it can infer which node in the second level of nodes the input content belongs to on the basis of the first level of nodes. This level of inference can generate thinking content that discriminates the input content as one of node A, node B, and node C. For example, the thinking content of this level is “the input content contains sensitive word XXX”, and the thinking result is “the input content belongs to node A”, and the inference path is from the unsafe node to node A. In this way, the inference path of the large language model can be obtained. For example, the inference path of the large language model is unsafe node→node A→node A1.

[0042] The target node in the inference tree corresponding to the input content is the node to which the input content belongs according to the inference of the large language model. After determining the target node to which the input content currently belongs, the thinking content and the thinking result of the next level of the large language model can be generated on the basis of the target node, and the thinking result can be a target child node determined from multiple candidate child nodes of the target node. For example, after determining that the input content belongs to an unsafe target node, the large language model determines a target child node A from multiple candidate child nodes A, B, and C of the target node. In turn, the target child node A can be used as a new target node, and a target child node is determined from child nodes A1, A2, and A3 of the target child node A.

[0043] Although the inference process of the large language model described above can generate the thinking content, the thinking result, and the inference path at each step (i.e., each level), it lacks a reflection mechanism and cannot be corrected in the case of inference errors of the large language model. Especially in the case of inference errors in relatively early inference steps, it will lead to the superposition of subsequent inference errors, making it difficult to obtain a correct discrimination result.

[0044] Therefore, the embodiments of the present disclosure determine the accuracy of the inference path according to the thinking content and the thinking result at each step after generating the inference path at each step. In the case of determining that the inference path is incorrect, updated thinking content, thinking result, and inference path are generated.

[0045] For example, the large language model infers from node A to node A1. The logical consistency between the thinking content generated for inferring from node A to node A1 and the category represented by node A1 can be determined to determine the accuracy of the inference path “node A→node A1”. If it is determined that the inference path “node A→node A1” is correct, the next step of inference can be performed on the basis of node A1. If it is determined that the inference path “node A→node A1” is incorrect, node A can be returned to generate new thinking content, thinking result, and inference path on the basis of node A. For example, the new thinking result can be determined from node A2 and A3. For the new inference path, the step of determining the correctness of the inference path according to the thinking content and the thinking result can be returned until a correct inference path is obtained. For example, the correct inference path can be “node A→node A2”.

[0046] The embodiments of the present disclosure generate the thinking content, the thinking result, and the inference path of the inference of the large language model, determine the accuracy of the inference path according to the thinking content and the thinking result, enable the large language model to have the ability of self-reflection, return to the previous node in the case of determining that the inference path is incorrect, generate updated thinking content, thinking result, and inference path, enable the large model to have the ability of backtracking and error correction, find an error node, generate a new inference path, and improve the accuracy of inference.

[0047] According to an embodiment of this disclosure, the above operation S230 includes determining the logical consistency between the thinking content and the thinking result based on the semantics of the thinking content and the semantics of the target sub-node represented by the thinking result; and determining the correctness of the reasoning path based on the logical consistency between the thinking content and the thinking result.

[0048] The semantic consistency between the semantics of the thought content and the semantics of the target sub-node represented by the thought result can represent the logical consistency between the thought content and the thought result. For example, the thought content from node A to node A1 is "the input content contains the sensitive word XXX", and the thought result is "the input content belongs to node A". However, if "sensitive word XXX" is a sensitive word belonging to category A2, which is inconsistent with category A1 represented by the target sub-node A1, then the logical inconsistency between the thought content and the thought result can be identified as an error in the reasoning path.

[0049] The embodiments of this disclosure determine the logical accuracy of each step of the reasoning path, enabling the large language model to have the ability to self-reflect, thereby improving the accuracy of the large language model's reasoning.

[0050] Figure 3 This is a schematic diagram of a reasoning method for a large language model according to an embodiment of the present disclosure.

[0051] like Figure 3 As shown, a reasoning tree with first-level nodes in the unsafe category is displayed, where unsafe nodes are identified by R, representing risk.

[0052] According to embodiments of this disclosure, in response to determining that the reasoning path is correct, the reasoning path is determined as a historical path, the target child node is determined as the updated target node, and the steps of generating thinking content, thinking results and reasoning path for reasoning against the input content are returned based on the input content and the target node, until the target node corresponding to the input content in the reasoning tree is determined to be the last level node.

[0053] According to embodiments of this disclosure, in response to determining that the reasoning path is incorrect, updated thinking content, thinking results, and reasoning path are generated based on the input content and the target node; for the updated thinking content, thinking results, and reasoning path, the step of determining the correctness of the reasoning path based on the thinking content and thinking results is returned until the reasoning path is determined to be correct.

[0054] For example, after the large language model infers that the target node of the input content is node R, it infers the target sub-node A based on node R, and generates the thinking content and reasoning path from node R to node A. Then, according to the logical consistency of the thinking content and node A, the correctness of the reasoning path from node R to node A is determined. In the case where the reasoning path from node R to node A is determined to be correct, the reasoning path from node R to node A is determined as the historical path. And the target sub-node A is determined as the new target node, and the inference is continued based on node A.

[0055] For example, the large language model infers the target sub-node A1 based on node A, and generates the thinking content and reasoning path from node A to node A1. If the thinking content from node A to node A1 is not logically consistent with node A1, it can be determined that the reasoning path from node A to node A1 is incorrect. Then return to node A from node A1, continue to infer with node A as the target node, determine a new target sub-node, and generate a new reasoning path.

[0056] For example, the new reasoning path is from node A to node A2, and the new thinking content is logically consistent with node A2, then the reasoning path from node A to node A2 is correct. The reasoning path from node A to node A2 can be determined as the historical path, and node A2 is taken as the new target node to continue the inference. Repeat the above inference process until the last level target node is obtained, and the multiple levels of historical paths obtained in the inference process can constitute the reasoning path of the large language model. For example, the reasoning path of the large language model can be node R→node A→node A2→node A22.

[0057] According to an embodiment of the present disclosure, the node represents a security risk category of the input content, and the sub-node represents a security risk sub-category of the input content. The thinking content, the thinking result and the reasoning path generated for the inference of the input content include: generating the thinking content for the security risk identification of the input content according to the semantics of the input content; determining the target category sub-node corresponding to the input content from the multiple candidate sub-nodes of the target category node as the thinking result according to the thinking content; and determining the reasoning path according to the target category node and the target category sub-node.

[0058] For example, in the field of content review, the inference process of the large language model is the process of security identification of the input content. According to the semantics of the input content, the intermediate step of the inference, i.e., the thinking content, can be generated in the inference process. The last level node (such as node A22) in the complete reasoning path generated by the large language model can be the final risk category of the input content.

[0059] Embodiments of the present disclosure can improve the accuracy of reasoning of a large language model by generating intermediate steps and reasoning paths through multi-level reasoning of the large language model, reflecting and correcting according to the intermediate steps, and obtaining a complete and accurate reasoning path. In the scenario of auditing input content, the accuracy of the auditing result and the fineness of the category determination result can be improved.

[0060] Figure 4 is a flowchart of a training method of a large language model according to an embodiment of the present disclosure.

[0061] As shown in Figure 4 , the training method 400 of the large language model includes operations S410-S460.

[0062] At operation S410, for sample content, a target node corresponding to the sample content in a reasoning tree is determined, wherein the reasoning tree includes multiple levels of nodes.

[0063] At operation S420, according to the sample content and the target node, thinking content, thinking result and reasoning path for reasoning the sample content are generated, and the thinking result is a target child node determined from multiple candidate child nodes of the target node.

[0064] At operation S430, the correctness of the reasoning path is determined according to the thinking content and the thinking result.

[0065] At operation S440, in response to determining that the reasoning path is correct, the reasoning path is determined as a historical path, and the target child node is determined as an updated target node.

[0066] At operation S450, it is determined whether the target node is the last level node. If yes, the reasoning path of the large language model is obtained, and operation S460 is performed, otherwise operation S420 is returned.

[0067] At operation S460, according to the evaluation result of the reasoning path of the large language model, the parameters of the large language model are adjusted.

[0068] The above operations S410-S440 are similar to the corresponding content of the above reasoning method of the large language model. In the training phase, the large language model also generates thinking content, thinking result and reasoning path for each step of reasoning, and determines the accuracy of the reasoning path according to the logical consistency of the thinking content and the thinking result. In the case where the reasoning path is correct, the reasoning path is determined as a historical path, and the target child node indicated by the thinking result is determined as a new target node, and the reasoning continues. Until the last level target node is reasoned out, the multi-level historical paths obtained in the reasoning process can constitute the reasoning path of the large language model for reasoning the sample content.

[0069] Next, the inference path of the large language model can be evaluated. For example, an evaluation model can be used to evaluate the inference path of the large language model based on the reference path. The reference path can be an annotated inference path for the sample content, and can include multiple levels of intermediate steps in the inference process (i.e., reference content) and inference results at each level (i.e., reference nodes).

[0070] For example, the inference path of the large language model can be evaluated according to the difference between the inference path of the large language model and the annotated reference path. The evaluation result can represent the inference ability and inference accuracy of the large language model. According to the evaluation result, the parameters of the large language model can be adjusted to make the large language model adjust in the direction of stronger inference ability and higher inference accuracy.

[0071] Embodiments of the present disclosure generate an inference path of a large language model, and by evaluating the inference path of the large language model and adjusting the parameters of the large language model, the inference ability and inference accuracy of the large language model can be improved.

[0072] Figure 5 is a schematic diagram of a training method of a large language model according to an embodiment of the present disclosure.

[0073] As shown in Figure 5 The first annotation data 501 can be a data set annotated with a corresponding relationship between sample content and categories. The categories can be security risk categories. The initial model 510 can be an initialized large language model. By training the initial model 510 using the first annotation data 501, the first model 520 can be obtained. The first model 520 can be a large language model that learns knowledge in the content review field.

[0074] The second annotation data 502 can be a data set annotated with a reference path for sample content. The reference path can include multiple levels of inference steps for determining the security risk categories for the sample content and inference results at each level of inference steps. The content at each level of inference steps can be used as reference content, and the category nodes at each level of inference results can be used as reference nodes.

[0075] According to an embodiment of the present disclosure, the evaluation result is determined according to at least one of a difference between the multi-level reference path and the multi-level historical path, a difference between the reference content of the multi-level reference path and the thinking content of the multi-level historical path, and a difference between the reference nodes in the multi-level reference path and the target nodes in the multi-level historical path.

[0076] For example, the second data set 502 can be input into the first model 520, so that the first model 520 generates an inference path and multiple levels of intermediate steps (i.e., thinking content) and intermediate results (target nodes) included in the inference path on the second data set 502.

[0077] Next, the inference path generated by the first model 520 can be evaluated based on the reference path using an evaluation model or manually by a human, to obtain an evaluation result 503. The evaluation result 503 can include differences between the reference path and the inference path, differences between the reference content and the thinking content, and differences between the reference node and the target node. The loss of the first model 520 can be determined according to at least one of the above differences, and the parameters of the first model 520 are adjusted according to the loss, so that the first model 520 improves the inference ability and the inference accuracy.

[0078] The above way of evaluating the inference path generated by the first model 520 based on the reference path and adjusting the parameters of the first model 520 based on the evaluation result is a step performed based on the idea of Proximal Policy Optimization (PPO) or Direct Preference Optimization (DPO). Compared with the conventional PPO or DPO, the embodiment is to perform reinforcement learning or optimization on the inference path containing intermediate steps, which can improve the inference ability of the first model 520.

[0079] According to an embodiment of the present disclosure, the present disclosure also provides an inference device of a large language model and a training device of a large language model.

[0080] Figure 6 is a block diagram of an inference device of a large language model according to an embodiment of the present disclosure.

[0081] As shown in Figure 6 The inference device of the large language model 600 includes a first target node determination module 610, a first generation module 620, a first reflection module 630, and a first update module 640.

[0082] The first target node determination module 610 is configured to determine, for input content, a target node corresponding to the input content in an inference tree, wherein the inference tree includes multiple levels of nodes.

[0083] The first generation module 620 is configured to generate, according to the input content and the target node, thinking content, a thinking result, and an inference path for inferring the input content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the inference path is a path from the target node to the target child node.

[0084] The first reflection module 630 is configured to determine the correctness of the inference path according to the thinking content and the thinking result.

[0085] The first updating module 640 is configured to, in response to determining that the inference path is incorrect, generate updated thinking content, a thinking result, and an inference path according to the input content and the target node.

[0086] According to an embodiment of the present disclosure, the inference device 600 of the large language model further comprises a first inference path determination module.

[0087] The first inference path determination module is configured to, in response to determining that the inference path is correct, determine the inference path as a historical path, determine the target sub-node as an updated target node, and return to the step of generating, according to the input content and the target node, the thinking content, the thinking result, and the inference path for inferring the input content until the target node corresponding to the input content in the inference tree is determined as the last level node, obtaining a multi-level historical path as the inference path of the large language model.

[0088] The inference device 600 of the large language model further comprises a first returning module.

[0089] The first returning module is configured to, for the updated thinking content, the thinking result, and the inference path, return the first reflection module 630 to perform the step of determining the correctness of the inference path according to the thinking content and the thinking result until the inference path is determined to be correct.

[0090] The first reflection module 630 comprises a first reflection unit and a second reflection unit.

[0091] The first reflection unit is configured to determine the logical consistency of the thinking content and the thinking result according to the semantics of the thinking content and the semantics of the target sub-node represented by the thinking result.

[0092] The second reflection unit is configured to determine the correctness of the inference path according to the logical consistency of the thinking content and the thinking result.

[0093] According to an embodiment of the present disclosure, the node represents a security risk category of the input content, and the sub-node represents a security risk sub-category of the input content. The first generation module 620 comprises a thinking content generation unit, a thinking result generation unit, and an inference path generation unit.

[0094] The thinking content generation unit is configured to generate, according to the semantics of the input content, thinking content for security risk judgment of the input content.

[0095] The thinking result generation unit is configured to determine, according to the thinking content, a target category sub-node corresponding to the input content from a plurality of candidate sub-nodes of the target category node as a thinking result.

[0096] The inference path generation unit is configured to determine an inference path according to the target category node and the target category sub-node.

[0097] Figure 7is a block diagram of a training device of a large language model according to one embodiment of the present disclosure.

[0098] As shown in Figure 7 The training device 700 of the large language model includes a second target node determination module 710, a second generation module 720, a second reflection module 730, a second reasoning path determination module 740, and an adjustment module 750.

[0099] The second target node determination module 710 is configured to determine, for a sample content, a target node in an inference tree corresponding to the sample content, wherein the inference tree includes multiple levels of nodes.

[0100] The second generation module 720 is configured to generate, according to the sample content and the target node, thinking content, a thinking result, and a reasoning path for reasoning on the sample content, wherein the thinking result is a target child node determined from multiple candidate child nodes of the target node, and the reasoning path is a path from the target node to the target child node.

[0101] The second reflection module 730 is configured to determine, according to the thinking content and the thinking result, correctness of the reasoning path.

[0102] The second reasoning path determination module 740 is configured to, in response to determining that the reasoning path is correct, determine the reasoning path as a historical path, determine the target child node as an updated target node, and return to the step of generating, according to the sample content and the target node, the thinking content, the thinking result, and the reasoning path for reasoning on the sample content, until the target node in the inference tree corresponding to the sample content is determined to be a last level node, and obtain multiple historical paths as the reasoning path of the large language model.

[0103] The adjustment module 750 is configured to adjust parameters of the large language model according to an evaluation result of the reasoning path of the large language model.

[0104] The training device 700 of the large language model further includes a second update module and a second return module.

[0105] The second update module is configured to, in response to determining that the reasoning path is incorrect, generate, according to the sample content and the target node, updated thinking content, a thinking result, and a reasoning path.

[0106] The second return module is configured to, for the updated thinking content, the thinking result, and the reasoning path, return to the second reflection module 730 to perform the step of determining, according to the thinking content and the thinking result, correctness of the reasoning path, until the reasoning path is determined to be correct.

[0107] The second reflection module 730 includes a third reflection unit and a fourth reflection unit.

[0108] The third reflection unit is used to determine the logical consistency between the thinking content and the thinking result based on the semantics of the thinking content and the semantics of the target sub-nodes represented by the thinking result.

[0109] The fourth reflection unit is used to determine the correctness of the reasoning path based on the logical consistency between the content and result of the thinking.

[0110] The training device 700 for the large language model also includes an evaluation module.

[0111] The evaluation module is used to evaluate the reasoning path of the large language model based on the reference path and obtain the evaluation results.

[0112] According to embodiments of this disclosure, the reference path includes multi-level reference paths, each level of the reference path having corresponding reference content and reference nodes.

[0113] The evaluation module is used to determine the evaluation result based on at least one of the following: the difference between the multi-level reference path and the multi-level historical path; the difference between the reference content of the multi-level reference path and the thinking content of the multi-level historical path; and the difference between the reference nodes in the multi-level reference path and the target nodes in the multi-level historical path.

[0114] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0115] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0116] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

[0117] A plurality of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0118] The computing unit 801 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 801 performs various methods and processes described above, such as at least one of the inference method of a large language model and the training method of a large language model. For example, in some embodiments, at least one of the inference method of a large language model and the training method of a large language model can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of at least one of the inference method of a large language model and the training method of a large language model described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform at least one of the inference method of a large language model and the training method of a large language model by any other appropriate means, such as by means of firmware.

[0119] Various implementations of the systems and techniques described above herein can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application-specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0120] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or the block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0121] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0122] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0123] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0124] The computer system can include clients and servers. This relationship can be

[0125] It should be understood that the procedures shown above can be re-ordered, added to, or removed from, while still being within the scope of the present disclosure. For example, the steps recited in the present disclosure can be performed in parallel, in series, or in a different order, as long as the desired results of the technology disclosed in the present disclosure are achieved, and are not limited herein.

[0126] The specific embodiments described above are not intended to be limiting, and persons skilled in the art will appreciate that various modifications, combinations, sub-combinations and alternatives can be made to the specific embodiments without departing from the spirit and principles of the disclosure. Accordingly, the disclosure is not limited to the specific embodiments described above.

Claims

1. A method for security discrimination of content to be audited by a large language model, applied to the field of content auditing, the method comprising: determining a target node corresponding to input content to be audited in an inference tree, wherein the inference tree comprises multiple levels of nodes, a first level of nodes representing a safe category or an unsafe category, and nodes other than the first level of nodes representing sub-risk categories under the unsafe category; generating thinking content, a thinking result and an inference path for reasoning on the input content according to the input content and the target node, wherein the thinking result is a target sub-node determined from multiple candidate sub-nodes of the target node, the inference path is a path from the target node to the target sub-node, the input content, the thinking content and the thinking result are all texts containing semantics, and the thinking result represents a category discrimination result of the input content; determining the correctness of the inference path according to the thinking content and the thinking result; and in response to determining that the inference path is incorrect, generating updated thinking content, a thinking result and an inference path according to the input content and the target node, and returning the step of determining the correctness of the inference path according to the thinking content and the thinking result until the inference path is determined to be correct; determining the category represented by the last level of nodes in the correct inference path as the category discrimination result of the input content; wherein the determining the correctness of the inference path according to the thinking content and the thinking result comprises: determining semantic consistency of the thinking content and the thinking result according to semantics of the thinking content and semantics of the target sub-node represented by the thinking result; and determining the correctness of the inference path according to the semantic consistency of the thinking content and the thinking result.

2. The method of claim 1, further comprising: in response to determining that the inference path is correct, determining the inference path as a historical path, determining the target sub-node as an updated target node, returning the step of generating thinking content, a thinking result and an inference path for reasoning on the input content according to the input content and the target node until the target node corresponding to the input content in the inference tree is determined to be the last level of nodes, obtaining a multi-level historical path as an inference path of the large language model.

3. The method of claim 1 or 2, wherein, The generating thinking content, a thinking result and an inference path for reasoning on the input content according to the input content and the target node comprises: generating thinking content for security risk discrimination of the input content according to semantics of the input content; determining a target category sub-node corresponding to the input content from multiple candidate sub-nodes of a target category node as a thinking result according to the thinking content; and determining the inference path according to the target category node and the target category sub-node.

4. A training method of a large language model for security discrimination of content to be audited, applied to the field of content auditing, the method comprising: determining a target node corresponding to the sample content in an inference tree, wherein the inference tree comprises multiple levels of nodes, a first level of nodes representing a safe category or an unsafe category, and nodes other than the first level of nodes representing sub-risk categories under the unsafe category; generating, according to the sample content and the target node, thinking content, a thinking result, and an inference path for reasoning on the sample content, wherein the thinking result is a target sub-node determined from multiple candidate sub-nodes of the target node, the inference path is a path from the target node to the target sub-node, the sample content, the thinking content, and the thinking result are all texts containing semantics, and the thinking result represents a category determination result of the sample content; determining the correctness of the inference path according to the thinking content and the thinking result; in response to determining that the inference path is correct, determining the inference path as a historical path and the target sub-node as an updated target node, returning to the step of generating, according to the sample content and the target node, the thinking content, the thinking result, and the inference path for reasoning on the sample content until it is determined that the target node corresponding to the sample content in the inference tree is a last level of nodes, obtaining multiple levels of historical paths as the inference path of the large language model, and determining a category represented by the last level of nodes as the category determination result of the sample content; and adjusting parameters of the large language model according to an evaluation result of the inference path of the large language model. The determining of the correctness of the inference path according to the thinking content and the thinking result comprises: determining semantic consistency of the thinking content and the thinking result according to semantics of the thinking content and semantics of the target sub-node represented by the thinking result; and determining the correctness of the inference path according to the semantic consistency of the thinking content and the thinking result.

5. The method of claim 4, further comprising: in response to determining that the inference path is incorrect, generating updated thinking content, a thinking result, and an inference path according to the sample content and the target node; for the updated thinking content, the thinking result, and the inference path, returning to the step of determining the correctness of the inference path according to the thinking content and the thinking result until it is determined that the inference path is correct.

6. The method of claim 4, further comprising: evaluating the inference path of the large language model according to a reference path to obtain the evaluation result.

7. The method of claim 6, wherein, The reference path comprises multiple levels of reference paths, and each level of reference path has corresponding reference content and a reference node. The evaluating of the inference path of the large language model according to a reference path to obtain the evaluation result comprises: determining the evaluation result according to at least one of a difference between the multiple levels of reference paths and the multiple levels of historical paths, a difference between the reference content of the multiple levels of reference paths and the thinking content of the multiple levels of historical paths, and a difference between the reference nodes in the multiple levels of reference paths and the target nodes in the multiple levels of historical paths.

8. An apparatus for security judgment of content to be audited by a large language model, applied to the field of content auditing, the apparatus comprising: a first target node determination module configured to determine, for input content to be audited, a target node corresponding to the input content in an inference tree, wherein the inference tree comprises multiple levels of nodes, a first level of nodes representing a safe category or an unsafe category, and nodes other than the first level of nodes representing sub-risk categories under the unsafe category; a first generation module configured to generate, according to the input content and the target node, thinking content, a thinking result, and an inference path for reasoning on the input content, wherein the thinking result is a target sub-node determined from multiple candidate sub-nodes of the target node, the inference path is a path from the target node to the target sub-node, the input content, the thinking content, and the thinking result are all texts containing semantics, and the thinking result represents a category judgment result of the input content; a first reflection module configured to determine correctness of the inference path according to the thinking content and the thinking result; and an updating module configured to, in response to determining that the inference path is incorrect, generate updated thinking content, a thinking result, and an inference path according to the input content and the target node, and return to the step of determining correctness of the inference path according to the thinking content and the thinking result until the inference path is determined to be correct; a result determination module configured to determine a category represented by a last level of nodes in a correct inference path as a category judgment result of the input content; the first reflection module is configured to determine semantic consistency of the thinking content and the thinking result according to semantics of the thinking content and semantics of a target sub-node represented by the thinking result, and determine correctness of the inference path according to the semantic consistency of the thinking content and the thinking result.

9. A training apparatus for a large language model for security judgment of content to be audited, applied to the field of content auditing, the apparatus comprising: a second target node determination module configured to determine, for sample content, a target node corresponding to the sample content in an inference tree, wherein the inference tree comprises multiple levels of nodes, a first level of nodes representing a safe category or an unsafe category, and nodes other than the first level of nodes representing sub-risk categories under the unsafe category; a second generation module configured to generate, according to the sample content and the target node, thinking content, a thinking result, and an inference path for reasoning on the sample content, wherein the thinking result is a target sub-node determined from multiple candidate sub-nodes of the target node, the inference path is a path from the target node to the target sub-node, the sample content, the thinking content, and the thinking result are all texts containing semantics, and the thinking result represents a category judgment result of the sample content; a second reflection module configured to determine correctness of the inference path according to the thinking content and the thinking result; and The reasoning path determination module is configured to, in response to determining that the reasoning path is correct, determine the reasoning path as a historical path, determine the target sub-node as an updated target node, return to a step of generating, according to the sample content and the target node, thinking content, a thinking result and a reasoning path for reasoning on the sample content until it is determined that the target node corresponding to the sample content in the reasoning tree is a last-level node, and obtain a multi-level historical path as the reasoning path of the large language model, and determine a category represented by the last-level node as a category determination result of the sample content. The adjustment module is configured to adjust parameters of the large language model according to an evaluation result of the reasoning path of the large language model. The second reflection module is configured to determine semantic consistency of the thinking content and the thinking result according to semantics of the thinking content and semantics of the target sub-node represented by the thinking result, and determine correctness of the reasoning path according to the semantic consistency of the thinking content and the thinking result. 10.An electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 7.

11. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1 to 7. 12.A computer program product comprising a computer program stored on at least one of a readable storage medium and an electronic device, the computer program, when executed by a processor, implements the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Intelligent question and answer method based on cooperation of large language model and knowledge graph

    CN118797017A

  • Design method, system and device of large model reasoning path verifier based on preference tree

    CN119293657A