Response text generation method and device, computer equipment and storage medium
By introducing background detection and vector splicing technology into the question-and-answer system, the traditional deep learning question-and-answer model has solved the problem of low accuracy when dealing with problems involving time, place or application scenarios, and achieved higher reply accuracy and user experience.
Patent Information
- Application Number
- CN202411531087.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-28
AI Technical Summary
The traditional deep learning question-and-answer model has low accuracy when dealing with problems involving time, place or application scenarios. Especially when relevant background knowledge is insufficient or conflicts with knowledge in memory, the model will ignore the background output answers in memory, resulting in errors.
A reply text generation method is proposed, and first vector conversion and background detection are performed by receiving consultation text data sent by the user terminal. If relevant background knowledge exists, it is transformed in a second vector and the consultation text and background knowledge vector are spliced as input data for the question and answer model to generate more accurate reply text.
Through background detection and vector splicing technology, the accuracy and relevance of the question-and-answer system are improved, the adaptability and flexibility of the system are enhanced, the user experience is optimized, and technological development and innovation in related fields are promoted.
Smart Images

Figure CN119537530A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and is applicable to the financial or medical fields, and in particular to a reply text generation method, device, computer equipment and storage medium. Background Art
[0002] The question-and-answer model is the most common way of delivering information. It is usually used to answer questions and provide information related to the questions. The question-and-answer model is often used in scenarios such as online customer service, smart assistants, and companion chats. In the question-and-answer model, the quality of answers is often measured from dimensions such as authenticity, helpfulness, and fluency, among which authenticity is the most basic and important feature of all criteria.
[0003] The answers to general questions are fixed, but the answers to questions related to time, place, and application scenarios are related to time, place, and application scenarios. For example, the answer to "what is our time zone" in the United States is different from that in China; the answer to "what is the company's homepage address" in Ping An is also different from that in China Merchants Bank.
[0004] At present, general deep learning question-answering models usually memorize common sense knowledge into model parameters, and give the same answer no matter what scenario the same question is asked. In order to make the model adapt to different scenarios, relevant background knowledge related to the scenario is usually input into the model to inspire the model to output answers related to the background. However, if the relevant background knowledge is relatively rare or conflicts with the knowledge in memory, the model will ignore the background and still output the answer in memory, resulting in errors. It can be seen that traditional deep learning question-answering models have the problem of low accuracy. Summary of the invention
[0005] The purpose of the embodiments of the present application is to propose a reply text generation method, apparatus, computer device and storage medium to solve the problem of low accuracy of traditional deep learning question-answering models.
[0006] In order to solve the above technical problems, the present application embodiment provides a method for generating a reply text, which adopts the following technical solution:
[0007] Receiving consultation text data sent by a user terminal;
[0008] Performing a first vector conversion operation on the consultation text data to obtain a consultation text vector;
[0009] Performing a background detection operation on the consultation text data to obtain a background detection result;
[0010] If the background detection result does not contain relevant background knowledge, the consultation text vector is used as model input data of the question-answering model;
[0011] If the background detection result contains relevant background knowledge, performing a second vector conversion operation on the relevant background knowledge to obtain a relevant background knowledge vector;
[0012] Performing a splicing operation on the consulting text vector and the relevant background knowledge vector to obtain a spliced text vector;
[0013] Using the concatenated text vector as model input data for the question-answering model;
[0014] The model input data is input into the question-answering model to perform a reply text generation operation to obtain a target reply text.
[0015] Furthermore, the step of performing a background detection operation on the consultation text data to obtain a background detection result specifically includes the following steps:
[0016] Performing a key information extraction operation on the consultation text data to obtain key feature information;
[0017] Constructing a semantic representation vector according to the key feature information;
[0018] The background knowledge corresponding to the semantic representation vector is retrieved from a pre-built background knowledge base to obtain the background detection result.
[0019] Furthermore, the step of retrieving the background knowledge corresponding to the semantic representation vector in a pre-built background knowledge base to obtain the background detection result specifically includes the following steps:
[0020] The similarity between the semantic representation vector and the vector of the background knowledge in the background knowledge base is calculated, and it is determined whether the similarity is greater than or equal to a preset similarity threshold.
[0021] Furthermore, the step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text specifically includes the following steps:
[0022] According to the Pointer-Generator Network mechanism, the consulting text data and keywords in the relevant background knowledge are copied to the output data of the question-answering model with a preset probability to obtain the target reply text.
[0023] Furthermore, after the step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text, the following steps are also included:
[0024] Performing a syntactic analysis operation on the target reply text to obtain a syntactic analysis result;
[0025] If there is grammatically incorrect text in the syntactic analysis result, the grammatically incorrect text is corrected according to preset grammatical rules.
[0026] Furthermore, after the step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text, the following steps are also included:
[0027] Calculating the relevance of the target reply text to the consultation text data and / or the relevant background knowledge;
[0028] If the correlation does not satisfy a preset correlation threshold, the reply text generation operation is re-executed until the correlation between the target reply text and the consultation text data and / or the relevant background knowledge satisfies the correlation threshold.
[0029] In order to solve the above technical problems, the embodiment of the present application further provides a reply text generation device, which adopts the following technical solution:
[0030] A consultation text acquisition module, used to receive consultation text data sent by a user terminal;
[0031] A first vector conversion module, used for performing a first vector conversion operation on the consultation text data to obtain a consultation text vector;
[0032] A background detection module, used to perform a background detection operation on the consultation text data to obtain a background detection result;
[0033] A first input data confirmation module, configured to use the consultation text vector as model input data of a question-answering model if the background detection result does not contain relevant background knowledge;
[0034] A second vector conversion module, configured to perform a second vector conversion operation on the relevant background knowledge to obtain a relevant background knowledge vector if the background detection result contains relevant background knowledge;
[0035] A vector splicing module, used for splicing the consulting text vector and the relevant background knowledge vector to obtain a spliced text vector;
[0036] A second input data confirmation module, configured to use the concatenated text vector as model input data of the question-answering model;
[0037] The reply text generation module is used to input the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text.
[0038] Furthermore, the background detection module includes:
[0039] A key information extraction submodule is used to perform a key information extraction operation on the consultation text data to obtain key feature information;
[0040] A semantic vector construction submodule, used to construct a semantic representation vector according to the key feature information;
[0041] The background detection result acquisition submodule is used to retrieve the background knowledge corresponding to the semantic representation vector in a pre-built background knowledge library to obtain the background detection result.
[0042] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0043] It includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the reply text generation method as described above when executing the computer-readable instructions.
[0044] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0045] The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the reply text generation method described above are implemented.
[0046] The present application provides a reply text generation method, comprising: receiving consultation text data sent by a user terminal; performing a first vector conversion operation on the consultation text data to obtain a consultation text vector, which is convenient for subsequent processing and analysis by a computer. This conversion enables the text data to be effectively processed by machine learning and deep learning models in numerical form while retaining key information; performing a background detection operation on the consultation text data to obtain a background detection result. Through the background detection, the system can identify the subject, field or context information involved in the consultation text, which helps the system to better understand the user's problem and provide useful context information for subsequent processing; if the background detection result does not contain relevant background knowledge, the consultation text vector is used as the model input data of the question-answering model; if the background detection result contains relevant background knowledge, the relevant background knowledge is subjected to a second vector conversion operation. The consultation text vector and the relevant background knowledge vector are concatenated to obtain a concatenated text vector. The concatenation operation effectively combines the consultation text and the background knowledge in the vector space, provides richer input information for the question-answering model, and helps to improve the accuracy and relevance of the answer. The concatenated text vector is used as the model input data of the question-answering model. By using the concatenated text vector as input, the question-answering model can comprehensively consider the consultation text and the background knowledge, thereby generating an answer that is more in line with the user's expectations. The model input data is input into the question-answering model to perform the answer text generation operation to obtain the target answer text. The question-answering model generates the answer text according to the input data, realizing the complete process from user consultation to system answer. This process makes full use of the results of vector conversion and background detection, and improves the quality and efficiency of the answer. Compared with the prior art, the present application not only improves the intelligence level of the question-answering system and the accuracy of the answer, but also enhances the adaptability and flexibility of the system, optimizes the user experience, and promotes the technical development and innovation in related fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] 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.
[0048] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0049] Figure 2 It is a flowchart of the implementation of the reply text generation method provided in the embodiment of the present application;
[0050] Figure 3It is a structural schematic diagram of a reply text generating device provided in an embodiment of the present application;
[0051] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0052] 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.
[0053] 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.
[0054] 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.
[0055] 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, etc.
[0056] 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.
[0057] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to the laptop computer 1011, tablet computer 1012 or 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.
[0058] 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 .
[0059] It should be noted that the reply text generation method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the reply text generation device is generally arranged in the server / terminal device.
[0060] 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.
[0061] Continue to refer Figure 2 , shows a flow chart of an embodiment of a reply text generation method according to the present application. The reply text generation method comprises: step S201, step S202, step S203, step S204, step S205, step S206, step S207 and step S208.
[0062] In step S201, consultation text data sent by a user terminal is received.
[0063] In the embodiments of the present application, the user terminal refers to a terminal device used to execute the image processing method for preventing document abuse provided by the present application. The user terminal can be a mobile terminal such as a mobile phone, a smart phone, a laptop computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a navigation device, etc., as well as a fixed terminal such as a digital TV, a desktop computer, etc. It should be understood that the examples of user terminals here are only for the convenience of understanding and are not used to limit the present application.
[0064] In the embodiment of the present application, the user inputs a question or inquiry through their terminal device (such as a mobile phone, computer, etc.), and this input is received by the system. This inquiry text data is the specific content that the user wants the system to answer. Specifically, the inquiry text data can be "transaction data or payment data or business data or purchase data" related to a financial institution (such as a bank, etc.). The inquiry text data can also be medical data related to medical scenarios, such as personal health records, prescriptions, examination reports, etc. It should be understood that the examples of inquiry text data here are only for the convenience of understanding and are not used to limit this application.
[0065] In step S202, a first vector conversion operation is performed on the consultation text data to obtain a consultation text vector.
[0066] In the embodiment of the present application, the system first needs to convert the consultation text data input by the user into a format that the computer can understand and process. This is usually achieved through natural language processing (NLP) technology, especially word embeddings or sentence embeddings technology, which converts the text data into a vector representation in a high-dimensional space, i.e., the consultation text vector. This vector can capture the semantic information in the text.
[0067] In step S203, a background detection operation is performed on the consultation text data to obtain a background detection result.
[0068] In the embodiment of the present application, before processing the consultation text, the system will also try to detect whether the consultation involves specific relevant background knowledge. This can be achieved by analyzing the text content, querying the database, or using other knowledge graph technologies. The purpose of background detection is to determine whether additional background information is needed to more accurately answer the user's question.
[0069] In step S204, if the background detection result does not contain relevant background knowledge, the consultation text vector is used as model input data of the question-answering model.
[0070] In an embodiment of the present application, if the background detection result indicates that there is no relevant background knowledge, the system directly uses the consultation text vector as input data for the question-answering model.
[0071] In step S205, if there is relevant background knowledge in the background detection result, a second vector conversion operation is performed on the relevant background knowledge to obtain a relevant background knowledge vector.
[0072] In the embodiment of the present application, if the background detection result shows that there is relevant background knowledge, the system will perform a second vector conversion operation on the relevant background knowledge, converting them into vector form (relevant background knowledge vector). This is done to allow the model to consider both the consultation text and the relevant background knowledge at the same time, thereby generating a more accurate response.
[0073] In step S206, the consultation text vector and the relevant background knowledge vector are concatenated to obtain a concatenated text vector.
[0074] In the embodiment of the present application, if there is a relevant background knowledge vector, the system will concatenate the consultation text vector and the relevant background knowledge vector to form a new concatenated text vector containing more information. This vector contains both the direct information of the user's consultation and the relevant background knowledge.
[0075] In step S207, the concatenated text vector is used as model input data of the question-answering model.
[0076] In the embodiment of the present application, whether the consultation text vector is used directly or the concatenated text vector is used, these vectors will eventually be used as input data for the question-answering model. The question-answering model is a trained machine learning or deep learning model that can understand and generate text.
[0077] In step S208, the model input data is input into the question-answering model to perform a reply text generation operation to obtain a target reply text.
[0078] In the embodiment of the present application, after receiving the input data, the question-answering model will perform a series of calculations and reasoning, and finally generate a reply text. This reply text is a direct response to the user's inquiry, and it may contain the information, answers or suggestions required by the user.
[0079] In the embodiments of the present application, it is possible to distinguish between professional questions with background and general questions without background. Therefore, in practical applications, it can not only support general questions, but also effectively integrate relevant background knowledge to output correct answers in specific scenarios.
[0080] In an embodiment of the present application, a reply text generation method is provided, including: receiving consultation text data sent by a user terminal; performing a first vector conversion operation on the consultation text data to obtain a consultation text vector, which is convenient for subsequent processing and analysis by a computer. This conversion enables the text data to be effectively processed by machine learning and deep learning models in numerical form while retaining key information; performing a background detection operation on the consultation text data to obtain a background detection result. Through the background detection, the system can identify the subject, field or context information involved in the consultation text, which helps the system to better understand the user's problem and provide useful context information for subsequent processing; if the background detection result does not contain relevant background knowledge, the consultation text vector is used as the model input data of the question-answering model; if the background detection result contains relevant background knowledge, a second vector conversion operation is performed on the relevant background knowledge. Vector conversion operation is performed to obtain the relevant background knowledge vector. The splicing operation effectively combines the consultation text and background knowledge in the vector space, provides richer input information for the question-answering model, and helps to improve the accuracy and relevance of the answer; the consultation text vector and the relevant background knowledge vector are spliced to obtain the spliced text vector; the spliced text vector is used as the model input data of the question-answering model. By using the spliced text vector as input, the question-answering model can comprehensively consider the consultation text and background knowledge, thereby generating a reply that is more in line with user expectations; the model input data is input into the question-answering model for reply text generation operation to obtain the target reply text. The question-answering model generates the reply text according to the input data, realizing the complete process from user consultation to system reply. This process makes full use of the results of vector conversion and background detection, and improves the quality and efficiency of the reply. Compared with the prior art, this application not only improves the intelligence level of the question-answering system and the accuracy of the reply, but also enhances the adaptability and flexibility of the system, optimizes the user experience, and promotes the technical development and innovation in related fields.
[0081] In some optional implementations of the embodiments of the present application, the above-mentioned step of performing a background detection operation on the consultation text data to obtain a background detection result specifically includes the following steps:
[0082] Performing a key information extraction operation on the consultation text data to obtain key feature information;
[0083] Constructing a semantic representation vector according to the key feature information;
[0084] The background knowledge corresponding to the semantic representation vector is retrieved from a pre-built background knowledge base to obtain the background detection result.
[0085] In an embodiment of the present application, the key information extraction operation is intended to identify and extract information from the text that is crucial to understanding the content of the text. This information may be words after part-of-speech annotations such as nouns, verbs, adjectives, or phrases, sentences, or more complex structures. The specific method of key information extraction includes but is not limited to rule-based methods, statistical methods (such as TF-IDF, word bag models), and deep learning-based methods (such as using neural network models for information extraction).
[0086] In the embodiment of the present application, the extracted key information is further processed (such as deduplication, merging, etc.) to form a series of feature information that can represent the main content of the original text. These feature information will be used for subsequent semantic representation and background knowledge retrieval.
[0087] In the embodiments of the present application, the semantic representation vector refers to the conversion of text or vocabulary into a mathematical representation that can reflect its meaning or context. This representation is usually a vector (i.e., a set of numerical values), each of which represents the intensity of a certain semantic feature or attribute.
[0088] In the embodiment of the present application, based on the extracted key feature information, a specific algorithm or model (such as a word embedding model Word2Vec, BERT, etc.) is used to convert this information into a vector form. These vectors are close to each other in the semantic space. Words or phrases usually have similar meanings or contexts.
[0089] In the embodiment of the present application, the background knowledge base is a pre-built database containing a large amount of background knowledge (such as common sense, professional knowledge, historical facts, etc.) This background knowledge is usually stored in various forms such as text, images, videos, etc., and is indexed and annotated for easy retrieval.
[0090] In the embodiment of the present application, the constructed semantic representation vector is used to search in the background knowledge base, which usually involves calculating the similarity between vectors (such as cosine similarity, Euclidean distance, etc.) to find the background knowledge item that is most similar to the query vector.
[0091] In some optional implementations of the embodiments of the present application, the step of retrieving the background knowledge corresponding to the semantic representation vector in the pre-built background knowledge base to obtain the background detection result specifically includes the following steps:
[0092] The similarity between the semantic representation vector and the vector of the background knowledge in the background knowledge base is calculated, and it is determined whether the similarity is greater than or equal to a preset similarity threshold.
[0093] In the embodiment of the present application, similarity is mainly used to measure the distance or similarity between two vectors in the semantic space. The similarity calculation method can be:
[0094] 1) Cosine similarity: The similarity between two vectors is measured by calculating the cosine value of the angle between them. The closer the cosine value is to 1, the more consistent the directions of the two vectors are, i.e. the higher the similarity.
[0095] 2) Euclidean distance: measures the straight-line distance between two vectors in multidimensional space. The smaller the distance, the closer the two vectors are, that is, the higher the similarity (but note that Euclidean distance is usually used for points in metric space, while in semantic vector space, cosine similarity is more commonly used because it better reflects the similarity in direction).
[0096] 3) Manhattan distance: Also known as city block distance, it is the sum of the absolute differences of the elements in the vector. Compared with Euclidean distance, it is more suitable for processing sparse data.
[0097] 4) Jaccard similarity: It is used to measure the similarity between two sets, and is obtained by calculating the ratio of the size of the intersection of the two sets to the size of the union. Although it is mainly used for set comparison, it can also be used to calculate vector similarity in some specific scenarios (for example, treating the vector as a binary feature set).
[0098] In the embodiment of the present application, through the above operations, content related to the query can be quickly screened out from a large amount of background knowledge.
[0099] In some optional implementations of the embodiments of the present application, the step of inputting the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text specifically includes the following steps:
[0100] According to the Pointer-Generator Network mechanism, the consulting text data and the keywords in the relevant background knowledge are copied to the output data of the question-answering model with a preset probability to obtain the target reply text, wherein the preset probability can be 20% as the optimal preset probability value.
[0101] In an embodiment of the present application, the Pointer-Generator Network mechanism combines the advantages of the sequence-to-sequence model and the pointer network, which can not only generate new vocabulary, but also copy vocabulary from the input text with a certain probability. This mechanism is particularly suitable for text generation tasks containing a large number of proper nouns or specific expressions. Among them, the sequence-to-sequence model includes an encoder (Encoder) and a decoder (Decoder). The encoder converts the input text into a series of hidden states, and the decoder generates new text based on these hidden states and previous outputs; the pointer network introduces a pointer to the elements in the input sequence in the decoding stage, so that the model can directly copy the vocabulary in the input text to the output, instead of relying solely on the generation ability of the decoder.
[0102] In an embodiment of the present application, by copying keywords in the consultation text data and related background knowledge into the output data with a certain probability, a target reply text that is both accurate and fluent can be generated.
[0103] In some optional implementations of the embodiments of the present application, after the step of inputting the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text, the following steps are also included:
[0104] Performing a syntactic analysis operation on the target reply text to obtain a syntactic analysis result;
[0105] If there is grammatically incorrect text in the syntactic analysis result, the grammatically incorrect text is corrected according to preset grammatical rules.
[0106] In the embodiments of the present application, the syntactic analysis operation refers to the analysis of the grammatical structure of the text to identify the subject, predicate, object, attributive, adverbial and other sentence components in the sentence, and understand the hierarchy and relationship between them. This usually involves the use of a syntactic analyzer (such as a rule-based parser, a statistical parser or a deep learning model) to automatically parse the text.
[0107] In the embodiment of the present application, the result of the syntactic analysis is a tree structure (such as a syntactic tree), which shows the hierarchy and dependency relationship between the various components in the sentence. This structure is crucial for understanding the meaning of the sentence, detecting grammatical errors, and subsequent text processing (such as machine translation, sentiment analysis, etc.).
[0108] In the embodiment of the present application, if there are sentence components or structures in the result of syntactic analysis that do not conform to the preset grammatical rules or common language habits, these parts are regarded as grammatically incorrect texts. These errors may include subject-verb inconsistency, missing necessary sentence components (such as verbs, nouns), incorrect word order, etc.
[0109] In the embodiment of the present application, the preset grammatical rules are formulated based on the grammatical system of the language and are used to determine whether a sentence conforms to the correct grammatical structure. These rules can be based on linguistic theories (such as syntactic theory, semantic theory), or can be obtained based on statistics of large-scale corpora (such as statistical grammatical rules).
[0110] In the embodiment of the present application, once a grammatically incorrect text is detected, it is necessary to correct it according to the preset grammatical rules. This usually involves replacing, deleting or adding necessary words or phrases to the incorrect part to ensure that the sentence conforms to the correct grammatical structure. The specific method of correction processing may include rule-based correction, statistical model-based correction or a combination of the two.
[0111] In an embodiment of the present application, syntactic analysis of the target reply text and correction of grammatical errors help improve text quality, enhance the robustness of the NLP system, and provide support for subsequent text processing tasks.
[0112] In some optional implementations of the embodiments of the present application, after the step of inputting the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text, the following steps are also included:
[0113] Calculating the relevance of the target reply text to the consultation text data and / or the relevant background knowledge;
[0114] If the correlation does not satisfy a preset correlation threshold, the reply text generation operation is re-executed until the correlation between the target reply text and the consultation text data and / or the relevant background knowledge satisfies the correlation threshold.
[0115] In the present application embodiment, relevance refers to the relevance or matching degree between the target reply text and the consultation text data (and related background knowledge, if applicable). It can be measured in many ways, such as based on vocabulary overlap, semantic similarity, contextual consistency, etc.
[0116] In the embodiment of the present application, in order to quantify the relevance between the target reply text and the consultation text data and related background knowledge, a specific algorithm or model needs to be used. These algorithms may be based on vector space models, semantic networks, deep learning and other technologies, and obtain the relevance value by calculating the similarity or distance between texts.
[0117] In an embodiment of the present application, the relevance of the target reply text to the consultation text data and / or relevant background knowledge is calculated, and the reply text generation operation is re-executed based on the relevance threshold, thereby ensuring that the question-and-answer system generates high-quality reply text, effectively improving the accuracy of the reply, enhancing the user experience and optimizing system performance.
[0118] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0119] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0120] 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).
[0121] 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.
[0122] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a reply text generation device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0123] like Figure 3 As shown, the reply text generating device 200 of the embodiment of the present application includes:
[0124] The consultation text acquisition module 210 is used to receive the consultation text data sent by the user terminal;
[0125] A first vector conversion module 220, used to perform a first vector conversion operation on the consulting text data to obtain a consulting text vector;
[0126] Background detection module 230, used to perform background detection operation on consultation text data to obtain background detection results;
[0127] A first input data confirmation module 240 is used to use the consultation text vector as model input data of the question-answering model if the background detection result does not contain relevant background knowledge;
[0128] A second vector conversion module 250 is used to perform a second vector conversion operation on the relevant background knowledge to obtain a relevant background knowledge vector if the background detection result contains relevant background knowledge;
[0129] A vector concatenation module 260 is used to concatenate the consulting text vector and the related background knowledge vector to obtain a concatenated text vector;
[0130] A second input data confirmation module 270, configured to use the concatenated text vector as model input data of the question-answering model;
[0131] The reply text generation module 280 is used to input the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text.
[0132] In the embodiments of the present application, the user terminal refers to a terminal device used to execute the image processing method for preventing document abuse provided by the present application. The user terminal can be a mobile terminal such as a mobile phone, a smart phone, a laptop computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a navigation device, etc., as well as a fixed terminal such as a digital TV, a desktop computer, etc. It should be understood that the examples of user terminals here are only for the convenience of understanding and are not used to limit the present application.
[0133] In the embodiment of the present application, the user inputs a question or inquiry through their terminal device (such as a mobile phone, computer, etc.), and the input is received by the system. The inquiry text data is the specific content that the user hopes the system will answer.
[0134] In the embodiment of the present application, the system first needs to convert the consultation text data input by the user into a format that the computer can understand and process. This is usually achieved through natural language processing (NLP) technology, especially word embeddings or sentence embeddings technology, which converts the text data into a vector representation in a high-dimensional space, i.e., the consultation text vector. This vector can capture the semantic information in the text.
[0135] In the embodiment of the present application, before processing the consultation text, the system will also try to detect whether the consultation involves specific relevant background knowledge. This can be achieved by analyzing the text content, querying the database, or using other knowledge graph technologies. The purpose of background detection is to determine whether additional background information is needed to more accurately answer the user's question.
[0136] In an embodiment of the present application, if the background detection result indicates that there is no relevant background knowledge, the system directly uses the consultation text vector as input data for the question-answering model.
[0137] In the embodiment of the present application, if the background detection result shows that there is relevant background knowledge, the system will perform a second vector conversion operation on the relevant background knowledge, converting them into vector form (relevant background knowledge vector). This is done to allow the model to consider both the consultation text and the relevant background knowledge at the same time, thereby generating a more accurate response.
[0138] In the embodiment of the present application, if there is a relevant background knowledge vector, the system will concatenate the consultation text vector and the relevant background knowledge vector to form a new concatenated text vector containing more information. This vector contains both the direct information of the user's consultation and the relevant background knowledge.
[0139] In the embodiment of the present application, whether the consultation text vector is used directly or the concatenated text vector is used, these vectors will eventually be used as input data for the question-answering model. The question-answering model is a trained machine learning or deep learning model that can understand and generate text.
[0140] In the embodiment of the present application, after receiving the input data, the question-answering model will perform a series of calculations and reasoning, and finally generate a reply text. This reply text is a direct response to the user's inquiry, and it may contain the information, answers or suggestions required by the user.
[0141] In the embodiments of the present application, it is possible to distinguish between professional questions with background and general questions without background. Therefore, in practical applications, it can not only support general questions, but also effectively integrate relevant background knowledge to output correct answers in specific scenarios.
[0142] In an embodiment of the present application, a reply text generating device 200 is provided, including: a consultation text acquiring module 210, for receiving consultation text data sent by a user terminal; a first vector conversion module 220, for performing a first vector conversion operation on the consultation text data to obtain a consultation text vector, so as to facilitate subsequent processing and analysis by a computer. This conversion enables the text data to be effectively processed by machine learning and deep learning models in numerical form while retaining key information; a background detection module 230, for performing a background detection operation on the consultation text data to obtain a background detection result. Through the background detection, the system can identify the subject, field or context information involved in the consultation text, which helps the system to better understand the user's problem and provide useful context information for subsequent processing; a first input data confirmation module 240, for using the consultation text vector as the model input data of the question-answering model if the background detection result does not contain relevant background knowledge; a second vector conversion module 250, for using the consultation text vector as the model input data of the question-answering model if the background detection result does not contain relevant background knowledge knowledge, then the relevant background knowledge is subjected to a second vector conversion operation to obtain a relevant background knowledge vector; a vector concatenation module 260 is used to concatenate the consultation text vector and the relevant background knowledge vector to obtain a concatenated text vector. The concatenation operation effectively combines the consultation text and the background knowledge in the vector space, provides richer input information for the question-answering model, and helps to improve the accuracy and relevance of the reply; a second input data confirmation module 270 is used to use the concatenated text vector as the model input data of the question-answering model. By using the concatenated text vector as input, the question-answering model can comprehensively consider the consultation text and the background knowledge, thereby generating a reply that is more in line with the user's expectations; a reply text generation module 280 is used to input the model input data into the question-answering model for a reply text generation operation to obtain a target reply text. The question-answering model generates a reply text based on the input data, realizing a complete process from user consultation to system reply. This process makes full use of the results of vector conversion and background detection, and improves the quality and efficiency of the reply. Compared with the prior art, the present application not only improves the intelligence level of the question-answering system and the accuracy of the reply, but also enhances the adaptability and flexibility of the system, optimizes the user experience, and promotes the technical development and innovation in related fields.
[0143] In some optional implementations of the embodiments of the present application, the background detection module includes:
[0144] A key information extraction submodule is used to perform a key information extraction operation on the consultation text data to obtain key feature information;
[0145] A semantic vector construction submodule, used to construct a semantic representation vector according to the key feature information;
[0146] The background detection result acquisition submodule is used to retrieve the background knowledge corresponding to the semantic representation vector in a pre-built background knowledge library to obtain the background detection result.
[0147] 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 a computer device according to an embodiment of the present application.
[0148] The computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 300 having components 310-330, 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.
[0149] 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.
[0150] The memory 310 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, magnetic disk, optical disk, etc. In some embodiments, the memory 310 can be an internal storage unit of the computer device 300, such as a hard disk or memory of the computer device 300. In other embodiments, the memory 310 can also be an external storage device of the computer device 300, such as a plug-in hard disk equipped on the computer device 300, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Of course, the memory 310 can also include both the internal storage unit of the computer device 300 and its external storage device. In the embodiment of the present application, the memory 310 is generally used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions of the reply text generation method, etc. In addition, the memory 310 can also be used to temporarily store various data that have been output or are to be output.
[0151] The processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 300. In the embodiment of the present application, the processor 320 is used to run the computer-readable instructions stored in the memory 310 or process data, such as computer-readable instructions for running the reply text generation method.
[0152] The network interface 330 may include a wireless network interface or a wired network interface. The network interface 330 is generally used to establish a communication connection between the computer device 300 and other electronic devices.
[0153] The computer device provided by this application not only improves the intelligence level of the question-answering system and the accuracy of the answers, but also enhances the adaptability and flexibility of the system, optimizes the user experience, and promotes technological development and innovation in related fields.
[0154] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which 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 reply text generation method as described above.
[0155] The computer-readable storage medium provided in this application not only improves the intelligence level of the question-answering system and the accuracy of the answers, but also enhances the adaptability and flexibility of the system, optimizes the user experience, and promotes technological development and innovation in related fields.
[0156] 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.
[0157] 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 perform equivalent replacement of some of the technical features therein. 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.
Claims
1. A method for generating a reply text, characterized in that: The steps include: Receiving consultation text data sent by a user terminal; Performing a first vector conversion operation on the consultation text data to obtain a consultation text vector; Performing a background detection operation on the consultation text data to obtain a background detection result; If the background detection result does not contain relevant background knowledge, the consultation text vector is used as model input data of the question-answering model; If the background detection result contains relevant background knowledge, performing a second vector conversion operation on the relevant background knowledge to obtain a relevant background knowledge vector; Performing a splicing operation on the consulting text vector and the relevant background knowledge vector to obtain a spliced text vector; Using the concatenated text vector as model input data for the question-answering model; The model input data is input into the question-answering model to perform a reply text generation operation to obtain a target reply text.
2. The reply text generation method according to claim 1, characterized in that: The step of performing a background detection operation on the consultation text data to obtain a background detection result specifically includes the following steps: Performing a key information extraction operation on the consultation text data to obtain key feature information; Constructing a semantic representation vector according to the key feature information; The background knowledge corresponding to the semantic representation vector is retrieved from a pre-built background knowledge library to obtain the background detection result.
3. The reply text generation method according to claim 2, characterized in that: The step of retrieving the background knowledge corresponding to the semantic representation vector in a pre-built background knowledge base to obtain the background detection result specifically includes the following steps: The similarity between the semantic representation vector and the vector of the background knowledge in the background knowledge base is calculated, and it is determined whether the similarity is greater than or equal to a preset similarity threshold.
4. The reply text generation method according to claim 1, characterized in that: The step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text specifically comprises the following steps: According to the Pointer-Generator Network mechanism, the consultation text data and keywords in the relevant background knowledge are copied to the output data of the question-answering model with a preset probability to obtain the target reply text.
5. The reply text generation method according to claim 1, characterized in that: After the step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text, the following steps are also included: Performing a syntactic analysis operation on the target reply text to obtain a syntactic analysis result; If there is grammatically incorrect text in the syntactic analysis result, the grammatically incorrect text is corrected according to preset grammatical rules.
6. The reply text generation method according to claim 1, characterized in that: After the step of inputting the model input data into the question-answering model to generate a reply text to obtain a target reply text, the following steps are also included: Calculating the relevance of the target reply text to the consultation text data and / or the relevant background knowledge; If the correlation does not satisfy a preset correlation threshold, the reply text generation operation is re-executed until the correlation between the target reply text and the consultation text data and / or the relevant background knowledge satisfies the correlation threshold.
7. A reply text generating device, characterized in that: include: A consultation text acquisition module, used to receive consultation text data sent by a user terminal; A first vector conversion module, used for performing a first vector conversion operation on the consultation text data to obtain a consultation text vector; A background detection module, used to perform a background detection operation on the consultation text data to obtain a background detection result; A first input data confirmation module, configured to use the consultation text vector as model input data of a question-answering model if the background detection result does not contain relevant background knowledge; A second vector conversion module, configured to perform a second vector conversion operation on the relevant background knowledge to obtain a relevant background knowledge vector if the background detection result contains relevant background knowledge; A vector splicing module, used for splicing the consulting text vector and the relevant background knowledge vector to obtain a spliced text vector; A second input data confirmation module, configured to use the concatenated text vector as model input data of the question-answering model; The reply text generation module is used to input the model input data into the question-answering model to perform a reply text generation operation to obtain a target reply text.
8. The reply text generating device according to claim 7, characterized in that: The background detection module comprises: A key information extraction submodule is used to perform a key information extraction operation on the consultation text data to obtain key feature information; A semantic vector construction submodule, used to construct a semantic representation vector according to the key feature information; The background detection result acquisition submodule is used to retrieve the background knowledge corresponding to the semantic representation vector in a pre-built background knowledge library to obtain the background detection result.
9. A computer device comprising a memory and a processor, characterized in that: The memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the reply text generation method as described in any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the reply text generation method as described in any one of claims 1 to 6.