Question and answer processing method and device, electronic equipment, medium and program product
The operation navigation documents of the power automation metering system are disassembled and vectorized through a pre-trained large language model, which solves the problem of low query efficiency in the existing technology and realizes an efficient and accurate automatic question-answering system.
Patent Information
- Application Number
- CN202410251112.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2025-09-09
AI Technical Summary
In the prior art, the efficiency of querying operation navigation documents for systems with complex user operations, such as power automation metering systems, is low, resulting in cumbersome and inefficient user operations.
A pre-trained large language model is used for document decomposition and vectorization processing, and answer information is generated through vector matching, including text decomposition, vector generation, semantic analysis and vector library construction, combined with local sensitive hashing to improve query efficiency.
It realizes efficient and accurate automatic query of answers in complex systems such as power automation metering systems, improving user operation efficiency and query accuracy.
Smart Images

Figure CN120611038A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic question answering technology, and in particular to a method, device, electronic device, medium and program product for question answering processing. Background Art
[0002] With the advancement of science and technology, the structure of systems such as power automation metering is becoming increasingly complex, and users may not be able to understand how to operate the system. In existing technologies, it is possible to set up operation navigation documents, and users can query the operation navigation documents to learn how to operate the system. However, this method is cumbersome and inefficient. Summary of the Invention
[0003] In view of the above problems, a method, apparatus, electronic device, medium, and program product for question-answering processing are proposed to overcome the above problems or at least partially solve the above problems, including:
[0004] A question-answering processing method, comprising:
[0005] Obtaining a question text input by a user and generating a second vector corresponding to the question text;
[0006] Using the second vector, performing vector matching in a pre-built vector library to obtain a target first vector, and determining a target text portion corresponding to the target first vector; wherein the vector library includes a plurality of first vectors, and the first vectors correspond to text portions in the target document;
[0007] Based on the target text portion, answer information for the question text is generated.
[0008] Optionally, generating answer information for the question text based on the target text portion includes:
[0009] generating prompt information according to the target text portion and the question text;
[0010] A pre-trained target model is used to generate answer information for the question text based on the prompt information.
[0011] Optionally, the prompt information includes a question type, and the using of a pre-trained target model to generate answer information for the question text according to the prompt information includes:
[0012] A corresponding question-answering scenario is determined according to the question type, and a pre-trained target model is used to generate answer information for the question text in the corresponding question-answering scenario.
[0013] Optionally, before obtaining the question text input by the user, the method further includes:
[0014] Obtaining a target document and decomposing the target document to obtain multiple text parts;
[0015] First vectors corresponding to the multiple text parts are generated respectively, and a vector library is constructed based on the first vectors.
[0016] Optionally, before constructing a vector library according to the first vector, the method further includes:
[0017] According to the requirements of the question-answering task, the first vector is fine-tuned.
[0018] Optionally, constructing a vector library according to the first vector includes: generating a first hash value corresponding to the first vector, and mapping the first vector to a hash bucket according to the first hash value to construct the vector library;
[0019] The using the second vector to perform vector matching in a pre-built vector library to obtain the target first vector includes: generating a second hash value corresponding to the second vector, and performing vector matching in a pre-built vector library based on the second hash value to obtain the target first vector.
[0020] Optionally, respectively generating the first vectors corresponding to the plurality of text parts includes: for each text part, converting words in the text part into subvectors, and generating the first vector corresponding to the text part based on the subvectors of all words in the text part;
[0021] Generating the second vector corresponding to the question text includes: converting words in the question text into subvectors, and generating the second vector corresponding to the question text based on the subvectors of all words in the question text.
[0022] Optionally, generating a first vector corresponding to the text portion according to subvectors of all words in the text portion includes:
[0023] The sub-vectors of all words in the text portion are averaged to obtain a first vector corresponding to the text portion.
[0024] Optionally, after the target document is disassembled to obtain multiple text parts, the method further includes:
[0025] Perform semantic analysis on the text portion, and mark the text portion according to the semantic analysis result of the text portion; wherein the marking result is used for vector matching.
[0026] Optionally, the target model is a large language model.
[0027] Optionally, the target document is an operation navigation document for a power metering automation system.
[0028] A device for question-answering processing, comprising:
[0029] A second vector generating module, configured to obtain a question text input by a user and generate a second vector corresponding to the question text;
[0030] a target text portion determination module, configured to use the second vector to perform vector matching in a pre-built vector library to obtain a target first vector, and determine a target text portion corresponding to the target first vector; wherein the vector library includes a plurality of first vectors, each of which corresponds to a text portion in a target document;
[0031] The answer information generating module is used to generate answer information for the question text according to the target text portion.
[0032] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the question-answering processing method described above when executed by the processor.
[0033] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the question-answering processing method described above.
[0034] A computer program product includes a computer program, which implements the question-answering processing method described above when executed by a processor.
[0035] The embodiments of the present invention have the following advantages:
[0036] In an embodiment of the present invention, a question text input by a user is obtained and a second vector corresponding to the question text is generated. The second vector is used to perform vector matching in a pre-built vector library to obtain a target first vector, and a target text portion corresponding to the target first vector is determined. The vector library includes multiple first vectors, and the first vectors correspond to text portions in a target document. Based on the target text portion, answer information for the question text is generated, thereby automatically searching for the corresponding answer in the document based on the question, thereby improving query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the description of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 is a schematic diagram of a system architecture provided by some embodiments of the present invention;
[0039] Figure 2 is a flowchart of the steps of a question-answering processing method provided by some embodiments of the present invention;
[0040] Figure 3 is a flowchart of the steps of another question-answering processing method provided by some embodiments of the present invention;
[0041] Figure 4 is a flowchart of the steps of another question-answering processing method provided by some embodiments of the present invention;
[0042] Figure 5 This is a structural block diagram of a question-answering processing device provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0043] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments described are only a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are also within the scope of protection of the present invention.
[0044] In the embodiment of the present invention, it is mainly divided into two parts: data loading and understanding and online computing services, including document disassembly, document slicing, text vectorization, external vector library update, user input question representation, similar text recall, and large model result induction module, providing an external operation navigation document question and answer interface to meet the real-time operation navigation document question and answer needs.
[0045] like Figure 1 The target document automatic question answering system with a pre-trained large language model can include document decomposition, paragraph representation, vector update, question representation, vector matching, result generation and other capability modules.
[0046] Specifically, by pre-training on large-scale text data, the model provides rich semantic understanding capabilities and contextual information for document question answering tasks. During the pre-training phase, the model learns rich linguistic knowledge from unsupervised data through self-supervised learning. Then, in the document question answering task, the pre-trained model is fine-tuned to enable it to understand questions and document content. The advantage of pre-trained large language models in document question answering scenarios is that they can understand context and complex questions, thereby providing accurate answers. Based on the input question and document content, the model can perform semantic matching, extract key information, and generate answers. It can handle complex questions, understand the meaning of questions, and find relevant information in the document to provide answers. By applying pre-trained large language models in document question answering scenarios, researchers and developers can build efficient and accurate question answering systems. Such systems can help users quickly find and understand document content, improving work efficiency and accuracy. The application of pre-trained large language models in document question answering scenarios will promote the development of natural language processing technology and provide more powerful solutions for intelligent question answering and information retrieval.
[0047] By using pre-trained large-scale language models, it has powerful semantic understanding and generation capabilities, enabling the system to better understand the semantics of documents and questions. It no longer relies on manually written and maintained rules or precise keyword matching, and can capture rich contextual information and perform global semantic modeling of the entire document. In contrast, systems based on keyword matching can only be limited to keyword matching and cannot fully understand the semantics of the document.
[0048] Moreover, pre-trained large language models are more flexible in dealing with complex question-and-answer scenarios. By fine-tuning the model, it can be trained for specific operation navigation document question-and-answer tasks, improving the system's ability to understand and answer domain-specific questions, and avoiding the cost of constantly maintaining and adjusting rules in rule-based systems.
[0049] Reference Figure 2 , showing a step flow chart of a question and answer processing method provided by some embodiments of the present invention. The method can be applied to an automatic question and answer system. For example, the automatic question and answer system can be an automatic question and answer system for operation navigation documents of an electric power metering automation system, that is, it is applied in a document question and answer scenario. Of course, it can also be an automatic question and answer system for other systems and other documents, such as an automatic question and answer system for customer service response documents in a customer service system.
[0050] Specifically, the following steps may be included:
[0051] Step 201: Obtain a question text input by a user, and generate a second vector corresponding to the question text.
[0052] When using the question-answering system, users can input question text through the interactive interface, and then the question text can be converted into a second vector by using a pre-trained target model. For example, a large language model with a Transformer structure can generate word embedding representations with strong semantic understanding capabilities by pre-training on large-scale data.
[0053] In some embodiments of the present invention, generating a second vector corresponding to the question text includes:
[0054] The words in the question text are converted into sub-vectors, and a second vector corresponding to the question text is generated according to the sub-vectors of all the words in the question text.
[0055] In practical applications, text representation technology can be used to convert words in the question text into sub-vectors using the target model. Then, by performing a pooling operation on the sub-vectors of the words in the question text, a vector representation that comprehensively considers the semantics of the question can be obtained, namely the second vector.
[0056] In some examples, other methods may be used to convert the question text into a sub-vector and then generate a second vector based on the sub-vector, such as converting the question text into the second vector using one-hot encoding.
[0057] In some embodiments of the present invention, before obtaining the question text input by the user, the method further includes:
[0058] A target document is obtained and decomposed to obtain multiple text parts; first vectors corresponding to the multiple text parts are generated respectively, and a vector library is constructed based on the first vectors.
[0059] In some embodiments of the present invention, the target document may be an operation navigation document for the power metering automation system. The operation navigation document may be used to guide office personnel who are not familiar with the power metering automation system on how to use the system.
[0060] In some examples, the target document may also be other documents, such as a product installation manual or an operation and maintenance manual.
[0061] In practical applications, sentence segmentation algorithms or paragraph segmentation algorithms in natural language processing technology can be used to split the target document into multiple text parts, such as paragraphs or sentences. For example, the algorithm can disassemble the target document based on punctuation, contextual information or grammatical structure.
[0062] In some embodiments of the present invention, after the target document is disassembled to obtain multiple text parts, the method further includes: performing semantic analysis on the text parts, and marking the text parts based on the semantic analysis results of the text parts; wherein the marking results are used for vector matching.
[0063] After obtaining multiple text parts, semantic analysis technology can be used to mark each paragraph or sentence to identify its topic or keywords. This can be achieved through part-of-speech tagging, named entity recognition, keyword extraction and other technologies. The marked topics or keywords help the system understand the document content and provide more accurate question-answer matching.
[0064] After obtaining the marked results, the marked results (such as topics and keywords) are essentially a summary of the content of the document segment. When subsequently matching with the user input question, the marked results (such as topics and keywords) can be used to quickly find the text segments related to the user input question.
[0065] In some examples, document structure analysis techniques, such as title extraction and table of contents analysis, can be applied to further decompose documents. Specifically, by identifying and extracting structural information such as titles, chapters, and sub-chapter information, a document hierarchy can be constructed, providing more accurate document fragments for question-answer matching. For example, document pages can be segmented first, followed by multi-level headings. If there are tables or images in a chapter, their location will also be segmented.
[0066] When decomposing documents, by selecting appropriate sentence segmentation algorithms or paragraph division algorithms, using accurate semantic analysis techniques for keyword tagging, and applying effective document structure analysis methods, we can ensure that the document is correctly split and useful information is extracted, providing accurate input for subsequent text representation and vector matching.
[0067] In practical applications, a pre-trained target model, such as a large language model, can be used to convert the text portion into a vector representation, i.e., a first vector. Then, all first vectors can be aggregated to construct a vector library.
[0068] In some examples, other methods may be used to convert the text portion into the first vector, such as converting the text portion into the first vector using a one-hot encoding method.
[0069] In some embodiments of the present invention, respectively generating first vectors corresponding to the plurality of text portions includes:
[0070] For each text portion, the words in the text portion are converted into sub-vectors, and a first vector corresponding to the text portion is generated according to the sub-vectors of all the words in the text portion.
[0071] In some embodiments of the present invention, generating a first vector corresponding to the text portion based on subvectors of all words in the text portion includes:
[0072] The sub-vectors of all words in the text portion are averaged to obtain a first vector corresponding to the text portion.
[0073] In practical applications, a pre-trained target model, such as a large language model, can be fine-tuned to adapt to the specific tasks of the question-answering system, enabling the model to better understand and generate accurate and fluent answers.
[0074] Through the pre-trained target model, each word in the text part is converted into a vector representation. For example, a large language model using the Transformer (a sequence model based on the attention mechanism) structure can generate word embedding representations with strong semantic understanding capabilities by pre-training on large-scale data.
[0075] By using a language model based on the Transformer architecture, we learn the rich semantic information between words. After document decomposition, each word in the text is converted into a vector representation. Compared to traditional bag-of-words models or solutions, this model captures the contextual relationships and semantic information between words, providing a more accurate and semantically rich text vector representation. This allows for a better understanding of the content in operational navigation documents and provides a stronger foundation for subsequent question-answer matching and result generation.
[0076] After obtaining the sub-vectors, the word embedding representation is combined with text representation techniques, such as vector averaging, to obtain a vector representation of the entire text section, namely the first vector. By averaging all the word embedding vectors in the text section, a vector representation that can capture the overall semantics of the text section is obtained.
[0077] In an embodiment of the present invention, by using the target model for word embedding representation and performing vector averaging on the word embedding vectors to obtain a vector representation of the text portion, an accurate and semantically rich vector representation of the text segment can be provided, providing a strong foundation for subsequent vector matching and result generation modules.
[0078] In some embodiments of the present invention, constructing a vector library based on the first vector includes:
[0079] A first hash value corresponding to the first vector is generated, and the first vector is mapped to a hash bucket according to the first hash value to construct a vector library.
[0080] In practical applications, we can use a specific vector library (such as the Annoy vector library) for storage and indexing, and use Locality Sensitive Hashing (LSH) to improve search efficiency, providing a stronger foundation for subsequent question-answer matching and result generation.
[0081] In some examples, other methods may be used to store and index vectors, such as using data tables, matrices, etc. Other hashing methods may also be used to improve search efficiency, such as consistent hashing.
[0082] In some examples, a specific vector library can be an efficient approximate nearest neighbor search library, which accelerates the search process by constructing a multi-layer binary tree structure and provides an efficient approximate nearest neighbor search algorithm. It can quickly find text vectors similar to a given vector to support subsequent vector matching processes.
[0083] To further improve search efficiency, locality-sensitive hashing can be used to map vectors into a hash space and map similar vectors into similar hash buckets, enabling fast approximate nearest neighbor searches. This approach, using hash mapping and bucketing, reduces the search space, enabling rapid location of similar vectors in large vector sets and improving system response speed.
[0084] For example, after the target document is segmented, many text segments are formed. The text segments are represented as vectors through a large model. By constructing multiple hash functions, each vector is input into the hash function for calculation to obtain a hash value. The choice of hash function is based on the characteristics of similarity metrics such as Euclidean distance or cosine similarity, so that similar vectors have a higher probability of being mapped to the same hash bucket in the hash space. The text segment vectors in a hash bucket are similar text segment vectors.
[0085] In some embodiments of the present invention, before constructing a vector library based on the first vector, the method further includes:
[0086] According to the requirements of the question-answering task, the first vector is fine-tuned.
[0087] After obtaining the first vector, the pre-trained target model can be used to fine-tune the first vector according to the requirements of the question-answering task, such as the specific task requirements of the electric navigation manual question-answering system. For example, the expression form of the vector and the value range of the vector can be adjusted, so that it can adapt to specific tasks such as the electric navigation manual question-answering system.
[0088] Step 202: Use the second vector to perform vector matching in a pre-built vector library to obtain a target first vector, and determine the target text portion corresponding to the target first vector; wherein the vector library includes multiple first vectors, and the first vectors correspond to the text portion in the target document.
[0089] After obtaining the second vector, the second vector can be used to perform vector matching in a vector library. A target first vector that matches the second vector can be determined from multiple first vectors in the vector library. For example, vector matching can be performed based on similarity between vectors, with the first vector with the highest similarity being determined as the target first vector. After determining the target first vector, the target text portion corresponding to the target first vector can be determined from the multiple text portions.
[0090] In some embodiments of the present invention, using the second vector to perform vector matching in a pre-built vector library to obtain the target first vector includes:
[0091] A second hash value corresponding to the second vector is generated, and vector matching is performed in a pre-built vector library based on the second hash value to obtain a target first vector.
[0092] In practical applications, locality-sensitive hashing can be used to improve the speed of vector matching. Specifically, a pre-trained large language model can be used to represent the text part and question text as vectors. These vectors capture the semantic information of the text and question, and then locality-sensitive hashing can be used to accelerate the vector matching process.
[0093] Locality-sensitive hashing (LSH) achieves fast approximate nearest neighbor search by mapping vectors into a hash space and mapping similar vectors into similar hash buckets. This approach significantly reduces the search space and improves system response speed. By selecting a target model for vector representation and using LSH for vector matching, similar vectors can be quickly located in the hash space, significantly improving vector matching efficiency.
[0094] Step 203: Generate answer information for the question text based on the target text portion.
[0095] After obtaining the target text portion, answer information for the question text may be generated based on the target text portion, and the answer information may be fed back to the user through an interactive interface.
[0096] For example, the question text entered by the user is: "How to query the automatic meter reading rate of a power plant?", and the output answer information is: "Operation process: 1. Log in to the system and follow the path: Power Trading--Application Query--Indicator Management--Power Plant Automatic Meter Reading to enter the page. 2. Select the provincial unit in the query conditions, leave the other conditions as default, and click the [Query] button; 3. Switch to the municipal, district, county, and power supply station units respectively, and click the [Query] button; 4. Select different time types, switch the time, and click the [Query] button; 5. Select different main and secondary meter symbols, and click the [Query] button."
[0097] In this embodiment of the present invention, the target document contains information from multiple fields and scenarios, and different questions may correspond to different scenarios. To improve the accuracy and pertinence of Q&A, a scenario selection mechanism is introduced. Based on the user's question and question type, the corresponding scenario is automatically selected for Q&A matching and result generation. By accurately determining and selecting the appropriate scenario, more precise and personalized answer results can be provided, improving the user's Q&A experience and query effectiveness.
[0098] In some embodiments of the present invention, generating answer information for the question text based on the target text portion includes: generating prompt information based on the target text portion and the question text; and using a pre-trained target model to generate answer information for the question text based on the prompt information.
[0099] In some embodiments of the present invention, the target model may be a large language model. In some examples, other models, such as a neural network model, may also be used.
[0100] Pre-trained large language models are a natural language processing technology based on deep learning. By pre-training on large amounts of text data, the models acquire rich linguistic knowledge and semantic understanding capabilities. These models utilize deep neural network structures, such as the Transformer, to capture long-range dependencies and contextual information. During the pre-training phase, the models use self-supervised learning to learn a language model from massive amounts of unsupervised text data and predict missing words. Through this prediction task, the models learn information such as relationships between words and the semantic representation of sentences. After pre-training, the models can be applied to a variety of natural language processing tasks, such as question answering, text classification, and machine translation. For specific tasks, the models are further trained through fine-tuning or specialized training methods to adapt to the specific requirements. The advantage of pre-trained large language models lies in their ability to learn from large amounts of text data and capture richer semantic information. These models have achieved remarkable results in natural language processing tasks, significantly improving performance and efficiency. Pre-trained large language models enable researchers and developers to leverage existing linguistic knowledge and models to quickly build and optimize various natural language processing applications, thereby promoting the development of natural language processing technology.
[0101] In practical applications, this can be achieved by fine-tuning Prompt based on a large model. Using a pre-trained large language model as a foundation, the model is fine-tuned to generate context-aware and semantically rich responses. Specifically, a pre-trained large language model can be used to generate the initial response. These models have been pre-trained through large-scale unsupervised learning and possess rich semantic understanding and generation capabilities. Then, the model is fine-tuned to train it specifically for the question-answering task of the target document. During the fine-tuning process, the model is targeted to generate accurate and fluent responses using a dataset related to the target document.
[0102] In the process of generating answer information, Prompt Engineering technology can be used. That is, by adding specific prompt information (prompt) to the input, the model can be guided to generate expected answers. For example, the prompt information can include question type, scenario restrictions, etc., which helps the model better understand and generate corresponding answers.
[0103] In some embodiments of the present invention, the prompt information includes a question type, and the generating of answer information for the question text based on the prompt information using a pre-trained target model includes:
[0104] A corresponding question-answering scenario is determined according to the question type, and a pre-trained target model is used to generate answer information for the question text in the corresponding question-answering scenario.
[0105] In actual applications, the prompt information may include the question type corresponding to the question text. Different question types may correspond to different question-and-answer scenarios. By adopting a scenario selection mechanism, the corresponding question-and-answer scenario is automatically selected for question-and-answer matching and result generation based on the user's question text and question type. By accurately judging and selecting appropriate scenarios, more accurate and personalized answer results can be provided, improving the user's question-and-answer experience and query effect.
[0106] By selecting an appropriate pre-trained language model as a foundation, fine-tuning the model to suit the target document question-answering task, and adding specific prompts to guide the model in generating accurate and relevant responses, and fine-tuning Prompts based on a large model, we can generate context-aware and semantically rich responses, providing more accurate and personalized Q&A results. This delivers a better Q&A experience and greater practicality for users.
[0107] For example, the input question text is: "How to query power data on the new master station?" The large model input prompt is: "You are a document understanding assistant. The following is a document for reference. Please answer the user's question professionally and concisely. Note: (1) It is forbidden to fabricate data outside the document; (2) Please try to explain the points.\n\nDocument: {Document 1, Document 2}\nUser question: {How to query power data on the new master station}".
[0108] In an embodiment of the present invention, a target document is obtained and decomposed to obtain multiple text parts, first vectors corresponding to the multiple text parts are generated respectively, and a vector library is constructed based on the first vectors. The question text input by the user is obtained, and a second vector corresponding to the question text is generated. The second vector is used to perform vector matching in the vector library to obtain a target first vector, and the target text part corresponding to the target first vector is determined. Based on the target text part, answer information for the question text is generated, thereby realizing automatic query of the corresponding answer in the document according to the question, thereby improving the efficiency of the query.
[0109] Reference Figure 3 , which shows a flowchart of another question-answering processing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0110] Step 301: Obtain a target document and decompose the target document to obtain multiple text parts.
[0111] Step 302 : Generate first vectors corresponding to the multiple text parts respectively, and construct a vector library based on the first vectors.
[0112] Step 303: Obtain the question text input by the user and generate a second vector corresponding to the question text.
[0113] Step 304 : Using the second vector, perform vector matching in the vector library to obtain a target first vector, and determine the target text portion corresponding to the target first vector.
[0114] Step 305: Generate answer information for the question text based on the target text portion.
[0115] Reference Figure 4 , which shows a flowchart of another question-answering processing method provided by some embodiments of the present invention, which may specifically include the following steps:
[0116] Step 401: Obtain a target document and decompose the target document to obtain multiple text parts.
[0117] Step 402: Generate first vectors corresponding to the multiple text parts respectively.
[0118] Step 403: Generate a first hash value corresponding to the first vector, and map the first vector to a hash bucket according to the first hash value to construct a vector library.
[0119] Step 404: Obtain the question text input by the user and generate a second vector corresponding to the question text.
[0120] Step 405: Generate a second hash value corresponding to the second vector, and perform vector matching in the vector library based on the second hash value to obtain a target first vector.
[0121] Step 406: Determine the target text portion corresponding to the target first vector.
[0122] Step 407: Generate answer information for the question text based on the target text portion.
[0123] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0124] Reference Figure 5 , shows a structural block diagram of a question-answering processing apparatus provided by some embodiments of the present invention, which may specifically include the following modules:
[0125] The second vector generating module 501 is used to obtain the question text input by the user and generate a second vector corresponding to the question text;
[0126] a target text portion determination module 502 configured to use the second vector to perform vector matching in a pre-built vector library to obtain a target first vector, and determine a target text portion corresponding to the target first vector; wherein the vector library includes a plurality of first vectors, each of which corresponds to a text portion in a target document;
[0127] The answer information generating module 503 is configured to generate answer information for the question text based on the target text portion.
[0128] In some embodiments of the present invention, the answer information generating module 503 includes:
[0129] A prompt information generating submodule, configured to generate prompt information based on the target text portion and the question text;
[0130] The answer generation submodule according to the prompt information is used to use a pre-trained target model to generate answer information for the question text according to the prompt information.
[0131] In some embodiments of the present invention, the prompt information includes the question type, and the submodule for generating an answer based on the prompt information includes:
[0132] The question-answering scenario selection unit is used to determine the corresponding question-answering scenario according to the question type, and use a pre-trained target model to generate answer information for the question text in the corresponding question-answering scenario.
[0133] In some embodiments of the present invention, the present invention further includes:
[0134] A document decomposition module is used to obtain a target document and decompose the target document to obtain multiple text parts;
[0135] The vector library construction module is used to generate first vectors corresponding to the multiple text parts respectively, and construct a vector library based on the first vectors.
[0136] In some embodiments of the present invention, the present invention further includes:
[0137] A vector fine-tuning module is used to fine-tune the first vector according to the requirements of the question-answering task.
[0138] In some embodiments of the present invention, the vector library construction module includes:
[0139] The hash mapping submodule is configured to generate a first hash value corresponding to the first vector, and map the first vector to a hash bucket according to the first hash value to construct a vector library.
[0140] In some embodiments of the present invention, the target text portion determination module 502 includes:
[0141] The target first vector determination submodule is configured to generate a second hash value corresponding to the second vector, and perform vector matching in a pre-built vector library based on the second hash value to obtain a target first vector.
[0142] In some embodiments of the present invention, the vector library construction module includes:
[0143] A first vector generating submodule is configured to convert, for each text portion, words in the text portion into subvectors, and generate a first vector corresponding to the text portion based on the subvectors of all words in the text portion;
[0144] In some embodiments of the present invention, the second vector generating module 501 includes:
[0145] The text conversion vector submodule is used to convert the words in the question text into subvectors, and generate a second vector corresponding to the question text based on the subvectors of all the words in the question text.
[0146] In some embodiments of the present invention, the first vector generation submodule includes:
[0147] The vector averaging unit is used to average the sub-vectors of all words in the text portion to obtain a first vector corresponding to the text portion.
[0148] In some embodiments of the present invention, the present invention further includes:
[0149] The text tagging module is used to perform semantic analysis on the text portion and tag the text portion according to the semantic analysis result of the text portion; wherein the tagging result is used for vector matching.
[0150] In some embodiments of the present invention, the target model is a large language model.
[0151] In some embodiments of the present invention, the target document is an operation navigation document for an electric power metering automation system. Some embodiments of the present invention also provide an electronic device that may include a processor, a memory, and a computer program stored in the memory and executable on the processor. When executed by the processor, the computer program implements the above-described question-and-answer processing method.
[0152] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for question-and-answer processing as described above is implemented.
[0153] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0154] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0155] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0156] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, compact disc read-only memory, optical storage, etc.) containing computer-usable program code.
[0157] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0158] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0159] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0160] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0161] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0162] The above is a detailed introduction to the provided question-and-answer processing methods, devices, electronic devices, media and program products. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A question-answering processing method, characterized in that: The method comprises: Obtaining a question text input by a user and generating a second vector corresponding to the question text; Using the second vector, performing vector matching in a pre-built vector library to obtain a target first vector, and determining a target text portion corresponding to the target first vector; wherein the vector library includes a plurality of first vectors, and the first vectors correspond to text portions in the target document; Based on the target text portion, answer information for the question text is generated.
2. The method according to claim 1, characterized in that Generating answer information for the question text based on the target text portion includes: generating prompt information according to the target text portion and the question text; A pre-trained target model is used to generate answer information for the question text based on the prompt information.
3. The method according to claim 2, characterized in that The prompt information includes the question type, and the pre-trained target model is used to generate answer information for the question text according to the prompt information, including: A corresponding question-answering scenario is determined according to the question type, and a pre-trained target model is used to generate answer information for the question text in the corresponding question-answering scenario.
4. The method according to any one of claims 1 to 3, characterized in that Before obtaining the question text input by the user, it also includes: Obtaining a target document and decomposing the target document to obtain multiple text parts; First vectors corresponding to the multiple text parts are generated respectively, and a vector library is constructed based on the first vectors.
5. The method according to claim 4, characterized in that Before constructing a vector library according to the first vector, the method further includes: According to the requirements of the question-answering task, the first vector is fine-tuned.
6. The method according to claim 4, characterized in that The constructing a vector library according to the first vector includes: generating a first hash value corresponding to the first vector, and mapping the first vector to a hash bucket according to the first hash value to construct the vector library; The using the second vector to perform vector matching in a pre-built vector library to obtain the target first vector includes: generating a second hash value corresponding to the second vector, and performing vector matching in a pre-built vector library based on the second hash value to obtain the target first vector.
7. The method according to claim 4, characterized in that Generating first vectors corresponding to the plurality of text parts respectively includes: for each text part, converting words in the text part into subvectors, and generating the first vector corresponding to the text part based on the subvectors of all words in the text part; Generating the second vector corresponding to the question text includes: converting words in the question text into subvectors, and generating the second vector corresponding to the question text based on the subvectors of all words in the question text.
8. The method according to claim 7, characterized in that Generating a first vector corresponding to the text portion according to subvectors of all words in the text portion includes: The sub-vectors of all words in the text portion are averaged to obtain a first vector corresponding to the text portion.
9. The method according to claim 4, characterized in that After the target document is disassembled to obtain multiple text parts, the method further includes: Perform semantic analysis on the text portion, and mark the text portion according to the semantic analysis result of the text portion; wherein the marking result is used for vector matching.
10. The method according to claim 1, characterized in that The target model is a large language model.
11. The method according to claim 1, wherein The target document is an operation navigation document for the power metering automation system.
12. A device for question-answering processing, characterized in that: The device comprises: A second vector generating module, configured to obtain a question text input by a user and generate a second vector corresponding to the question text; a target text portion determination module, configured to use the second vector to perform vector matching in a pre-built vector library to obtain a target first vector, and determine a target text portion corresponding to the target first vector; wherein the vector library includes a plurality of first vectors, each of which corresponds to a text portion in a target document; The answer information generating module is used to generate answer information for the question text according to the target text portion.
13. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for question-answering processing according to any one of claims 1 to 11 is implemented.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the question-answering processing method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the question-answering processing method according to any one of claims 1 to 11.
Citation Information
Patent Citations
K nearest neighbor approximation query method based on multi-layer locality sensitive hashing
CN110489419A
Question and answer method and device based on long document, storage medium and equipment
CN117216208A
Utilizing external knowledge and memory networks in a question-answering system
US20200167428A1