Method and device for reasoning reflection of large language model and storage medium

Through preset propt rules and multiple attempts, the problem of difficult to improve the accuracy of output content of large language models is solved, and rapid and accurate execution information generation and network or model problems are achieved.

CN119476485APending Publication Date: 2025-02-18SHENZHEN SANTU TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411542176.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art is difficult to improve the accuracy of the output content of large language models through reflection mechanisms, especially when determining the cause of output abnormalities.

Method used

The preset propt rule determines whether the execution information generated by the large language model complies with the rules. If it does not comply, a history is obtained and multiple attempts to generate execution information that complies with the rules are attempted, and finally the user instructions are executed based on the execution information that complies with the rules.

Benefits of technology

It realizes the rapid and accurate generation of execution information that meets the requirements, improves overall processing efficiency, and uses multiple attempts to identify network problems or inconsistencies in the model analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476485A_ABST
    Figure CN119476485A_ABST
Patent Text Reader

Abstract

The invention discloses an inference reflection method and device for a large language model and a storage medium, and relates to the technical field of artificial intelligence, and the method comprises the steps: after obtaining first execution information outputted by the large language model according to a user instruction, judging whether the first execution information accords with a preset prompt rule; if the first execution information does not accord with the user instruction, acquiring a historical record, and inputting the historical record and the user instruction into the large language model to generate second execution information; when the second execution information does not accord with the preset prompt rule, inputting the user instruction into the large language model again, and generating third execution information; and when the third execution information accords with the preset prompt rule, executing the user instruction according to the third execution information. According to the method, the accuracy of the content output by the large language model is improved by reflecting with the historical record and without the historical record.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a reasoning and reflection method, device and storage medium for a large language model. Background Art

[0002] An agent is a system that can autonomously perceive the environment, make decisions and execute actions. It belongs to the field of artificial intelligence research to some extent. Reflection is an important design concept of an agent. This design mode requires the agent to reflect after outputting results and continuously improve itself based on feedback.

[0003] Currently, when an agent reflects with historical records, it can use past inputs, outputs, and environmental states to more fully analyze problems. This helps the agent identify potential patterns, trends, or anomalies, but it cannot determine whether the output anomaly is caused by user input problems, or whether the network is in poor condition or the model's internal analysis is messy, causing the output to not meet expectations.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a reasoning reflection method, device and storage medium for a large language model, aiming to solve the technical problem of how to improve the accuracy of the content output by the large language model through a reflection mechanism.

[0006] To achieve the above objectives, the present application proposes a reasoning and reflection method for a large language model, the method comprising:

[0007] After obtaining the first execution information output by the large language model according to the user instruction, determining whether the first execution information complies with a preset prompt rule;

[0008] If the first execution information does not match, obtaining a historical record, and inputting the historical record and the user instruction into the large language model to generate second execution information;

[0009] When the second execution information does not conform to the preset prompt rule, the user instruction is input into the large language model again to generate third execution information;

[0010] When the third execution information meets the preset prompt rule, the user instruction is executed according to the third execution information.

[0011] In one embodiment, after obtaining the first execution information output by the large language model according to the user instruction, before the step of determining whether the first execution information conforms to the preset prompt rule includes:

[0012] After obtaining the user instruction, inputting the user instruction and the preset prompt rule into the large language model;

[0013] The user instruction is parsed according to the model, and the first execution information is generated according to the preset prompt rule.

[0014] In one embodiment, the step of parsing the user instruction according to the large language model and generating the first execution information according to the preset prompt rule includes:

[0015] Parsing the user instruction according to the large language model, and determining the instruction category of the user instruction according to the parsing result;

[0016] Determining, according to the instruction category, a target prompt rule matching the user instruction from the preset prompt rules;

[0017] The first execution information is generated according to the target prompt rule.

[0018] In one embodiment, after obtaining the first execution information output by the large language model according to the user instruction, the step of determining whether the first execution information conforms to the preset prompt rule includes:

[0019] If the first execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

[0020] In one embodiment, after the step of executing the user instruction according to the first execution information if the first execution information meets the preset prompt rule, the following steps are included:

[0021] The user instruction and the first execution information are stored, and the history record is updated.

[0022] In one embodiment, the step of inputting the historical record and the user instruction into the large language model to generate the second execution information includes:

[0023] splicing the historical records and the user instructions in chronological order to obtain a spliced ​​text;

[0024] The concatenated text is input into the large language model to generate the second execution information.

[0025] In one embodiment, after the step of obtaining a historical record if the first execution information does not match, and inputting the historical record and the user instruction into the large language model to generate the second execution information, the step includes:

[0026] If the second execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

[0027] In one embodiment, when the third execution information meets the preset prompt rule, after the step of executing the user instruction according to the third execution information, the following steps are included:

[0028] If the third execution information does not conform to the preset prompt rule, an error prompt is generated according to the preset prompt rule.

[0029] In addition, to achieve the above-mentioned purpose, the present application also proposes a reasoning and reflection device for a large language model, and the reasoning and reflection device for a large language model includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the reasoning and reflection method for a large language model as described above.

[0030] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the reasoning and reflection method of the large language model as described above are implemented.

[0031] The present application provides a reasoning and reflection method for a large language model. Through the preset prompt rules, it is possible to quickly determine whether the execution information generated by the large language model complies with the rules without manual inspection one by one. If the first execution information does not comply with the rules, the historical records are obtained and input into the large language model to generate the second execution information; by introducing the historical records, more contextual information can be provided to the large language model, which helps to generate execution information that is more in line with the user's intentions. When the second execution information does not comply with the preset rules, the user instructions are input again to generate the third execution information; when the third execution information complies with the preset rules, the user instructions are executed according to the third execution information, and the instructions issued by the user can be automatically executed.

[0032] In summary, through the preset rules and multiple attempts mechanism, the execution information that meets the requirements can be generated quickly and accurately, thereby improving the overall processing efficiency. Through multiple attempts and the introduction of historical records and other mechanisms, the results are re-output with and without historical records. If the results that meet the preset rules cannot be output after multiple attempts, it means that there is a network problem or the internal analysis of the model is disordered. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0035] Figure 1 A flowchart diagram of the first embodiment of the inference reflection method of the large language model of the present application is provided;

[0036] Figure 2 A detailed flow chart of the first embodiment of the reasoning and reflection method of the large language model of the present application;

[0037] Figure 3 A flowchart diagram of the second embodiment of the reasoning reflection method of the large language model of the present application is provided;

[0038] Figure 4 A detailed flow chart of the second embodiment of the reasoning and reflection method of the large language model of this application;

[0039] Figure 5 A flowchart diagram of the third embodiment of the inference reflection method of the large language model of the present application;

[0040] Figure 6 A flowchart diagram of the fourth embodiment of the reasoning and reflection method of the large language model of the present application is provided;

[0041] Figure 7 A flowchart diagram of the fifth embodiment of the reasoning and reflection method of the large language model of the present application is provided;

[0042] Figure 8 This is a schematic diagram of the device structure of the hardware operating environment involved in the reasoning and reflection method of a large language model in an embodiment of the present application. DETAILED DESCRIPTION

[0043] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0044] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0045] The main solution of the embodiment of the present application is: after obtaining the first execution information output by the large language model according to the user instruction, determine whether the first execution information complies with the preset prompt rule; if the first execution information does not comply, obtain the historical record, and input the historical record and the user instruction into the large language model to generate the second execution information; when the second execution information does not comply with the preset prompt rule, input the user instruction into the large language model again to generate the third execution information; when the third execution information complies with the preset prompt rule, execute the user instruction according to the third execution information.

[0046] An agent is a system that can autonomously perceive the environment, make decisions and execute actions. It belongs to the field of artificial intelligence research to some extent. Reflection is an important design concept of an agent. This design mode requires the agent to reflect after outputting results and continuously improve itself based on feedback.

[0047] Currently, when an agent reflects with historical records, it can use past inputs, outputs, and environmental states to more fully analyze problems. This helps the agent identify potential patterns, trends, or anomalies, but it cannot determine whether the output anomaly is caused by user input problems, or whether the network is in poor condition or the model's internal analysis is messy, causing the output to not meet expectations.

[0048] The present application provides a reasoning and reflection method for a large language model. Through the preset prompt rules, it is possible to quickly determine whether the execution information generated by the large language model complies with the rules without manual inspection one by one. If the first execution information does not comply with the rules, the historical records are obtained and input into the large language model to generate the second execution information; by introducing the historical records, more contextual information can be provided to the large language model, which helps to generate execution information that is more in line with the user's intentions. When the second execution information does not comply with the preset rules, the user instructions are input again to generate the third execution information; when the third execution information complies with the preset rules, the user instructions are executed according to the third execution information, and the instructions issued by the user can be automatically executed.

[0049] In summary, through the preset rules and multiple attempts mechanism, the execution information that meets the requirements can be generated quickly and accurately, thereby improving the overall processing efficiency. Through multiple attempts and the introduction of historical records and other mechanisms, the results are re-output with and without historical records. If the results that meet the preset rules cannot be output after multiple attempts, it means that there is a network problem or the internal analysis of the model is disordered.

[0050] It should be noted that the execution subject of this embodiment can be a computing service device with network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a device, etc. that can realize the above functions. The following takes the reasoning and reflection device of a large language model as an example to illustrate this embodiment and the following embodiments.

[0051] Based on this, the embodiment of the present application provides a reasoning and reflection method for a large language model, referring to Figure 1 , Figure 1 This is a flowchart of the first embodiment of the reasoning and reflection method of the large language model of the present application.

[0052] In this embodiment, the reasoning and reflection method of the large language model includes steps S100 to S400:

[0053] Step S100, after obtaining the first execution information output by the large language model according to the user instruction, it is determined whether the first execution information complies with the preset prompt rule.

[0054] It should be noted that large language models (LLMs) refer to large neural network models based on deep learning, which are used to process and understand natural language texts. They are able to capture the complexity and diversity of language. Intent information refers to the goals or desired results that users want to achieve.

[0055] Prompt rules refer to text inputs that guide the model to generate specific content or perform specific tasks. Through given prompts, the model can be guided to focus on task-related information and avoid straying from the topic. By properly designing prompt text, the model can be restricted from generating answers that do not meet requirements or are unreasonable.

[0056] In this embodiment, after obtaining the first execution information generated by the large language model according to the user instruction, the AI ​​Agent verifies the first execution information using the preset prompt rule. Specifically, the preset prompt rule is parsed, and the rule stipulates that the execution information must contain specific content and follow a specific structure. And extract key information from the first execution information and compare it with the preset rules. This may include words, phrases, numbers, symbols, etc. in the text, as well as the relationship and structure between them.

[0057] For example, when the input user instruction is "Please send a message to Dr. Li to start a seminar at 11 a.m. tomorrow", the corresponding prompt rule is [message category message recipient: xx message content: XX1]. When verifying whether the rule is met, check whether the extracted message category is a valid category label and is located in the correct position within the square brackets; whether there is a format of "message recipient: XX", and you can also query the database or user list to verify whether "XX" is a valid recipient identifier; and check whether there is a format of "message content: XXX".

[0058] Step S200: If the first execution information does not match, obtain the historical record, and input the historical record and the user instruction into the large language model to generate second execution information.

[0059] In this embodiment, when the first execution information does not meet the preset rules, the historical records related to the user instructions are obtained, and the historical records include previous user instructions, execution results, model outputs, etc. The historical records and user instructions are input into the large language model together. The large language model generates the second execution information according to the input information.

[0060] In one possible implementation, please refer to Figure 2 , step S200 may further include steps S210 to S220:

[0061] Step S210, splicing the historical records and the user instructions in chronological order to obtain a spliced ​​text;

[0062] Step S220: input the concatenated text into the large language model to generate the second execution information.

[0063] In this embodiment, the historical records may include the user's previous instructions, the execution results of these instructions, the model's previous output, and any contextual information related to the user's instructions. First, determine the scope of the historical records required, retrieve the relevant historical records from the database based on the determined scope, and preprocess the historical records, such as cleaning the data, removing irrelevant information, formatting the data, etc., to ensure that they are compatible with the user's instructions and easy for the model to process. Integrate the preprocessed historical records with the user's instructions, concatenate multiple records into a string, or organize them into a structured data format (such as a JSON object) to form a complete input information. The integrated input information is input into the large language model. After receiving the input information, the large language model understands the user's intentions, identifies key information, applies logical reasoning, etc., and generates the second execution information. Compared with the first execution information, the second execution information can better reflect the user's intentions and system requirements.

[0064] Optionally, when selecting historical records, intelligent filtering can be performed based on the context and relevance of user instructions. First, the goal of filtering historical records needs to be clarified, that is, to find the records that are most relevant to user instructions and most helpful in generating rule-compliant execution information. Secondly, parse the instruction content, parse the user instructions, and extract key information, such as the type of instruction (query, modify, delete, etc.), the object of operation (data, file, setting, etc.), and specific operation requirements (such as time range, sorting method, etc.). Then, match the keywords in the historical records with the keywords in the user instructions to find records related to the instruction content. Analyze the contextual relevance between historical records and user instructions, such as temporal continuity, similarity of operation objects, and coherence of operation logic. According to the keyword matching degree and contextual relevance, a weight value is calculated for each historical record. The higher the weight value, the greater the relevance of the record to the user instruction. A filtering threshold is set according to the weight value, and only records with a weight value exceeding the threshold will be selected. Sort the filtered records according to the weight value, and give priority to records with high weight values. Finally, the filtered historical records and user instructions are input into the large language model together to generate execution information. Through the above steps, the goal of intelligently filtering historical records based on the context and relevance of user instructions can be achieved, thereby increasing the possibility of generating rule-compliant execution information.

[0065] Step S300: When the second execution information does not conform to the preset prompt rule, the user instruction is input into the large language model again to generate third execution information.

[0066] Step S400: When the third execution information meets the preset prompt rule, execute the user instruction according to the third execution information.

[0067] In this embodiment, the preset prompt rule is used again to verify the second execution information. If the second execution information still does not meet the preset rule, reflection is performed without the historical record, the user instruction is re-entered and the third execution information is generated. The preset prompt rule is used to verify the third execution information. If the third execution information meets the preset rule, the user instruction is executed according to the execution information.

[0068] In this embodiment, through the preset prompt rules, it is possible to quickly determine whether the execution information generated by the large language model complies with the rules without manual inspection one by one. If the first execution information does not comply with the rules, the historical records are obtained and input into the large language model to generate the second execution information; by introducing the historical records, more contextual information can be provided to the large language model, which helps to generate execution information that is more in line with the user's intentions. When the second execution information does not comply with the preset rules, the user instruction is input again to generate the third execution information; when the third execution information complies with the preset rules, the user instruction is executed according to the third execution information, and the instructions issued by the user can be automatically executed.

[0069] In summary, through the preset rules and multiple attempts mechanism, the execution information that meets the requirements can be generated quickly and accurately, thereby improving the overall processing efficiency. Through multiple attempts and the introduction of historical records and other mechanisms, the results are re-output with and without historical records. If the results that meet the preset rules cannot be output after multiple attempts, there is a network problem or the model's internal analysis is disordered.

[0070] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3 , before step S100, steps S01 to S02 are also included:

[0071] Step S01, after obtaining the user instruction, input the user instruction and the preset prompt rule into the large language model;

[0072] In this embodiment, the user input instructions are received through the user interface (such as an input box, a speech recognition module, etc.), and the user instructions are preprocessed, such as removing irrelevant characters and performing grammar checks, to ensure the accuracy and completeness of the instructions. When the instructions input by the user are voice, the captured voice signal is converted into text form using speech recognition technology. The prompt rules are predefined to define how to parse the user instructions and the format of the execution information output by the large language model. The preprocessed user instructions and the preset prompt rules are passed to the large language model as input. The large language model performs parsing and reasoning based on the input information, combined with its internally trained knowledge and algorithms.

[0073] Step S02: parsing the user instruction according to the large language model, and generating the first execution information according to the preset prompt rule.

[0074] In this embodiment, the large language model parses the user's instructions and identifies the keywords, parameters and other information in the instructions. According to the preset prompt rules, the model generates corresponding execution information, such as message category, message recipient, message content, etc. Through the preset prompt rules, the user's instructions can be understood and parsed more quickly, reducing the user's waiting time.

[0075] Specifically, in the step of parsing the user instructions according to the large language model, the user instructions and the preset prompt rules are passed as input to the large language model. The large language model first performs word segmentation and part-of-speech tagging on the user instructions to identify the keywords in the instructions. The keywords are words related to the instruction format defined in the preset prompt rules. After identifying the keywords, the model will further analyze the user instructions to extract parameters related to the operation. These parameters may include numerical values, dates, user IDs, message content, etc. Based on the keywords and parameters in the user instructions, the type of instruction can be determined, such as query instructions, modification instructions, or other types of instructions. Based on the determined instruction type and the extracted parameters, they are matched with the preset prompt rules. Based on the matching results, the first execution information is generated.

[0076] In this embodiment, the preset pormpt rules include the following:

[0077] (1) When sending a WeChat message, the user is prompted to enter the message recipient and the message content (note that the person must be converted), and the output is [message category message recipient: xx message content: XX1];

[0078] (2) When making a WeChat call, the user is prompted to enter the call recipient and call type and the output is [Call category Call recipient: XX Call type: Voice / Video];

[0079] (3) When searching for chat records in WeChat, the user is prompted to enter the search content and output [record category search content: xx]; "+

[0080] (4) When searching for a mini-program on WeChat, prompt the user to enter the name of the WeChat mini-program (note that the user is prompted to enter) and output [Mini-program category program name: Xx];

[0081] (5) When opening an app, the user is prompted to enter the app name and output [App Category App Name: Didi / WeChat / Payment Code / Receipt Code / QR Code / Friends Circle / Tongcheng];

[0082] (6) When sending a WeChat red envelope, prompt the user to enter the red envelope recipient and remind the user to enter the red envelope amount and output [red envelope category red envelope recipient: xx / amount xx (Arabic numerals)];

[0083] (7) If the current location is sent, the user is prompted to enter the location recipient and output [location category location recipient: XX];

[0084] (8) When sending a business card, the user is prompted to enter the business card recipient and output [Business Card Category Business Card Recipient: Xx];

[0085] (9) In other cases, directly output [Other Category Description].

[0086] In one possible implementation, please refer to Figure 4 , step S02 may further include steps D100 to D300:

[0087] Step D100, parsing the user instruction according to the large language model, and determining the instruction category of the user instruction according to the parsing result;

[0088] Step D200, determining a target prompt rule matching the user instruction from the preset prompt rules according to the instruction category;

[0089] Step D300: Generate the first execution information according to the target prompt rule.

[0090] In this embodiment, the large language model receives the user instruction input by the user and parses it. The parsing process may include natural language processing (NLP) technologies such as word segmentation, part-of-speech tagging, and syntactic analysis. The model determines the user intention and the category of the instruction by analyzing the syntax and semantics of the instruction. The instruction category is determined based on the preset prompt rules, and each category represents a class of similar user intentions and operations. After the category of the user instruction is determined, a matching target prompt rule is selected from the preset prompt rules according to this category. After the target prompt rule is determined, the first execution information is generated according to this rule. In the process of generating the first execution information, the target prompt rule is a string containing placeholders. After all necessary parameters are parsed from the user instruction, the placeholders are replaced with the actual parameter values ​​extracted from the user instruction.

[0091] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 5 The reasoning and reflection method of the large language model may further include steps A100 to A200:

[0092] Step S100, after obtaining first execution information output by the large language model according to the user instruction, determining whether the first execution information complies with a preset prompt rule;

[0093] Step A100: If the first execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

[0094] In this embodiment, after obtaining the first execution information, the system needs to verify the information to ensure that it complies with the preset prompt rules. These rules may include the format of the information, content requirements, the appearance of keywords, etc. If the first execution information passes the verification, that is, it complies with the preset prompt rules, the user instruction input by the user is executed according to the first execution information. The execution information is converted into a specific operation instruction, and then the corresponding function module or interface is called to complete the task.

[0095] In this embodiment, the execution information is converted into specific operation instructions, and the corresponding functional modules or interfaces are called to complete the task. Specifically, the first execution information is first parsed to extract key information in the execution information, such as operation type, operation object, operation parameters, etc. After the parsing is completed, the parsing results are verified to check the integrity and consistency of the data and whether it conforms to the expected format and range to ensure that the extracted information is accurate. According to the parsing results, the operation type is mapped to a specific operation instruction, and the operation type is converted into a specific function call, command execution or API call. According to the operation instruction, the functional module or interface to be called is determined. After the call is completed, the returned execution result simulates the user operation, automatically completes the user instruction, and displays the result on the user interface.

[0096] Step A200: store the user instruction and the first execution information, and update the history record.

[0097] In this embodiment, the user instruction and the first execution information are stored, the historical record is updated, a new record is added to the database, an existing record is updated, or a log file is maintained to record the interaction information.

[0098] Based on the first embodiment of the present application, in the fourth embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be described in detail later. Figure 6 In a feasible implementation manner, the reasoning and reflection method of the large language model may further include steps S100 to B100:

[0099] Step S100, after obtaining first execution information output by the large language model according to the user instruction, determining whether the first execution information complies with a preset prompt rule;

[0100] Step S200, if the first execution information does not match, obtaining a historical record, and inputting the historical record and the user instruction into the large language model to generate second execution information;

[0101] Step B100: If the second execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

[0102] In this embodiment, the user instruction is input into the large language model, and the model generates the first execution information according to the instruction. It is determined whether the first execution information meets the preset prompt rules: if the first execution information meets these rules, the first execution information can be directly executed; if not, the previous historical records are obtained, and the historical records and the user instructions are input into the large language model again to generate the second execution information, and it is determined whether the second execution information meets the preset rules, and the same rule check is performed on the second execution information. If the second execution information meets the preset rules, the user instruction is executed according to the second execution information.

[0103] Optionally, if the second execution information still does not conform to the preset prompt rule, the training data or model structure of the large language model can be adjusted to improve its ability to generate rule-compliant execution information. Specifically, first, collect all execution information samples that do not conform to the preset rules, analyze the collected samples in detail, and determine the types of errors (such as format errors, content errors, logical errors, etc.) and frequencies. Based on error analysis, identify key factors that may cause these errors, such as insufficient training data, defects in the model structure, or improper hyperparameter settings during training. Secondly, increase or adjust the training data set for insufficient or biased data found in the analysis. Ensure the diversity and representativeness of the data set to cover more possible user instructions and scenarios. Optionally, the labels of the training data can also be refined to more accurately reflect the preset rules. Alternatively, adjust the architecture of the model according to the error type and influencing factors. For example, increase the number of network layers, change the activation function, introduce an attention mechanism, etc. to improve the expressiveness and generalization ability of the model. Introduce regularization techniques (such as L1, L2 regularization) or constraints during model training to limit the complexity of the model, prevent overfitting, and promote the model to generate more rule-compliant execution information. Carefully tune the model's hyperparameters (such as learning rate, batch size, number of iterations, etc.) to find the best configuration and improve the performance of the model.

[0104] Optionally, the training strategy can be dynamically adjusted based on the training progress and performance feedback of the model. For example, the method of gradually reducing the learning rate and introducing an early stopping mechanism can be used to optimize the training process. A multi-stage training strategy is adopted, first using simple tasks or data sets for pre-training, and then gradually transitioning to more complex tasks and data sets to improve the adaptability and generalization ability of the model. During the training process, the model is regularly evaluated using a validation set to monitor changes in the model's performance. If the performance is found to have degraded or is no longer improving, the training strategy or model structure is adjusted in a timely manner. By adjusting the training data or model structure of the large language model, the large language model can be systematically optimized so that it can more accurately generate execution information that conforms to the preset rules.

[0105] Based on the first embodiment of the present application, in the fifth embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be described in detail later. Figure 7 The reasoning and reflection method of the large language model may include steps S100 to C100:

[0106] Step S100, after obtaining first execution information output by the large language model according to the user instruction, determining whether the first execution information complies with a preset prompt rule;

[0107] Step S200, if the first execution information does not match, obtaining a historical record, and inputting the historical record and the user instruction into the large language model to generate second execution information;

[0108] Step S300, when the second execution information does not conform to the preset prompt rule, the user instruction is input into the preset large language model again to generate third execution information;

[0109] Step C100: if the third execution information does not conform to the preset prompt rule, an error prompt is generated according to the preset prompt rule.

[0110] In this embodiment, after the user instruction is input into the large language model, the large language model generates the first execution information according to the user instruction. If the first execution information meets the preset rules, the user instruction is executed according to the second execution information; if the first execution information does not meet the preset rules, the historical records related to the user instruction are obtained, and the historical records and the user instructions are input into the large language model together to generate the second execution information. It is determined whether the second execution information meets the preset rules. If the second execution information meets the preset rules, the user instruction is executed according to the second execution information; if the second execution information still does not meet the preset rules, the user instruction is input into the large language model again, and the historical records are no longer included at this time. After the third execution information is generated, the third execution information is checked for rules. If the third execution information meets the preset rules, the user instruction is executed according to the second execution information. If the third execution information still does not meet the preset rules, an error prompt is generated according to the target output rule. The error prompt should clearly inform the user of the problem, and may provide solution suggestions or guide the user to the next step.

[0111] In this embodiment, by comparing the output results with and without historical records, the agent can more easily identify network problems or confusion in the internal analysis of the model. If the output results of both methods deviate significantly from expectations, it indicates that there are problems such as confusion in the internal analysis of the model. In this case, the agent exits the current task or state and reinitializes or calibrates to ensure that future outputs are more accurate and reliable.

[0112] The present application provides a reasoning and reflection device for a large language model, which includes: 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 so that the at least one processor can execute the reasoning and reflection method for the large language model in the above-mentioned embodiment one.

[0113] Reference below Figure 8 , which shows a schematic diagram of the structure of a large language model reasoning and reflection device suitable for implementing the embodiment of the present application. The large language model reasoning and reflection device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8The reasoning and reflection device of the large language model shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0114] like Figure 8 As shown, the reasoning and reflection device of the large language model may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the reasoning and reflection device of the large language model are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 can allow the reasoning and reflection device of the large language model to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a reasoning and reflection device of a large language model with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.

[0115] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0116] The inference reflection device of the large language model provided by the present application adopts the inference reflection method of the large language model in the above-mentioned embodiment, which can solve the technical problem of how to improve the accuracy of the content output by the large language model through the reflection mechanism. Compared with the prior art, the beneficial effects of the inference reflection device of the large language model provided by the present application are the same as the beneficial effects of the inference reflection method of the large language model provided by the above-mentioned embodiment, and the other technical features in the inference reflection device of the large language model are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0117] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0118] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0119] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, the computer-readable program instructions being used to execute the reasoning and reflection method of the large language model in the above-mentioned embodiment.

[0120] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0121] The computer-readable storage medium may be included in the reasoning and reflection device of the large language model; or may exist independently without being assembled into the reasoning and reflection device of the large language model.

[0122] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the reasoning and reflection device of the large language model, the reasoning and reflection device of the large language model: after obtaining the first execution information output by the large language model according to the user instruction, judge whether the first execution information complies with the preset prompt rule; if the first execution information does not comply, obtain the historical record, and input the historical record and the user instruction into the large language model to generate second execution information; when the second execution information does not comply with the preset prompt rule, input the user instruction into the large language model again to generate third execution information; when the third execution information complies with the preset prompt rule, execute the user instruction according to the third execution information.

[0123] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0124] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0125] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0126] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned reasoning and reflection method of the large language model, and can solve the technical problem of how to improve the accuracy of the content output by the large language model through the reflection mechanism. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the reasoning and reflection method of the large language model provided in the above-mentioned embodiment, and will not be repeated here.

[0127] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A method for reasoning and reflection of a large language model, characterized in that: The method includes: After obtaining the first execution information output by the large language model according to the user instruction, determining whether the first execution information complies with a preset prompt rule; If the first execution information does not match, obtaining a historical record, and inputting the historical record and the user instruction into the large language model to generate second execution information; When the second execution information does not conform to the preset prompt rule, the user instruction is input into the large language model again to generate third execution information; When the third execution information meets the preset prompt rule, the user instruction is executed according to the third execution information.

2. The method according to claim 1, characterized in that After obtaining the first execution information output by the large language model according to the user instruction, before the step of determining whether the first execution information conforms to the preset prompt rule, the step includes: After obtaining the user instruction, inputting the user instruction and the preset prompt rule into the large language model; The user instruction is parsed according to the large language model, and the first execution information is generated according to the preset prompt rule.

3. The method according to claim 2, characterized in that The step of parsing the user instruction according to the large language model and generating the first execution information according to the preset prompt rule includes: Parsing the user instruction according to the large language model, and determining the instruction category of the user instruction according to the parsing result; Determining, according to the instruction category, a target prompt rule matching the user instruction from the preset prompt rules; The first execution information is generated according to the target prompt rule.

4. The method according to claim 1, characterized in that After obtaining the first execution information output by the large language model according to the user instruction, the step of determining whether the first execution information conforms to the preset prompt rule includes: If the first execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

5. The method according to claim 4, characterized in that After the step of executing the user instruction according to the first execution information if the first execution information meets the preset prompt rule, the method further includes: The user instruction and the first execution information are stored, and the history record is updated.

6. The method according to claim 1, characterized in that The step of inputting the historical record and the user instruction into the large language model to generate the second execution information comprises: splicing the historical records and the user instructions in chronological order to obtain a spliced ​​text; The concatenated text is input into the large language model to generate the second execution information.

7. The method according to claim 1, characterized in that After the step of obtaining historical records if the first execution information does not match, and inputting the historical records and the user instructions into the large language model to generate the second execution information, the following steps are included: If the second execution information meets the preset prompt rule, the user instruction is executed according to the first execution information.

8. The method according to claim 1, characterized in that After the step of executing the user instruction according to the third execution information when the third execution information meets the preset prompt rule, the method further comprises: If the third execution information does not conform to the preset prompt rule, an error prompt is generated according to the preset prompt rule.

9. A reasoning and reflection device for a large language model, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the reasoning and reflection method for a large language model as described in any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the reasoning and reflection method of the large language model as described in any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Communication method and device and storage medium

    CN120321335A