Text generation method based on large language model and related product
By using large language models to identify problem types and calculate similarity in intelligent customer service systems, the problem of inefficient problem text filtering accuracy and efficiency in traditional systems is solved, and more efficient filtering of invalid problem and answer generation is achieved.
Patent Information
- Application Number
- CN202410931298.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-26
AI Technical Summary
In the existing intelligent customer service system, the diversity and colloquial characteristics of user problems make it difficult for traditional automatic reply systems based on text matching to effectively filter invalid problem text, resulting in insufficient filtering accuracy and efficiency.
Using a text generation method based on a large language model, the reference reply text is output to improve filtering accuracy and efficiency by identifying the problem type and calculating the similarity between the problem text and the preset acceptance problem library and the rejection problem library.
It effectively improves the filtering accuracy and efficiency of invalid problem text, saves the cost of using large language models, and reduces misleading replies.
Smart Images

Figure CN119025636A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text generation method based on a large language model and related products. Background Art
[0002] The user questions received by the current intelligent customer service system are mostly diverse and colloquial, which poses a great challenge to the traditional automatic reply system based on text matching. The rapid development of related technologies such as large language models has brought hope for solving this problem, but in order to save the cost of using large models and avoid the misleading situation caused by artificial intelligence when dealing with some issues not related to responsibilities, it is necessary to filter some questions raised by users that are not within the scope of service. Traditional question filtering methods are mainly based on preset filtering rules or keywords to filter question texts. Although these methods can play a certain filtering role to a certain extent, they cannot exhaust all the keywords that need to be rejected. Therefore, the filtering accuracy and efficiency are difficult to meet the needs of current usage scenarios. Summary of the invention
[0003] The main purpose of this application is to provide a text generation method based on a large language model and related products, which can at least solve the problem of low filtering efficiency and accuracy of invalid problem text in related technologies.
[0004] To achieve the above-mentioned objectives, the first aspect of the present application provides a text generation method based on a large language model, the method comprising: in response to an input question text, calling a preset large language model to identify the question type of the question text as a target question or a non-target question; when the question text is the non-target question, outputting a preset fixed reply text; when the question text is the target question, respectively calculating the similarity between the question text and the reference question texts in a preset acceptance question library and a preset rejection question library to obtain a first average similarity and a second average similarity; wherein the preset acceptance question library includes the question text corresponding to the target question, and the preset rejection question library includes the question text corresponding to the non-target question; and outputting a reference reply text based on the comparison result of the first average similarity and the second average similarity.
[0005] The second aspect of the present application provides an intelligent question-answering system, comprising: a terminal device for inputting a question text; a server for responding to the question text input by the user and processing the question text according to the text generation method based on the large language model provided in the first aspect of the present application to obtain a reference answer text for the question text.
[0006] The third aspect of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the text generation method based on the large language model provided in the first aspect of the present application are implemented.
[0007] The present application uses a large language model to identify the question type of an input question text as a target question or a non-target question. When the question text is a non-target question, a preset fixed reply text is output. When the question text is a target question, the similarity between the question text and the reference question texts in a preset acceptance question library and a preset rejection question library is calculated respectively to obtain a first average similarity and a second average similarity. Finally, based on the comparison result of the first average similarity and the second average similarity, a reference reply text is output, which can effectively improve the filtering accuracy and efficiency of invalid question texts, thereby saving the cost of using a large model. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] 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 some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0009] Figure 1 An application scenario diagram of a text generation method based on a large language model provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application; Figure 3 A schematic diagram of a basic flow chart of a text generation method based on a large language model provided in an embodiment of the present application; Figure 4 A detailed flow chart of a text generation method based on a large language model provided in one embodiment of the present application; Figure 5 A detailed flowchart of another text generation method based on a large language model provided in an embodiment of the present application; Figure 6 A module diagram of a text generation device based on a large language model provided in one embodiment of the present application. DETAILED DESCRIPTION
[0010] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0011] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0012] In order to solve the problem of low filtering efficiency and accuracy of invalid question text in the related art, an embodiment of the present application provides a text generation method based on a large language model. The present application provides a text generation method, device, electronic device and computer-readable storage medium based on a large language model.
[0013] Figure 1 An application scenario diagram of a text generation method based on a large language model provided in an embodiment of the present application, the text generation method based on a large language model is applied to an intelligent customer service system. The intelligent customer service system includes a terminal device 101 and a server 102, and the terminal device 101 and the server 102 are connected in communication. The user inputs the question text through the terminal device 101, and the server 102 deploys a large language model, a preset acceptance question library, a preset rejection question library, and a preset reply library. The large language model responds to the question text input by the user, calls the above database, and processes the question text according to the text generation method based on the large language model provided in one or more embodiments of the present application to obtain a reference reply text of the question text. After the server 102 obtains the reply text, it is output to the terminal device 101, and the terminal device 101 displays it to the user. The terminal device 101 can be a mobile phone, a computer, a tablet, a robot, a self-service terminal, etc. The server 102 can be a cloud server, a network server, an application server, etc., which is not limited here.
[0014] Figure 2A schematic diagram of the structure of an electronic device provided in one embodiment of the present application, the electronic device can be used to implement the text generation method based on a large language model provided in one or more embodiments of the present application, the electronic device mainly includes: a memory 201, a processor 202, and a computer program 203 stored in the memory 201 and executable on the processor 202, the memory 201 and the processor 202 are connected by communication. When the processor 202 executes the computer program 203, the aforementioned text generation method based on a large language model is implemented. Among them, the electronic device can be a mobile phone, a computer, an intelligent voice interaction device and other devices, and can also be a server.
[0015] In an optional embodiment, the number of processors may be one or more. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), neural network chips or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0016] In an optional implementation, the memory is used to store a computer program corresponding to the text generation method based on a large language model provided in one or more embodiments of the present application, so that the processor can read the program when processing, thereby realizing the processing of the text generation process. It should be noted that the memory can be set independently or integrally with the processor, and it can be a high-speed random access memory (RAM) memory or a non-volatile memory (non-volatile memory), such as a disk memory, which is not limited here.
[0017] The embodiment of the present application also provides a computer-readable storage medium, which may be disposed in the above-mentioned electronic device, and the computer-readable storage medium may be the memory in the aforementioned embodiment. The computer-readable storage medium stores a computer program, and when the program is executed by the processor, the text generation method based on the large language model in the aforementioned embodiment is implemented. The computer-storable medium may also be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a RAM, a magnetic disk or an optical disk, and other media that can store program codes.
[0018] The embodiment of the present application also provides a computer program product comprising instructions, and when the computer program product is run on a computer or a processor, the process of the aforementioned text generation method based on a large language model can be implemented.
[0019] Figure 3 A basic flow chart of a text generation method based on a large language model provided in an embodiment of the present application, wherein the text generation method includes the following steps 301 to 304.
[0020] Step 301: In response to an input question text, a preset large language model is called to identify the question type of the question text as a target question or a non-target question.
[0021] When the user inputs a question, that is, when a question query instruction is received, the preset large language model is called to identify the question type of the received question text, where the question type includes target questions or non-target questions. Target questions are questions related to the responsibilities of intelligent customer service, such as questions related to pre-sales consultation and after-sales support consultation. Other questions are invalid questions, such as chat questions.
[0022] In one embodiment, the preset large language model includes a recognition layer, and the recognition layer identifies whether the question text belongs to a target question or a non-target question by calculating the probability value of the question text belonging to each type of question. For example, when the question text input by the user is "How is the weather today?", the recognition layer identifies that the probability of the question text belonging to the pre-sales consultation type is 0.1, the probability of belonging to the after-sales support consultation type is 0.2, and the probability of belonging to the chat type is 0.7, thereby obtaining that the question text is a non-target question; when the question text input by the user is "Introduce Gemini2", the recognition layer identifies that the probability of the question text belonging to the pre-sales consultation type is 0.8, the probability of belonging to the after-sales support consultation type is 0.1, and the probability of belonging to the chat type is 0.1, thereby obtaining that the question text is a target question.
[0023] Step 302: When the question text is a non-target question, output a preset fixed answer text.
[0024] In this embodiment, when the recognition layer of the preset large language model identifies the question that the user needs to query as a non-target question, such as the casual chat question "How is the weather today?", a fixed reply text of polite rejection is returned, such as "Sorry, as a company customer service assistant, I can only provide relevant information about the company's products and services. If you have any related questions, I am happy to answer them for you" to avoid misleading reply content. At the same time, it can reduce the interference of invalid questions on the intelligent customer service scenario and save the cost of using the large language model.
[0025] Step 303: When the question text is a target question, the similarities between the question text and reference question texts in a preset acceptance question library and a preset rejection question library are calculated respectively to obtain a first average similarity and a second average similarity.
[0026] Taking into account that there may be certain errors in the results of large language model recognition, the preset large language model in this embodiment also includes a calculation layer. When identifying the question input by the user as a target question, for example, when it is a pre-sales consultation question "Introduce Gemini2", the calculation layer of the preset large language model calculates the similarity of the input question text with the preset acceptance question library corresponding to the target question and the preset rejection question library corresponding to the non-target question, and obtains a first average similarity corresponding to the preset acceptance question library and a second average similarity corresponding to the preset rejection question library.
[0027] In some embodiments, multiple target questions and multiple non-target questions are listed by exhaustive method and stored in preset acceptance question library and preset rejection question library as reference question texts of each question library. Preferably, the reference question texts in the preset acceptance question library and the preset rejection question library are stored in vector form, and the similarity between the question text and the reference question text in the preset acceptance question library and the preset rejection question library is calculated by the calculation layer of the preset large language model to obtain the first average similarity and the second average similarity, including: vectorizing the input question text to obtain the question text vector, respectively calculating the similarity between the question text vector and each reference question text vector in the preset acceptance question library and the preset rejection question library to obtain multiple first similarities and multiple second similarities; respectively sorting the multiple first similarities and multiple second similarities from high to low; calculating the average of the first M first similarities to obtain the first average similarity; wherein M≥2; calculating the average of the first M second similarities to obtain the second average similarity.
[0028] In this embodiment, the reference question texts in the accepted question library and the rejected question library are stored in the form of vectors. By vectorizing the input question text to obtain a digital vector, matching analysis can be facilitated. After the input question text is vectorized, the similarity between the input question text vector and each reference question text vector in the two question libraries is calculated respectively, and then the multiple similarities corresponding to each question library are sorted in descending order to obtain two similarity sequences, and the first M similarities of each sequence are selected respectively, and the average value of the M similarities is calculated as the similarity between the question text and each question library; wherein, M≥2, M can be a value such as 2, 3, 4, 5, etc., which can be reasonably selected according to demand and efficiency.
[0029] Step 304: output a reference reply text according to the comparison result of the first average similarity and the second average similarity.
[0030] After obtaining the average similarity between the question text and the reference question texts in the preset acceptance question library and the preset rejection question library, the average similarities corresponding to the two question libraries are compared respectively, and the corresponding reference answer text is selected for output according to the comparison result.
[0031] In some embodiments, the preset large language model also includes a judgment layer, which is used to output a reference reply text according to the comparison result of the first average similarity and the second average similarity, and the reference reply text includes a target reply text corresponding to the target question or a preset fixed reply text corresponding to the non-target question. Wherein, if the first average similarity is greater than the second average similarity, the reply text block of the question text is obtained in the preset reply library, the correlation between the reply text block and the question text is calculated, and the target reply text corresponding to the question text is determined according to the correlation; if the first average similarity is less than the second average similarity, the preset fixed reply text is output; if the first average similarity is equal to the second average similarity, the reference reply text is output according to the comparison result of the highest similarity corresponding to multiple first similarities and the highest similarity corresponding to multiple second similarities.
[0032] Specifically, when the first average similarity is greater than the second average similarity, it means that the input question text is the target question. Therefore, the answer text block of the question text can be further obtained in the preset answer library, and the target answer text that best matches the question text can be determined based on the correlation between the answer text block that matches the question text in the preset answer library. In this embodiment, the answer text block includes multiple answer texts, and determining the target answer text based on the correlation between the question text and the answer text block that matches the preset answer library includes: calculating the correlation between the input question text and each answer text in the answer text block, calculating the average of the correlations corresponding to each answer text in the answer text block, and using the average as the correlation between each answer text block and the question text; also directly calculating the correlation of the answer text block through the trained neural network model to obtain the correlation between the answer text block and the question text, and selecting the target answer text that best matches the question text according to the correlation. When the average similarity is equal to the second average similarity, the highest one of the multiple first similarities may be obtained respectively. In some embodiments, the preset answer library includes multiple answer texts stored in the form of vectors, and obtaining the answer text block of the question text in the preset answer library includes: calculating the similarity between the question text vector corresponding to the question text and each answer text vector in the preset answer library; sorting each answer text vector according to the similarity from high to low; determining the answer texts corresponding to the first N answer text vectors as the answer text block of the question text; wherein N≥2.
[0033] Furthermore, the reply text vector includes the knowledge text vector corresponding to the knowledge text and the hypothetical question text vector corresponding to the knowledge text, and the reply texts corresponding to the first N reply text vectors are determined as the reply text block of the question text, including: distinguishing the knowledge text vectors and the hypothetical question text vectors in the N reply text vectors; using the knowledge text corresponding to the hypothetical question text vector in the N reply text vectors as the first reply text of the question text vector; using all the knowledge texts corresponding to the knowledge text vectors in the N reply text vectors as the second reply text of the question text vector; and combining the first reply text and the second reply text to obtain the reply text block of the question text.
[0034] In this embodiment, the method for obtaining the hypothetical question text vector includes: generating one or more hypothetical questions for each knowledge text block, and the hypothetical questions corresponding to each knowledge text block can be the same or different. For example, the knowledge text blocks "OrbbecViewer for OpenNI2 obtains infrared gain value" and "OrbbecViewer for OpenNI2 sets infrared gain value" both correspond to a hypothetical question text "How to set the exposure value of the infrared camera in OrbbecViewer". The hypothetical question is converted into a vector to obtain a hypothetical question text vector, and stored in the answer library. In the process of retrieving the answer text block from the answer library based on the question text vector, the hypothetical question text block vector also participates in the retrieval. The retrieval process can also adopt a similarity matching method. When the question text vector matches the hypothetical question text block vector, the corresponding knowledge text block vector is used as the first answer text; when the knowledge text block vector of other non-hypothetical question text block vectors is matched, it is directly used as the second answer text, and the first answer text and the second answer text are combined to obtain the answer text block of the question text. By setting two types of matching text block vectors, this embodiment can improve the robustness and comprehensiveness of the retrieval, thereby improving the efficiency, accuracy and robustness of the retrieval.
[0035] In some embodiments, the target reply text includes a reply text containing an answer and / or a fixed reply text without an answer, and the target reply text that best matches the question text is determined based on the correlation, including: when the correlation is greater than or equal to a preset correlation threshold, obtaining the authenticity score and validity score of the reply text containing the answer; when the authenticity score and the validity score are both greater than or equal to the preset score threshold, outputting the reply text containing the answer; when the authenticity score or the validity score is less than the preset score threshold, outputting the fixed reply text without an answer; when the correlation is less than the preset correlation threshold, outputting the fixed reply text without an answer.
[0036] In this embodiment, after obtaining the reply text block of the question text, the relevance between the reply text block and the question text is first determined. If the relevance of the obtained reply text block is greater than or equal to a preset relevance threshold (e.g., 5), it means that the obtained reply text block meets the relevance requirement, and the target reply text is determined to be a reply text containing an answer. Furthermore, in order to obtain a more accurate reply text, after determining the reply text containing an answer, the accuracy of the reply text containing an answer can also be determined; if the accuracy meets the requirement, the reply text containing the answer is output to the user; if not, a fixed reply text without an answer is output to the user.
[0037] Specifically, the accuracy of the reply text is judged from the authenticity of the reply text containing the answer (determining whether there is content that is irrelevant to the question or fabricated in the answer) and the effectiveness (determining whether the answer can solve the user's problem). The authenticity and effectiveness of the reply text containing the answer are judged by the default logic of the large language model, which is equivalent to asking the large language model questions by default after obtaining the reply text containing the answer, and the large language model generates the score. For example, for authenticity, it is equivalent to inputting the following question to the large language model by default: Please determine whether there is content that is irrelevant to the user's question or fabricated in the generated reply text, and score it on a scale of 0-10, with a larger number indicating a higher score; the large language model outputs an authenticity score. For effectiveness, it is equivalent to inputting the following question to the large language model by default: Please determine whether the reply text can solve the user's problem, and score it on a scale of 0-10, with a larger number indicating a higher score; the large language model outputs an effectiveness score. When the authenticity and validity scores are both greater than or equal to a preset threshold, for example 5, it is determined that the reply text containing the answer meets the accuracy requirement, and the large language model outputs the reply text containing the answer, otherwise a fixed reply text without an answer is output, such as "I cannot answer your question well at the moment, please ask the question again in a different way."
[0038] Furthermore, before obtaining the authenticity score and validity score of the reply text containing the answer, the method further includes: deduplicating and merging the reply text blocks obtained from the preset reply library to obtain the target reply text block; and performing logical sorting based on the target reply text block and the question text to obtain the reply text containing the answer. In this embodiment, since there may be duplicate text blocks in the reply text block, the obtained reply text block is deduplicated, the similarity between each reply text block and the question text is obtained, and all the deduplicated reply text blocks are merged in order of similarity from high to low to obtain the target text block.
[0039] When the first average similarity corresponding to the accepted question library is less than the second average similarity corresponding to the rejected question library, it means that the question text has a higher similarity to the non-target question, and a preset fixed reply text is output, such as a fixed reply text of "Sorry, as a company customer service assistant, I can only provide relevant information about the company's products and services. If you have any related questions, I am happy to answer them for you"; when the first average similarity is equal to the second average similarity, it is necessary to obtain the highest similarity among multiple first similarities and the highest similarity among multiple second similarities respectively, and select the reference reply text that best matches the input question text according to the higher similarity of the two highest similarities.
[0040] In some embodiments, based on the comparison results of the highest similarity corresponding to multiple first similarities and the highest similarity corresponding to multiple second similarities, a reference reply text is output, including: if the highest similarity corresponding to multiple first similarities is greater than or equal to the highest similarity corresponding to multiple second similarities, then matching the reply text block of the question text in the preset reply library, calculating the correlation between the reply text block and the question text, and outputting the target reply text corresponding to the question text according to the correlation. This specific process is the same as the process of obtaining the target reply text when the first average similarity is greater than the second average similarity, and will not be repeated here; if the highest similarity corresponding to multiple first similarities is less than the highest similarity corresponding to multiple second similarities, then outputting the preset fixed reply text.
[0041] Through the implementation of the present application scheme, after the question text is identified as the type and determined as the target question type, it is then matched with the preset acceptance question library and the preset rejection question library for similarity, so as to filter out invalid question texts based on the comparison results between the two similarities, and output the corresponding reference answer text, thereby effectively improving the filtering accuracy and efficiency of invalid question texts.
[0042] Figure 4 and Figure 5 The present invention is a flowchart of a text generation method based on a large language model according to an embodiment of the present application. The text generation method comprises the following steps: Step 401: In response to the input question text, calling a large language model to identify the question type of the question text as a target question or a non-target question; Step 402: when the question text is a non-target question, output a preset fixed answer text; Step 403: when the question text is a target question, the similarity between the question text and the reference question texts in the preset acceptance question library and the preset rejection question library is calculated respectively to obtain a first average similarity and a second average similarity; Step 404: if the first average similarity A1 is greater than the second average similarity A2, then obtaining a reply text block of the question text in the preset reply library; Step 405: input the reply text block and the question text into the large language model to obtain the target reply text, and output the target reply text; Step 406: if the first average similarity A1 is less than the second average similarity A2, output a preset fixed reply text; Step 407: if the first average similarity A1 is equal to the second average similarity A2, and the highest similarity corresponding to the preset acceptance question library is greater than or equal to the highest similarity corresponding to the preset rejection question library, then output the target reply text; Step 408: If the first average similarity A1 is equal to the second average similarity A2, and the highest similarity corresponding to the preset acceptance question library is less than the highest similarity corresponding to the preset rejection question library, then output the preset fixed reply text.
[0043] It should be understood that the size of the serial number of each step in this embodiment does not mean the order of execution of the steps. The execution order of each step should be determined by its function and internal logic, and should not constitute a sole limitation on the implementation process of the embodiment of this application.
[0044] This embodiment classifies user questions through a large language model, and establishes a preset acceptance question library and a preset rejection question library to screen out invalid questions by similarity matching, thereby effectively improving the question-answering system's success rate in rejecting invalid questions and reducing the interference of invalid questions on the question-answering system. At the same time, the large language model is used only for valid questions to generate reply texts containing answers, effectively saving the cost of using the large language model.
[0045] Figure 6A text generation device based on a large language model is provided for an embodiment of the present application. The text generation device can be applied to the aforementioned text generation method based on a large language model. The text generation device includes: an identification module 601, which is used to call a preset large language model to identify the question type of the question text as a target question or a non-target question in response to an input question text; a first output module 602, which is used to output a preset fixed reply text when the question text is a non-target question; a calculation module 603, which is used to calculate the similarity between the question text and the reference question text in a preset acceptance question library and a preset rejection question library when the question text is a target question, respectively, to obtain a first average similarity and a second average similarity; wherein the question text in the preset acceptance question library corresponds to the target question, and the question text in the preset rejection question library corresponds to the non-target question; a second output module 604, which is used to output a reference reply text according to the comparison result of the first average similarity and the second average similarity.
[0046] It should be noted that the text generation methods based on the large language model in the aforementioned embodiments can all be implemented based on the text generation device based on the large language model provided in this embodiment. Ordinary technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working process of the text generation device based on the large language model described in this embodiment can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0047] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0048] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0049] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0050] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a readable storage medium, including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned readable storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD-ROM and other media that can store program codes.
[0051] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0052] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0053] The above is a description of the text generation method based on a large language model and related products provided by this application. For technicians in this field, according to the ideas of the embodiments of this application, there may be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on this application.
Claims
1. A text generation method based on a large language model, characterized in that: include: In response to the input question text, calling a preset large language model to identify the question type of the question text as a target question or a non-target question; When the question text is the non-target question, outputting a preset fixed answer text; When the question text is the target question, the similarity between the question text and the reference question texts in the preset acceptance question library and the preset rejection question library is calculated respectively to obtain a first average similarity and a second average similarity; wherein the preset acceptance question library includes the question text corresponding to the target question, and the preset rejection question library includes the question text corresponding to the non-target question; Outputting a reference reply text according to a comparison result of the first average similarity and the second average similarity.
2. The text generation method according to claim 1, characterized in that: The reference question texts in the preset accepted question library and the preset rejected question library are stored in the form of vectors, and the similarities between the question text and the reference question texts in the preset accepted question library and the preset rejected question library are respectively calculated to obtain a first average similarity and a second average similarity, including: Performing vectorization processing on the question text to obtain a question text vector, respectively calculating the similarity between the question text vector and each reference question text vector in a preset acceptance question library and a preset rejection question library, to obtain a plurality of first similarities and a plurality of second similarities; sorting the plurality of first similarities and the plurality of second similarities from high to low respectively; Calculate the average of the first M similarities to obtain a first average similarity; wherein M≥2; An average of the first M second similarities is calculated to obtain a second average similarity.
3. The text generation method according to claim 1, characterized in that: The reference answer text includes a target answer text corresponding to the target question or a preset fixed answer text corresponding to the non-target question; Outputting a reference reply text according to a comparison result of the first average similarity and the second average similarity includes: If the first average similarity is greater than the second average similarity, obtaining a reply text block of the question text from a preset reply library, calculating the correlation between the reply text block and the question text, and outputting a target reply text corresponding to the question text according to the correlation; If the first average similarity is less than the second average similarity, outputting the preset fixed reply text; If the first average similarity is equal to the second average similarity, a reference reply text is output according to a comparison result between a highest similarity corresponding to the multiple first similarities and a highest similarity corresponding to the multiple second similarities.
4. The text generation method according to claim 3, characterized in that: The step of obtaining a reply text block of the question text from a preset reply library includes: Calculate the similarity between the question text vector corresponding to the question text and each answer text vector in the preset answer library; Sorting the reply text vectors from high to low according to the similarity; The reply texts corresponding to the first N reply text vectors are determined as the reply text blocks of the question text; wherein N≥2.
5. The text generation method according to claim 4, characterized in that: The reply text vector includes the knowledge text vector corresponding to the knowledge text and the hypothetical question text vector corresponding to the knowledge text, and determining the reply texts corresponding to the first N reply text vectors as the reply text block of the question text includes: Distinguishing the knowledge text vector and the hypothetical question text vector among the N answer text vectors; Using the knowledge text corresponding to the hypothetical question text vector in the N answer text vectors as the first answer text of the question text vector; The knowledge texts corresponding to the knowledge text vectors in the N answer text vectors are all used as the second answer texts of the question text vector; The first reply text and the second reply text are combined to obtain a reply text block for the question text.
6. The text generation method according to claim 3, characterized in that: Outputting the target reply text according to the comparison result of the highest similarity corresponding to the plurality of first similarities and the highest similarity corresponding to the plurality of second similarities comprises: If the highest similarity corresponding to the multiple first similarities is greater than or equal to the highest similarity corresponding to the multiple second similarities, then matching the answer text block of the question text in the preset answer library, calculating the correlation between the answer text block and the question text, and outputting the target answer text corresponding to the question text according to the correlation; If the highest similarity corresponding to the multiple first similarities is smaller than the highest similarity corresponding to the multiple second similarities, the preset fixed reply text is output.
7. The text generation method according to any one of claims 3 to 6, characterized in that: The target reply text includes a reply text containing an answer and / or a fixed reply text without an answer, and the outputting the target reply text corresponding to the corresponding question text according to the correlation degree includes: When the relevance is greater than or equal to a preset relevance threshold, obtaining the authenticity score and validity score of the reply text containing the answer; When the authenticity score and the effectiveness score are both greater than or equal to the preset score threshold, outputting the reply text containing the answer; When the authenticity score or the effectiveness score is less than the preset score threshold, outputting the fixed reply text of no answer; When the relevance is less than a preset relevance threshold, the fixed reply text of no answer is output.
8. The text generation method according to claim 7, characterized in that: Before obtaining the authenticity score and effectiveness score of the reply text containing the answer, the method further includes: De-duplication and merging of the reply text blocks obtained from the preset reply library to obtain a target reply text block; The target reply text block and the question text are input into the large language model to obtain the reply text containing the answer.
9. An intelligent question-answering system, characterized in that: include: Terminal device, used to input question text; The server is used to respond to a question text input by a user and process the question text according to the text generation method based on a large language model as described in any one of claims 1 to 8 to obtain a reference answer text for the question text.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the text generation method based on a large language model as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Intelligent question answering method and device
CN106874441A
Natural language question and answer method, system and device and electronic equipment
CN114896380A
Agricultural knowledge question and answer method and device, storage medium and equipment
CN117708294A
