Automatic thinking chain construction method and device, equipment and storage medium
Through the method of automatically constructing thinking chains, including language amplification, named entity extraction, answer review and model fine-tuning, the interference and hallucination problems in large-model logical reasoning are solved, and the accuracy of thinking chains and the credibility of large-models are improved.
Patent Information
- Application Number
- CN202411710074.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-02-28
AI Technical Summary
In the prior art, large models are prone to interference and hallucination problems in the logical reasoning process, and artificially constructing thinking chains is complex and time-consuming. Automatically constructing thinking chains is difficult to cover all reasoning knowledge and may cause error accumulation.
By obtaining the input text, language expansion is used to generate paragraphs, extracting named entities to generate questions and answer them, reviewing answers according to the review rules, fine-tuning the model until the answer is reviewed, and building a thinking chain based on the relationship between the question and answer.
It improves the accuracy of thinking chains and the accuracy and credibility of big model reasoning, avoids the hallucination problems in implicit reasoning, and reduces the cost and time of manually constructing thinking chains.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for automatically constructing a thought chain. Background Art
[0002] A large model, or large language model, is a language model that is widely used in the field of artificial intelligence. Its main feature is that it has an extremely large number of parameters, so it is called a large model. The large language model is trained with a large amount of data so that it can understand and generate natural language text. Its application range is very wide, including but not limited to automatic translation, text generation, dialogue systems, information retrieval, etc. Due to its large number of parameters and complex structure, the large language model can capture complex patterns and semantic relationships in language, and thus perform well in a variety of tasks.
[0003] In the existing technology, there are two main types of large model logical reasoning technology. One is to use the internal knowledge of the large model for implicit reasoning, and the second is to perform explicit reasoning by automatically or manually constructing a chain of thought. Implicit reasoning only uses the knowledge of the large model itself. Chain of Thought (CoT) is a technology that can inspire the large model to answer difficult questions through "thinking". It refers to the process of breaking down logically complex problems and forming a complete thinking process through a series of logically related thinking. It aims to show a small number of examples to the large language model and explain the reasoning process through these examples, so that the large language model can learn to show the reasoning process when generating answers and guide it to get more accurate answers.
[0004] However, implicit reasoning usually causes certain interference in different tasks, and is prone to hallucination problems when there are insufficient instructions; hallucination problems refer to the phenomenon that the content provided by the large language model when generating content is inconsistent with real-world facts or user input. As for explicit reasoning, taking the thought chain as an example, the construction of the thought chain itself is complex, and manual construction requires a lot of manpower and material resources; there are solutions in the prior art that propose models to automatically construct thought chains, but for automatic model construction, due to the limitations of large models, it is difficult to cover all the reasoning knowledge to build the thought chain, and if the thought chain reasoning is too long, it may also cause error accumulation. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a method, device, equipment and storage medium for automatically constructing a thought chain, which can improve the accuracy of the thought chain and improve the accuracy and credibility of large model reasoning. The specific scheme is as follows: In a first aspect, the present application discloses a method for automatically constructing a thought chain, comprising: Obtaining input text, and generating paragraphs corresponding to the input text through language expansion; Generate relevant questions for the named entities in the paragraph, and generate answers corresponding to the questions; The answers are reviewed according to the review rules to select unreviewed answers, the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; Based on the association between all the questions and all the approved answers, a thought chain corresponding to the input text is obtained.
[0006] Optionally, obtaining an input text, generating a paragraph corresponding to the input text by language expansion, generating relevant questions for named entities in the paragraph, and generating answers corresponding to the questions, including: Extract keywords from the input text to obtain keywords corresponding to the input text; Performing language expansion on the input text based on the keyword to obtain a paragraph corresponding to the input text; Extracting all named entities from the paragraph by using a named entity recognition method; A question for each of the named entities is generated in combination with the content of the paragraph, and an answer corresponding to the question is generated.
[0007] Optionally, the steps of reviewing the answers according to the review rules to select unreviewed answers, fine-tuning the large model according to the unreviewed answers, and regenerating new answers for the unreviewed answers until the new answers pass the review include: Reviewing the answers according to review rules to screen out unreviewed answers; the review rules include logical review and factual review; According to the unreviewed answers, fine-tuning the large model through an instruction fine-tuning method; For the target question corresponding to the unreviewed answer, the answer to the target question is regenerated using the fine-tuned model as the new answer until the answer generated for the target question passes review.
[0008] Optionally, obtaining a thought chain corresponding to the input text based on the association relationship between all the questions and all the reviewed answers includes: Determining whether the thought chain reaches a target length; the target length is determined according to the complexity of the input text and / or the type of field involved in the input text; If the target length is not reached, generating questions and answers based on the named entities in the reviewed answers, so as to expand the thought chain according to the newly generated questions and answers until the thought chain reaches the target length; Based on the association between all the questions and all the approved answers, a thought chain corresponding to the input text is obtained.
[0009] Optionally, the training process of the large model includes: Determine the weight of each text according to a weight determination rule; the weight determination rule is a rule based on text length and / or text importance; Based on the weight corresponding to each of the texts and the loss corresponding to each of the texts, a loss function of the large model is obtained by weighted summation; The large model is trained using the loss function.
[0010] Optionally, the training process of the large model includes: Obtaining a training set; the training set is a training set that has passed diversity screening, accuracy screening, and representative screening; Merging the texts in the training set according to the maximum text packing length, and when the maximum text packing length is not reached after merging and the remaining space is insufficient to merge a complete text, padding with spaces, so as to divide the training set into a plurality of task blocks of the same size; the task blocks contain one or more complete texts; Training large models is accomplished by distributing the task blocks to graphics processors.
[0011] Optionally, merging the texts in the training set according to the maximum text packing length includes: Sorting the texts in the training set according to the text length; Based on the sorting, the texts in the training set are merged according to the maximum text packing length, so that the lengths of different texts in the obtained single task block are similar.
[0012] In a second aspect, the present application discloses a device for automatically constructing a thought chain, comprising: An input text acquisition module, used to acquire input text and generate paragraphs corresponding to the input text by language expansion; A question and answer generation module, used to generate relevant questions for the named entities in the paragraph and generate answers corresponding to the questions; An audit module is used to audit the answers according to the audit rules to select unapproved answers, fine-tune the large model according to the unapproved answers, and regenerate new answers for the unapproved answers until the new answers pass the audit; The thought chain building module is used to obtain the thought chain corresponding to the input text based on the association relationship between all the questions and all the reviewed answers.
[0013] In a third aspect, the present application discloses an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute the computer program to implement the aforementioned method for automatically constructing a thought chain.
[0014] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned method for automatically constructing a thought chain.
[0015] In this application, an input text is obtained, and a paragraph corresponding to the input text is generated through language expansion; relevant questions are generated for the named entities in the paragraph, and answers corresponding to the questions are generated; the answers are reviewed according to the review rules to screen out unreviewed answers, and the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; based on the association between all the questions and all the reviewed answers, a thought chain corresponding to the input text is obtained. It can be seen that the large model is expanded by language expansion technology according to the input text to obtain the corresponding paragraph, and the large model automatically generates questions and answers according to the named entities in the paragraph, and then the answers are reviewed, and errors are corrected according to the unreviewed answers to correct the large model; thus, the thought chain is automatically generated by using the large model, and the generated thought chain is corrected to improve the accuracy of the thought chain, ensure the correctness of the model's explicit reasoning, avoid hallucination problems in implicit reasoning, and improve the accuracy and credibility of the large model's reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0017] Figure 1 A flow chart of a method for automatically constructing a thought chain provided for this application; Figure 2 A specific flowchart of the automatic construction method of thought chain provided for this application; Figure 3 A specific large model training method flow chart provided for this application; Figure 4 A schematic diagram of the structure of a device for automatically building a thought chain provided in this application; Figure 5 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] In the prior art, there are two main types of large model logical reasoning technology. One is to use the internal knowledge of the large model for implicit reasoning, and the second is to perform explicit reasoning by automatically or manually constructing a chain of thoughts. However, implicit reasoning usually causes certain interference in different tasks, and is prone to hallucination problems under the condition of insufficient instructions. This is because in multi-round dialogue generation, the large model itself is an end-to-end generation solution, and the input text has a length limit, which leads to the generation of large models when there are many dialogue rounds or the context length exceeds the limit of the large model itself. The generation of the large model often has low accuracy or hallucinations. The hallucination problem refers to the phenomenon that the content provided by the large language model is inconsistent with the facts of the real world or the user input when generating content. For explicit reasoning, taking the chain of thoughts as an example, the construction of the chain of thoughts itself is complex, and manual construction requires a lot of manpower and material resources; there are solutions in the prior art that propose models to automatically construct the chain of thoughts, but for the automatic construction of the model, due to the limitations of the large model, it is difficult to cover all the reasoning knowledge to be constructed in the chain of thoughts, and if the reasoning of the chain of thoughts is too long, it may also cause error accumulation. In order to overcome the above technical problems, this application proposes a method for automatically constructing a thought chain, which can improve the accuracy of the thought chain and improve the accuracy and credibility of large model reasoning.
[0020] The present application embodiment discloses a method for automatically constructing a thought chain, see Figure 1 As shown, the method may include the following steps: Step S11: obtaining input text, and generating paragraphs corresponding to the input text by language expansion.
[0021] First, the text input by the user is obtained. The text can be a question or a text of other sentence patterns. After obtaining the text, the input text is first expanded into a paragraph using language expansion technology, that is, the input text is enriched.
[0022] In some embodiments, the above-mentioned acquisition of input text and generation of paragraphs corresponding to the input text through language expansion include: extracting keywords from the input text to obtain keywords corresponding to the input text; and performing language expansion on the input text based on the keywords to obtain paragraphs corresponding to the input text. It can be understood that for the input text, the large model first extracts the core keywords in the text as the main points of the input text, so as to grasp the key content of the conversation and lay the foundation for subsequent language expansion; after obtaining the core keywords, the large model will perform language expansion on them and expand them into a complete article paragraph. The purpose of this is to provide richer contextual information to assist the model in better understanding and generating content. In this way, the length of the thought chain can be gradually extended.
[0023] Step S12: Generate relevant questions for the named entities in the paragraph, and generate answers corresponding to the questions.
[0024] In this embodiment, after the language expansion generates a paragraph, questions about the command entity are generated for the named entity in the paragraph, and answers are automatically given, that is, answers are generated. The generated questions and answers further expand the relevant information for the input text and enrich the thinking chain. Named entities are names of people, institutions, places, specific terms, and all other entities identified by names. More extensive entities also include numbers, dates, currencies, addresses, and so on.
[0025] The above-mentioned generation of relevant questions for the named entities in the paragraph and generation of answers corresponding to the questions include: extracting all named entities from the paragraph through a named entity recognition method; generating questions for each of the named entities in combination with the content of the paragraph, and generating answers corresponding to the questions. Specifically, the large model will combine the content of the paragraph, ask relevant questions for each extracted named entity, and automatically generate answers to the questions. That is, in the expanded paragraph, the named entity recognition (NER) technology is used to extract all the entities contained in the paragraph text, so as to further enrich and improve the knowledge base, provide more valuable information for subsequent analysis and generation, and provide generation nodes for the next step of thinking chain generation.
[0026] Step S13: review the answers according to the review rules to filter out unreviewed answers, fine-tune the large model based on the unreviewed answers, and regenerate new answers for the unreviewed answers until the new answers pass the review.
[0027] In this embodiment, after the large model generates the answer, it will further review the answer to determine whether the generated answer is unreasonable. If so, the model will automatically correct itself.
[0028] The above-mentioned process of reviewing the answers according to the review rules to screen out answers that have not passed the review, fine-tuning the large model according to the answers that have not passed the review, and regenerating new answers for the answers that have not passed the review until the new answers pass the review specifically includes: reviewing the answers according to the review rules to screen out answers that have not passed the review; the review rules include logical review and factual review; according to the answers that have not passed the review, fine-tuning the large model through the instruction fine-tuning method; for the target question corresponding to the answer that has not passed the review, using the fine-tuned model to regenerate the answer to the target question as the new answer, until the answer generated for the target question passes the review.
[0029] It is understandable that in order to ensure the safety, compliance, harmlessness and ethics of the thinking chain, the answers are reviewed according to the review rules, which include but are not limited to logical review and factual review, that is, the generated answers need to be logical and consistent with the facts. When the answer fails to pass the review, it means that the model is not completely accurate, so the instruction fine-tuning method is used to review the large model, delete the unreviewed answers, and regenerate the answers. If the new answer still fails to pass the review, the model will continue to be fine-tuned until the answer passes the review to ensure the safety and compliance of the thinking chain.
[0030] Step S14: Based on the association relationship between all the questions and all the approved answers, the thought chain corresponding to the input text is obtained.
[0031] According to all the questions generated by the big model for the input text and the corresponding approved answers to each question, as well as the correlation between questions and answers, the thought chain corresponding to the input text is obtained; that is, all the generated questions and answers are connected to form a coherent thought chain; the obtained thought chain not only contains the core content of the conversation, but also includes a large amount of relevant background information and explanations. The thought chain is automatically generated by the big model, and the big model conducts multiple text reviews and error correction feedback during the generation process; therefore, the thought chain has relatively high stability and reliability, and enables the model to better deal with the problem of too long context information when processing multi-round conversations, ensuring that the generated content is more accurate and coherent, effectively improving the performance of the big model in multi-round conversation generation, and reducing the occurrence of hallucinations.
[0032] Thinking chain is a process of breaking down complex problems into a series of logical steps. In the past, thinking chains were usually constructed manually, which was inefficient and had poor transferability. In this application, in the process of automatically generating thinking chains, the big model not only processes information, but also has intelligent filtering and review functions; after the initial generation of the thinking chain, the model will carefully check each step to ensure the logic and correctness of each link; at the same time, the model also has automatic error correction capabilities. If logical errors or unreasonableness are found during the review process, the model will automatically correct them, while ensuring the security of the thinking chain; thus, it can ensure that the generated thinking chain is scientific and rigorous, providing a reliable basis for subsequent decision-making and execution.
[0033] For example Figure 2 As shown, in some embodiments, the thinking chain corresponding to the input text is obtained based on the association relationship between all the questions and all the reviewed answers, which may include: judging whether the thinking chain reaches the target length; the target length is determined according to the complexity of the input text and / or the type of field involved in the input text; if the target length is not reached, question generation and answer generation are performed based on the named entities in the reviewed answers, so as to expand the thinking chain according to the newly generated questions and answers until the thinking chain reaches the target length; based on the association relationship between all the questions and all the reviewed answers, the thinking chain corresponding to the input text is obtained.
[0034] It is understandable that the length of the thought chain may vary in different application scenarios. Some problems require detailed analysis and multi-step solutions, while some problems can be solved in just a few simple steps. This application enables the large language model to have flexible control capabilities by setting the target length, and can adjust the length of the thought chain according to specific needs; if the problem is complex and requires detailed analysis, the model will generate a longer thought chain that covers all necessary steps and details; for simpler problems, the model will generate a short and concise thought chain, thereby improving processing efficiency; through this flexible control, the model can better adapt to different types of problems and application scenarios. The termination condition is determined based on the required length of the thought chain and the richness of information collection. The richness of information collection is related to the field, and the richness of information collection required for different knowledge fields is different. Therefore, the paragraph expansion is performed again for the answer entity generated in the previous step, and steps S12-S14 are repeated to continuously enrich and expand the thought chain, and gradually build a complete thought chain. As can be seen from the above, in this embodiment, the input text is obtained, and the paragraph corresponding to the input text is generated through language expansion; relevant questions are generated for the named entities in the paragraph, and answers corresponding to the questions are generated; the answers are reviewed according to the review rules to screen out the unreviewed answers, and the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; based on the association between all the questions and all the reviewed answers, the thought chain corresponding to the input text is obtained. It can be seen that the large model is expanded by language expansion technology according to the input text to obtain the corresponding paragraph, and the large model automatically generates questions and answers according to the named entities in the paragraph, and then the answers are reviewed, and errors are corrected according to the unreviewed answers to correct the large model; thus, the thought chain is automatically generated by using the large model, and the generated thought chain is corrected to improve the accuracy of the thought chain, ensure the correctness of the model's explicit reasoning, avoid the illusion problem in implicit reasoning, and improve the accuracy and credibility of the large model reasoning.
[0035] Based on the above embodiments, this application embodiment discloses a specific large model training method, see Figure 3 As shown, the method may include the following steps: Step S21: Obtain a training set; the training set is a training set that has passed diversity screening, accuracy screening, and representativeness screening.
[0036] For example, we first collected a dataset of 30,000 long text instructions with a length of more than 64k. These data come from 9 different data sources, including but not limited to general common sense, financial common sense, Baidu Encyclopedia, etc., covering a wide range of knowledge fields. The task types of this dataset are very rich, involving question answering, summary generation, text translation, sentiment analysis, content classification, knowledge graph construction, information extraction, and text cloze. Each instruction in the dataset has been strictly screened and verified to ensure its accuracy and comprehensiveness, so as to provide high-quality training data for various natural language processing tasks.
[0037] In addition, multi-level quality control measures are adopted to ensure the diversity and representativeness of the data, so that the model can perform well in various application scenarios. Specific data set screening strategies include diversity screening, accuracy screening, and representative screening; specifically, the cosine similarity algorithm can be used to ensure the diversity of samples from different data sources; the combination of manual review and automated detection can be used to ensure the accuracy of the data; and the cluster analysis algorithm can be used to ensure the representativeness of data samples in various fields.
[0038] Step S22: Merge the texts in the training set according to the maximum text packing length. When the maximum text packing length is not reached after merging and the remaining space is insufficient to merge a complete text, fill with spaces so as to divide the training set into multiple task blocks of the same size; the task blocks contain one or more complete texts.
[0039] That is, by packing texts of different lengths to the maximum length and then distributing them to the graphics processing unit (GPU) for calculation, the idle time between graphics processing units can be effectively reduced. Specifically, by merging multiple texts of different lengths, if the maximum text packing length is not reached after merging and the remaining space is insufficient to merge a complete text, spaces are used to fill the text to the maximum text packing length, thereby ensuring that the task block size processed by each graphics processor is consistent. This avoids the need for the graphics processor to process multiple short texts multiple times, avoids the waste of resources when the graphics processor processes shorter texts, and maximizes the utilization of graphics processor resources.
[0040] Furthermore, the present embodiment also proposes a grouping, sorting and packaging strategy. That is, the above-mentioned merging of the texts in the training set according to the maximum text packaging length may include: sorting the texts in the training set according to the text length; based on the sorting, merging the texts in the training set according to the maximum text packaging length, so that the lengths of different texts in the obtained single task block are similar. It can be understood that by sorting the texts by length and then training them in batches, the idle time within the same batch can be further reduced. Specifically, all the texts to be processed are first sorted according to their length from short to long or from long to short, and then the texts of similar length are divided into the same batch, and multiple graphics processors are used for parallel calculation; it can ensure that the text lengths within the same batch are as consistent as possible, so that the calculation time of the graphics processor is similar, thereby further improving the calculation efficiency.
[0041] In this application, by introducing a grouping, sorting and packaging strategy, the architecture of the large model is optimized when processing complex tasks; by packaging texts of different lengths to the maximum length and distributing them to the GPU for calculation, the idle time between GPUs is reduced; it not only effectively improves the computing efficiency, but also enhances the accuracy of the model when processing complex tasks.
[0042] Traditional large models often consume a lot of computing resources and time when performing multi-step reasoning tasks, and are prone to errors. However, the system proposed in this patent significantly improves the efficiency and accuracy of large model architecture in multi-step reasoning tasks. This improvement enables the model to complete complex tasks more quickly, while reducing the waste of computing resources and lowering the error rate.
[0043] Specifically, the grouping, sorting and packing strategy first groups and sorts the input data according to the length of the text, then packs these groups to a maximum length close to the GPU processing capability, and finally distributes the packed data to each GPU for parallel computing. This processing method avoids the waste of computing resources caused by inconsistent data length in traditional methods, improves the utilization rate of GPUs, significantly improves the efficiency and accuracy of large models in complex task processing, and provides a more optimized solution for large-scale artificial intelligence applications.
[0044] Step S23: training the large model by assigning the task blocks to the graphics processor.
[0045] Finally, the large model is trained using a graphics processor based on the task blocks. The training process of the large model may specifically include: determining the weight of each text according to a weight determination rule; the weight determination rule is a rule based on text length and / or text importance; based on the weight corresponding to each text and the loss corresponding to each text, a loss function of the large model is obtained by weighted summation; and the large model is trained using the loss function.
[0046] That is, when calculating the final loss function, the loss of each text is weighted. Specifically, when calculating the loss, each text can be assigned different weights according to its length or importance, and then these weighted losses are summed up to get the final loss value. This method can not only take into account the importance of different texts, but also balance the impact of texts of different lengths on the overall loss to a certain extent, ensuring that the model training is more stable and accurate. The above loss function is as follows: ; Where n represents the number of batches, m represents the number of sequences, Indicates that the i-th generated sequence is in the target sequence The loss function and p represent the number of sub-packets in each batch. Through the above method, the utilization efficiency of GPU can be significantly improved, the resource waste in the training process can be reduced, and the training process of the model can be accelerated; in addition, by weighted calculation of the loss function, the adaptability of the model to different texts can be improved, making the training results more ideal.
[0047] In order to verify the above scheme, 200 data were selected for experiments. The effects of generating thought chains in different ways were compared with the two indicators of diversity and availability. The diversity score range was 1-100. After scoring, the final average score was calculated. The availability calculated the available proportion of test cases. In the prior art, the scheme of generating thought chains with models had a diversity score of 60 and an availability of 38%; the method of manually constructing thought chains had a diversity score of 74 and an availability of 42%; the diversity score of the scheme in this application was 84 and the availability was 79%. In addition, experiments were conducted on the training time of large models. The use of sorting and packaging sorting strategies to train large models can significantly reduce the training time.
[0048] As can be seen from the above, in this embodiment, the input text is obtained, and the paragraph corresponding to the input text is generated through language expansion; relevant questions are generated for the named entities in the paragraph, and answers corresponding to the questions are generated; the answers are reviewed according to the review rules to screen out the unreviewed answers, and the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; based on the association between all the questions and all the reviewed answers, the thought chain corresponding to the input text is obtained. It can be seen that the large model is expanded by language expansion technology according to the input text to obtain the corresponding paragraph, and the large model automatically generates questions and answers according to the named entities in the paragraph, and then the answers are reviewed, and errors are corrected according to the unreviewed answers to correct the large model; thus, the thought chain is automatically generated by using the large model, and the generated thought chain is corrected to improve the accuracy of the thought chain, ensure the correctness of the model's explicit reasoning, avoid the illusion problem in implicit reasoning, and improve the accuracy and credibility of the large model reasoning.
[0049] Correspondingly, the present application embodiment also discloses a device for automatically constructing a thought chain, see Figure 4 As shown, the device comprises: An input text acquisition module 11 is used to acquire input text and generate a paragraph corresponding to the input text by language expansion; A question and answer generation module 12, used to generate relevant questions for the named entities in the paragraph and generate answers corresponding to the questions; The review module 13 is used to review the answers according to the review rules to select unreviewed answers, fine-tune the large model according to the unreviewed answers, and regenerate new answers for the unreviewed answers until the new answers pass the review; The thought chain construction module 14 is used to obtain the thought chain corresponding to the input text based on the association relationship between all the questions and all the approved answers.
[0050] As can be seen from the above, in this embodiment, the input text is obtained, and the paragraph corresponding to the input text is generated through language expansion; relevant questions are generated for the named entities in the paragraph, and answers corresponding to the questions are generated; the answers are reviewed according to the review rules to screen out the unreviewed answers, and the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; based on the association between all the questions and all the reviewed answers, the thought chain corresponding to the input text is obtained. It can be seen that the large model is expanded by language expansion technology according to the input text to obtain the corresponding paragraph, and the large model automatically generates questions and answers according to the named entities in the paragraph, and then the answers are reviewed, and errors are corrected according to the unreviewed answers to correct the large model; thus, the thought chain is automatically generated by using the large model, and the generated thought chain is corrected to improve the accuracy of the thought chain, ensure the correctness of the model's explicit reasoning, avoid the illusion problem in implicit reasoning, and improve the accuracy and credibility of the large model reasoning.
[0051] In some specific embodiments, the input text acquisition module 11 may specifically include: A key extraction unit, used to extract keywords from the input text to obtain keywords corresponding to the input text; A language expansion unit, configured to perform language expansion on the input text based on the keyword to obtain a paragraph corresponding to the input text; In some specific embodiments, the question and answer generation module 12 may specifically include: A named entity recognition unit, used to extract all named entities from the paragraph by a named entity recognition method; The question and answer generating unit is used to generate questions for each of the named entities in combination with the content of the paragraph, and to generate answers corresponding to the questions.
[0052] In some specific embodiments, the audit module 13 may specifically include: A screening unit, used for screening the answers according to the review rules to screen out the unreviewed answers; the review rules include logic review and factual review; A model fine-tuning unit, used for fine-tuning the large model through an instruction fine-tuning method according to the unreviewed answer; The answer regeneration unit is used to regenerate the answer to the target question corresponding to the unreviewed answer by using the fine-tuned model as the new answer until the answer generated for the target question passes the review.
[0053] In some specific embodiments, the thought chain building module 14 may specifically include: A length judgment unit, used to judge whether the thought chain reaches a target length; the target length is determined according to the complexity of the input text and / or the type of field involved in the input text; An expansion unit, configured to generate questions and answers based on the named entities in the reviewed answers if the target length is not reached, so as to expand the thought chain according to the newly generated questions and answers until the thought chain reaches the target length; A thought chain generating unit is used to obtain a thought chain corresponding to the input text based on the association relationship between all the questions and all the approved answers.
[0054] In some specific embodiments, the automatic thought chain construction device may specifically include: A weight determination unit, used to determine the weight of each text according to a weight determination rule; the weight determination rule is a rule based on the length of the text and / or the importance of the text; A loss function generating unit, used for obtaining the loss function of the large model by weighted summation based on the weight corresponding to each of the texts and the loss corresponding to each of the texts; A model training unit is used to train the large model using the loss function.
[0055] In some specific embodiments, the automatic thought chain construction device may specifically include: A training set acquisition unit, used to acquire a training set; the training set is a training set that has passed diversity screening, accuracy screening and representative screening; A text packing unit, used to merge the texts in the training set according to a maximum text packing length, and fill in spaces when the maximum text packing length is not reached after merging and the remaining space is insufficient to merge a complete text, so as to divide the training set into a plurality of task blocks of the same size; the task blocks contain one or more complete texts; The model training unit is used to train a large model by allocating the task blocks to a graphics processor for processing.
[0056] In some specific embodiments, the text packaging unit may specifically include: A sorting unit, used to sort the texts in the training set according to the length of the texts; The text merging unit is used to merge the texts in the training set according to the maximum text packing length based on the sorting, so that the lengths of different texts in the obtained single task block are similar.
[0057] Furthermore, the present application also discloses an electronic device, see Figure 5 As shown, the contents in the drawings should not be considered as any limitation on the scope of use of the present application.
[0058] Figure 5 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the method for automatically constructing a thinking chain disclosed in any of the aforementioned embodiments.
[0059] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0060] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222, and data 223 including input text, etc. The storage method can be temporary storage or permanent storage.
[0061] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the automatic construction method of the thinking chain performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can also further include a computer program that can be used to complete other specific tasks.
[0062] Furthermore, an embodiment of the present application also discloses a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the method for automatically constructing a thinking chain disclosed in any of the aforementioned embodiments are implemented.
[0063] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0064] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0065] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0066] The above is a detailed introduction to the automatic construction method, device, equipment and storage medium of a thought chain provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for automatically constructing a thought chain, characterized in that: Applicable to large models, including: Obtaining input text, and generating paragraphs corresponding to the input text through language expansion; Generate relevant questions for the named entities in the paragraph, and generate answers corresponding to the questions; The answers are reviewed according to the review rules to select unreviewed answers, the large model is fine-tuned according to the unreviewed answers, and new answers are regenerated for the unreviewed answers until the new answers are reviewed; Based on the association between all the questions and all the approved answers, a thought chain corresponding to the input text is obtained.
2. The method for automatically constructing a thought chain according to claim 1, characterized in that: Obtaining input text, generating paragraphs corresponding to the input text through language expansion, generating relevant questions for named entities in the paragraphs, and generating answers corresponding to the questions, including: Extract keywords from the input text to obtain keywords corresponding to the input text; Performing language expansion on the input text based on the keyword to obtain a paragraph corresponding to the input text; Extracting all named entities from the paragraph by using a named entity recognition method; A question for each of the named entities is generated in combination with the content of the paragraph, and an answer corresponding to the question is generated.
3. The method for automatically constructing a thought chain according to claim 1, characterized in that: The step of reviewing the answers according to the review rules to select unreviewed answers, fine-tuning the large model according to the unreviewed answers, and regenerating new answers for the unreviewed answers until the new answers pass the review includes: Reviewing the answers according to review rules to screen out unreviewed answers; the review rules include logical review and factual review; According to the unreviewed answers, fine-tuning the large model through an instruction fine-tuning method; For the target question corresponding to the unreviewed answer, the answer to the target question is regenerated using the fine-tuned model as the new answer until the answer generated for the target question passes review.
4. The method for automatically constructing a thought chain according to claim 1, characterized in that: The method of obtaining a thought chain corresponding to the input text based on the association relationship between all the questions and all the reviewed answers includes: Determining whether the thought chain reaches a target length; the target length is determined according to the complexity of the input text and / or the type of field involved in the input text; If the target length is not reached, generating questions and answers based on the named entities in the reviewed answers, so as to expand the thought chain according to the newly generated questions and answers until the thought chain reaches the target length; Based on the association between all the questions and all the approved answers, a thought chain corresponding to the input text is obtained.
5. The method for automatically constructing a thought chain according to claim 1, characterized in that: The training process of the large model includes: Determine the weight of each text according to a weight determination rule; the weight determination rule is a rule based on text length and / or text importance; Based on the weight corresponding to each of the texts and the loss corresponding to each of the texts, a loss function of the large model is obtained by weighted summation; The large model is trained using the loss function.
6. The method for automatically constructing a thought chain according to any one of claims 1 to 5, characterized in that: The training process of the large model includes: Obtaining a training set; the training set is a training set that has passed diversity screening, accuracy screening, and representative screening; Merging the texts in the training set according to the maximum text packing length, and when the maximum text packing length is not reached after merging and the remaining space is insufficient to merge a complete text, padding with spaces, so as to divide the training set into a plurality of task blocks of the same size; the task blocks contain one or more complete texts; Training large models is accomplished by distributing the task blocks to graphics processors.
7. The method for automatically constructing a thought chain according to claim 6, characterized in that: The merging of the texts in the training set according to the maximum text packing length includes: Sorting the texts in the training set according to the text length; Based on the sorting, the texts in the training set are merged according to the maximum text packing length, so that the lengths of different texts in the obtained single task block are similar.
8. A device for automatically constructing a thought chain, characterized in that: include: An input text acquisition module, used to acquire input text and generate paragraphs corresponding to the input text by language expansion; A question and answer generation module, used to generate relevant questions for the named entities in the paragraph and generate answers corresponding to the questions; An audit module is used to audit the answers according to the audit rules to select unapproved answers, fine-tune the large model according to the unapproved answers, and regenerate new answers for the unapproved answers until the new answers pass the audit; The thought chain building module is used to obtain the thought chain corresponding to the input text based on the association relationship between all the questions and all the reviewed answers.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, used to execute the computer program to implement the method for automatically constructing a thinking chain as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein when the computer programs are executed by a processor, the method for automatically constructing a thinking chain as described in any one of claims 1 to 7 is implemented.