Question and answer processing method and device, electronic equipment and storage medium
Through vectorized query and domain keyword extraction, combined with vector similarity search and keyword recall, multi-feature fusion and rearrangement are carried out, which solves the problem of poor processing results in specific domain content and improves the recall and accuracy of question-and-answer processing.
Patent Information
- Application Number
- CN202411091833.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-09
- Publication Date
- 2024-12-27
AI Technical Summary
In the process of user question and answer processing, the results of specific fields are poor, resulting in low recall and accuracy.
By conducting vectorized query and domain keyword extraction on the problem content, combining vector similarity search and keyword recall, multi-feature fusion and rearrangement are carried out to generate the final answer.
It effectively overcomes the problem of low accuracy of the semantic vector recall method, improves the relevance and effectiveness of the recall documents, and ensures the accuracy of the answers.
Smart Images

Figure CN119202151A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a question and answer processing method, device, electronic device and storage medium. Background Art
[0002] With the continuous development of deep learning technology, a large number of language models have made rapid progress. They learn on massive data, significantly improving the ability of machines to understand and answer natural language questions, making artificial intelligence closer to human intelligence, and enhancing cross-industry applications such as intelligent customer service, search optimization, and virtual assistants, greatly improving information acquisition efficiency and user experience.
[0003] However, in the process of user question and answer processing, there is still the problem of poor processing results for content in specific fields. Summary of the invention
[0004] The present invention provides a question-answering processing method, device, electronic device and storage medium, which are used to solve the problem in the prior art that in the user question-answering processing process, there is still poor processing result for content in a specific field.
[0005] The present invention provides a question-answering processing method, comprising: Perform vectorized query and domain keyword extraction on the question content to obtain the question query vector and question domain keywords; Performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Based on the recalled document and the question, multi-feature fusion rearrangement is performed to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0006] According to a question-answering processing method provided by the present invention, before the step of performing retrieval and recall based on the question query vector and the question domain keywords to obtain the recalled document, the method further includes: Performing text parsing on the local document, removing symbols and irrelevant characters in the local document, and obtaining a plain text corresponding to the local document; After the plain text is processed into blocks, the text blocks are processed into vectorized text blocks through a large vectorization model, and each of the text blocks is converted into a numerical vector to obtain a local text vector library; Extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords; wherein the keyword extraction model is obtained by adjusting a general language model based on domain annotation data; All the local domain keywords are indexed to create a keyword inverted index; wherein the keyword inverted index is used to map the local domain keywords to a document list containing the local domain keywords.
[0007] According to a question-answering processing method provided by the present invention, retrieval and recall are performed based on the question query vector and the question domain keywords to obtain recalled documents, including: Based on the question query vector, vector similarity retrieval and recall are performed in the local text vector library, and based on the question domain keywords, similarity retrieval and recall are performed in the local domain keywords to obtain recalled documents.
[0008] According to a question-answer processing method provided by the present invention, multi-feature fusion rearrangement is performed according to the recalled document and the question to obtain the rearranged recalled document, including: Acquire key information in the recalled document, concatenate the key information with the recalled document, and construct a rearrangement feature; Based on a similarity measurement method, calculating the similarity between the question and the rearrangement feature; According to the similarity calculation result, the recalled documents are rearranged to obtain rearranged recalled documents.
[0009] According to a question-answering processing method provided by the present invention, the key information includes at least one of the following: title, section title, domain keyword, document time.
[0010] According to a question-answer processing method provided by the present invention, after the step of calculating the similarity between the question and the rearrangement feature based on the similarity measurement method, and rearranging the recalled documents according to the similarity settlement result, the method further includes: Obtaining a prompt template corresponding to the question; wherein the prompt template is used to guide the generation of a large model to construct an answer; The rearranged recall documents and the prompt template are input into a large model to output the answer corresponding to the question.
[0011] According to a question-answering processing method provided by the present invention, before the step of extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords, the method further includes: Obtain system fine-tuning prompt words and user fine-tuning prompt words annotated by domain; The system fine-tuning prompt words and the user fine-tuning prompt words are input into a general language model to obtain the keyword extraction model.
[0012] The present invention also provides a question-answer processing device, comprising: The extraction module is used to perform vectorized query and domain keyword extraction on the question content to obtain the question query vector and question domain keywords; A recall module, used to retrieve and recall based on the question query vector and the question domain keywords to obtain a recalled document; A rearrangement module is used to perform multi-feature fusion rearrangement according to the recalled document and the question to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0013] Optionally, the device is also used for: Performing text parsing on the local document, removing symbols and irrelevant characters in the local document, and obtaining a plain text corresponding to the local document; After the plain text is processed into blocks, the text blocks are processed into vectorized text blocks through a large vectorization model, and each of the text blocks is converted into a numerical vector to obtain a local text vector library; Extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords; wherein the keyword extraction model is obtained by adjusting a general language model based on domain annotation data; All the local domain keywords are indexed to create a keyword inverted index; wherein the keyword inverted index is used to map the local domain keywords to a document list containing the local domain keywords.
[0014] Optionally, the device is also used for: Based on the question query vector, vector similarity retrieval and recall are performed in the local text vector library, and based on the question domain keywords, similarity retrieval and recall are performed in the local domain keywords to obtain recalled documents.
[0015] Optionally, the key information includes at least one of the following: title, section title, domain keyword, document time.
[0016] Optionally, the device is also used for: splicing the key information with the recalled document to construct a rearrangement feature; Based on a similarity measurement method, calculating the similarity between the question and the rearrangement feature; According to the similarity calculation result, the recalled documents are rearranged to obtain rearranged recalled documents.
[0017] Optionally, the device is also used for: Obtaining a prompt template corresponding to the question; wherein the prompt template is used to guide the generation of a large model to construct an answer; The rearranged recall documents and the prompt template are input into a large model to output the answer corresponding to the question.
[0018] Optionally, the device is also used for: Obtain system fine-tuning prompt words and user fine-tuning prompt words annotated by domain; The system fine-tuning prompt words and the user fine-tuning prompt words are input into a general language model to obtain the keyword extraction model.
[0019] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the question and answer processing methods described above is implemented.
[0020] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the question-and-answer processing methods described above.
[0021] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned question and answer processing methods.
[0022] The question and answer processing method, device, electronic device and storage medium provided by the present invention perform multi-way retrieval and recall based on question query vectors and question domain keywords in the retrieval stage. The multi-way recall method that combines domain keyword recall and vector recall can effectively overcome the problem of low recall accuracy of the semantic vector recall method due to inaccurate semantic vectors. Moreover, in the rearrangement stage, on the basis of the recalled documents, the key information of the recalled documents is further integrated to achieve the integration of more detailed features without changing the rearrangement model, thereby improving the effectiveness of the rearrangement and ensuring the accuracy of the final output answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 This is the architecture diagram of the RAG question-answering system in the related technology; Figure 2 A flowchart of a question-and-answer processing method provided in an embodiment of the present application; Figure 3 A flowchart of the question-answering system provided in the embodiment of the present application; Figure 4A schematic diagram of the structure of a question-and-answer processing device provided in an embodiment of the present application; Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] Among related technologies, RAG technology cleverly combines information retrieval (Retrieval) with natural language generation (Generation), giving large language models stronger understanding and answering capabilities.
[0027] Before the advent of RAG technology, large language models relied mainly on knowledge gained from pre-training on large-scale text data when answering questions. However, these models often struggle when faced with questions that require the latest information, domain-specific knowledge, or uncommon facts. This is because the model's training data usually ends at a certain point in time, and the model's internal knowledge may be too generalized to accurately respond to specific details. In addition, the model may also "hallucinate", that is, generate information that does not match the facts.
[0028] The emergence of RAG technology provides a solution to these problems. It effectively improves the accuracy and reliability of large language models when answering questions by combining the two methods of retrieval and generation. Currently, RAG has been widely used in many fields, including customer service, intelligent search, personalized recommendations, etc., and performs well in dealing with problems that require specific domain knowledge or real-time information.
[0029] The basic process of RAG technology is as follows: Retrieval: Enter a question or query and use a retriever (usually a retrieval algorithm based on keywords or semantic similarity) to find contextual information related to the question from external knowledge sources (such as databases, documents, web pages, etc.).
[0030] Augmentation: The retrieved relevant contextual information is input into the generative model together with the original question as additional information for the model to generate the answer.
[0031] Generation: The large language model generates the final answer based on the input question and the retrieved context information.
[0032] During the generation process, the model uses the retrieved information to guide the generation process, ensuring that the generated answers are both accurate and relevant. The core advantage of RAG technology is that it can effectively alleviate the problem of information overload while improving the accuracy and controllability of generated content, allowing large language models to use the latest, specific and domain-related knowledge when dealing with specific problems, thereby providing higher quality answers.
[0033] Figure 1 This is the architecture diagram of the RAG question-answering system in the related technology, such as Figure 1 As shown in Figure 1, in the question-answering system of the RAG architecture, the retrieval-recall stage plays a vital role. It matches the user's question with the documents in the knowledge base and provides relevant information to the generation model to generate accurate answers.
[0034] Document slicing, vectorization, and retrieval are key components of the retrieval phase, which together constitute the retrieval recall process: Document slicing: Divide documents in the knowledge base into smaller, independently meaningful fragments. This can more accurately match user questions and improve retrieval efficiency.
[0035] Vectorization: Convert document fragments and user queries into vector representations. Vector representations can better capture the semantic information of the text and facilitate subsequent similarity calculations.
[0036] Retrieval: Use retrieval algorithms (such as based on keywords, semantic similarity, etc.) to retrieve document fragments related to the user query from the knowledge base.
[0037] The retrieved information is the source of information for the large model to answer. The generative model generates the final answer based on the retrieved document fragments and the user's questions.
[0038] However, in the related art, there are still problems such as low accuracy of RAG based on vector recall.
[0039] Figure 2 A flowchart of the question-answering processing method provided in the embodiment of the present application is shown in FIG. Figure 2 As shown, including: Step 210, performing vectorized query and domain keyword extraction on the question content to obtain a question query vector and question domain keywords; In the application embodiment, first, natural language processing operations such as word segmentation and part-of-speech tagging are performed on the question input by the user to better capture the semantic information of the question.
[0040] Convert the text content of the question into a vector representation. This is usually done using a pre-trained language model (such as BERT, GPT, etc.). These models can convert text into a high-dimensional vector, where each dimension represents a certain semantic feature of the text. Thus, the semantic similarity between texts can be measured by calculating the similarity between vectors.
[0041] Using pre-trained language models or other natural language processing techniques, keywords related to specific fields are extracted from the text content of the question. These keywords can more accurately reflect the core content of the question, thereby more effectively retrieving relevant documents.
[0042] Finally, we get the vector representation of the question, i.e. the query vector and the domain keywords of the question. These two pieces of information will serve as key inputs in the subsequent retrieval and recall phase to help find the document fragments most relevant to the question.
[0043] Step 220, performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Use the question query vector to calculate the similarity (e.g. cosine similarity) with the vectors of all document fragments in the knowledge base.
[0044] According to the similarity score, the document fragment with the highest similarity is selected as the preliminary retrieval result. The problem domain keywords are used to match keywords with the title, abstract, body and other text content of all document fragments in the knowledge base.
[0045] According to the matching score, the document fragment with the highest matching degree is selected as the preliminary retrieval result.
[0046] The results of vector retrieval recall and domain keyword retrieval recall are merged, duplicate document fragments are removed, and the final recalled document list is generated.
[0047] In the embodiment of the present application, through the two methods of vector retrieval recall and domain keyword retrieval recall, the document fragments related to the question can be more comprehensively covered, thereby improving the recall rate. The domain keyword can more accurately reflect the core content of the question, thereby improving the relevance of the recalled document.
[0048] Step 230, performing multi-feature fusion rearrangement based on the recalled document and the question to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0049] In an embodiment of the present application, keywords related to a specific field are identified from a document through a pre-trained field keyword extraction model.
[0050] Get the title and section title in the document, which usually reflects the theme and structure of the document. Get the release time of the document, which is especially important for question-answering systems that need the latest information. It is still necessary to extract the text content of the document, which is the basis for re-ranking.
[0051] The extracted features are represented as vectors for subsequent similarity calculations. Different methods can be used for feature representation, such as: Word embedding: Convert text features such as text content, title, and section title into vectors. Domain keyword encoding: Convert domain keywords into vectors, using methods such as one-hot encoding or word embedding. Time encoding: Convert time features into vectors, using methods such as timestamps or time differences.
[0052] The feature vectors from different sources are fused to obtain the final document representation. The similarity between the question vector and the fused document vector is calculated. Different similarity calculation methods can be used, such as cosine similarity, Euclidean distance, etc. The recalled documents are sorted according to the similarity score. The higher the similarity score, the higher the document is ranked.
[0053] In an embodiment of the present application, in the retrieval stage, multi-way retrieval recall is performed based on the question query vector and the question domain keywords. The multi-way recall method that combines domain keyword recall and vector recall can effectively overcome the problem of low recall accuracy of the semantic vector recall method due to inaccurate semantic vectors. In addition, in the rearrangement stage, on the basis of the recalled documents, the key information of the recalled documents is further integrated to achieve the integration of more detailed features without changing the rearrangement model, thereby improving the effectiveness of the rearrangement and ensuring the accuracy of the final output answer.
[0054] Optionally, before the step of performing retrieval and recall based on the question query vector and the question domain keywords to obtain the recalled documents, the method further includes: Performing text parsing on the local document, removing symbols and irrelevant characters in the local document, and obtaining a plain text corresponding to the local document; After the plain text is processed into blocks, the text blocks are processed into vectorized text blocks through a large vectorization model, and each of the text blocks is converted into a numerical vector to obtain a local text vector library; Extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords; wherein the keyword extraction model is obtained by adjusting a general language model based on domain annotation data; All the local domain keywords are indexed to create a keyword inverted index; wherein the keyword inverted index is used to map the local domain keywords to a document list containing the local domain keywords.
[0055] In the embodiment of the present application, symbols and irrelevant characters in the document, such as punctuation marks, spaces, line breaks, etc., are removed to obtain plain text content. Regular expressions or natural language processing tools can be used for text parsing.
[0056] In the embodiment of the present application, text segmentation can segment the plain text content into smaller text blocks, such as paragraphs, sentences, etc. This helps to improve the efficiency and accuracy of retrieval because smaller text blocks are easier to vectorize and retrieve. Text segmentation can be performed using a text segmentation algorithm, such as based on the number of characters, sentence structure, topic consistency, etc.
[0057] In the embodiment of the present application, text vectorization converts a text block into a numerical vector for subsequent retrieval and similarity calculation. A pre-trained vectorization large model can be used for text vectorization, such as Word2Vec, BERT, etc.
[0058] In the embodiment of the present application, domain keyword extraction can extract keywords related to a specific domain from a text block, and these keywords can more accurately describe the subject and content of the document.
[0059] In the embodiment of the present application, creating a keyword inverted index can map a domain keyword to a document list containing the keyword, so as to quickly retrieve relevant documents. The keyword inverted index can be created using an inverted index technology, such as using a database or a search engine.
[0060] In the embodiment of the present application, text vectorization and keyword inverted index can quickly retrieve relevant documents and improve retrieval efficiency. Domain keywords can more accurately describe the subject and content of the document and improve retrieval accuracy.
[0061] Optionally, performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents includes: Based on the question query vector, vector similarity retrieval and recall are performed in the local text vector library, and based on the question domain keywords, similarity retrieval and recall are performed in the local domain keywords to obtain recalled documents.
[0062] In an embodiment of the present application, vector similarity retrieval and recall are performed based on the question query vector, and the similarity between the question query vector and each document fragment vector in the local text vector library is calculated, for example, using cosine similarity or Euclidean distance. Several document fragments with the highest similarity are selected as recalled documents. Document fragments with semantic similarity to the question can be retrieved from the local text vector library.
[0063] In the embodiment of the present application, similarity retrieval and recall based on problem domain keywords may refer to querying the keyword inverted index to find a list of documents containing the problem domain keywords. Retrieve relevant document fragments from these documents and use them as recalled documents. Document fragments related to the problem domain keywords may be retrieved from local domain keywords.
[0064] Optionally, the key information includes at least one of the following: title, section title, domain keyword, document time.
[0065] According to the recalled document and the question, multi-feature fusion rearrangement is performed to obtain the rearranged recalled document, including: splicing the key information with the recalled document to construct a rearrangement feature; Based on a similarity measurement method, calculating the similarity between the question and the rearrangement feature; According to the similarity calculation result, the recalled documents are rearranged to obtain rearranged recalled documents.
[0066] In the embodiment of the present application, the selected key information is spliced with the text content of the recalled document to construct a rearrangement feature. For example, the document title, section title, domain keywords and text content are spliced together. The spliced rearrangement feature is represented by a vector, and word embedding or other vector representation methods can be used.
[0067] In the embodiment of the present application, a suitable similarity measurement method is selected, such as cosine similarity, Euclidean distance, etc. The similarity between the question vector and the rearranged feature vector of each recalled document is calculated. The recalled documents are sorted according to the similarity calculation result, and the higher the similarity, the higher the document is. The rearranged list of recalled documents is returned as the basis for generating the answer.
[0068] In the embodiment of the present application, by considering information such as the document title, section title, field keywords and document time, the document can be described more comprehensively, thereby improving the accuracy of the retrieval results.
[0069] Optionally, after the step of calculating the similarity between the question and the rearrangement feature based on the similarity measurement method, and rearranging the recalled documents according to the similarity calculation result, the method further includes: Obtaining a prompt template corresponding to the question; wherein the prompt template is used to guide the generation of a large model to construct an answer; The rearranged recall documents and the prompt template are input into a large model to output the answer corresponding to the question.
[0070] In an embodiment of the present application, a prompt template is used to guide the generation of a large model to construct an answer, such as specifying the format, style, tone, etc. of the answer. An appropriate prompt template can be selected according to the question type and application scenario.
[0071] The rearranged recall documents and prompt templates are spliced together as input to generate a large model, thereby guiding the large model to construct answers.
[0072] In the embodiment of the present application, generating answers is the ultimate goal of the RAG architecture question-answering system. By inputting the retrieved relevant documents and prompt templates into a large model, high-quality and accurate answers can be generated to meet the diverse needs of users.
[0073] Optionally, before the step of extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords, the step further includes: Obtain system fine-tuning prompt words and user fine-tuning prompt words annotated by domain; The system fine-tuning prompt words and the user fine-tuning prompt words are input into a general language model to obtain the keyword extraction model.
[0074] In the embodiment of the present application, the domain annotation data is used to train the keyword extraction model to ensure that the model can accurately identify the domain keywords. The domain annotation data can be obtained by manual annotation or semi-automatic annotation.
[0075] System fine-tuning prompts and user fine-tuning prompts are used to guide the fine-tuning of the general language model so that it can adapt to keyword extraction tasks in specific fields.
[0076] System fine-tuning prompt words and user fine-tuning prompt words can be written by domain experts or annotators, for example: System fine-tuning prompt: "You are a senior technical expert in the field of computer storage."
[0077] User-adjusted prompt: "Please help find the technical terms involved in the following text. List only the technical terms and no other unnecessary words."
[0078] Fine-tune the general language model using domain annotation data and fine-tuning prompt words so that it can accurately identify domain keywords. You can use various pre-trained general language models, such as BERT, RoBERTa, etc., and perform fine-tuning training. Finally, you will get a model that can accurately identify domain keywords. The fine-tuned general language model is the keyword extraction model.
[0079] Figure 3 The question-answering system flow chart provided in the embodiment of the present application is as follows: Figure 3As shown, it includes: segmenting the document into smaller text blocks, such as paragraphs, sentences, etc. This helps to improve the efficiency and accuracy of retrieval because smaller text blocks are easier to vectorize and retrieve.
[0080] However, existing document segmentation algorithms may fail to identify meaningful semantic units, such as segmenting text fragments that express different meanings into one text block. This will result in the text vector being unable to accurately express the meaning of the semantic fragment.
[0081] Therefore, in the embodiment of the present application, keywords related to a specific field are extracted from the text block, and these keywords can more accurately describe the subject and content of the document. A pre-trained keyword extraction model can be used for field keyword extraction, such as a model based on TF-IDF, TextRank and other algorithms.
[0082] Specifically, the keyword extraction model can be a fine-tuning of a general language model to adapt it to keyword extraction tasks in a specific field. For example, the general language model is fine-tuned using field data annotated by human experts to enable it to accurately identify field keywords.
[0083] Domain keywords can more accurately describe the subject and content of a document, thereby improving retrieval recall, and can also help distinguish documents with similar semantics, thereby improving retrieval accuracy.
[0084] In the embodiment of the present application, two-way retrieval recall is proposed: Text vector-based recall can be to calculate the similarity between the question query vector and each document fragment vector in the local text vector library, and select the document fragments with the highest similarity as the recalled documents.
[0085] Recall based on domain keywords can be done by querying the keyword inverted index to find a list of documents containing the keywords in the problem domain. Retrieve relevant document fragments from these documents and use them as recalled documents.
[0086] In the embodiment of the present application, multi-feature fusion rearrangement is proposed; the document title, section title, field keywords, document time and other information are spliced with the document text content to construct rearrangement features. The similarity between the question vector and the rearrangement feature vector of each recalled document is calculated.
[0087] In an optional embodiment, the rearrangement feature in the related art is: {query text: document fragment}; the feature of multi-feature fusion is: {query text: document fragment + document title + section title + domain keyword + document time}.
[0088] Finally, the recalled documents are sorted according to the similarity calculation results. The higher the similarity, the higher the document is ranked.
[0089] In the embodiment of the present application, multiple features of a document are taken into consideration, so that the document can be described more comprehensively, thereby improving the accuracy of the retrieval results.
[0090] The question and answer processing device provided by the present invention is described below. The question and answer processing device described below and the question and answer processing method described above can be referenced to each other.
[0091] Figure 4 A schematic diagram of the structure of the question-answer processing device provided in the embodiment of the present application is shown in FIG. Figure 4 As shown, including: The extraction module 410 is used to perform vectorized query and domain keyword extraction on the question content to obtain the question query vector and question domain keywords; The recall module 420 is used to perform retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; The rearrangement module 430 is used to perform multi-feature fusion rearrangement according to the recalled document and the question to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0092] Optionally, the device is also used for: Performing text parsing on the local document, removing symbols and irrelevant characters in the local document, and obtaining a plain text corresponding to the local document; After the plain text is processed into blocks, the text blocks are processed into vectorized text blocks through a large vectorization model, and each of the text blocks is converted into a numerical vector to obtain a local text vector library; Extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords; wherein the keyword extraction model is obtained by adjusting a general language model based on domain annotation data; All the local domain keywords are indexed to create a keyword inverted index; wherein the keyword inverted index is used to map the local domain keywords to a document list containing the local domain keywords.
[0093] Optionally, the device is also used for: Based on the question query vector, vector similarity retrieval and recall are performed in the local text vector library, and based on the question domain keywords, similarity retrieval and recall are performed in the local domain keywords to obtain recalled documents.
[0094] Optionally, the key information includes at least one of the following: title, section title, domain keyword, document time.
[0095] Optionally, the device is also used for: splicing the key information with the recalled document to construct a rearrangement feature; Based on a similarity measurement method, calculating the similarity between the question and the rearrangement feature; According to the similarity calculation result, the recalled documents are rearranged to obtain rearranged recalled documents.
[0096] Optionally, the device is also used for: Obtaining a prompt template corresponding to the question; wherein the prompt template is used to guide the generation of a large model to construct an answer; The rearranged recall documents and the prompt template are input into a large model to output the answer corresponding to the question.
[0097] Optionally, the device is also used for: Obtain system fine-tuning prompt words and user fine-tuning prompt words annotated by domain; The system fine-tuning prompt words and the user fine-tuning prompt words are input into a general language model to obtain the keyword extraction model.
[0098] In an embodiment of the present application, in the retrieval stage, multi-way retrieval recall is performed based on the question query vector and the question domain keywords. The multi-way recall method that combines domain keyword recall and vector recall can effectively overcome the problem of low recall accuracy of the semantic vector recall method due to inaccurate semantic vectors. In addition, in the rearrangement stage, on the basis of the recalled documents, the key information of the recalled documents is further integrated to achieve the integration of more detailed features without changing the rearrangement model, thereby improving the effectiveness of the rearrangement and ensuring the accuracy of the final output answer.
[0099] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the question-answering processing method, which includes: performing vectorized query and domain keyword extraction on the question content to obtain the question query vector and the question domain keyword; Performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Based on the recalled document and the question, multi-feature fusion rearrangement is performed to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0100] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0101] On the other hand, the present invention also provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the question-answering processing method provided by the above methods, the method includes: performing vectorized query and domain keyword extraction on the question content to obtain a question query vector and question domain keywords; Performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Based on the recalled document and the question, multi-feature fusion rearrangement is performed to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0102] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the question-answering processing method provided by the above methods, the method comprising: performing vectorized query and domain keyword extraction on the question content to obtain a question query vector and question domain keywords; Performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Based on the recalled document and the question, multi-feature fusion rearrangement is performed to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
[0103] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A question-answering processing method, characterized in that: include: Perform vectorized query and domain keyword extraction on the question content to obtain the question query vector and question domain keywords; Performing retrieval and recall based on the question query vector and the question domain keywords to obtain recalled documents; Based on the recalled document and the question, multi-feature fusion rearrangement is performed to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
2. The question-answer processing method according to claim 1, characterized in that: Before the step of performing retrieval and recall based on the question query vector and the question domain keywords to obtain the recalled documents, the method further includes: Performing text parsing on the local document, removing symbols and irrelevant characters in the local document, and obtaining a plain text corresponding to the local document; After the plain text is processed into blocks, the text blocks are processed into vectorized text blocks through a large vectorization model, and each of the text blocks is converted into a numerical vector to obtain a local text vector library; Extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords; The keyword extraction model is obtained by adjusting the general language model based on the domain annotation data; Indexing all the local domain keywords and creating a keyword inverted index; The keyword inverted index is used to map the local domain keyword to a document list containing the local domain keyword.
3. The question-answer processing method according to claim 2, characterized in that: Retrieval and recall are performed based on the question query vector and the question domain keywords to obtain recalled documents, including: Based on the question query vector, vector similarity retrieval and recall are performed in the local text vector library, and based on the question domain keywords, similarity retrieval and recall are performed in the local domain keywords to obtain recalled documents.
4. The question-answer processing method according to claim 1, characterized in that: Perform multi-feature fusion rearrangement according to the recalled document and the question to obtain rearranged recalled documents, including: Acquire key information in the recalled document, concatenate the key information with the recalled document, and construct a rearrangement feature; Based on a similarity measurement method, calculating the similarity between the question and the rearrangement feature; According to the similarity calculation result, the recalled documents are rearranged to obtain rearranged recalled documents.
5. The question-answer processing method according to claim 4, characterized in that: The key information includes at least one of the following: title, section title, domain keyword, document time.
6. The question-answer processing method according to claim 4, characterized in that: After the step of calculating the similarity between the question and the rearrangement feature based on the similarity measurement method and rearranging the recalled documents according to the similarity calculation result, the method further includes: Obtaining a prompt template corresponding to the question; wherein the prompt template is used to guide the generation of a large model to construct an answer; The rearranged recall documents and the prompt template are input into a large model to output the answer corresponding to the question.
7. The question-answer processing method according to claim 2, characterized in that: Before the step of extracting domain keywords from the text block through a keyword extraction model to obtain local domain keywords, the method further includes: Obtain system fine-tuning prompt words and user fine-tuning prompt words annotated by domain; The system fine-tuning prompt words and the user fine-tuning prompt words are input into a general language model to obtain the keyword extraction model.
8. A question-answer processing device, characterized in that: include: The extraction module is used to perform vectorized query and domain keyword extraction on the question content to obtain the question query vector and question domain keywords; A recall module, used to retrieve and recall based on the question query vector and the question domain keywords to obtain a recalled document; A rearrangement module is used to perform multi-feature fusion rearrangement based on the recalled document and the question to obtain a rearranged recalled document, wherein the rearranged recalled document is used to generate an answer corresponding to the question.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the question and answer processing method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the question and answer processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Question answering method, question answering system and computer readable storage medium
CN117520488A
Large model question and answer result optimization method, system and device
CN117540010A
Domain retrieval method based on meta-learning and knowledge enhancement
CN117609419A
Online intelligent question answering method and device based on instruction fine tuning and retrieval enhancement generation
CN117688163A
LLM-based intelligent questioning and answering method, system and equipment in power field and medium
CN118277521A
Cited By
Scientific and technological intelligence information retrieval result reordering method and equipment
CN119988585A
Text processing method and device and storage medium
CN119990142A
High-capacity text clue retrieval method and system based on enhanced retrieval, product and medium
CN120336494A
Intelligent question and answer method, device and equipment for knowledge in power production field and medium
CN120653727A
Intelligent document question and answer method, device and equipment and storage medium
CN120706544A