Question and answer method and device, computer equipment and storage medium
Through the combination of text embedding model and second language model, the problem and fact entries in the question and answer system are automatically processed, and the problem of manual extraction of question and answer is solved in the prior art is heavy and inefficient, and an efficient and accurate question and answer system is realized.
Patent Information
- Application Number
- CN202411582009.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-03-07
AI Technical Summary
The existing Q&A system relies on manual extraction of Q&A pairs, which is heavy and inefficient, and cannot fully parse document content, resulting in the system being unable to provide effective guidance when facing user questions, which can easily lead to incorrect reply and affect customer experience.
The text embedding model is used to vectorize the target problems entered by the user, and combined with the pre-extracted set of fact entry vectors, the similarity is calculated to obtain relevant fact entries, and the second language model is used to generate the reply content for the target questions.
It reduces the burden of manually extracting Q&A, improves Q&A efficiency and accuracy, and can quickly and accurately find fact entries related to user questions, and generate more targeted reply content.
Smart Images

Figure CN119577078A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method, apparatus, computer device, and storage medium. Background Art
[0002] Traditional question-answering systems mainly rely on the FAQ method, which requires manual extraction of a large number of knowledge points based on knowledge base documents to form question-answer pairs. Subsequently, the questions in these question-answer pairs are expanded based on similarity. When a user enters a question, the system will find the FAQ question that is most similar to the user's question in the existing FAQ and output the corresponding answer.
[0003] However, the existing FAQ method requires manual extraction of question-answer pairs, which is very arduous and requires a lot of manpower and material resources. Secondly, due to the limitations of manual extraction, it is impossible to fully analyze the factual content in the document, and it is easy to miss some important question-answer pairs, resulting in the system being unable to give effective guidance when facing user questions, which easily leads to wrong replies and affects customer experience. Therefore, it is necessary to improve and optimize the question-answering technology to improve the efficiency and accuracy of question-answering. Summary of the invention
[0004] The purpose of the embodiments of the present application is to propose a question-answering method, apparatus, computer device, and storage medium that can reduce the burden of manually extracting question-answer pairs and improve question-answering efficiency and accuracy.
[0005] In order to solve the above technical problems, the embodiment of the present application provides a question-answering method, which adopts the following technical solution:
[0006] Obtaining a target question input by a user, inputting the target question into a trained text embedding model, and using the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question;
[0007] Obtaining a pre-extracted fact item vector set, and calculating the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from knowledge base documents using a trained first language model, and performing vectorization processing on the extracted fact item set based on the text embedding model;
[0008] Acquire at least one fact item vector having the highest similarity to the question vector, and determine the fact item corresponding to the at least one fact item vector as a target fact item related to the target question;
[0009] The target question and the target fact entry are input into a trained second language model, and the second language model is used to generate a response content for the target question based on the target question and the target fact entry.
[0010] In order to solve the above technical problems, the embodiment of the present application further provides a question-answering device, which adopts the following technical solution:
[0011] A question processing module is used to obtain a target question input by a user, input the target question into a trained text embedding model, and use the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question;
[0012] a similarity calculation module, configured to obtain a pre-extracted fact item vector set, and calculate the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from knowledge base documents using a trained first language model, and performing vectorization processing on the extracted fact item set based on the text embedding model;
[0013] An item determination module, configured to obtain at least one fact item vector having the highest similarity to the question vector, and determine the fact item corresponding to the at least one fact item vector as a target fact item related to the target question;
[0014] The answer generation module is used to input the target question and the target fact entry into the trained second language model, and use the second language model to generate answer content for the target question based on the target question and the target fact entry.
[0015] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, which adopts the technical solution described below: the computer device includes a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the question-and-answer method described in any one of the above items when executing the computer-readable instructions.
[0016] In order to solve the above technical problems, an embodiment of the present application also provides a computer-readable storage medium, which adopts the following technical solution: the computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the question-and-answer method described in any one of the above items are implemented.
[0017] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0018] The embodiment of the present application can efficiently vectorize the target question to obtain a question vector by inputting the target question input by the user into the text embedding model. The question vectorization not only improves the processing efficiency of the question, but also preserves the characteristics of the question at the semantic level. By extracting fact items from the knowledge base document using the first language model and vectorizing the extracted fact items based on the text embedding model, the cumbersomeness and subjectivity of manual intervention are avoided, and the efficiency and accuracy of knowledge extraction are improved. By calculating the similarity between the question vector and each fact item vector in the fact item vector set, and obtaining the target fact item related to the target question based on the similarity, the fact item related to the user question can be found quickly and accurately, improving the response speed and accuracy of the system. By inputting the target question and the target fact item into the second language model, the reply content for the target question is generated, which not only takes into account the semantic characteristics of the target question, but also combines the fact items most relevant to the target question, so that the reply content is more targeted, effectively improving the efficiency and accuracy of question and answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0021] Figure 2 It is a flowchart of an embodiment of the question-answering method of the present application;
[0022] Figure 3 is a structural schematic diagram of an embodiment of the question-answering device of the present application;
[0023] Figure 4 It is a structural diagram of an embodiment of a computer device of the present application. DETAILED DESCRIPTION
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0025] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0027] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0028] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0029] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0030] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0031] It should be noted that the question-and-answer method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the question-and-answer device is generally arranged in the server / terminal device.
[0032] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0033] Continue to refer Figure 2 , shows a flow chart of an embodiment of a question-answering method according to the present application. The question-answering method comprises the following steps:
[0034] Step S201, obtaining a target question input by a user, inputting the target question into a trained text embedding model, and using the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question;
[0035] In this embodiment, the electronic device (eg Figure 1 The server / terminal device shown in the figure can obtain the target question input by the user through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 2G / 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0036] Specifically, the target question refers to the information that the user needs to query, usually presented in the form of natural language text. For example, "What is artificial intelligence" or "What is the weather like today". The text embedding model is a machine learning model that can convert natural language text into vector representations in a high-dimensional space. These vectors can capture the semantic information of the text, so that similar texts have similar representations in the vector space. The question vector refers to the vector obtained by vectorizing the target question through the text embedding model. The question vector is the representation of the target question in a high-dimensional space, contains the semantic information of the target question, and can be used for comparison and calculation with other vectors.
[0037] Specifically, a text embedding model is pre-trained, which can convert natural language text into a vector representation in a high-dimensional space while retaining the semantic information of the text. The text embedding model can be constructed using word embedding models such as Word2Vec, GloVe, FastText, and Transformer-based contextual embedding models such as BERT and GPT.
[0038] Specifically, a target question input by a user through a user interface (such as a webpage, application, etc.) is obtained. The target question is input into a trained text embedding model, and the target question is vectorized using the text embedding model to convert the target question into a vector representation of a preset dimension, which is the question vector corresponding to the target question.
[0039] In some optional implementations, the above-mentioned vectorization processing of the target question using the text embedding model to obtain the question vector corresponding to the target question may include the following steps:
[0040] Using the text embedding model, split the target question into a plurality of words, and extract the relationship between the plurality of words;
[0041] Specifically, the trained text embedding model is used to split the input target question into several words, which may include words, phrases or language structure units. The several words are subjected to natural language processing tasks such as grammatical parsing and semantic role labeling to identify the relationship between the words. The relationship between the words may include but is not limited to the sequential relationship, the upper and lower relationship, the synonym relationship, etc.
[0042] Mapping the vocabulary into entity nodes of a knowledge graph, mapping the relationships between the vocabulary into edges of a knowledge graph, and constructing a knowledge graph corresponding to the target question;
[0043] Specifically, the trained text embedding model is used to map the split words into entity nodes in the knowledge graph, which represent the key concepts or objects in the target question. The relationships between words are mapped into edges in the knowledge graph, which connect different entity nodes and represent the semantic connections between entity nodes. Based on the mapped entity nodes and edges, the knowledge graph corresponding to the target question is constructed. The knowledge graph is a structured representation that can clearly display the semantic information in the target question.
[0044] The constructed knowledge graph is input into a graph embedding algorithm, and based on the graph embedding algorithm, the entity nodes and edges in the knowledge graph are mapped to a vector space to obtain a vector representation of each entity node and edge as a problem vector corresponding to the target problem.
[0045] Specifically, the trained text embedding model is used to obtain a predefined graph embedding algorithm, which can map entity nodes and edges in the knowledge graph into a vector space while retaining the structural information of the knowledge graph. The graph embedding algorithm can be DeepWalk, Node2Vec, LINE, TransE and other algorithms. The constructed knowledge graph is input into the graph embedding algorithm, and the nodes and edges in the knowledge graph are traversed through the graph embedding algorithm, and each entity node and edge in the knowledge graph is mapped to the vector space to obtain a vector representation of each entity node and edge, and the vector representation of each entity node and edge is aggregated to obtain the question vector corresponding to the target question.
[0046] The embodiment of the present application can analyze the target problem in more detail and capture the various components of the target problem by splitting the target problem into several words and extracting the relationship between the words. Extracting the relationship between the words helps to understand the semantic structure and context of the target problem. By mapping the words to the entity nodes of the knowledge graph, mapping the relationship between the words to the edges of the knowledge graph, and constructing the knowledge graph corresponding to the target problem, the words and their relationships in the problem can be clearly displayed by constructing the knowledge graph, further enhancing the semantic features of the target problem, and making the vectorization processing more accurate and effective. By adopting the graph embedding algorithm, the complex knowledge graph structure can be mapped to a low-dimensional vector space. The vectorized representation allows the target problem to be efficiently calculated and compared in the vector space, improving the processing efficiency of the system.
[0047] Step S202, obtaining a pre-extracted fact item vector set, and calculating the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from knowledge base documents using a trained first language model, and performing vectorization processing on the extracted fact item set based on the text embedding model;
[0048] In this embodiment, the knowledge base document is a text collection containing a large number of fact entries. A fact entry is a basic information unit in a knowledge base document, which contains specific information about a subject or entity. For example, a fact entry may be "the earth is the third planet in the solar system". The first language model is a trained machine learning model that can extract and understand information from text based on natural language processing (NLP) technology. In this embodiment, the first language model is used to extract fact entries from the knowledge base document.
[0049] Specifically, a large amount of annotated data is collected in advance for training the first language model so that the model can extract factual items from the input text. The annotated data includes factual items and the text context corresponding to the factual items. After completing the training of the first language model, the pre-collected knowledge base document is obtained, and the knowledge base document is input into the trained first language model. The knowledge base document is subjected to factual item extraction by the trained first language model to obtain a set of factual items. The set of factual items is input into the trained text embedding model, and the extracted set of factual items is vectorized using the trained text embedding model to convert each factual item in the set of factual items into a corresponding factual item vector, thereby obtaining a set of factual item vectors composed of a plurality of factual item vectors.
[0050] Specifically, a pre-extracted fact entry vector set is obtained, each fact entry vector in the fact entry vector set is traversed, and the similarity between each fact entry vector and the question vector is calculated. The similarity calculation method can use a measurement method such as cosine similarity and Euclidean distance.
[0051] In some optional implementations, before using the text embedding model to obtain the pre-extracted fact entry vector set, the following steps may also be included:
[0052] Acquire a knowledge base document to be processed, wherein the knowledge base document includes at least one chapter;
[0053] Specifically, a knowledge base document to be processed is obtained, which can be stored in a local file system, a database or a server. The knowledge base document includes at least one chapter, and each chapter includes a series of related chapter information (such as chapter title, subsection title, paragraph division, etc.).
[0054] Using the trained first language model, extracting fact items from the knowledge base document according to the chapter information of the at least one chapter, to obtain a set of fact items corresponding to the knowledge base document;
[0055] Specifically, the trained first language model is used to parse the knowledge base document to be processed to identify and extract chapter information such as chapter titles, subsection titles, and paragraph divisions of at least one chapter, and the knowledge base document is divided into different chapter contents according to the identified chapter information, and fact items in each chapter content are identified and extracted to form a fact item set corresponding to the knowledge base document.
[0056] The fact item set is input into a trained text embedding model, and each fact item in the fact item set is vectorized using the text embedding model to obtain a fact item vector set corresponding to the fact item set.
[0057] Specifically, each fact entry in the fact entry set is traversed, and each fact entry is input into the trained text embedding model in turn. Each fact entry is vectorized using the text embedding model to convert each fact entry into a vector representation of a preset dimension. The vector representation is the fact entry vector corresponding to the fact entry, and each fact entry vector is combined to obtain a fact entry vector set.
[0058] The embodiment of the present application uses the trained first language model to extract factual items from knowledge base documents according to chapter information, and can automatically identify and extract key information from documents, significantly improving the efficiency of information extraction and avoiding the tediousness of manual screening and extraction. By inputting the extracted factual item set into the trained text embedding model for vectorization processing, the text semantic embedding of the extracted factual items is achieved to form a specific vector, so that the factual item texts with different expressions but similar semantics have a higher vector similarity, which is convenient for subsequent more accurate similarity matching with the question vector. Compared with the traditional solution that determines the question and answer matching method of similar items based on the hit volume of vocabulary, this solution can meet the differentiated questioning methods of different users and achieve higher answer accuracy.
[0059] In some optional implementations, the extracting of fact items from the knowledge base document according to the chapter information of the at least one chapter to obtain a set of fact items corresponding to the knowledge base document may include the following steps:
[0060] Extracting chapter information of at least one chapter from the knowledge base document according to a predefined regular expression;
[0061] Specifically, a regular expression is defined in advance according to a specific format required by chapter information in a knowledge base document, and the knowledge base document is scanned by the regular expression to extract chapter information of at least one chapter matching the regular expression.
[0062] Obtaining a predefined prompt word constraint, inputting the prompt word constraint and the chapter information into the first language model, and extracting at least one fact information from the knowledge base document according to the prompt word constraint using the first language model;
[0063] Specifically, a predefined prompt word constraint is obtained, which is pre-set according to the content characteristics of the knowledge base document and the knowledge granularity requirements of the target extraction task, and is used to guide the first language model to extract factual entries from the knowledge base document according to the chapter information. The prompt word constraint may include keywords, phrases, or specific sentence structures. The prompt word constraint and the chapter information are input into the trained first language model together, and the knowledge base document is divided into different chapter contents according to the chapter information by the first language model, and at least one factual information in each chapter content is identified and extracted according to the prompt word constraint.
[0064] The at least one piece of fact information is structured and sorted to obtain a set of fact items corresponding to the knowledge base document.
[0065] Specifically, each extracted fact information is organized in a structured format, including determining the subject, predicate, object and other elements in the fact information to obtain a fact entry that meets the format requirements. The structured and organized fact entries are combined to obtain a fact entry set corresponding to the knowledge base document.
[0066] The embodiment of the present application quickly locates and extracts chapter information through predefined regular expressions, which reduces the time cost of manual screening and positioning and significantly improves the extraction efficiency of factual entries. By using the first language model to extract factual information according to the prompt word constraint, it is possible to accurately identify and extract key information related to the prompt word, avoid extraction errors caused by differences in manual understanding, and improve the accuracy of factual entries. By designing clear prompt word constraints, the granularity of knowledge extraction can be controlled, solving the problem of knowledge omission or duplication caused by different extraction granularities, and improving the consistency and comparability of the extraction results.
[0067] In some optional implementations, the above-mentioned calculation of the similarity between the question vector and each fact entry vector in the fact entry vector set may include the following steps:
[0068] Obtain each fact entry vector in the fact entry vector set by traversing;
[0069] The dot product between the question vector and each of the fact entry vectors is calculated, and the calculated dot product is used as the similarity between the question vector and the corresponding fact entry vector.
[0070] Specifically, dot product is a method for calculating vector similarity. The larger the calculated value, the more similar the two vectors are. In a traversal manner, each fact entry vector is obtained from the fact entry vector set in turn. For each obtained fact entry vector, the dot product between the fact entry vector and the question vector is calculated, and the calculated dot product is used as the similarity between the fact entry vector and the question vector.
[0071] Exemplarily, the dot product between the fact entry vector and the question vector may be calculated using the following formula:
[0072] Where v is the question vector, w is the fact entry vector, and n is the dimension of the vector.
[0073] Step S203, obtaining at least one fact item vector having the highest similarity to the question vector, and determining the fact item corresponding to the at least one fact item vector as a target fact item related to the target question;
[0074] In this embodiment, the similarities between all fact entry vectors and the question vector are sorted according to the numerical values, so that the fact entry vectors with larger similarity values are ranked at the front, and a sorted list is obtained. A specified number of fact entry vectors with the highest similarity are obtained from the sorted list, and the specified number is at least one. For each obtained fact entry vector, the corresponding fact entry is searched, and the searched fact entry is determined as the target fact entry related to the target question.
[0075] Step S204: input the target question and the target fact entry into the trained second language model, and use the second language model to generate a response content for the target question based on the target question and the target fact entry.
[0076] In this embodiment, the second language model is a trained machine learning model that can understand natural language text and generate natural language responses based on the input text content. The second language model is based on deep learning technologies such as recurrent neural networks (RNNs), long short-term memory networks (LSTMs), Transformers, etc., and is trained with a large amount of text data to learn the grammar, semantics, and contextual relationships of the language. In this embodiment, the second language model can generate one or more response contents related to the question based on the input target question and target fact entry, using the learned language knowledge and contextual information.
[0077] Specifically, the acquired target question and target fact entry are input into the trained second language model, and the second language model generates one or more reply contents according to the target question and target fact entry by using the learned language knowledge and context information. The reply contents are coherent and meaningful texts related to the target question.
[0078] In some optional implementations, the step of inputting the target question and the target fact item into the trained second language model may include the following steps:
[0079] splicing the target fact entries to obtain fact entry texts;
[0080] Specifically, multiple target fact entries are spliced to form a coherent fact entry text. The splicing method of the fact entries can be determined according to the content and format of the fact entries. For example, if the fact entries are short sentences or phrases, punctuation marks such as spaces, commas or periods are used to connect them. If the fact entries contain more complex structures (such as lists, tables, etc.), the structures need to be converted into text form before splicing.
[0081] The target question and the fact entry text are concatenated to obtain a question-answer text pair, and the question-answer text pair is input into the trained second language model.
[0082] Specifically, the target question is concatenated with the concatenated fact item text to form a question-answer text pair. For example, appropriate conjunctions or punctuation marks are added between the target question and the fact item text to concatenate the target question and the fact item text into a question-answer text pair, and the question-answer text pair is input into the trained second language model.
[0083] The embodiment of the present application can integrate scattered information into a coherent fact entry text by splicing the target fact entry; by combining the target question with the spliced fact entry text to form a complete question-answer text pair, it helps to improve the concentration and readability of the information, making the question-answer pair easier to understand and analyze, and improving the processing efficiency and accuracy of the model.
[0084] The embodiment of the present application uses the above scheme, specifically by inputting the target question input by the user into the text embedding model, the target question can be efficiently vectorized to obtain the question vector. The question vectorization not only improves the processing efficiency of the question, but also preserves the characteristics of the question at the semantic level. By extracting fact items from the knowledge base document using the first language model, and vectorizing the extracted fact items based on the text embedding model, the cumbersomeness and subjectivity of manual intervention are avoided, and the efficiency and accuracy of knowledge extraction are improved. By calculating the similarity between the question vector and each fact item vector in the fact item vector set, and obtaining the target fact item related to the target question based on the similarity, the fact item related to the user question can be found quickly and accurately, and the response speed and accuracy of the system are improved. By inputting the target question and the target fact item into the second language model, the reply content for the target question is generated, which not only takes into account the semantic characteristics of the target question, but also combines the fact items most relevant to the target question, so that the reply content is more targeted, effectively improving the efficiency and accuracy of question and answer.
[0085] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned target questions, fact item vector sets, reply content and other information as well as other relevant data, the above-mentioned target questions, fact item vector sets, reply content and other information as well as other relevant data can also be stored in a node of a blockchain.
[0086] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0087] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0088] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0089] Further references Figure 3 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of a question-answering device, and the embodiment of the device is Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0090] like Figure 3 As shown, the question-answering device 400 of this embodiment includes: a question processing module 401, a similarity calculation module 402, an item determination module 403 and a reply generation module 404. Among them:
[0091] The question processing module 401 is used to obtain a target question input by a user, input the target question into a trained text embedding model, and use the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question;
[0092] A similarity calculation module 402 is used to obtain a pre-extracted fact item vector set, and calculate the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from the knowledge base document using the trained first language model and performing vectorization processing on the extracted fact item set based on the text embedding model;
[0093] An item determination module 403 is used to obtain at least one fact item vector with the highest similarity to the question vector, and determine the fact item corresponding to the at least one fact item vector as a target fact item related to the target question;
[0094] The answer generation module 404 is used to input the target question and the target fact entry into the trained second language model, and use the second language model to generate answer content for the target question based on the target question and the target fact entry.
[0095] In this embodiment, the target question refers to the information that the user needs to query, which is usually presented in the form of natural language text. For example, "What is artificial intelligence" or "What is the weather like today". The text embedding model is a machine learning model that can convert natural language text into vector representations in a high-dimensional space. These vectors can capture the semantic information of the text, so that similar texts have similar representations in the vector space. The question vector refers to the vector obtained after the target question is vectorized by the text embedding model. The question vector is the representation of the target question in a high-dimensional space, contains the semantic information of the target question, and can be used for comparison and calculation with other vectors.
[0096] Specifically, a text embedding model is pre-trained, which can convert natural language text into a vector representation in a high-dimensional space while retaining the semantic information of the text. The text embedding model can be constructed using word embedding models such as Word2Vec, GloVe, FastText, and Transformer-based contextual embedding models such as BERT and GPT.
[0097] Specifically, the question processing module 401 is used to obtain a target question input by a user through a user interface (such as a web page, an application, etc.), input the target question into a trained text embedding model, and use the text embedding model to vectorize the target question to convert the target question into a vector representation of a preset dimension, which is the question vector corresponding to the target question.
[0098] Specifically, a knowledge base document is a text collection containing a large number of factual entries. A factual entry is a basic information unit in a knowledge base document, which contains specific information about a certain subject or entity. For example, a factual entry may be "the earth is the third planet in the solar system". The first language model is a trained machine learning model that can extract and understand information from text based on natural language processing (NLP) technology. In this embodiment, the first language model is used to extract factual entries from the knowledge base document.
[0099] Specifically, a large amount of annotated data is collected in advance for training the first language model so that the model can extract factual items from the input text. The annotated data includes factual items and the text context corresponding to the factual items. After completing the training of the first language model, the pre-collected knowledge base document is obtained, and the knowledge base document is input into the trained first language model. The knowledge base document is subjected to factual item extraction by the trained first language model to obtain a set of factual items. The set of factual items is input into the trained text embedding model, and the extracted set of factual items is vectorized using the trained text embedding model to convert each factual item in the set of factual items into a corresponding factual item vector, thereby obtaining a set of factual item vectors composed of a plurality of factual item vectors.
[0100] Specifically, the similarity calculation module 402 is used to obtain a pre-extracted fact entry vector set, traverse each fact entry vector in the fact entry vector set, and calculate the similarity between each fact entry vector and the question vector. The similarity calculation method can use a measurement method such as cosine similarity and Euclidean distance.
[0101] Specifically, the entry determination module 403 is used to sort the fact entry vectors according to the similarity between all fact entry vectors and the question vector, so that the fact entry vectors with larger similarity values are arranged at the front, and a sorted list is obtained. A specified number of fact entry vectors with the highest similarity are obtained from the sorted list, and the specified number is at least one. For each obtained fact entry vector, the corresponding fact entry is searched, and the found fact entry is determined as the target fact entry related to the target question.
[0102] Specifically, the second language model is a trained machine learning model that can understand natural language text and generate natural language responses based on the input text content. The second language model is based on deep learning technologies such as recurrent neural networks (RNNs), long short-term memory networks (LSTMs), Transformers, etc., and is trained with a large amount of text data to learn the grammar, semantics, and contextual relationships of the language. In this embodiment, the second language model can generate one or more response contents related to the question based on the input target question and target fact entry, using the learned language knowledge and contextual information.
[0103] Specifically, the reply generation module 404 is used to input the acquired target question and target fact entry into the trained second language model, and generate one or more reply contents according to the target question and target fact entry by using the learned language knowledge and context information through the second language model. The reply content is a coherent and meaningful text related to the target question.
[0104] The question-answering device 400 of the embodiment of the present application can efficiently vectorize the target question to obtain a question vector by inputting the target question input by the user into the text embedding model. The question vectorization not only improves the processing efficiency of the question, but also preserves the characteristics of the question at the semantic level. By extracting fact items from the knowledge base document using the first language model and vectorizing the extracted fact items based on the text embedding model, the cumbersomeness and subjectivity of manual intervention are avoided, and the efficiency and accuracy of knowledge extraction are improved. By calculating the similarity between the question vector and each fact item vector in the fact item vector set, and obtaining the target fact item related to the target question based on the similarity, the fact item related to the user question can be found quickly and accurately, and the response speed and reply accuracy of the system are improved. By inputting the target question and the target fact item into the second language model, the reply content for the target question is generated, which not only takes into account the semantic characteristics of the target question, but also combines the fact items most relevant to the target question, so that the reply content is more targeted, effectively improving the efficiency and accuracy of question-answering.
[0105] In some optional implementations of this embodiment, the question processing module 401 may include a question splitting submodule, a graph construction submodule, and a vector mapping submodule.
[0106] A question splitting submodule, used to split the target question into a plurality of words by using the text embedding model, and extract the relationship between the plurality of words;
[0107] A graph construction submodule, used to map the vocabulary into entity nodes of the knowledge graph, map the relationships between the vocabulary into edges of the knowledge graph, and construct a knowledge graph corresponding to the target question;
[0108] The vector mapping submodule is used to input the constructed knowledge graph into the graph embedding algorithm, map the entity nodes and edges in the knowledge graph to the vector space based on the graph embedding algorithm, and obtain the vector representation of each entity node and edge as the problem vector corresponding to the target problem.
[0109] Specifically, the question splitting submodule is used to use the trained text embedding model to split the input target question into several words, which may include words, phrases or language structure units, etc. The several words are subjected to natural language processing tasks such as grammatical parsing and semantic role labeling to identify the relationship between the words. The relationship between the words may include but is not limited to the sequential relationship, the upper and lower relationship, the synonym relationship, etc.
[0110] Specifically, the graph construction submodule is used to use the trained text embedding model to map the split vocabulary into entity nodes in the knowledge graph, which represent the key concepts or objects in the target question. The relationship between the vocabulary is mapped into edges in the knowledge graph, which connect different entity nodes and represent the semantic connection between entity nodes. Based on the mapped entity nodes and edges, the knowledge graph corresponding to the target question is constructed. The knowledge graph is a structured representation that can clearly display the semantic information in the target question.
[0111] Specifically, the vector mapping submodule is used to use the trained text embedding model to obtain a predefined graph embedding algorithm, which can map the entity nodes and edges in the knowledge graph into the vector space while retaining the structural information of the knowledge graph. The graph embedding algorithm can be DeepWalk, Node2Vec, LINE, TransE and other algorithms. The constructed knowledge graph is input into the graph embedding algorithm, the nodes and edges in the knowledge graph are traversed through the graph embedding algorithm, and each entity node and edge in the knowledge graph is mapped to the vector space to obtain the vector representation of each entity node and edge, and the vector representation of each entity node and edge is aggregated to obtain the question vector corresponding to the target question.
[0112] The problem processing module 401 of the embodiment of the present application can analyze the target problem more carefully and capture the various components of the target problem by splitting the target problem into several words and extracting the relationship between the words. Extracting the relationship between the words helps to understand the semantic structure and context of the target problem. By mapping the words to the entity nodes of the knowledge graph, mapping the relationship between the words to the edges of the knowledge graph, and constructing the knowledge graph corresponding to the target problem, the words and their relationships in the problem can be clearly displayed by constructing the knowledge graph, further enhancing the semantic features of the target problem, and making the vectorization processing more accurate and effective. By adopting the graph embedding algorithm, the complex knowledge graph structure can be mapped to a low-dimensional vector space. The vectorized representation allows the target problem to be efficiently calculated and compared in the vector space, improving the processing efficiency of the system.
[0113] In some optional implementations of this embodiment, the question-answering device 400 may further include a knowledge acquisition module, an item extraction module, and an item vectorization module.
[0114] A knowledge acquisition module, used to acquire a knowledge base document to be processed, wherein the knowledge base document includes at least one chapter;
[0115] An entry extraction module, configured to extract fact entries from the knowledge base document according to the chapter information of the at least one chapter by using the trained first language model, so as to obtain a set of fact entries corresponding to the knowledge base document;
[0116] An entry vectorization module is used to input the fact entry set into a trained text embedding model, and use the text embedding model to vectorize each fact entry in the fact entry set to obtain a fact entry vector set corresponding to the fact entry set.
[0117] Specifically, the knowledge acquisition module is used to acquire the knowledge base document to be processed, which can be stored in a local file system, a database or a server. The knowledge base document contains at least one chapter, and each chapter includes a series of related chapter information (such as chapter title, subsection title, paragraph division, etc.).
[0118] Specifically, the entry extraction module is used to parse the knowledge base document to be processed using the trained first language model to identify and extract chapter information such as chapter titles, subsection titles and paragraph divisions of at least one chapter, divide the knowledge base document into different chapter contents according to the identified chapter information, identify and extract fact entries in each chapter content, and form a fact entry set corresponding to the knowledge base document.
[0119] Specifically, the entry vectorization module is used to traverse each fact entry in the fact entry set, input each fact entry into the trained text embedding model in turn, and use the text embedding model to vectorize each fact entry to convert each fact entry into a vector representation of a preset dimension. The vector representation is the fact entry vector corresponding to the fact entry, and the fact entry vectors are combined to obtain a fact entry vector set.
[0120] The question-and-answer device 400 of the embodiment of the present application, through the trained first language model, extracts factual items from the knowledge base document according to the chapter information, can automatically identify and extract key information from the document, significantly improves the efficiency of information extraction, and avoids the tediousness of manual screening and extraction. By inputting the extracted factual item set into the trained text embedding model for vectorization processing, the text semantic embedding of the extracted factual items is realized to form a specific vector, so that the factual item texts with different expressions but similar semantics have a higher vector similarity, which is convenient for subsequent more accurate similarity matching with the question vector. Compared with the traditional solution that determines the question-and-answer matching method of similar items based on the hit volume of vocabulary, this solution can meet the differentiated questioning methods of different users and achieve higher answer accuracy.
[0121] In some optional implementations of this embodiment, the above-mentioned item extraction module may include an information extraction submodule, a constraint extraction submodule and a structure arrangement submodule. Among them:
[0122] An information extraction submodule, used for extracting chapter information of at least one chapter from the knowledge base document according to a predefined regular expression;
[0123] a constraint extraction submodule, configured to obtain a predefined prompt word constraint, input the prompt word constraint and the chapter information into the first language model, and extract at least one fact information from the knowledge base document according to the prompt word constraint using the first language model;
[0124] The structure arrangement submodule is used to structure the at least one piece of fact information to obtain a set of fact items corresponding to the knowledge base document.
[0125] Specifically, the information extraction submodule is used to define a regular expression in advance according to the specific format required by the chapter information in the knowledge base document, scan the knowledge base document using the regular expression, and extract the chapter information of at least one chapter matching the regular expression.
[0126] Specifically, the constraint extraction submodule is used to obtain a predefined prompt word constraint, which is pre-set according to the content characteristics of the knowledge base document and the knowledge granularity requirements of the target extraction task, and is used to guide the first language model to extract factual entries from the knowledge base document according to the chapter information. The prompt word constraint may include keywords, phrases or specific sentence structures. The prompt word constraint and the chapter information are input into the trained first language model together, and the knowledge base document is divided into different chapter contents according to the chapter information by the first language model, and at least one factual information in each chapter content is identified and extracted according to the prompt word constraint.
[0127] Specifically, the structural arrangement submodule is used to arrange each extracted fact information in a structured format, including determining the subject, predicate, object and other elements in the fact information to obtain fact entries that meet the format requirements. The structurally arranged fact entries are combined to obtain a fact entry set corresponding to the knowledge base document.
[0128] The entry extraction module of the embodiment of the present application quickly locates and extracts chapter information through predefined regular expressions, which reduces the time cost of manual screening and positioning and significantly improves the extraction efficiency of factual entries. By using the first language model to extract factual information according to the prompt word constraint, it is possible to accurately identify and extract key information related to the prompt word, avoid extraction errors caused by differences in manual understanding, and improve the accuracy of factual entries. By designing clear prompt word constraints, the granularity of knowledge extraction can be controlled, solving the problem of knowledge omission or duplication caused by different extraction granularities, and improving the consistency and comparability of the extraction results.
[0129] In some optional implementations of this embodiment, the similarity calculation module 402 may include a third traversal submodule, a total number acquisition submodule, and an average calculation submodule.
[0130] A vector acquisition submodule, used for acquiring each fact entry vector in the fact entry vector set by traversing;
[0131] The dot product calculation submodule is used to calculate the dot product between the question vector and each of the fact entry vectors, and use the calculated dot product as the similarity between the question vector and the corresponding fact entry vector.
[0132] Specifically, dot product is a method for calculating vector similarity. The larger the calculated value, the more similar the two vectors are. The vector acquisition submodule is used to obtain each fact entry vector from the fact entry vector set in turn by traversal. The dot product calculation submodule is used to calculate the dot product between each obtained fact entry vector and the question vector, and use the calculated dot product as the similarity between the fact entry vector and the question vector.
[0133] Exemplarily, the dot product between the fact entry vector and the question vector may be calculated using the following formula:
[0134] Where v is the question vector, w is the fact entry vector, and n is the dimension of the vector.
[0135] In some optional implementations of this embodiment, the answer generation module 404 may include a first splicing submodule and a second splicing submodule.
[0136] A first splicing submodule, used for splicing the target fact entries to obtain fact entry texts;
[0137] The second concatenation submodule is used to concatenate the target question with the fact entry text to obtain a question-answer text pair, and input the question-answer text pair into the trained second language model.
[0138] Specifically, the first splicing submodule is used to splice multiple target fact entries to form a coherent fact entry text. The splicing method of the fact entries can be determined according to the content and format of the fact entries. For example, if the fact entry is a short sentence or phrase, punctuation marks such as spaces, commas or periods are used to connect them. If the fact entry contains a more complex structure (such as a list, table, etc.), it is necessary to convert the structure into text form before splicing.
[0139] Specifically, the second concatenation submodule is used to concatenate the target question with the concatenated fact entry text to form a question-answer text pair. For example, appropriate conjunctions or punctuation marks may be added between the target question and the fact entry text to concatenate the target question and the fact entry text into a question-answer text pair, and the question-answer text pair is input into the trained second language model.
[0140] The reply generation module 404 of the embodiment of the present application can integrate scattered information into a coherent fact entry text by splicing the target fact entry; by combining the target question with the spliced fact entry text to form a complete question-answer text pair, it helps to improve the concentration and readability of the information, making the question-answer pair easier to understand and analyze, and improving the processing efficiency and accuracy of the model.
[0141] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0142] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 6 with a memory 61, a processor 62, and a network interface 63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0143] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0144] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the question-answering method, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.
[0145] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run the computer-readable instructions stored in the memory 61 or process data, such as computer-readable instructions for running the question-answering method.
[0146] The network interface 63 may include a wireless network interface or a wired network interface. The network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.
[0147] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the question-and-answer method as described above.
[0148] The computer device, computer-readable storage medium and computer-readable instructions provided by the embodiment of the present application can efficiently vectorize the target problem to obtain a problem vector by inputting the target problem input by the user into the text embedding model through the processor. The problem vectorization not only improves the processing efficiency of the problem, but also preserves the characteristics of the problem at the semantic level. By extracting fact items from the knowledge base document using the first language model and vectorizing the extracted fact items based on the text embedding model, the cumbersomeness and subjectivity of manual intervention are avoided, and the efficiency and accuracy of knowledge extraction are improved. By calculating the similarity between the question vector and each fact item vector in the fact item vector set, and obtaining the target fact item related to the target problem based on the similarity, the fact item related to the user problem can be found quickly and accurately, and the response speed and reply accuracy of the system are improved. By inputting the target question and the target fact item into the second language model, the reply content for the target question is generated, which not only takes into account the semantic characteristics of the target question, but also combines the fact items most relevant to the target question, so that the reply content is more targeted, effectively improving the efficiency and accuracy of question-answering.
[0149] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0150] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to replace some of the technical features therein with equivalents. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
[0151] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
Claims
1. A question-answering method, characterized in that: The steps include: Obtaining a target question input by a user, inputting the target question into a trained text embedding model, and using the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question; Obtaining a pre-extracted fact item vector set, and calculating the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from knowledge base documents using a trained first language model, and performing vectorization processing on the extracted fact item set based on the text embedding model; Acquire at least one fact item vector having the highest similarity to the question vector, and determine the fact item corresponding to the at least one fact item vector as a target fact item related to the target question; The target question and the target fact entry are input into a trained second language model, and the second language model is used to generate a response content for the target question based on the target question and the target fact entry.
2. The question-answering method according to claim 1, characterized in that: Before the step of using the text embedding model to obtain a pre-extracted fact entry vector set, the method further includes: Acquire a knowledge base document to be processed, wherein the knowledge base document includes at least one chapter; Using the trained first language model, extracting fact items from the knowledge base document according to the chapter information of the at least one chapter, to obtain a set of fact items corresponding to the knowledge base document; The fact item set is input into a trained text embedding model, and each fact item in the fact item set is vectorized using the text embedding model to obtain a fact item vector set corresponding to the fact item set.
3. The question-answering method according to claim 2, characterized in that: The step of extracting fact items from the knowledge base document according to the chapter information of the at least one chapter to obtain a set of fact items corresponding to the knowledge base document includes: Extracting chapter information of at least one chapter from the knowledge base document according to a predefined regular expression; Obtaining a predefined prompt word constraint, inputting the prompt word constraint and the chapter information into the first language model, and extracting at least one fact information from the knowledge base document according to the prompt word constraint using the first language model; The at least one piece of fact information is structured and sorted to obtain a set of fact items corresponding to the knowledge base document.
4. The question-answering method according to claim 1, characterized in that: The step of using the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question includes: Using the text embedding model, split the target question into a plurality of words, and extract the relationship between the plurality of words; Mapping the vocabulary into entity nodes of a knowledge graph, mapping the relationships between the vocabulary into edges of a knowledge graph, and constructing a knowledge graph corresponding to the target question; The constructed knowledge graph is input into a graph embedding algorithm, and based on the graph embedding algorithm, the entity nodes and edges in the knowledge graph are mapped to a vector space to obtain a vector representation of each entity node and edge as a problem vector corresponding to the target problem.
5. The question-answering method according to claim 1, characterized in that: The step of calculating the similarity between the question vector and each fact entry vector in the fact entry vector set comprises: Obtain each fact entry vector in the fact entry vector set by traversing; The dot product between the question vector and each of the fact entry vectors is calculated, and the calculated dot product is used as the similarity between the question vector and the corresponding fact entry vector.
6. The question-answering method according to claim 1, characterized in that: The step of inputting the target question and the target fact entry into the trained second language model comprises: splicing the target fact entries to obtain fact entry texts; The target question and the fact entry text are concatenated to obtain a question-answer text pair, and the question-answer text pair is input into the trained second language model.
7. A question-answering device, characterized in that: The device comprises: A question processing module is used to obtain a target question input by a user, input the target question into a trained text embedding model, and use the text embedding model to vectorize the target question to obtain a question vector corresponding to the target question; a similarity calculation module, configured to obtain a pre-extracted fact item vector set, and calculate the similarity between the question vector and each fact item vector in the fact item vector set, wherein the fact item vector set is obtained by extracting fact items from knowledge base documents using a trained first language model, and performing vectorization processing on the extracted fact item set based on the text embedding model; An item determination module, configured to obtain at least one fact item vector having the highest similarity to the question vector, and determine the fact item corresponding to the at least one fact item vector as a target fact item related to the target question; The answer generation module is used to input the target question and the target fact entry into the trained second language model, and use the second language model to generate answer content for the target question based on the target question and the target fact entry.
8. The question-and-answer device according to claim 7, characterized in that: The device also includes: A knowledge acquisition module, used to acquire a knowledge base document to be processed, wherein the knowledge base document includes at least one chapter; An entry extraction module, configured to extract fact entries from the knowledge base document according to the chapter information of the at least one chapter by using the trained first language model, so as to obtain a set of fact entries corresponding to the knowledge base document; An entry vectorization module is used to input the fact entry set into a trained text embedding model, and use the text embedding model to vectorize each fact entry in the fact entry set to obtain a fact entry vector set corresponding to the fact entry set.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the question-answering method according to any one of claims 1 to 6 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the question-answering method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Software development target analysis device and method, and storage medium
CN120669960A
Software development target analysis device, method, and storage medium
CN120669960B