Man-machine conversation control method, device and equipment and storage medium
By using text vector matching and optimizing prompt words in a large language model, the model illusion problem in human-computer dialogue is solved, improving the accuracy of answers and the efficiency of the system.
Patent Information
- Application Number
- CN202311204585.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-09-18
AI Technical Summary
Large language models suffer from model illusion in human-computer dialogue, leading to logical or factual errors in answers and reducing the accuracy of answers obtained in human-computer dialogue.
By obtaining the text vector of the question text, matching it in a pre-set vector knowledge base according to the information entropy from high to low, generating optimized prompt words, and inputting them into a large language model to suppress the model's divergence and improve the accuracy of the answer.
It improves the output of large language models, enhances the accuracy of human-computer dialogue in obtaining answers, reduces the occurrence of model illusion problems, saves labor costs, and improves the efficiency of system establishment.
Smart Images

Figure CN117149981B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing, and in particular relates to a human-computer dialogue control method, apparatus, device and storage medium. Background Technology
[0002] With the continuous development of electronic information technology, human-computer dialogue is being applied in an increasing number of scenarios, such as intelligent customer service and intelligent assistants. Large Language Models (LLMs) can be used to implement human-computer dialogue. LLMs are models based on machine learning and natural language processing techniques, trained on large amounts of text data to learn the ability to understand and generate human language. However, LLMs suffer from the model illusion problem, which can cause logical or factual errors in the answers they provide based on questions, reducing the accuracy of answers obtained in human-computer dialogue. Summary of the Invention
[0003] This application provides a human-computer dialogue control method, apparatus, device, and storage medium, which can improve the accuracy of obtaining answers through human-computer dialogue.
[0004] In a first aspect, embodiments of this application provide a human-computer dialogue control method, comprising: obtaining a text vector of a question text; using the text vector, matching it in multiple vector sub-libraries in a preset vector knowledge base according to the order of information entropy from high to low, to obtain a first matching result, wherein the vectors in different vector sub-libraries correspond to different text types; generating a first prompt word according to the question text, the first matching result, and a preset prompt word generation criterion; inputting the first prompt word into a pre-trained large language model, and determining the output of the large language model as the target answer text corresponding to the question text.
[0005] Secondly, embodiments of this application provide a human-computer dialogue control device, comprising: a vector acquisition module for acquiring text vectors of question text; a first matching module for matching the text vectors in multiple vector sub-libraries in a preset vector knowledge base according to the order of information entropy from high to low, to obtain a first matching result, wherein the vectors in different vector sub-libraries correspond to different text types; a prompt word generation module for generating a first prompt word based on the question text, the first matching result, and preset prompt word generation criteria; and a large language processing module for inputting the first prompt word into a pre-trained large language model and determining the output of the large language model as the target answer text corresponding to the question text.
[0006] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory storing computer program instructions; the processor executes the computer program instructions to implement the human-computer dialogue control method of the first aspect.
[0007] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement the human-computer dialogue control method of the first aspect.
[0008] This application provides a human-computer dialogue control method, apparatus, device, and storage medium. It first acquires the question text, then uses the text vector of the question text to match vectors in a preset vector knowledge base with vectors in multiple vector sub-bases, arranged in descending order of information entropy, to obtain a first matching result. Because the matching is done in descending order of information entropy, the content in the first matching result contains content with relatively higher information content. The prompt words are optimized using prompt word generation criteria. The optimized content, the first matching result serving as the context of the question text, and the question text are input together into a large language model. The first matching result and the optimized content are used to suppress the divergence of the large language model, thereby improving the model illusion problem and enabling the large language model to output more accurate answer text, thus improving the accuracy of answer acquisition in human-computer dialogue. Attached Figure Description
[0009] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 A flowchart of a human-computer dialogue control method provided in an embodiment of this application;
[0011] Figure 2 A flowchart of a human-computer dialogue control method provided in another embodiment of this application;
[0012] Figure 3 A flowchart of a human-computer dialogue control method provided in another embodiment of this application;
[0013] Figure 4 A logical schematic diagram illustrating an example of human-computer dialogue control provided in an embodiment of this application;
[0014] Figure 5 This is a schematic diagram of the structure of a human-computer dialogue control device provided in an embodiment of this application;
[0015] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0016] The features and exemplary embodiments of various aspects of this application will be described in detail below. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain this application and not to limit it. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples. It should be noted that the acquisition, storage, use, and processing of information and data in the embodiments of this application are all authorized by users or relevant organizations and comply with the relevant provisions of national laws and regulations.
[0017] With the continuous development of electronic information technology, human-computer dialogue is being applied in an increasing number of scenarios, such as intelligent customer service and intelligent assistants. Large Language Models (LLMs) can be used to implement human-computer dialogue. LLMs are models based on machine learning and natural language processing techniques, trained on large amounts of text data to learn the ability to understand and generate human language. However, LLMs are susceptible to the "model illusion" problem, which can lead to logical or factual errors in the answers they provide based on questions, reducing the accuracy of answers obtained in human-computer dialogue.
[0018] This application provides a human-computer dialogue control method, apparatus, device, and storage medium. It first acquires the question text, then uses the text vector of the question text to match vectors in a preset vector knowledge base with vectors in multiple vector sub-bases according to information entropy from high to low, obtaining a matching result. This matching result is then used as the context of the question text and input together with the question text into a large language model. The matching result is used to suppress the divergence of the large language model, thereby reducing the possibility of model illusion problems and obtaining a more accurate answer text output by the large language model, thus improving the accuracy of answer acquisition in human-computer dialogue.
[0019] The human-computer dialogue control method, device, equipment, and storage medium provided in this application will be described below.
[0020] The first aspect of this application provides a human-computer dialogue control method, which can be applied to scenarios requiring human-computer dialogue, such as intelligent customer service and intelligent assistants. This human-computer dialogue control method can be executed by a human-computer dialogue control device, electronic device, etc., and is not limited thereto. Figure 1 A flowchart of a human-computer dialogue control method provided in an embodiment of this application is shown below. Figure 1 As shown, the human-computer dialogue control method may include steps S101 to S104.
[0021] In step S101, the text vector of the problem text is obtained.
[0022] The system can obtain the query text based on user input, and then convert it into a text vector using a pre-defined vectorization model. User input can include text or speech. If the user input includes text, the query text can be extracted directly from the input text; if the user input includes speech, the speech input can first be converted into text, and then the query text can be extracted from the text. The vectorization model can be selected based on factors such as the language environment, sequence length, and similarity function, and is not limited here.
[0023] In step S102, using text vectors, matching is performed in multiple vector sub-databases in a preset vector knowledge base according to the order of information entropy from high to low, to obtain the first matching result.
[0024] A vector knowledge base can include multiple vector sub-bases, each containing at least one vector. Vectors in different sub-bases correspond to different text types, and the information entropy of vectors corresponding to different text types also differs. The information entropy of the vector corresponding to the text type can be used as the information entropy of the corresponding vector sub-base. Higher information entropy means a greater amount of information can be conveyed. Matching is performed sequentially in each vector sub-base according to the information entropy from highest to lowest. For example, if a vector knowledge base includes three vector sub-bases, arranged in descending order of information entropy (sub-base 1, sub-base 2, and sub-base 3), then the text vector will first be matched with vectors in sub-base 1, then with vectors in sub-base 2, and finally with vectors in sub-base 3.
[0025] Matching text vectors within a vector sub-library involves matching text vectors against vectors in that sub-library. This matching is achieved by calculating a matching degree parameter between the text vector and the vectors in the sub-library. The matching degree parameter characterizes the degree of matching and can be positively or negatively correlated with the degree of matching; this is not a limitation. The matching degree can be considered as similarity, and similarity and matching degree are positively correlated; higher similarity leads to a higher matching degree. In some examples, matching may be achieved using algorithms such as Euclidean distance, inner product, and cosine similarity, but matching is not limited to these algorithms.
[0026] The first matching result obtained by matching text vectors across multiple vector sub-libraries can include the text corresponding to vectors that successfully match in multiple vector sub-libraries, and the texts are also sorted in descending order of information entropy of text type. The first matching result can include the text corresponding to vectors that successfully match text vectors from multiple vector sub-libraries. Through the first matching result, texts with relatively higher information content associated with the question text can be obtained.
[0027] In step S103, a first prompt word is generated based on the question text, the first matching result, and the preset prompt word generation criteria.
[0028] The first prompt word can include the question text, the first match result, and other text generated according to prompt word generation criteria. In the first prompt word, the first match result serves as context for the question text. Prompt word generation criteria can be used to optimize the prompt words, making the generated first prompt word more optimized than one that only includes the question text and the first match result, thus improving the quality of the generated prompt words.
[0029] In step S104, the first prompt word is input into the pre-trained large language model, and the output of the large language model is determined as the target answer text corresponding to the question text.
[0030] The first prompt word serves as input to the large language model. The model analyzes this prompt word and outputs the result. The output includes the answer text. The target answer text includes the answer text output by the large language model that corresponds to the question text. The first matching result in the first prompt word serves as the context of the question text, and the first prompt word is optimized using prompt word generation criteria. Using this first prompt word as input to the large language model can suppress the divergence of the model's output, thereby reducing the probability of model illusion problems.
[0031] In this embodiment, the question text is first obtained. Then, using the text vector of the question text, it is matched against vectors in multiple sub-vector libraries within a pre-defined vector knowledge base, arranged in descending order of information entropy, to obtain a first matching result. Since the matching is done in descending order of information entropy, the content in the first matching result contains information with a relatively higher information content. The prompt words are optimized using prompt word generation criteria. The optimized content, the first matching result serving as the context of the question text, and the question text are input together into a large language model. The first matching result and the optimized content are used to suppress the divergence of the large language model, thereby improving the model illusion problem and enabling the large language model to output more accurate answer text, thus improving the accuracy of answer retrieval in human-computer dialogue. Compared to traditional FAQ-based human-computer dialogue, the human-computer dialogue control method in this embodiment does not require a large amount of manpower to sort and obtain a large number of vertically deep FAQ question-answer pairs, ensuring the accuracy of answer retrieval in human-computer dialogue, saving labor costs, and improving the efficiency of establishing a human-computer dialogue control system.
[0032] In some embodiments, the vector knowledge base may include a vector sub-base of frequently asked questions and answers, a vector sub-base of summary text, and a vector sub-base of raw text. Matching can be performed among these three vector sub-bases to obtain a first matching result. Optimized text can be generated according to prompt word generation criteria and incorporated as part of the prompt words. Figure 2 A flowchart illustrating a human-computer dialogue control method provided in another embodiment of this application. Figure 2 and Figure 1 The difference is that, Figure 1 Step S202 can be further broken down into steps S2021 to S2023. Figure 1 Step S203 can be further subdivided into steps S2031 and S2032.
[0033] In step S1021, the text vector is matched sequentially in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library to obtain the matching degree parameter between the text vector and the vectors in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library.
[0034] The vectors in the frequently asked question and answer vector sub-library can be obtained by transforming frequently asked question and answer pairs. A frequently asked question and answer pair includes the question and its corresponding answer for a frequently asked question node. If there is an existing stock of frequently asked question and answer pairs, such as standard question-and-answer pairs or expert question-and-answer pairs from a frequently asked question and answer robot, the frequently asked question and answer vector sub-library can be formed based on this stock. If there is no existing stock of frequently asked question and answer pairs, they can be extracted in advance using a large language model. It should be noted that the large language model used to extract frequently asked question and answer pairs is different from the large language model in the above embodiment, which takes the first prompt word as input and outputs the target answer text; it is a different kind of large language model. In some examples, the frequently asked question and answer vector sub-library includes a first knowledge vector obtained by transforming frequently asked question and answer pairs according to knowledge points. This can be done by segmenting the frequently asked question and answer pairs according to knowledge points and then performing vector transformation to obtain the first knowledge vector. For example, a question in a frequently asked question and its corresponding answer can be classified as a knowledge point, and the vector obtained by transforming this knowledge point is the first knowledge vector.
[0035] The vectors in the abstract text vector sub-library can be obtained based on the abstract text. The abstract text is a summary of the original text, which can be obtained during the data processing stage by using text summarization methods based on the original document. The specific text summarization method is not limited here. For example, an extractive text summarization method, such as the TextRank method, can be used. This method segments the original text into individual sentences, calculates the similarity between sentences, and constructs undirected weighted edges based on the similarity. Sentences can be considered as nodes, and the similarity between sentences is the undirected weighted edge between them. The value of the node is obtained using the similarity corresponding to the undirected weighted edge, which is the value of the sentence. The sentences with the highest values are selected to form the summary. Another example is a generative text summarization method. The original text can be input into a generative large language model, such as the Transformer model, and the text output by the large language model is used as the abstract text. It should be noted that the large language model used to obtain the abstract text is different from the large language model used in the above embodiments, which takes the first prompt word as input and outputs the target answer text, and the large language model used to extract common question-answer pairs. In some examples, the abstract text vector sublibrary includes second knowledge vectors derived from the abstract text segmented by knowledge points. This involves segmenting the abstract text by knowledge points and then performing vector transformation to obtain the second knowledge vector. For instance, multiple subheadings under a main heading in the abstract text can be classified as a single knowledge point, and the vector derived from this knowledge point is the second knowledge vector.
[0036] The vectors in the original text vector sub-library can be obtained based on the original text. The original document can be segmented according to paragraphs, punctuation marks, or fixed lengths to obtain sentences, and then the sentences can be converted into vectors to form the original text vector sub-library. That is, the original text vector sub-library includes sentence vectors of the original text.
[0037] Among the aforementioned frequently asked question vector sub-database, summary text vector sub-database, and original text vector sub-database, the frequently asked question vector sub-database has the highest information entropy, followed by the summary text vector sub-database, and then the original text vector sub-database. During the matching process, text vectors are first matched against vectors in the frequently asked question vector sub-database, then against vectors in the summary text vector sub-database, and finally against vectors in the original text vector sub-database. Higher information entropy means a greater amount of information can be conveyed, and content with higher information entropy contributes to improving the overall accuracy of human-computer dialogue. For example, regarding the question text "The issuance of travel documents for non-registered personnel is divided into the following situations," the answer text obtained through human-computer dialogue using the original text is: "According to the question, the issuance of travel documents for non-registered personnel is divided into the following situations: 1. Traveling using annual leave: If a non-registered personnel uses annual leave for private travel abroad, they need to submit a leave application at least XX working days before departure. Only after approval can they collect their private travel documents within XX days before applying for a visa (endorsement), and return them within XX days after completion. 2. Traveling using statutory holidays (not involving leave application): If a non-registered personnel uses statutory holidays for private travel..." For those traveling abroad, a Private Exit / Entry Permit Application Form must be completed XX working days prior to departure. Only after approval can the private exit / entry permit be collected within XX days before visa / endorsement processing. It is important to note that the timing and duration of the private exit / entry trip must be confirmed before departure to avoid errors. The answer obtained through the human-computer dialogue using the abstract text is: "According to the question, the collection of exit / entry permits for non-registered personnel falls into the following categories: (i) Traveling during annual leave; (ii) Traveling during statutory holidays (not involving leave); (iii) Applying for visas / endorsements; (iv) Other purposes." As can be seen, due to the excessive length of the original text, its information entropy is lower than that of the abstract text, and the amount of information conveyed is less. Errors are easily made in extracting from the original document, leading to an incorrect and incomplete answer obtained through the human-computer dialogue using the original text. This further illustrates that content with high information entropy contributes to improved overall accuracy of human-computer dialogue.
[0038] The matching degree parameter between a text vector and another vector can characterize the degree of matching between the text vector and another vector. In some examples, the matching degree can be implemented as similarity; the higher the matching degree, the higher the similarity, that is, the matching degree parameter can characterize the similarity. Algorithms for obtaining the matching degree parameter can include Euclidean distance algorithm, inner product algorithm, cosine similarity algorithm, etc. For example, taking the cosine similarity algorithm as an example, the matching degree parameter between a text vector and any vector in any of the following vector sub-libraries: common question answer vector sub-library, summary text vector sub-library, and original text vector sub-library can be calculated according to the following formulas (1) and (2):
[0039]
[0040] VectorStore i ∈{FAQStore,SummaryStore,DocumentStore} (2)
[0041] Where cos(θ) is the cosine similarity; QueryVector is the text vector of the question text; VectorStore i This refers to any vector from any of the following sub-libraries: FAQ Store (for frequently asked questions and answers), Summary Store (for summary text), and Document Store (for raw text). It should be noted that VectorStore contains vectors for each of these sub-libraries. i The selection will proceed sequentially from the vectors in the frequently asked questions and answers vector sub-library, the vectors in the summary text vector sub-library, and the vectors in the original text vector sub-library for matching.
[0042] In step S1022, matching vectors are determined from the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library based on the matching degree parameter and the preset matching degree threshold.
[0043] The matching degree threshold is used to determine whether a match is successful. If the matching degree, represented by the matching degree parameter, is greater than or equal to the matching degree threshold, the match is successful; if the matching degree, represented by the matching degree parameter, is less than the matching degree threshold, the match fails. Matching vectors are determined sequentially from the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library, according to the information entropy from highest to lowest. The matching degree parameter of the matching vector represents a matching degree greater than or equal to the matching degree threshold; that is, the matching vectors include vectors that successfully match the text vectors in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library.
[0044] In step S1023, the text corresponding to the matching vector is determined as the first matching result.
[0045] The first matching result includes the text corresponding to the matching vector. At least a portion of the first matching result will be used as part of the input to a large language model used to output the target answer text.
[0046] In step S1031, optimized text is generated based on the prompt word generation criteria.
[0047] Optimized text can be used as part of the input to a large language model that outputs the target answer text, thereby improving the accuracy of the target answer text output by the large language model. Optimized text includes text that optimizes the prompt words.
[0048] In some examples, the optimization text may include one or more of the following: scenario setting text, role setting text, and realism condition setting text. Scenario setting text can be used to limit the scenario in the first prompt word, thereby using the scenario to limit the divergence of the large language model. Role setting text is used to limit the role in the first prompt word, thereby using the role to limit the divergence of the large language model. Realism condition setting is used to limit the realism of the large language model's output, thereby avoiding the model illusion problem of large language models.
[0049] For example, if the question text is "How can non-registered personnel obtain their documents when going abroad during their annual leave?", according to the prompt generation guidelines, the generated role setting text could be "Please play the role of a professional QA question tester and answer the user's question based on the known information," the generated scenario setting text could be "Ignore any parts of the known information that are irrelevant to the question and do not include them in the answer," and the generated authenticity condition setting text could be "The answer is extracted from the known information; fabricated scores are not allowed in the answer, and calculations are not allowed."
[0050] In step S1032, a first prompt word is generated according to the prompt word generation criteria, based on at least a portion of the first matching result, the question text, and the optimized text.
[0051] The first prompt word can be generated by combining at least a portion of the first matching result, the question text, and the optimized text according to the prompt word generation criteria. The first prompt word includes at least a portion of the first matching result, the question text, and the optimized text. The length of the first prompt word is less than or equal to the input length required by the large language model. The length of the first prompt word can be specifically implemented as the number of characters in the first prompt word. For example, the length requirement of the first prompt word can be shown in the following formula (3):
[0052]
[0053] Among them, Store i.length is the length of at least a portion of the text in the first matching result; Query.length is the length of the question text; Prompt.length is the length of the optimized text; LLM.token.length is the required length of the output of the large language model. It's important to note that the portion of the first matching result selected as the first prompt word must ensure that the length of the first prompt word is less than or equal to the input length required by the large language model. For example, if the first matching result includes the text corresponding to a vector in the common question answer vector sub-library, the text corresponding to a vector in the summary text vector sub-library, and the text corresponding to a vector in the original text vector library, the text corresponding to the vector in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library can be selected as part of the first prompt word, following the order of information entropy from high to low. If the length of the first prompt word is less than or equal to the input length required by the large language model, the text corresponding to the vector in the summary text vector sub-library can also be included as part of the first prompt word. If the length of the first prompt word is greater than the input length required by the large language model, then the first prompt word includes the text corresponding to this vector in the common question answer vector sub-library, but does not include the text corresponding to this vector in the summary text vector sub-library or the text corresponding to this vector in the original text vector library.
[0054] In some examples, the number of matching vectors corresponding to the first matching result included in the first prompt word is less than or equal to the preset number of matches. The number of matching vectors can also be used to limit which content from the first matching result is included in the first prompt word. The number of matches can be set according to the scenario, needs, experience, etc., and is not limited here. For example, if the first matching result includes the text corresponding to a matching vector in the frequently asked questions and answers vector sub-library, the text corresponding to a matching vector in the summary text vector sub-library, and the text corresponding to a matching vector in the original text vector library, and the number of matches is 1, then the first prompt word includes the text corresponding to this matching vector in the frequently asked questions and answers vector sub-library, but does not include the text corresponding to this matching vector in the summary text vector sub-library or the text corresponding to this matching vector in the original text vector library.
[0055] In some examples, at least a portion of the first match result can serve as known information in the first prompt word, thus using at least a portion of the first match result as context for the question text. The first match result in the first prompt word, the optimized text, and the question text can be separated by delimiters to distinguish the different parts, making it easier for large language models to understand the input.
[0056] Using at least a portion of the first match result from the first prompt word as context for the question text can limit the divergence of the large language model and improve the accuracy of the target answer text output by the large language model. Furthermore, by incorporating optimized text and using separators to separate the first match result, optimized text, and question text in the prompt word, the accuracy of the target answer text output by the large language model can be further improved.
[0057] For example, at least part of the first matching result is "(i) Traveling using annual leave: If a non-registered person uses annual leave to travel abroad for private purposes, they must submit a leave application in the process at least XX working days before departure. After approval, they can collect their private travel documents within XX days before applying for a visa (endorsement). After completion, they must return the documents within XX days and collect them again within XX days before departure." The question in this article is "How can a non-registered person collect their travel documents if they use annual leave to travel abroad?"
[0058] If the first prompt word includes at least a portion of the first match result and the question text, the generated first prompt word is:
[0059] Known information:
[0060] (i) Traveling using annual leave: If non-registered personnel use annual leave for private travel abroad, they must submit a leave application process at least XX working days before departure. After approval, they can collect their private travel documents within XX days before applying for a visa (endorsement). After the visa is processed, they must return the documents within XX days and collect them again within XX days before departure.
[0061] Please answer the question: How do unregistered personnel obtain travel documents if they use their annual leave to travel abroad?
[0062] Inputting the first prompt word into the large language model, the output text is: "If a non-registered person uses annual leave to travel abroad, they should submit a leave application at least XX working days before departure. After approval, they should collect their private travel documents within XX days before applying for a visa (endorsement). The specific process is as follows: 1. Submit a leave application and relevant supporting documents, such as passport and visa. 2. After approval, go to the local immigration department to apply for a visa (endorsement). 3. Within XX days before applying for a visa (endorsement), go to the local immigration department to collect your private travel documents. 4. Within XX days before departure, return your private travel documents to the local immigration department. It should be noted that non-registered persons need to understand the regulations and requirements of the local immigration department in advance and follow the relevant procedures to avoid unnecessary trouble."
[0063] The first prompt word obtained using the human-computer dialogue control method in this embodiment is:
[0064] Known information:
[0065] {(i) Travel using annual leave: Non-registered personnel who use annual leave for private travel abroad must submit a leave application at least XX working days before departure. After approval, they can collect their private travel documents within XX days before applying for a visa (endorsement), return them within XX days after completion, and collect them again within XX days before departure.}
[0066] Please assume the role of a professional QA tester and answer user questions based on given information. Answers must be extracted from the given information; fabricated information and calculations are not allowed. Ignore any parts of the given information irrelevant to the question and do not include them in your answer.
[0067] The question is: "How do unregistered personnel obtain their travel documents if they use their annual leave to travel abroad?"
[0068] Inputting the first prompt word into the large language model, the output text of the large language model is: "If a non-registered person uses annual leave to go abroad, they need to submit a leave application in the process at least XX working days before departure. After approval, they can collect their private travel document XX days before applying for a visa (endorsement). They must return it within XX days after completion and collect it again before going abroad."
[0069] The above comparison shows that the target answer text obtained by using the human-computer dialogue control method provided in this application is more accurate and more faithful to the standard answer.
[0070] In some embodiments, to improve the efficiency of human-computer dialogue, human-computer dialogue can be conducted using a common question-answering robot before obtaining the text vector of the question text and matching the text vector with the vector sub-library. Figure 3 A flowchart illustrating a human-computer dialogue control method provided in another embodiment of this application. Figure 3 and Figure 1 The difference is that, Figure 3 The human-computer dialogue control method shown may further include steps S105 and S106. Figure 1 Step S101 can be further refined as follows: Figure 3 Step S1011 in the process.
[0071] In step S105, the question text is input into the frequently asked questions answering robot.
[0072] Before converting the question text into a text vector and matching it with a vector knowledge base, the question text can be output to a frequently asked question answering robot to determine if the robot can provide an answer. The robot can query its pre-stored frequently asked question answer pairs based on the question text. For the question text, the robot has two possible outcomes: one is that it can find the corresponding answer in the pre-stored frequently asked question answer pairs, in which case it returns that answer; the other is that it cannot find the answer in the pre-stored frequently asked question answer pairs, in which case it returns information indicating that it cannot answer the question.
[0073] In step S106, if the frequently asked question answering robot provides the answer text, then the provided answer text is determined as the target answer text corresponding to the question text.
[0074] Frequently Asked Questions (FAQs) answering robots pre-store frequently asked questions and their corresponding answers, which have high information entropy. If the robot can provide the answer text corresponding to the question text, then that answer text is highly accurate and can be used as the target answer text. When the FAQ robot can provide the answer text, this process is faster than matching text vectors in a vector knowledge base, thus improving the efficiency of human-computer dialogue.
[0075] In step S1011, if the frequently asked question answering robot does not provide an answer text, then the text vector of the question text is obtained.
[0076] If the FAQ robot cannot provide the answer text corresponding to the question text, then relying solely on the FAQ robot will not yield the target answer text. It is necessary to use the text vector of the question text to perform matching in the vector knowledge base, as in steps S102 to S104, to obtain the target answer text with the help of the vector indicator library and the large language model.
[0077] Before vector knowledge base matching and large language model processing, a FAQ robot can be used to filter the question text. Question texts for which the FAQ robot cannot obtain answer texts are then subjected to vector knowledge base matching and large language model processing to further improve the efficiency of human-computer dialogue.
[0078] To facilitate understanding, the following example illustrates the logical flow of human-computer dialogue. Figure 4 A logical schematic diagram of an example of human-computer dialogue control provided in an embodiment of this application, such as... Figure 4As shown, the original text can be summarized to obtain summary text. Frequently asked questions (FAQs), the original text, and the summary text can be converted into vectors through an embedding layer and stored in a vector knowledge base (VectorStore). First, the question text (Query) can be input into the FAQBot to determine if it can provide an answer. If it can, the answer text can be used as the target answer text. If it cannot, the question text can be converted into a text vector (QueryVector) through the embedding layer. This text vector can then be matched in the vector knowledge base to obtain the first matching result. This first matching result can then be processed into a prompt word, which is output as the input to the large language model. The output of the large language model is then used as the target answer text for the question text.
[0079] In some embodiments, question texts of certain patterns may skip matching in the vector knowledge base and adopt other more efficient matching methods. It can be determined whether the question text meets preset matching conditions; if the question text meets the preset matching conditions, the matching method corresponding to the matching conditions is used to match the question text to obtain a second matching result; based on the question text, the second matching result, and the prompt word generation criteria, a second prompt word is generated; the second prompt word is input into the large language model, and the output of the large language model is determined as the target answer text.
[0080] Matching criteria can be used to determine question text that is more suitable for other matching methods. If matching the question text that meets the matching criteria is more efficient using the matching method corresponding to the matching criteria than using a vector knowledge base, then the more efficient matching method can be selected. The second matching result includes the matching result obtained by matching the question text using the matching method corresponding to the matching criteria. A second prompt word can be generated based on the question text, the second matching result, and the prompt word generation criteria. The method for generating the second prompt word is similar to the method for generating the first prompt word in the above embodiments and will not be repeated here. Optimized text can be generated based on the prompt word generation criteria. The second prompt word may include the question text, the second matching result, and the optimized text. For example, if the question text is a single-character keyword, an inverted index search method can be used to obtain the second matching result. Based on the question text, the second matching result, and the prompt word generation criteria, a second prompt word is generated and input into a large language model for processing.
[0081] In some embodiments, if the matching degree parameter, which represents the matching degree of the text vector with the vectors in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library, is less than the matching degree threshold, then the question text is input into the large language model, and the output of the large language model is determined as the target answer text.
[0082] The matching degree parameter, which represents the matching degree of the vectors in the text vector and the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library, is all less than the matching degree threshold. This indicates that the answer text corresponding to the question text is not in the corresponding text types in the knowledge vector library. The question text can be directly input into the large language model, and the large language model's own capabilities can be used for open-domain question answering to ensure that the obtained target answer text is relatively accurate and objective.
[0083] The second aspect of this application provides a human-computer dialogue control device. Figure 5 This is a schematic diagram of the structure of a human-computer dialogue control device provided in an embodiment of this application, as shown below. Figure 5 As shown, the human-computer dialogue control device 200 may include a vector acquisition module 201, a first matching module 202, a prompt word generation module 203, and a large language processing module 204.
[0084] The vector acquisition module 201 can be used to acquire the text vector of the question text.
[0085] The first matching module 202 can be used to match text vectors in multiple vector sub-libraries in a preset vector knowledge base according to the order of information entropy from high to low, and obtain the first matching result. The types of text corresponding to vectors in different vector sub-libraries are different.
[0086] The prompt word generation module 203 can be used to generate the first prompt word based on the question text, the first matching result, and the preset prompt word generation criteria.
[0087] The large language processing module 204 can be used to input the first prompt word into a pre-trained large language model and determine the output of the large language model as the target answer text corresponding to the question text.
[0088] In this embodiment, the question text is first obtained. Then, using the text vector of the question text, it is matched against vectors in multiple sub-vector libraries within a pre-defined vector knowledge base, arranged in descending order of information entropy, to obtain a first matching result. Since the matching is done in descending order of information entropy, the content in the first matching result contains information with a relatively higher information content. The prompt words are optimized using prompt word generation criteria. The optimized content, the first matching result serving as the context of the question text, and the question text are input together into a large language model. The first matching result and the optimized content are used to suppress the divergence of the large language model, thereby improving the model illusion problem and enabling the large language model to output more accurate answer text, thus improving the accuracy of answer retrieval in human-computer dialogue. Compared to traditional FAQ-based human-computer dialogue, the human-computer dialogue control method in this embodiment does not require a large amount of manpower to sort and obtain a large number of vertically deep FAQ question-answer pairs, ensuring the accuracy of answer retrieval in human-computer dialogue, saving labor costs, and improving the efficiency of establishing a human-computer dialogue control system.
[0089] In some embodiments, the vector knowledge base includes a common question answer vector sub-base, a summary text vector sub-base, and a raw text vector sub-base. The first matching module 202 can be specifically used to: sequentially match the text vectors in the common question answer vector sub-base, the summary text vector sub-base, and the raw text vector sub-base to obtain a matching degree parameter between the text vector and the vectors in the common question answer vector sub-base, the summary text vector sub-base, and the raw text vector sub-base; determine a matching vector in the common question answer vector sub-base, the summary text vector sub-base, and the raw text vector sub-base based on the matching degree parameter and a preset matching degree threshold, wherein the matching degree represented by the matching degree parameter of the matching vector is greater than or equal to the matching degree threshold; and determine the text corresponding to the matching vector as the first matching result.
[0090] In some examples, the frequently asked questions and answers vector sub-library includes a first knowledge vector derived from frequently asked questions and answers segmented by knowledge points. The summary text vector sub-library includes a second knowledge vector derived from summary text segmented by knowledge points. The original text vector sub-library includes sentence vectors of the original text.
[0091] In some embodiments, the prompt word generation module 203 may be specifically used to: generate optimized text based on prompt word generation criteria; and generate a first prompt word according to the prompt word generation criteria, based on at least a portion of the first matching result, the question text, and the optimized text, wherein the length of the first prompt word is less than or equal to the input requirement length of the large language model.
[0092] In some examples, the number of matching vectors corresponding to the first match result included in the first prompt word is less than or equal to the preset number of matches. The optimized text includes one or more of the following: scene setting text, character setting text, and authenticity condition setting text. At least a portion of the first match result is known information from the first prompt word. The first match result in the first prompt word, the optimized text, and the question text are separated by a separator.
[0093] In some embodiments, the human-computer dialogue control device 200 may further include a decision module. The decision module may be used to: input the question text into the frequently asked question answering robot; if the frequently asked question answering robot provides an answer text, then determine the provided answer text as the target answer text corresponding to the question text.
[0094] The vector acquisition module 201 can be specifically used to: if the frequently asked question answering robot does not provide an answer text, then acquire the text vector of the question text.
[0095] In some embodiments, the human-computer dialogue control device 200 may further include a second matching module. The second matching module can be used to: if the question text meets preset matching conditions, then use the matching method corresponding to the matching conditions to match the question text to obtain a second matching result. The efficiency of matching the question text that meets the matching conditions using the matching method corresponding to the matching conditions is higher than the efficiency of matching the question text using a vector knowledge base.
[0096] The prompt word generation module 203 can also be used to generate a second prompt word based on the question text, the second matching result, and the prompt word generation criteria.
[0097] The large language processing module 204 can also be used to: input the second prompt word into the large language model and determine the output of the large language model as the target answer text.
[0098] In some embodiments, the large language processing module 204 is further configured to: if the matching degree parameter representing the matching degree of the text vector with the vectors in the common question answer vector sub-library, the summary text vector sub-library, and the original text vector sub-library is less than the matching degree threshold, then input the question text into the large language model and determine the output of the large language model as the target answer text.
[0099] A third aspect of this application also provides an electronic device. Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6 As shown, the electronic device 300 includes a memory 301, a processor 302, and a computer program stored in the memory 301 and executable on the processor 302.
[0100] In some examples, the processor 302 described above may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits that may be configured to implement the embodiments of this application.
[0101] Memory 301 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the human-computer dialogue control method according to embodiments of this application.
[0102] The processor 302 runs a computer program corresponding to the executable program code by reading the executable program code stored in the memory 301, so as to implement the human-computer dialogue control method in the above embodiments.
[0103] In some examples, the electronic device 300 may also include a communication interface 303 and a bus 304. For example, Figure 6 As shown, the memory 301, processor 302, and communication interface 303 are connected through bus 304 and complete communication with each other.
[0104] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application. Input devices and / or output devices can also be connected through the communication interface 303.
[0105] Bus 304 includes hardware, software, or both, that couples components of electronic device 300 together. For example, and not limitingly, bus 304 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-E) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 304 may include one or more buses. Although specific buses are described and illustrated in the embodiments of this application, this application considers any suitable bus or interconnection.
[0106] A fourth aspect of this application also provides a computer-readable storage medium storing computer program instructions. When these computer program instructions are executed by a processor, they can implement the human-computer dialogue control method described in the above embodiments and achieve the same technical effect. To avoid repetition, further details are omitted here. The aforementioned computer-readable storage medium may include non-transitory computer-readable storage media, such as read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, etc., and is not limited thereto.
[0107] This application provides a computer program product. When the instructions in the computer program product are executed by the processor of an electronic device, the electronic device performs the human-computer dialogue control method described above and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0108] It should be clarified that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. For the device embodiments, equipment embodiments, and computer-readable storage medium embodiments, the relevant parts can be referred to the description section of the method embodiments. This application is not limited to the specific steps and structures described above and shown in the figures. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application. Furthermore, for the sake of brevity, detailed descriptions of known methods and techniques are omitted here.
[0109] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0110] Those skilled in the art will understand that the above embodiments are exemplary and not restrictive. Different technical features appearing in different embodiments can be combined to achieve beneficial effects. Based on a study of the drawings, specification, and claims, those skilled in the art should be able to understand and implement other variations of the disclosed embodiments. In the claims, the term "comprising" does not exclude other means or steps; the quantifier "a" does not exclude a plurality; the terms "first" and "second" are used to identify names and not to indicate any particular order. No reference numerals in the claims should be construed as limiting the scope of protection. The functionality of multiple parts appearing in the claims can be implemented by a single hardware or software module. The appearance of certain technical features in different dependent claims does not mean that these technical features cannot be combined to achieve beneficial effects.
Claims
1. A human-machine dialog control method, characterized by, The method comprises: obtaining a text vector of a question text; matching the text vector in a plurality of vector sub-libraries in a preset vector knowledge base in a descending order of information entropy corresponding to the vector sub-libraries to obtain a first matching result, the types of texts corresponding to vectors in different vector sub-libraries are different, the information entropy corresponding to the vector sub-libraries is the information entropy of the vectors corresponding to the types of texts, and the higher the information entropy, the higher the amount of information that can be transmitted; generating a first prompt word according to the question text, the first matching result, and a preset prompt word generation criterion; inputting the first prompt word into a pre-trained large language model, and determining an output result of the large language model as a target answer text corresponding to the question text.
2. The method of claim 1, wherein, The vector knowledge base comprises a common question and answer vector sub-library, an abstract text vector sub-library, and an original text vector sub-library, The matching of the text vector in a plurality of vector sub-libraries in a preset vector knowledge base in a descending order of information entropy corresponding to the vector sub-libraries to obtain a first matching result comprises: matching the text vector in the common question and answer vector sub-library, the abstract text vector sub-library, and the original text vector sub-library in sequence to obtain a matching degree parameter of the text vector and the vectors in the common question and answer vector sub-library, the abstract text vector sub-library, and the original text vector sub-library; determining a matching vector in the common question and answer vector sub-library, the abstract text vector sub-library, and the original text vector sub-library according to the matching degree parameter and a preset matching degree threshold value, and the matching degree represented by the matching degree parameter of the matching vector is greater than or equal to the matching degree threshold value; determining a text corresponding to the matching vector as the first matching result.
3. The method of claim 2, wherein: the common question and answer vector sub-library comprises first knowledge vectors converted from common question and answer pairs according to knowledge points; the abstract text vector sub-library comprises second knowledge vectors converted from abstract texts according to knowledge points; the original text vector sub-library comprises sentence vectors of original texts.
4. The method of claim 1, wherein, The generation of a first prompt word according to a question text, a first matching result, and a preset prompt word generation criterion comprises: generating an optimized text based on the prompt word generation criterion; generating the first prompt word according to at least part of the first matching result, the question text, and the optimized text according to the prompt word generation criterion, and the length of the first prompt word is less than or equal to the input requirement length of the large language model.
5. The method of claim 4, wherein: the first prompt word comprises a number of matching vectors corresponding to the first matching result, and the number is less than or equal to a preset matching number; the optimized text comprises one or more of a scene setting text, a role setting text, and a reality condition setting text; at least part of the first matching result is known information in the first prompt word; the first matching result, the optimized text, and the question text in the first prompt word are separated by a separator.
6. The method of claim 1, wherein, Before the text vector of the question text is acquired, further comprising: inputting the question text into a common question answering robot; if the common question answering robot feeds back an answer text, determining the fed back answer text as the target answer text corresponding to the question text; acquiring the text vector of the question text, comprising: if the common question answering robot does not feed back an answer text, acquiring the text vector of the question text.
7. The method of claim 1, wherein, Before the text vector of the question text is acquired, further comprising: if the question text meets a preset matching condition, matching the question text by using a matching method corresponding to the matching condition to obtain a second matching result, and the efficiency of matching the question text by using the matching method corresponding to the matching condition is higher than the efficiency of matching the question text by using the vector knowledge base; generating a second prompt word according to the question text, the second matching result and the prompt word generation criterion; inputting the second prompt word into the large language model, and determining the output result of the large language model as the target answer text.
8. The method of claim 2, wherein, Further comprising: if the matching degree represented by the matching degree parameter of the text vector and the vectors in the common question answering vector sub-library, the summary text vector sub-library and the original text vector sub-library is all less than the matching degree threshold, inputting the question text into the large language model, and determining the output result of the large language model as the target answer text.
9. An apparatus for controlling a dialogue with a human, characterized by Comprising: a vector acquisition module, configured to acquire a text vector of a question text; a first matching module, configured to match, by using the text vector, in a plurality of vector sub-libraries in a preset vector knowledge base in a sequence from high to low of information entropy corresponding to the vector sub-libraries, to obtain a first matching result, different vectors in different vector sub-libraries correspond to different types of texts, the information entropy corresponding to the vector sub-library is the information entropy of the vector corresponding to the type of text, and the higher the information entropy, the higher the amount of information that can be transmitted; a prompt word generation module, configured to generate a first prompt word according to the question text, the first matching result and a preset prompt word generation criterion; a large language processing module, configured to input the first prompt word into a pre-trained large language model, and determine the output result of the large language model as a target answer text corresponding to the question text.
10. An electronic device, comprising: Comprising: a processor and a memory having computer program instructions stored therein; the processor executes the computer program instructions to implement the man-machine dialogue control method in any one of claims 1 to 8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium has computer program instructions stored thereon, and the computer program instructions are executed by the processor to implement the man-machine dialogue control method in any one of claims 1 to 8.
Citation Information
Patent Citations
Text processing method and device, server and storage medium
CN112507088A
Question and answer robot reply optimization method and device, electronic equipment and storage medium
CN116701605A