Question and answer interaction method and device based on large language model data vectorization query
Patent Information
- Application Number
- CN202311807652.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-12-25
AI Technical Summary
但是,现有技术中问答系统,均强烈依赖大量的数据检索工作,如何在海量数据中,快速检索得到准确的答案,一直是研究的重点内容
[0021]根据本申请的基于大语言模型数据向量化查询的问答交互方法、装置、电子设备及计算机可读介质,通过对用户的输入数据进行语义识别,确定所述输入数据对应的问题类别;根据所述问题类别确定目标向量数据库;将所述输入数据转化为输入向量;利用所述输入向量在所述目标向量数据库中进行向量查询,并拼接成查询结果;通过所述输入数据和所述查询结果生成提示问题;将所述提示问题输入大语言模型中,获取逻辑分析结果;在所述逻辑分析结果为正向结果时,根据所述逻辑分析结果进行问答交互的方式,能够为用户提供智能化的问题回复方式,提升人机智能对话和问题查询的回答质量和准确性。
Smart Images

Figure CN117951268B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer information processing, and more specifically, to a question-and-answer interaction method, apparatus, electronic device, and computer-readable medium based on large language model data vectorization query. Background Technology
[0002] Intelligent Question Answering (IQA) is a core subfield of Natural Language Processing (NLP), aiming to design and develop systems that can parse, understand, and answer natural language questions posed by users. These systems go beyond simply returning text relevant to the question; they provide precise, concise, and direct answers.
[0003] One of the core components of an intelligent question-answering system is semantic understanding, which means the system needs to deeply understand the user's intent and the meaning behind their question. To answer questions, intelligent question-answering systems typically need to access large knowledge bases or databases containing vast amounts of facts, data, and information.
[0004] Knowledge-based question-answering systems are designed specifically to answer questions based on facts and data. They rely on predefined knowledge bases, which typically contain a large amount of facts, relationships, and other structured information. Retrieval-based question-answering systems, on the other hand, retrieve and return the most relevant answers from a large pre-existing document or FAQ set based on the semantic information of the user's question. Unlike knowledge-based systems, retrieval-based systems do not rely on structured data but rather on large amounts of textual data. In the past decade, breakthroughs in deep learning technology have led to a qualitative leap in question-answering systems. Neural networks, especially recurrent neural networks (RNNs) and the Transformer architecture, enable models to handle complex semantic structures and long-range dependencies. However, existing question-answering systems heavily rely on extensive data retrieval; how to quickly retrieve accurate answers from massive amounts of data remains a key research focus.
[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] In view of this, this application provides a question-and-answer interaction method, device, electronic device, and computer-readable medium based on large language model data vectorization query, which can provide users with an intelligent way to answer questions and improve the quality and accuracy of answers to human-computer intelligent dialogue and question queries.
[0007] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0008] According to one aspect of this application, a question-answering interaction method based on vectorized querying of large language model data is proposed. The method includes: performing semantic recognition on user input data to determine the question category corresponding to the input data; determining a target vector database based on the question category; wherein the target vector database is used to store data of different categories after vectorization and multi-dimensional labeling; converting the input data into input vectors; performing vector queries on the target vector database using the input vectors and concatenating the results to form a query result; generating a prompt question based on the input data and the query result; inputting the prompt question into a large language model to obtain a logical analysis result; and performing question-answering interaction based on the logical analysis result when the logical analysis result is positive.
[0009] Optionally, it also includes: vectorizing the knowledge data in the knowledge database, setting multi-dimensional labels, and storing it in the knowledge vector database; vectorizing the question and answer data in the question and answer data, setting multi-dimensional labels, and storing it in the question and answer vector database.
[0010] Optionally, the knowledge data in the knowledge database is vectorized, multi-dimensional labels are set, and the data is stored in the knowledge vector database. This includes: removing symbols from the knowledge data in the knowledge database to generate multiple short knowledge sentences; concatenating the multiple short knowledge sentences to generate multiple knowledge phrases that do not exceed a length threshold; converting the multiple knowledge phrases into multiple knowledge phrase vectors; and setting multi-dimensional labels for each knowledge phrase vector and storing them in the knowledge vector database.
[0011] Optionally, multi-dimensional labels are set for the knowledge phrase vectors and stored in the knowledge vector database, including: using the text, source, and type of the knowledge data corresponding to the knowledge phrase vector as one of the multi-dimensional labels; using the index value of the knowledge phrase vector in its corresponding knowledge data as one of the multi-dimensional labels; assigning an identifier to the knowledge phrase vector and using it as one of the multi-dimensional labels; and storing the knowledge phrase vector and its corresponding multi-dimensional labels in the knowledge vector database.
[0012] Optionally, the question-and-answer data in the question-and-answer data is vectorized, multi-dimensional labels are set, and the data is stored in a question-and-answer vector database. This includes: combining the questions and answers in the question-and-answer data into question-and-answer blocks; separating the question data and answer data from the question-and-answer blocks; converting the question data into question vectors; converting the answer data into multiple answer phrase vectors; and setting multi-dimensional labels for the question vectors and their corresponding answer phrase vectors and storing them in the question-and-answer vector database.
[0013] Optionally, converting the answer data into multiple answer phrase vectors includes: removing symbols from the answer data to generate multiple answer short sentences; concatenating the multiple answer short sentences to generate multiple answer phrases not exceeding a length threshold; and converting the multiple answer phrases into multiple answer phrase vectors.
[0014] Optionally, multi-dimensional labels are set for the question vector and its corresponding answer phrase vector and stored in the question-and-answer vector database, including: using the text, source, and type of the question vector and its corresponding answer phrase vector as one of the multi-dimensional labels; using the index value of the answer phrase vector in its corresponding answer data as one of the multi-dimensional labels; assigning an identifier to the answer phrase vector and using it as one of the multi-dimensional labels; and storing the question vector, its corresponding answer phrase vector, and the multi-dimensional labels in the question-and-answer vector database.
[0015] Optionally, when the target vector database is a knowledge vector database, performing a vector query in the target vector database using the input vector and concatenating the results into a query result includes: performing a vector query in the knowledge vector database using the input vector to generate a predetermined number of knowledge phrase vectors as the return result; extracting the multi-dimensional label of the first knowledge phrase vector in the return result; extracting the identifier and index value from the multi-dimensional label; extracting the contextual knowledge phrases in the knowledge vector database based on the identifier and the index value; and concatenating the contextual knowledge phrases to generate the query result.
[0016] Optionally, when the target vector database is a question-and-answer vector database, the input vector is used to perform a vector query in the target vector database and concatenate the results to form a query result. This includes: performing a vector query in the question-and-answer vector database using the input vector to generate a predetermined number of answer phrase vectors as the returned results; extracting the multi-dimensional label of the first answer phrase vector in the returned results; extracting an identifier from the multi-dimensional label; extracting all answer phrases in the question-and-answer vector database that correspond to the identifier; and concatenating all answer phrases that correspond to the identifier to generate the query result.
[0017] Optionally, generating a prompt question based on the input data and the query results includes: extracting a pre-generated yes / no prompt question template; and filling the input data and the query results into predetermined positions in the prompt question template to generate the prompt question.
[0018] According to one aspect of this application, a question-and-answer interaction device based on vectorized querying of large language model data is proposed. The device includes: an input module for semantic recognition of user input data to determine the question category corresponding to the input data; a target module for determining a target vector database based on the question category; a vector module for converting the input data into input vectors; a query module for performing vector queries on the target vector database using the input vectors and concatenating the results into a query result; a question module for generating a prompt question based on the input data and the query result; a model module for inputting the prompt question into a large language model to obtain a logical analysis result; and a response module for performing question-and-answer interaction based on the logical analysis result when the logical analysis result is positive.
[0019] According to one aspect of this application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method as described above.
[0020] According to one aspect of this application, a computer-readable medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0021] According to the question-and-answer interaction method, apparatus, electronic device, and computer-readable medium based on large language model data vectorization query of this application, the question category corresponding to the user's input data is determined by semantic recognition; a target vector database is determined according to the question category; the input data is converted into an input vector; a vector query is performed on the target vector database using the input vector, and the results are concatenated to form a query result; a prompt question is generated based on the input data and the query result; the prompt question is input into a large language model to obtain a logical analysis result; and when the logical analysis result is positive, a question-and-answer interaction is performed based on the logical analysis result. This approach can provide users with an intelligent question response method, improving the quality and accuracy of human-computer intelligent dialogue and question query answers.
[0022] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0023] The above and other objects, features, and advantages of this application will become more apparent from the detailed description of exemplary embodiments with reference to the accompanying drawings. The drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0024] Figure 1 This is a flowchart illustrating a question-answering interaction method based on large language model data vectorization query according to an exemplary embodiment.
[0025] Figure 2 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment.
[0026] Figure 3 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment.
[0027] Figure 4 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment.
[0028] Figure 5 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment.
[0029] Figure 6 This is a block diagram illustrating a question-and-answer interactive device based on large language model data vectorization query according to an exemplary embodiment.
[0030] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation
[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.
[0032] Figure 1 This is a flowchart illustrating a question-answering interaction method based on large language model data vectorization query according to an exemplary embodiment. The question-answering interaction method 10 based on large language model data vectorization query includes at least steps S102 to S108.
[0033] like Figure 1 As shown, in S102, semantic recognition is performed on the user's input data to determine the question category corresponding to the input data.
[0034] It can acquire user-input voice or text data, and can also process the voice data through speech recognition and other methods to convert it into text data. Furthermore, it can perform semantic recognition on the text data to determine the question category corresponding to the user input data.
[0035] In this application, the question category may include knowledge base questions, which refer to databases specifically designed to answer questions based on facts and data. They rely on predefined knowledge bases, which typically contain a large amount of facts, relationships, and other structured information.
[0036] In this application, the question category may also include question-and-answer questions, which refer to retrieving and returning the most relevant answers from a pre-existing large document or FAQ set based on the semantic information of the user's question. Unlike knowledge-based question-and-answer systems, retrieval-based systems do not rely on structured data; the question-and-answer knowledge base is generated through system logs. The system logs store a large number of daily user questions and answers, some of which are obtained through database retrieval, and others through human customer service or other means.
[0037] In S104, a target vector database is determined based on the problem category;
[0038] In this application, the target vector database is used to store data of different categories after vectorization and multi-dimensional labeling. For example, it can be used to vectorize knowledge data in a knowledge database, assign multi-dimensional labels, and store the data in the knowledge vector database. Alternatively, it can be used to vectorize question-and-answer data in question-and-answer data, assign multi-dimensional labels, and store the data in the question-and-answer vector database. Therefore, in this application, the target vector database can at least include a knowledge vector database and a question-and-answer vector database.
[0039] The specific technical content for generating the knowledge vector database and the specific content for generating the question-answer vector database are respectively in... Figure 2 and Figure 4 The corresponding embodiments are described in detail. It is understood that in this application, other categories of databases can also be set up for retrieval based on the problem category, and can be followed... Figure 2 or Figure 4 The steps involved in processing the application are not limited to these steps.
[0040] In S106, the input data is converted into an input vector. A Chinese embedding model can be pre-trained using historical data from the system, and the input data is then input into the Chinese embedding model to generate the input vector.
[0041] In this application, the method of training and generating a Chinese embedding model using historical user log data of this system platform can perform more accurate vectorization processing on the data of this platform, thereby improving the accuracy and efficiency of subsequent query.
[0042] In step S108, the input vector is used to perform a vector query in the target vector database, and the results are concatenated to form the query result. The similarity between the input vector and all vectors in the target vector database is compared. If the similarity comparison result is greater than a threshold, the vector in that knowledge class is considered a hit vector.
[0043] Different data concatenation methods are determined based on different target vector databases, thereby generating query results. In this application, the data concatenation method for the knowledge vector database will be... Figure 3 The corresponding embodiments will be described in detail, and the data concatenation method of the question-answer vector database will be described in detail. Figure 5 The corresponding embodiments are described in detail.
[0044] In S110, a prompt question is generated based on the input data and the query results.
[0045] In one embodiment, a pre-generated yes / no judgment prompt question template can be extracted; the input data and the query results are respectively filled into predetermined positions in the prompt question template to generate the prompt question.
[0046] A yes / no statement prompt template could be, for example, the "promp" template. A statement template could be formatted as "Determine whether the following is correct, and if correct, provide a response."
[0047] Furthermore, judgment questions can be generated using the judgment template. For example, in the question-answer pairs described above, the constructed judgment questions could be:
[0048] Determine whether the following content is correct:
[0049] Q: What is the power of product XX?
[0050] A: The product's power rating is 2000W.
[0051] The response result is:
[0052] In step S112, the prompt question is input into the large language model to obtain the logical analysis results. The large language model answers the question according to its requirements, responding with "yes" or "no," or other similar answers such as "correct" or "incorrect." It could also respond with "valid" or "invalid," etc.
[0053] In S114, when the logical analysis result is positive, intelligent question-and-answer interaction is performed based on the logical analysis result.
[0054] In this application, a positive judgment result can be "yes," "correct," or similar terms. When the logical analysis result is positive, display data is generated based on the output of the large language model, and the display data is pushed to the user's end for question answering.
[0055] In the example described above, the output of the large language model could be "The power of product XX is 2000W", or it could be "The rated power of product XX is 2000W", etc. This application is not limited to these possibilities.
[0056] According to the question-answering interaction method based on large language model data vectorization query of this application, the question category corresponding to the user's input data is determined by semantic recognition; a target vector database is determined according to the question category; the input data is converted into input vectors; vector queries are performed on the target vector database using the input vectors, and the results are concatenated to form a query result; a prompt question is generated based on the input data and the query result; the prompt question is input into a large language model to obtain a logical analysis result; when the logical analysis result is positive, question-answering interaction is performed based on the logical analysis result. This method can provide users with an intelligent question response method, improving the quality and accuracy of human-computer intelligent dialogue and question query answers.
[0057] This application's question-answering interaction method based on vectorized querying of large language model data optimizes the strategy of storing data in the platform database using a vector library. This includes employing different text segmentation strategies based on different file content types, and then using different concatenation strategies for queries based on different file types, thereby improving the quality and accuracy of queries. Based on the document splitting and query strategies in this application, in practical applications, the quality and accuracy of the platform's query question-answering database are improved by at least 50%, and the accuracy of intelligent question-answering responses is improved by at least 30%.
[0058] It should be clearly understood that this application describes how specific examples are formed and used, but the principles of this application are not limited to any details of these examples. Rather, based on the teachings of the disclosure of this application, these principles can be applied to many other embodiments.
[0059] Figure 2 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment. Figure 2The process 20 shown is a detailed description of "vectorizing and organizing the knowledge data in the knowledge database, setting multi-dimensional labels, and storing it in the knowledge vector database".
[0060] like Figure 2 As shown, in S202, symbols in the knowledge data of the knowledge base are removed to generate multiple knowledge phrases. The knowledge data in the original platform's knowledge base is extracted. This original knowledge data is stored according to different knowledge categories, and the text size for each data point varies. The text corresponding to each knowledge data point is extracted one by one, and symbols are removed to obtain multiple knowledge phrases without symbols.
[0061] For example, the original knowledge data was "In the history of database development, databases have gone through various stages, including hierarchical databases, network databases, and relational databases, reflecting the rapid development of database technology in various aspects." After removing symbols, the generated knowledge sentences are as follows:
[0062] In the history of database development
[0063] Databases have evolved into hierarchical databases.
[0064] The development of network databases and relational databases at various stages
[0065] The rapid development of database technology in various aspects
[0066] In S204, the multiple knowledge phrases are concatenated to generate multiple knowledge phrases not exceeding a length threshold. The knowledge phrases mentioned above are concatenated to form knowledge phrases not exceeding 100 characters.
[0067] As mentioned above, the knowledge phrases generated by splicing can be:
[0068] "In the history of database development, databases have gone through various stages of development, such as hierarchical databases, network databases, and relational databases. Database technology has developed rapidly in all aspects."
[0069] In S206, the multiple knowledge phrases are converted into multiple knowledge phrase vectors. A Chinese embedding model can be pre-trained using historical data from the system, and the multiple knowledge phrases are input into the Chinese embedding model to generate multiple knowledge phrase vectors.
[0070] In step S208, multi-dimensional labels are assigned to the knowledge phrase vectors and stored in the knowledge vector database. The text, source, and type of the knowledge data corresponding to the knowledge phrase vector can be used as one of the multi-dimensional labels; the index value of the knowledge phrase vector in its corresponding knowledge data can also be used as one of the multi-dimensional labels; an identifier can be assigned to the knowledge phrase vector and used as one of the multi-dimensional labels; the knowledge phrase vector and its corresponding multi-dimensional labels are stored in the knowledge vector database.
[0071] More specifically, the text, source, type (text - file, question - Q&A, withelist - whitelist for different subsequent query strategies), index value (for subsequent query strategies), and unique identifier (for representing the entire file) corresponding to the knowledge vector data can be stored in the vector library. The index value refers to the position of the knowledge vector within the entire knowledge data.
[0072] For example, if a piece of knowledge data is broken down into five knowledge phrases: a, b, c, d, and e, and these five knowledge phrases belong to the same knowledge data, then they share a common unique identifier, such as 11111. Furthermore, based on the order of the knowledge phrases in the source document, each knowledge phrase is assigned an index.
[0073] The index of 'a' is 1;
[0074] The index of b is 2;
[0075] The index of c is 3;
[0076] The index of d is 4;
[0077] The index of e is 5.
[0078] In a specific embodiment, the text corresponding to the knowledge phrase "In the history of database development, databases have successively gone through various stages of development such as hierarchical databases, network databases, and relational databases, and database technology has developed rapidly in various aspects" is "database", the source is "knowledge database", the type is "text-file", the index value is "3", and the unique identifier is "66666". The above content can be combined with the knowledge phrase vector and stored in the knowledge vector database.
[0079] Figure 3 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment. Figure 3 The illustrated process 30 describes the process when the target vector database is a knowledge vector database. Figure 1The flowchart shows a detailed description of S108, "using the input vector to perform a vector query in the target vector database and concatenating the results into a query result".
[0080] like Figure 3 As shown, in S302, the input vector is used to perform a vector query in the knowledge vector database to generate a predetermined number of knowledge phrase vectors as the return result.
[0081] More specifically, similarity comparison can be used to perform vector queries in the knowledge vector database. Specifically, the similarity between the input vector and multiple knowledge phrase vectors in the knowledge vector database can be compared. A similarity threshold can be set, and when the similarity comparison result is greater than the threshold, the current knowledge phrase vector is temporarily stored as the hit data.
[0082] After the similarity comparison is completed, all the hit data are sorted from high to low similarity. Based on the pre-set number, the knowledge phrase vectors of the hit data are extracted from high to low similarity as the return results of this query.
[0083] In S304, extract the multidimensional label of the first knowledge phrase vector in the returned results. Extract the multidimensional label of the knowledge phrase vector with the highest similarity.
[0084] In S306, the identifier and index value are extracted from the multidimensional label.
[0085] In step S308, contextual knowledge phrases are extracted from the knowledge vector database based on the identifier and the index value. Adjacent knowledge phrase vectors can be extracted from the knowledge vector database based on the index value and the unique identifier.
[0086] In S310, the contextual knowledge phrases are concatenated to generate query results.
[0087] In one embodiment, for example, if the index value of the current knowledge phrase vector is 3 and its corresponding unique identifier is 3333333333333333, then the unique identifier of the data in the vector library is 33333333333333333, and the five knowledge phrases with index values of 1, 2, 3, 4, and 5 are concatenated to form the query result.
[0088] It is worth mentioning that the number of knowledge phrases extracted from the context can be set by the system. In the preceding text, knowledge phrases with two index values are extracted and then combined with knowledge phrases with two index values in the following text to generate the query result. It can also be set to extract knowledge phrases with five index values in the preceding text and then combined with knowledge phrases with one index value in the following text to generate the query result. This application is not limited to this.
[0089] Figure 4This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment. Figure 4 The process 40 shown is a detailed description of "vectorizing and organizing the question and answer data in the question and answer data, setting multi-dimensional labels and storing them in the question and answer vector database".
[0090] like Figure 4 As shown in step S402, questions and answers in the question-and-answer data are combined into question-and-answer blocks in a one-to-one correspondence. In the original question-and-answer database, questions and answers are stored separately; one question may correspond to multiple answers, or one answer may correspond to multiple questions.
[0091] First, combine the questions and answers one by one to generate a question-answer block where one question corresponds to one answer.
[0092] In S404, the question data and answer data in the question-answer block are separated.
[0093] In step S406, the problem data is converted into problem vectors. A Chinese embedding model can be pre-trained using historical data from the system, and the problem data is input into the Chinese embedding model to generate multiple problem vectors.
[0094] In step S408, the answer data is transformed into multiple answer phrase vectors. Symbols in the answer data are removed to generate multiple answer short sentences; these short sentences are then concatenated to generate multiple answer phrases not exceeding a length threshold; finally, these multiple answer phrases are transformed into multiple answer phrase vectors. The answer phrase vectors can be generated using the knowledge phrase vector generation method described above in the knowledge vector database. Further details are omitted here.
[0095] In step S410, multi-dimensional labels are assigned to the question vector and its corresponding answer phrase vector, and stored in the question-and-answer vector database. The text, source, and type of the question vector and its corresponding answer phrase vector are used as one of the multi-dimensional labels; the index value of the answer phrase vector in its corresponding answer data is used as one of the multi-dimensional labels; an identifier is assigned to the answer phrase vector and used as one of the multi-dimensional labels; the question vector, its corresponding answer phrase vector, and the multi-dimensional labels are stored in the question-and-answer vector database.
[0096] In one embodiment, the text, vector value, source, type (text - file, question - question and answer, withelist - whitelist phrases used for different subsequent query strategies), index value (used for subsequent query strategies), and unique identifier (used to represent the identifier of the entire file) and other parameters of the question vector and its corresponding answer phrase vector can be stored in the question and answer vector database.
[0097] Figure 5 This is a flowchart illustrating a question-and-answer interaction method based on large language model data vectorization query according to another exemplary embodiment. Figure 5 The illustrated process 50 describes the process when the target vector database is a question-and-answer vector database. Figure 1 The flowchart shows a detailed description of S108, "using the input vector to perform a vector query in the target vector database and concatenating the results into a query result".
[0098] like Figure 5 As shown, in S502, the input vector is used to perform a vector query in the question-and-answer vector database to generate a predetermined number of answer phrase vectors as the return result.
[0099] More specifically, vector queries can be performed on the question-and-answer vector database through similarity comparison. Specifically, the similarity between the input vector and multiple answer phrase vectors in the question-and-answer vector database can be compared. A similarity threshold can be set, and when the similarity comparison result is greater than the threshold, the current answer phrase vector is temporarily stored as the hit data.
[0100] After the similarity comparison is completed, all the hit data are sorted from high to low similarity. Based on the pre-set number, the answer phrase vectors of the hit data are extracted from high to low similarity as the return results of this query.
[0101] In S504, extract the multidimensional label of the first answer phrase vector in the returned results. Extract the multidimensional label of the answer phrase vector with the highest similarity.
[0102] In S506, the identifier is extracted from the multidimensional label.
[0103] In step S508, all answer phrases corresponding to the identifier are extracted from the question-and-answer vector database. Adjacent vector content can be retrieved from the vector database based on the unique identifier. For example, if the unique identifier of the current answer phrase vector is 33333333333333333, then all answer phrases with the unique identifier 33333333333333333 are extracted from the vector database.
[0104] In step S510, all answer phrases corresponding to the identifier are concatenated to generate the query result. All answer phrases uniquely identified by the data in the vector library as 3333333333333333 can be concatenated into a complete question and answer. When generating the answer content, the concatenation can be performed according to the order of the index values of all answer phrases identified as 33333333333333333.
[0105] Those skilled in the art will understand that all or part of the steps of the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, it performs the functions defined by the method provided in this application. The program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk, or an optical disk.
[0106] Furthermore, it should be noted that the above figures are merely illustrative representations of the processes included in the method according to exemplary embodiments of this application, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0107] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0108] Figure 6 This is a block diagram illustrating a question-and-answer interaction device based on large language model data vectorization query, according to an exemplary embodiment. Figure 6 As shown, the question-answering interaction device 60 based on large language model data vectorization query includes: input module 602, target module 604, vector module 606, query module 608, question module 610, model module 612, response module 614, and database module 616.
[0109] Input module 602 is used to perform semantic recognition on user input data to determine the question category corresponding to the input data;
[0110] Target module 604 is used to determine a target vector database based on the problem category;
[0111] Vector module 606 is used to convert the input data into an input vector;
[0112] The query module 608 is used to perform vector queries in the target vector database using the input vector and concatenate the results into a query result;
[0113] When the target vector database is a knowledge vector database, the query module 608 is used to perform vector queries in the knowledge vector database using the input vector, generate a predetermined number of knowledge phrase vectors as the return result; extract the multi-dimensional label of the first knowledge phrase vector in the return result; extract the identifier and index value from the multi-dimensional label; extract the context knowledge phrases in the knowledge vector database according to the identifier and the index value; and concatenate the context knowledge phrases to generate the query result.
[0114] When the target vector database is a question-and-answer vector database, the query module 608 is used to perform a vector query in the question-and-answer vector database using the input vector, generate a predetermined number of answer phrase vectors as the return result; extract the multi-dimensional label of the first answer phrase vector in the return result; extract the identifier from the multi-dimensional label; extract all answer phrases in the question-and-answer vector database that correspond to the identifier; and concatenate all answer phrases that correspond to the identifier to generate the query result.
[0115] The question module 610 is used to generate a prompt question based on the input data and the query results;
[0116] Model module 612 is used to input the prompt question into the large language model and obtain the logical analysis results;
[0117] The response module 614 is used to perform question-and-answer interaction based on the logical analysis result when the logical analysis result is positive.
[0118] Database module 616 is used to vectorize and organize knowledge data in the knowledge database, set multi-dimensional labels, and store them in the knowledge vector database; database module 616 is also used to vectorize question and answer data in the question and answer data, set multi-dimensional labels, and store them in the question and answer vector database.
[0119] According to the question-answering interaction device based on large language model data vectorization query of this application, the question category corresponding to the user's input data is determined by semantic recognition; a target vector database is determined according to the question category; the input data is converted into input vectors; vector queries are performed on the target vector database using the input vectors, and the results are concatenated to form a query result; a prompt question is generated based on the input data and the query result; the prompt question is input into a large language model to obtain a logical analysis result; and when the logical analysis result is positive, question-answering interaction is performed based on the logical analysis result. This method can provide users with an intelligent question response method, improving the quality and accuracy of human-computer intelligent dialogue and question query answers.
[0120] like Figure 7 As shown, this application provides an electronic device including a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740.
[0121] Memory 730 is used to store computer programs;
[0122] When the processor 710 executes the program stored in the memory 730, it implements the question-and-answer interaction method based on large language model data vectorization query of any of the above embodiments.
[0123] The communication interface 720 is used for communication between the aforementioned electronic device and other devices.
[0124] The memory 730 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device 730. Optionally, the memory 730 may also be at least one storage device located remotely from the aforementioned processor 710.
[0125] This application provides a computer-readable storage medium storing one or more programs, which can be executed by one or more processors to implement the question-answering interaction method based on large language model data vectorization query of any of the above embodiments. For example, semantic recognition is performed on user input data to determine the question category corresponding to the input data; a target vector database is determined based on the question category; the input data is converted into input vectors; vector queries are performed on the target vector database using the input vectors, and the results are concatenated to form a query result; a prompt question is generated using the input data and the query result; the prompt question is input into a large language model to obtain a logical analysis result; and when the logical analysis result is positive, question-answering interaction is performed based on the logical analysis result.
[0126] Exemplary embodiments of this application have been specifically shown and described above. It should be understood that this application is not limited to the detailed structures, arrangements, or implementation methods described herein; rather, this application is intended to cover various modifications and equivalent arrangements contained within the spirit and scope of the appended claims.
Claims
1. A question-answering interaction method based on vectorized query of large language model data, characterized in that, include: Perform semantic recognition on the user's input data to determine the question category corresponding to the input data; A target vector database is determined based on the problem category; wherein, the target vector database is used to store data of different categories after vectorization and multi-dimensional labeling; The input data is converted into an input vector; When the target vector database is a knowledge vector database, the input vector is used to perform a vector query in the knowledge vector database to generate a predetermined number of knowledge phrase vectors as the return result; the multi-dimensional label of the first knowledge phrase vector in the return result is extracted; the identifier and index value are extracted from the multi-dimensional label; the context knowledge phrases in the knowledge vector database are extracted according to the identifier and the index value; and the context knowledge phrases are concatenated to generate the query result. When the target vector database is a question-and-answer vector database, the input vector is used to perform a vector query in the question-and-answer vector database to generate a predetermined number of answer phrase vectors as the return result; the multi-dimensional label of the first answer phrase vector in the return result is extracted; an identifier is extracted from the multi-dimensional label; all answer phrases corresponding to the identifier in the question-and-answer vector database are extracted; and all answer phrases corresponding to the identifier are concatenated to generate the query result. A prompt question is generated based on the input data and the query results; Input the prompt question into the large language model and obtain the logical analysis results; When the logical analysis result is positive, a question-and-answer interaction is performed based on the logical analysis result.
2. The method as described in claim 1, characterized in that, Also includes: The knowledge data in the knowledge database is vectorized, multi-dimensional labels are set, and the data is stored in the knowledge vector database. The question and answer data in the question and answer data are vectorized, multi-dimensional labels are set, and the data is stored in the question and answer vector database.
3. The method as described in claim 2, characterized in that, The knowledge data in the knowledge database is vectorized, multi-dimensional labels are assigned, and the data is stored in the knowledge vector database, including: Remove symbols from the knowledge data in the knowledge base to generate multiple short knowledge sentences; The multiple knowledge phrases are concatenated to generate multiple knowledge phrases that do not exceed a length threshold; Transform the multiple knowledge phrases into multiple knowledge phrase vectors; Multidimensional labels are assigned to the knowledge phrase vectors and stored in the knowledge vector database.
4. The method as described in claim 3, characterized in that, Assigning multidimensional labels to the knowledge phrase vectors and storing them in the knowledge vector database includes: The text, source, and type of the knowledge data corresponding to the knowledge phrase vector are used as one of the multi-dimensional tags; The index value of the knowledge phrase vector in its corresponding knowledge data is used as one of the multidimensional labels; Assign an identifier to the knowledge phrase vector and use it as one of the multi-dimensional labels; The knowledge phrase vectors and their corresponding multidimensional labels are stored in the knowledge vector database.
5. The method as described in claim 2, characterized in that, The question-and-answer data is vectorized, multi-dimensional labels are assigned, and the data is stored in a question-and-answer vector database, including: The questions and answers in the question-and-answer data are matched one-to-one to form question-and-answer blocks; Separate the question and answer data from the question-answer block; Transform the problem data into a problem vector; The answer data is converted into multiple answer phrase vectors; Multidimensional labels are assigned to the question vector and its corresponding answer phrase vector, and stored in the question-answer vector database.
6. The method as described in claim 5, characterized in that, The answer data is converted into multiple answer phrase vectors, including: Remove symbols from the answer data to generate multiple short answer sentences; The multiple answer phrases are concatenated to generate multiple answer phrases that do not exceed a length threshold; The multiple answer phrases are transformed into multiple answer phrase vectors.
7. The method as described in claim 5, characterized in that, Multidimensional labels are assigned to the question vector and its corresponding answer phrase vector, and stored in the question-answer vector database, including: The text, source, and type of the question vector and its corresponding answer phrase vector are used as one of the multi-dimensional tags; The index value of the answer phrase vector in its corresponding answer data is used as one of the multidimensional labels; Assign an identifier to the answer phrase vector and use it as one of the multidimensional labels; The question vector, its corresponding answer phrase vector, and multidimensional labels are stored in the question-answer vector database.
8. The method as described in claim 1, characterized in that, The system generates prompt questions based on the input data and the query results, including: Extract pre-generated yes / no judgment prompt question templates; The input data and the query results are respectively filled into the predetermined positions in the prompt question template to generate the prompt question.
9. A question-answering interactive device based on vectorized query of large language model data, characterized in that, include: The input module is used to perform semantic recognition on the user's input data and determine the question category corresponding to the input data. The target module is used to determine a target vector database based on the problem category, wherein the target vector database is used to store data of different categories after vectorization and setting multidimensional labels; The vector module is used to convert the input data into an input vector; The query module is configured to: when the target vector database is a knowledge vector database, perform a vector query in the knowledge vector database using the input vector to generate a predetermined number of knowledge phrase vectors as the return result; extract the multi-dimensional label of the first knowledge phrase vector in the return result; extract the identifier and index value from the multi-dimensional label; extract the context knowledge phrases in the knowledge vector database based on the identifier and the index value; and concatenate the context knowledge phrases to generate the query result; when the target vector database is a question-and-answer vector database, perform a vector query in the question-and-answer vector database using the input vector to generate a predetermined number of answer phrase vectors as the return result; extract the multi-dimensional label of the first answer phrase vector in the return result; extract the identifier from the multi-dimensional label; extract all answer phrases in the question-and-answer vector database corresponding to the identifier; and concatenate all answer phrases corresponding to the identifier to generate the query result; The question module is used to generate prompt questions based on the input data and the query results; The model module is used to input the prompt question into the large language model and obtain the logical analysis results; The response module is used to perform question-and-answer interaction based on the logical analysis result when the logical analysis result is positive.
10. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1 to 8.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Multi-engine intelligent question answering system for multi-type knowledge base
CN115238101A
Text answer reasoning method and device and storage medium
CN116521834A
Method and system for optimizing man-machine conversation based on LLM model
CN117271735A