CN117236340A - Question answering method, device, equipment and medium - Google Patents

Question answering method, device, equipment and medium Download PDF

Info

Publication number
CN117236340A
CN117236340A CN202311141388.2A CN202311141388A CN117236340A CN 117236340 A CN117236340 A CN 117236340A CN 202311141388 A CN202311141388 A CN 202311141388A CN 117236340 A CN117236340 A CN 117236340A
Authority
CN
China
Prior art keywords
document
name
question
user
names
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311141388.2A
Other languages
Chinese (zh)
Inventor
曹培治
杜悦艺
张丽
王忠鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202311141388.2A priority Critical patent/CN117236340A/en
Publication of CN117236340A publication Critical patent/CN117236340A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a question and answer method, a question and answer device, question and answer equipment and a question and answer medium, and relates to the fields of natural language processing, deep learning, cloud computing and the like. The specific implementation scheme is as follows: acquiring a problem characterization vector corresponding to a user problem and document characterization vectors corresponding to a plurality of document names; determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector; inputting at least one candidate name and a user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name; and generating an answer to the user question according to the document content corresponding to the target name. Therefore, the method and the device can realize the generation of the answers to the user questions based on twice semantic retrieval, effectively acquire the target names of the documents to which the answers belong, and further can improve the semantic retrieval capability and the accuracy and reliability of the answers to the user questions.

Description

Question answering method, device, equipment and medium
Technical Field
The disclosure relates to the field of artificial intelligence, in particular to the technical fields of natural language processing, deep learning, cloud computing and the like, and particularly relates to a question-answering method, a question-answering device, question-answering equipment and a question-answering medium.
Background
The document question-answering system is used for answering questions posed by users based on a document knowledge base in a specific field. In the era of the wind age of large language models (Large Language Model, LLM), document question-answering system solutions of the externally hung knowledge base of the large language models are popular. However, when the solution of the document question-answering system of the external knowledge base of the large model is applied to a specific field, the semantic retrieval accuracy is insufficient, and the generation effect of the large model is poor. How to improve the semantic retrieval accuracy to assist in improving the accuracy and effect of large model generation is very important.
Disclosure of Invention
The present disclosure provides a method, apparatus, device and medium for question answering.
According to an aspect of the present disclosure, there is provided a question answering method, including:
acquiring a problem characterization vector corresponding to a user problem and document characterization vectors corresponding to a plurality of document names;
determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question-characterizing vector and the document-characterizing vector;
inputting the at least one candidate name and the user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name;
And generating an answer to the user question according to the document content corresponding to the target name.
According to another aspect of the present disclosure, there is provided a question answering apparatus, including:
the first acquisition module is used for acquiring a problem characterization vector corresponding to a user problem and document characterization vectors corresponding to a plurality of document names;
a determining module configured to determine at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector;
the processing module is used for inputting the at least one candidate name and the user question as first prompt information into a language model so as to select a target name of a document to which an answer belongs from the at least one candidate name;
and the generating module is used for generating an answer to the user question according to the document content corresponding to the target name.
According to still another aspect of the present disclosure, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the question-answering method set forth in the above aspect of the present disclosure.
According to yet another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium of computer instructions for causing the computer to perform the question-answering method set forth in the above aspect of the present disclosure.
According to a further aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the question-answering method set forth in the above aspect of the present disclosure.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a flowchart of a question-answering method according to an embodiment of the disclosure;
fig. 2 is a flow chart of a question-answering method according to a second embodiment of the disclosure;
fig. 3 is a flow chart of a question-answering method according to a third embodiment of the present disclosure;
fig. 4 is a flow chart of a question-answering method according to a fourth embodiment of the present disclosure;
FIG. 5 is a schematic flow chart of a method for implementing a document question-answering system based on two-stage semantic retrieval and large model generation provided by the present disclosure;
Fig. 6 is a schematic structural diagram of a question answering device according to a fifth embodiment of the present disclosure;
FIG. 7 illustrates a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the solution of the document question-answering system of the large model plug-in knowledge base, the solution is mainly realized by the following five steps:
step 1, loading a local document, reading the local document, and loading the local document into a text.
And 2, splitting the text, namely splitting the text according to characters, lengths or semantics.
And 3, matching the text according to the question, and carrying out character matching or semantic retrieval on the text according to the question of the user.
And 4, constructing a promt, and adding the matching text and the user question into the promt template.
Step 5.LLM generates an answer, and the answer based on the document content is obtained by sending the Prompt to LLM.
Compared with a fine tuning large model, the scheme has the following advantages:
1. with a wider coverage of domain knowledge, the solution can provide more accurate and up-to-date domain knowledge.
The trimming data for trimming the large model is generally not complete enough, and the data distribution of the trimming data is greatly different from the knowledge coverage and the complete knowledge base, and the trimming data may become outdated with the passage of time, while the scope of semantic retrieval in the above scheme can cover the entire knowledge base.
2. Context-specific answers, semantic retrieval and large model questions and answers may generate context-specific, more accurate answers based on specific paragraphs in the relevant documents. While the fine-tuned large model relies more on knowledge of the training phase code to generate answers that may not be accurate enough and independent of the context of the question.
3. The method has the characteristics of high applicability and low cost, and semantic retrieval can easily update a knowledge base or adjust to different fields. And the fine-tuning large model needs to re-label the sample and retrain the model, which not only consumes time, but also has high labeling and calculating cost.
Compared with a fine tuning large model, the solution of the document question-answering system of the large model externally hung with the knowledge base has the advantages of no need of labeling samples and retraining the model, and the effect is more excellent, so that the solution attracts attention of users in different fields and industries. However, there are a number of problems in directly applying the above solution to a specific field, where the problem of insufficient semantic retrieval accuracy is particularly serious, which may directly lead to a problem of poor effect of the large model generation link.
In view of at least one of the problems presented above, the present disclosure proposes a question-answering method, apparatus, device and medium.
The following describes a question answering method, apparatus, device and medium of the embodiments of the present disclosure with reference to the accompanying drawings.
Fig. 1 is a flowchart of a question-answering method according to an embodiment of the disclosure.
The embodiments of the present disclosure are exemplified in that the question answering method is configured in a question answering apparatus that can be applied to any electronic device so that the electronic device can perform a question answering function.
The electronic device may be any device with computing capability, for example, a PC (Personal Computer ), a mobile terminal, a server, and the like, and the mobile terminal may be, for example, a vehicle-mounted device, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, and other hardware devices with various operating systems, touch screens, and/or display screens.
As shown in fig. 1, the question answering method may include the steps of:
step 101, obtaining a question characterization vector corresponding to a user question and document characterization vectors corresponding to a plurality of document names.
In the embodiment of the present disclosure, the document name may be the name of the document to which the answer to the user question belongs, or may not be the name of the document to which the answer to the user question belongs, which is not limited in the present disclosure.
The user problem may be set as needed.
As an example, the user question may be set according to a specific domain direction (such as a specific application domain direction), for example, when the application domain direction is an algorithm direction, the setting question may be "what the skill focus of the algorithm direction is," and further, when the application domain direction is a recommended service direction, the prompt information may be "what the focus of the recommended service direction is," and so on, which are not listed herein.
In the embodiment of the disclosure, after the user problem and the plurality of document names are acquired, a problem characterization vector corresponding to the user problem and a document characterization vector corresponding to the plurality of document names may be acquired.
Step 102, determining at least one candidate name matching the user question from a plurality of document names based on the similarity between the question characterization vector and the document characterization vector.
In embodiments of the present disclosure, a similarity between a problem characterization vector and a document characterization vector may be determined. For example, a similarity algorithm between vectors may be employed to determine the similarity between the problem token vector and the document token vector; the similarity algorithm between vectors may be, for example, but not limited to, euclidean distance, cosine similarity, pearson correlation coefficient, manhattan distance, etc., which is not limited by the present disclosure.
In the embodiment of the present disclosure, the number of candidate names may be, but is not limited to, one, which the present disclosure does not limit.
In embodiments of the present disclosure, at least one candidate name that matches the user question may be determined from a plurality of document names based on a similarity between the question characterization vector and the document characterization vector.
As one example, a document name having the highest similarity among the similarities between the question-characterizing vector and the document-characterizing vector may be determined as a candidate name matching the user question.
As another example, the similarity between the question-characterizing vector and the document-characterizing vector may be ranked in order of from large to small, and the document name corresponding to the similarity with the ranked sequence smaller than the set threshold may be determined as the candidate name matching the user question. The set threshold may be preset, and the value of the set threshold is not limited in the disclosure.
It should be noted that the present disclosure does not limit the length of the user problem and the length of each document name.
And step 103, inputting at least one candidate name and the user question into the language model as first prompt information so as to select a target name of a document to which the answer belongs from the at least one candidate name.
In an embodiment of the present disclosure, the first hint information may be generated based on each candidate name and the user question.
For example, at least one candidate name and the user question may be combined to obtain the first prompt. For example, assuming that the candidate names include a document 1 name, a document 2 name, and a document 3 name … … document n name, the candidate names and the user questions may be combined in the following manner to obtain the first hint information as:
document:
{ document 1 name
Document 2 name
Document 3 name
Document n name }
Problems:
{ user question } ")
It should be noted that the above examples of combining the candidate names and the user questions are merely exemplary, and in practical applications, a specific combination manner may be selected according to needs, and the candidate names and the user questions may be combined, which is not limited in this disclosure.
In the disclosed embodiments, the language model may be, for example, but not limited to, ERNIE-Bot, which is not limiting in this disclosure.
In the embodiment of the disclosure, each candidate name and the user question can be input into the language model as the first prompt information, so that the target name of the document to which the answer corresponding to the user question belongs can be selected from the candidate names.
It should be noted that the number of the target names may be one or may be plural, which is not limited in this disclosure.
And 104, generating an answer to the user question according to the document content corresponding to the target name.
In the embodiment of the disclosure, an answer to the user question can be generated according to the document content corresponding to the target name.
According to the question answering method, the question characterization vectors corresponding to the user questions and the document characterization vectors corresponding to the plurality of document names are obtained; determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector; inputting at least one candidate name and a user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name; and generating an answer to the user question according to the document content corresponding to the target name. Therefore, on the basis of the first semantic retrieval, namely vector matching, the second semantic retrieval is performed by adopting a language model based on the first prompt information, so that the target name of the document to which the answer belongs can be effectively obtained, further, the answer to the user question can be generated, the semantic retrieval capability can be improved, and the accuracy and reliability of the answer to the user question can be improved.
In order to clearly illustrate that in the above embodiments of the present disclosure, answers to user questions are generated according to document content corresponding to target names, the present disclosure also provides a question-answering method.
Fig. 2 is a flowchart of a question answering method according to a second embodiment of the present disclosure.
As shown in fig. 2, the question-answering method may include the steps of:
step 201, obtaining a question characterization vector corresponding to a user question and document characterization vectors corresponding to a plurality of document names.
The explanation of step 201 may be referred to the relevant description in any embodiment of the present disclosure, and will not be repeated here.
In one possible implementation manner of the embodiment of the present disclosure, before obtaining a problem representation vector corresponding to a user problem and a document representation vector corresponding to a plurality of document names, a plurality of original documents may be obtained; for any original document, splitting the original document according to each title in the original document to split document contents of a plurality of documents, wherein the document name corresponding to each document content is a combination of the name of the original document and the corresponding title.
In the embodiment of the present disclosure, the manner of obtaining the original document is not limited, for example, the original document may be obtained from a local storage, or the original document may be collected online, for example, the original document may be collected online by a web crawler technology, or the original document may be collected offline, or the original document may be input by a user, or the like, which is not limited in this disclosure.
In the embodiment of the disclosure, for any original document, the original document may be split according to each title in the original document, document contents of a plurality of documents may be obtained, and each document content obtained after the splitting may be named by adopting a combination of a name of the original document and a corresponding title to a corresponding document content, so as to obtain a document name corresponding to each document content.
It should be noted that, the splitting granularity used in splitting the original document may be, but is not limited to, a minimum title level, which is not limited by the present disclosure.
As an example, assume that an original document includes document 1, the structure of document 1 being:
"document name M
First level title 1
Two-level title 1.1
Three level title 1.1.1
Document content A
Two-level title 1.2
Document content B
First level title 2
Second order title 2.1
Document content C
Splitting the original document according to each title in the document 1, and assuming that the splitting granularity is the minimum title level, namely, three-level title, the document contents of the obtained multiple documents are document content A, document content B and document content C, and the document content A is named by adopting the 'document name M+primary title 1+secondary title 1.1+tertiary title 1.1', the document content B is named by adopting the 'document name M+primary title 1+secondary title 1.2', and the document content C is named by adopting the 'document name M+primary title 2+secondary title 2.1', so that the document names corresponding to the document contents can be obtained.
It should be noted that the above example of splitting an original document is merely exemplary, and in practical application, a specific combination manner may be selected according to actual needs to combine a name and a corresponding title of the original document, which is not limited in this disclosure.
Therefore, the original document is split, and the name of each document content obtained by splitting is named by adopting the combination of the name of the original document and the corresponding title, so that the document name corresponding to each document content can be effectively obtained, and the user problem and the document name can be conveniently and fully subjected to semantic interaction in the subsequent processing.
It can be understood that naming the document content by adopting the combination of the name of the original document and the corresponding title is the semantic compression of the corresponding document content; in some particular areas, the similarity between the user question and the document name may be greater than the similarity between the user question and the document content.
Step 202, determining at least one candidate name matching the user question from a plurality of document names based on the similarity between the question characterization vector and the document characterization vector.
And 203, inputting at least one candidate name and the user question as first prompt information into a language model to select a target name of a document to which the answer belongs from the at least one candidate name.
The explanation of steps 202 to 203 may be referred to the relevant descriptions in any embodiment of the disclosure, and will not be repeated here.
And 204, filling the target name, the corresponding document content and the user problem into the corresponding filling position in the second prompt template to obtain second prompt information.
In the embodiment of the disclosure, the target name, the corresponding document content and the user problem can be filled into the corresponding filling position in the second prompt template, and the second prompt information can be obtained.
As an example, assuming that the target names include a document 1 name and a document 2 name … … document k name, the document contents corresponding to the target names are document 1 contents and document 2 contents … … document k contents, respectively, the target names and the corresponding document contents thereof, and the user questions are filled into the corresponding filling positions in the second prompt template, and the obtained second prompt information is:
"known contents:
{ document 1 name:
document 1 content }
{ document 2 name:
document 2 content }
{ document k name:
document k content }
Problems:
{ user question } ")
It should be noted that the above examples of the second alert template are merely exemplary, and in practical applications, the second alert template may be designed according to needs, which is not limited in this disclosure.
In one possible implementation of the embodiment of the present disclosure, the second alert template may further include a first filling location for fixing the reply text.
In the embodiment of the disclosure, the fixed reply text may be set by the user according to the needs, and may be used to indicate output of the language model when the answer to the user question is not queried in the document content corresponding to the target name. For example, the fixed reply text may be "unable to answer the question based on known information" or "not providing sufficient relevant information" or the like, which is not limited by the present disclosure.
It should be noted that the above examples of the fixed reply text are merely exemplary, and in practical applications, the fixed reply text may be set according to needs, which is not limited in this disclosure.
It should also be noted that the present disclosure does not limit the number of fixed reply texts, the text content, and the text length.
As an example, the template format of the second hint template is, for example:
"based on the following known information, the user's question is answered professionally.
If no answer can be obtained from the answer, please say "filling position 1" or "filling position 2", the addition of the composition in the answer is not allowed, and the answer is made using Chinese.
The following are known:
{ document 1 name:
document 1 content }
{ document 2 name:
document 2 content }
{ document k name:
document k content }
Problems:
{ user question } ")
Wherein the filling position 1 and the filling position 2 are the first filling positions for fixing the reply text.
In another possible implementation manner of the embodiment of the present disclosure, in a case that the second prompt template further includes a first filling position of the fixed reply text, the set fixed reply text may be filled into the corresponding first filling position.
Therefore, the second prompt information not only can comprise the target name and the corresponding document content thereof and the user problem, but also can comprise the fixed reply text, so that on one hand, the setting flexibility of the second prompt information can be improved, and on the other hand, the generating capacity of the language model can be improved in subsequent processing.
Step 205, the second prompt message is input into the language model to obtain the answer output by the language model.
In the embodiment of the disclosure, the second prompt information may be input into the language model to obtain an answer output by the language model.
According to the question-answering method, the target name, the corresponding document content and the user problem are filled in the corresponding filling position in the second prompt template, so that second prompt information is obtained; and inputting the second prompt information into the language model to obtain an answer output by the language model. Therefore, based on deep learning, answers corresponding to the user questions can be effectively obtained.
In order to clearly explain how at least one candidate name and a user question are input as first prompt information into a language model in any of the above embodiments of the present disclosure, the present disclosure further provides a question-answering method for selecting a target name of a document to which an answer belongs from at least one candidate name.
Fig. 3 is a flow chart of a question-answering method according to a third embodiment of the present disclosure.
As shown in fig. 3, the question-answering method may include the steps of:
step 301, obtaining a question characterization vector corresponding to a user question and document characterization vectors corresponding to a plurality of document names.
The explanation of step 301 may be referred to the relevant descriptions in any embodiment of the disclosure, and will not be repeated here.
And 302, filling at least one candidate name and a user problem into corresponding filling positions in the first prompt template to obtain first prompt information.
In the embodiment of the disclosure, at least one candidate name and a user question may be filled into a corresponding filling position in the first prompt template to obtain the first prompt information.
As an example, assuming that the candidate names include a document 1 name and a document 2 name … … document n name, the candidate names and the user questions are filled into corresponding filling positions in the first prompt template, and the obtained first prompt information is:
Document:
{ document 1 name
Document 2 name
Document n name }
Problem(s)
{ user question } ")
It should be noted that the above examples of the first alert template are merely exemplary, and in practical applications, the first alert template may be designed according to needs, which is not limited in this disclosure
In one possible implementation manner of the embodiment of the present disclosure, in a case that the first alert template further includes the second filling position, the set fixed number may be filled into the second filling position.
The fixed number can be used for indicating the number of target names which are required to be selected by the language model in at least one candidate name.
It should be noted that the fixed number may be set by the user according to the need, and the fixed number may be less than or equal to the number of candidate names.
In another possible implementation manner of the embodiment of the present disclosure, in a case where the third filling position is further included in the first alert template, the area to which the user problem belongs may be filled into the third filling position.
The domain may be used for selecting a target name from at least one candidate name based on the domain by the language model.
As an example, the number of candidate names is n, the names of document 1 and document 2 are respectively the names of … …, the fixed number may be k, and k is less than or equal to n, where n and k are positive integers, the domain to which the user problem belongs is "XXX", the set fixed number is filled into the second filling position, each candidate name and the user problem are filled into the corresponding filling position in the first prompt template, and after the domain to which the user problem belongs is filled into the third filling position, the obtained first prompt information is:
"you are an XXX domain expert please find k documents from the following n documents that are most likely to contain answers to questions, ask the answers to contain only the document name, and not allow the addition of the composition to the answers.
Document:
{ document 1 name
Document 2 name
Document 3 name
Document n name }
Problems:
{ user question } ")
The position of "XXX" is the corresponding third filling position, and the position of "k" is the corresponding second filling position.
Therefore, the first prompt information not only can comprise candidate names and user problems, but also can comprise the number of fields and/or target names to which the user problems belong, on one hand, the setting flexibility of the first prompt information can be improved, and on the other hand, the semantic retrieval capability can be improved in subsequent processing.
Step 303, inputting the first prompt information into the language model to obtain a target name of the document to which the corresponding answer belongs from at least one candidate name based on the user question by the language model.
It should be noted that the explanation of the language model and the target name in step 103 is also applicable to this embodiment, and will not be described here.
In the embodiment of the disclosure, the first prompt information may be input into the language model, so that the language model may select, based on the user question, a target name of the document to which the corresponding answer belongs from at least one candidate name.
Step 304, at least one candidate name and a user question are input into the language model as first prompt information, so as to select a target name of a document to which an answer belongs from the at least one candidate name.
Step 305, generating an answer to the user question according to the document content corresponding to the target name.
The explanation of steps 304 to 305 may be referred to the relevant descriptions in any embodiment of the disclosure, and will not be repeated here.
According to the question-answering method, at least one candidate name and a user question are filled in corresponding filling positions in a first prompt template, so that first prompt information is obtained; and inputting the first prompt information into the language model to obtain a target name of a document to which the corresponding answer belongs from at least one candidate name based on the user question by the language model. Therefore, the second semantic retrieval of the user questions by adopting the language model based on the first prompt information can be realized, the target names of the documents to which the answers corresponding to the user questions belong can be effectively obtained, and the accuracy of the semantic retrieval is improved.
In order to clearly illustrate any embodiment of the present disclosure, the present disclosure further provides a question answering method, where the question characterizing vector corresponding to the user question and the document characterizing vectors corresponding to the plurality of document names are obtained.
Fig. 4 is a flowchart of a question-answering method according to a fourth embodiment of the present disclosure.
As shown in fig. 4, the question-answering method may include the steps of:
and step 401, encoding the user problem by adopting an embedded model to obtain a problem characterization vector of the user problem.
In the embodiment of the disclosure, the embedded model may be used to encode the user problem to obtain a problem characterization vector of the user problem.
Step 402, encoding the plurality of document names by using the embedded model to obtain a document characterization vector of each document name.
In embodiments of the present disclosure, multiple document names may be encoded using an embedded model to obtain a document characterization vector for each document name.
As one possible implementation, for any document name, the terms in the document name are compared with proper nouns in a proper noun dictionary; in the case that the proper noun is contained in the document name, replacing the proper noun by a general word for explaining the proper noun to obtain a replaced document name; the method comprises the steps of inputting a document name before replacement into an embedded model for encoding to obtain a document characterization vector corresponding to the document name before replacement, and inputting the document name after replacement into the embedded model for encoding to obtain the document characterization vector corresponding to the document name after replacement.
In the embodiment of the present disclosure, the proper noun dictionary may be a dictionary set or created in advance according to proper nouns of a specific field.
In the embodiment of the disclosure, for any document name, the words in the document name may be compared with proper nouns in the proper noun dictionary. For example, for any document name, word segmentation processing can be performed on the document name to obtain each word segment; and comparing each word with the proper nouns in the proper noun dictionary to determine whether each word is a proper noun in the proper noun dictionary, namely determining whether each word in the document name is a proper noun in the proper noun dictionary.
In the embodiment of the present disclosure, in the case where proper nouns are included in document names, the proper nouns may be replaced with general words explaining the proper nouns to obtain replaced document names. For example, the document name contains a proper noun "QoS", a generic word explaining the proper noun is "flow control", and "flow control" may be used to replace the proper noun "QoS" in the document name, so that the replaced document name may be obtained.
In the embodiment of the disclosure, the document name before the replacement may be input to the embedded model to be encoded so as to obtain a document characterization vector corresponding to the document name before the replacement, and the document name after the replacement may be input to the embedded model to be encoded so as to obtain a document characterization vector corresponding to the document name after the replacement.
Therefore, the embedded model can learn the semantic information of proper nouns in the specific field, and the flexibility and applicability of the method are improved.
Step 403, determining at least one candidate name matching the user question from the plurality of document names based on the similarity between the question characterization vector and the document characterization vector.
The explanation of step 403 may be referred to the relevant descriptions in any embodiment of the disclosure, and will not be repeated here.
As one possible implementation manner, in the case that the document characterization vector of each document name includes a document characterization vector corresponding to the document name before replacement and a document characterization vector corresponding to the document name after replacement, when at least one of the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector and the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector is greater than the set similarity threshold, the document name before replacement may be determined as the candidate name.
That is, whether the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector is greater than the set similarity threshold, or the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector is greater than the set similarity threshold, the document name before replacement may be determined as the candidate name.
It should be noted that, the set similarity threshold may be preset, and the value of the set similarity threshold is not limited in this disclosure.
Therefore, whether the document name before replacement is a candidate name can be determined based on the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector, and whether the document name before replacement is a candidate name can be determined based on the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector, so that the flexibility and the comprehensiveness of the method can be improved.
Step 404, at least one candidate name and a user question are input into the language model as first prompt information, so as to select a target name of a document to which the answer belongs from the at least one candidate name.
Step 405, generating an answer to the user question according to the document content corresponding to the target name.
The explanation of steps 404 to 405 may be referred to the relevant descriptions in any embodiment of the disclosure, and will not be repeated here.
According to the question answering method, the embedded model is adopted to encode the user questions so as to obtain the question characterization vectors of the user questions; and encoding the plurality of document names by adopting an embedded model to obtain document characterization vectors of the document names. Therefore, the problem representation vector of the user problem and the document representation vector of each document name can be effectively obtained.
In order to more clearly illustrate the above embodiments, the following detailed description is made in connection with examples.
As one example, an example is illustrated with the question-answering method of the present disclosure applied to a document question-answering system generated based on two-stage semantic retrieval and a large model. Fig. 5 is a schematic flow chart of a method for implementing a document question-answering system based on two-stage semantic search and large model generation provided by the present disclosure. The method is based on a document library in a specific field, and optimizes a document segmentation or splitting mode and a semantic retrieval strategy.
As shown in FIG. 5, the method for implementing the document question-answering system based on two-stage semantic retrieval and large model generation can comprise the following steps:
step 1, original document parsing and splitting
First, a locally stored original document may be read and may be loaded as corresponding text.
The original document may then be split.
The splitting granularity can be the minimum title level to ensure semantic continuity and knowledge integrity.
Note that, the document content of the plurality of divided documents may adopt "the name of the original document+the corresponding respective levels of titles" as the corresponding document name, and a dictionary corresponding thereto may be generated, where key is the "the name of the original document+the corresponding respective levels of titles" form of the document name, and value is the divided document content.
It will be appreciated that due to the complexity of the document content, there may be problems with matching the document content with the user questions. In the subsequent semantic retrieval, the present disclosure may perform semantic retrieval on the document name according to the user question. Because the document names are a combination of the names of the original documents and the corresponding levels of titles, which may be considered semantic compression of the document content, in some particular areas, user questions may be more matched to the document names than to the document content, i.e., the similarity between the user questions and the document names is greater than the similarity between the user questions and the corresponding document content.
Meanwhile, as the input length which can be received by the embedding model (recorded as the embedding model in the disclosure) is limited, the original document is split according to the title, each text content after the splitting is generally longer, but the document name length corresponding to each text content is limited, so that the document name is more suitable for the embedding model, and the calculation amount of the model can be reduced. Therefore, the semantic retrieval is carried out on the document name, and the problem that the receiving length of the ebedding model is limited can be effectively avoided.
Step 2, proper noun replacement
First, because the emmbedding model is not trained on domain data, the emmbedding model may lack some domain knowledge, primarily in the sense that proper nouns cannot be understood.
Therefore, a domain proper noun dictionary (which is referred to as proper noun dictionary in the present disclosure) may be created in advance, in which a key is a domain proper noun (which is referred to as proper noun in the present disclosure), a value is a generic word explaining a domain proper noun, such as "flow control" as a generic word corresponding to a domain proper noun "QoS".
According to the domain proper noun dictionary, the domain proper noun in the document name is replaced by a general word for explaining the domain proper noun, and the two document names before and after replacement correspond to the same document content. That is, the user can search the document name before the replacement or search the document name after the replacement, and whether the document name before the replacement or the document name after the replacement is searched, the recall of the correct answer can be ensured. It should be noted that, the method may indirectly inject the expert knowledge for the ebedding model.
Step 3, constructing a knowledge base
1) Vectorizing each document name by adopting an Embedding model to obtain a corresponding document name vector (marked as a document characterization vector in the present disclosure);
2) Storing the document name vector in a vector database;
3) An index between the document name vector and the document name and document content is established.
Step 4, searching the document name according to the user problem
1) Acquiring a user problem;
2) Vectorizing user questions using an Embedding model to obtain question vectors (denoted as question characterization vectors in this disclosure);
3) Searching n document name vectors with highest cosine similarity with the problem vectors in a vector database;
4) According to the index between the document name vector and the document name, the document names corresponding to the n document name vectors are obtained, namely, the n document names most similar to the user problem are obtained.
Step 5, constructing a semantic retrieval Prompt template (noted as a first hint template in this disclosure)
And (5) adding the n document names and the user questions retrieved in the step (4) into a semantic retrieval campt template. The semantic search template format is as follows:
"you are an XXX domain expert please find k documents most likely to contain answers to questions from the following n document names, ask the answers to contain only the document names, and not allow the addition of the composition to the answers.
Document:
{ document 1 name
Document 2 name
Document 3 name
Document n name }
Problems:
{ user question } ")
Step 6, large model secondary semantic retrieval
It should be noted that the present invention adopts the ERNIE-Bot model as the secondary semantic retrieval model (denoted as language model in this disclosure).
Inputting the semantic search Prompt content (noted as first Prompt information in the disclosure) constructed in the step 5 into an ERNIE-Bot model, and selecting k most similar target names of a document to which an answer corresponding to a user question belongs from n document names.
Step 7, constructing a Prompt template (noted as a second hint template in this disclosure)
And (3) filling k most similar target names and corresponding document contents and user problems which are searched by the secondary semantic search model in the step (6) into a Prompt template. The format of the template is as follows:
"based on the following known information, the user's question is answered professionally.
If an answer cannot be obtained from the answer, please say "the question cannot be answered according to the known information" or "sufficient relevant information is not provided", the addition of the composition to the answer is not allowed, and the answer is made using Chinese.
The following are known:
{ document 1 name:
document 1 content }
{ document 2 name:
document 2 content }
{ document k name:
document k content }
Problems:
{ user question } ")
Step 8, generating answers by the large model
It should be noted that the invention adopts the ERNIE-Bot model as the final answer generation model.
The Prompt content constructed in step 7 (noted as second Prompt in this disclosure) is input into an ERNIE-Bot model, which can generate context-specific answers from user questions and related documents.
In conclusion, the document question-answering system implementation method based on two-stage semantic retrieval and large model generation can effectively improve the field document recall accuracy and the large model generation effect. Compared with the document question-answering system solution of a large model plug-in knowledge base in the related technical field, the document question-answering system solution has the following innovation points:
1. the present disclosure optimizes document segmentation policies and document retrieval approaches.
Firstly, splitting an original document according to titles, so that semantic continuity and knowledge integrity can be reserved, and the split document content can be named by adopting 'the names of the original document + corresponding titles of all levels'; meanwhile, domain proper nouns in the names of all documents are replaced by using domain proper noun dictionaries, so that the problem that a semantic retrieval model lacks domain knowledge is effectively solved; then, semantic retrieval is carried out on each document name according to the user problem, so that the correlation between the user problem and the original document can be improved, and the matching difficulty between the user problem and the document content can be reduced.
2. The present disclosure proposes a large model secondary semantic retrieval method based on semantic retrieval using an ebadd model.
Firstly, adopting n document names with highest similarity between recalling and user questions of an embellishing model, constructing a semantic retrieval template by utilizing the n document names and the user, and inputting the template into a large model to carry out second semantic retrieval, so that the large model outputs k most similar target names of documents corresponding to answers of the user questions based on the user questions.
The method fully utilizes the general knowledge of the large model coding in the training stage, overcomes the disadvantage that the self-training of the empdding model is impossible, and is very suitable for semantic retrieval scenes with few samples or without labeling samples.
In correspondence to the question-answering method provided by the embodiments of fig. 1 to 4, the present disclosure also provides a question-answering device, and since the question-answering device provided by the embodiments of the present disclosure corresponds to the question-answering method provided by the embodiments of fig. 1 to 4, the implementation of the question-answering method is also applicable to the question-answering device provided by the embodiments of the present disclosure, and will not be described in detail in the embodiments of the present disclosure.
Fig. 6 is a schematic structural diagram of a question answering device according to a fifth embodiment of the present disclosure.
As shown in fig. 6, the question answering apparatus 600 may include: a first acquisition module 601, a determination module 602, a processing module 603, and a generation module 604.
The first obtaining module 601 is configured to obtain a problem token vector corresponding to a user problem and document token vectors corresponding to a plurality of document names.
A determining module 602 is configured to determine at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector.
The processing module 603 is configured to input at least one candidate name and a user question as a first prompt information into the language model, so as to select a target name of a document to which the answer belongs from the at least one candidate name.
And the generating module 604 is used for generating an answer to the user question according to the document content corresponding to the target name.
In one possible implementation of the embodiments of the present disclosure, the generating module 604 is configured to: filling the target name, the corresponding document content and the user problem into the corresponding filling position in the second prompt template to obtain second prompt information; and inputting the second prompt information into the language model to obtain an answer output by the language model.
In one possible implementation manner of the embodiment of the present disclosure, the second prompting template further includes a first filling location for fixing the reply text, and the question answering apparatus 600 may further include:
the first filling module is used for filling the set fixed reply text into the first filling position, wherein the fixed reply text is used for indicating the language model to output when the answer of the user question is not queried in the document content corresponding to the target name.
In one possible implementation of the embodiment of the disclosure, the processing module 603 is configured to: filling at least one candidate name and a user problem into a corresponding filling position in a first prompt template to obtain first prompt information; and inputting the first prompt information into the language model to obtain a target name of a document to which the corresponding answer belongs from at least one candidate name based on the user question by the language model.
In one possible implementation manner of the embodiment of the present disclosure, the first prompt template further includes a second filling location, and the question answering apparatus 600 may further include:
and the second filling module is used for filling the set fixed number into a second filling position, wherein the fixed number is used for indicating the number of target names which are required to be selected in at least one candidate name by the language model.
In one possible implementation manner of the embodiment of the present disclosure, the first prompt template further includes a third filling location, and the question answering apparatus 600 may further include:
and a third filling module, configured to fill a domain to which the user problem belongs to a third filling location, where the domain is used by the language model to select a target name from at least one candidate name based on the domain.
In one possible implementation of the embodiment of the present disclosure, the question answering apparatus 600 may further include:
and the second acquisition module is used for acquiring a plurality of original documents.
The splitting module is used for splitting the original document according to each title in the original document aiming at any original document to split document contents of a plurality of documents, wherein the document name corresponding to each document content is a combination of the name of the original document and the corresponding title.
In one possible implementation manner of the embodiment of the present disclosure, the first obtaining module 601 is configured to: encoding the user problem by adopting an embedded model to obtain a problem characterization vector of the user problem; and encoding the plurality of document names by adopting an embedded model to obtain document characterization vectors of the document names.
In one possible implementation manner of the embodiment of the present disclosure, the first obtaining module 601 is configured to: comparing the words in the document names with proper nouns in the proper noun dictionary aiming at any document name; in the case that the proper noun is contained in the document name, replacing the proper noun by a general word for explaining the proper noun to obtain a replaced document name; the method comprises the steps of inputting a document name before replacement into an embedded model for encoding to obtain a document characterization vector corresponding to the document name before replacement, and inputting the document name after replacement into the embedded model for encoding to obtain the document characterization vector corresponding to the document name after replacement.
In one possible implementation of an embodiment of the disclosure, the determining module 602 is configured to: and determining the document name before replacement as a candidate name if at least one of the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector and the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector is larger than a set similarity threshold.
According to the question answering device, the question characterization vectors corresponding to the user questions and the document characterization vectors corresponding to the plurality of document names are obtained; determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector; inputting at least one candidate name and a user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name; and generating an answer to the user question according to the document content corresponding to the target name. Therefore, on the basis of the first semantic retrieval, namely vector matching, the second semantic retrieval is performed by adopting a language model based on the first prompt information, so that the target name of the document to which the answer belongs can be effectively obtained, further, the answer to the user question can be generated, the semantic retrieval capability can be improved, and the accuracy and reliability of the answer to the user question can be improved.
To achieve the above embodiments, the present disclosure also provides an electronic device that may include at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the question-answering method according to any one of the above embodiments of the present disclosure.
To achieve the above embodiments, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the question answering method set forth in any one of the above embodiments of the present disclosure.
To achieve the above embodiments, the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the question answering method set forth in any one of the above embodiments of the present disclosure.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
FIG. 7 illustrates a schematic block diagram of an example electronic device that may be used to implement embodiments of the present disclosure. The electronic device may include the server and the client in the above embodiments. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 702 or a computer program loaded from a storage unit 708 into a RAM (Random Access Memory ) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 may also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. An I/O (Input/Output) interface 705 is also connected to bus 704.
Various components in the electronic device 700 are connected to the I/O interface 705, including: an input unit 706 such as a keyboard, a mouse, etc.; an output unit 707 such as various types of displays, speakers, and the like; a storage unit 708 such as a magnetic disk, an optical disk, or the like; and a communication unit 709 such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information/data with other devices through a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 701 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 701 include, but are not limited to, a CPU (Central Processing Unit ), a GPU (Graphic Processing Units, graphics processing unit), various dedicated AI (Artificial Intelligence ) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor ), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the respective methods and processes described above, such as the question-answering method described above. For example, in some embodiments, the question answering method described above may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 700 via the ROM 702 and/or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the question-answering method described above can be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the question-answering method described above by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit System, FPGA (Field Programmable Gate Array ), ASIC (Application-Specific Integrated Circuit, application-specific integrated circuit), ASSP (Application Specific Standard Product, special-purpose standard product), SOC (System On Chip ), CPLD (Complex Programmable Logic Device, complex programmable logic device), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory, erasable programmable read-Only Memory) or flash Memory, an optical fiber, a CD-ROM (Compact Disc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display ) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network ), WAN (Wide Area Network, wide area network), internet and blockchain networks.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service (Virtual Private Server, virtual special servers) are overcome. The server may also be a server of a distributed system or a server that incorporates a blockchain.
It should be noted that, artificial intelligence is a subject of studying a certain thought process and intelligent behavior (such as learning, reasoning, thinking, planning, etc.) of a computer to simulate a person, and has a technology at both hardware and software level. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing, and the like; the artificial intelligence software technology mainly comprises a computer vision technology, a voice recognition technology, a natural language processing technology, a machine learning/deep learning technology, a big data processing technology, a knowledge graph technology and the like.
Deep learning is a new research direction in the field of machine learning. It is the inherent law and presentation hierarchy of learning sample data, and the information obtained during these learning processes greatly helps the interpretation of data such as text, images and sounds. Its final goal is to have the machine have analytical learning capabilities like a person, and to recognize text, image, and sound data.
Cloud computing (cloud computing) refers to a technical system that accesses an elastically extensible shared physical or virtual resource pool through a network, wherein resources can include servers, operating systems, networks, software, applications, storage devices and the like, and can be deployed and managed in an on-demand and self-service manner. Through cloud computing technology, high-efficiency and powerful data processing capability can be provided for technical application such as artificial intelligence and blockchain, and model training.
According to the technical scheme of the embodiment of the disclosure, the problem characterization vectors corresponding to the user problems and the document characterization vectors corresponding to the plurality of document names are obtained; determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector; inputting at least one candidate name and a user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name; and generating an answer to the user question according to the document content corresponding to the target name. Therefore, on the basis of the first semantic retrieval, namely vector matching, the second semantic retrieval is performed by adopting a language model based on the first prompt information, so that the target name of the document to which the answer belongs can be effectively obtained, further, the answer to the user question can be generated, the semantic retrieval capability can be improved, and the accuracy and reliability of the answer to the user question can be improved.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the technical solutions presented in the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (23)

1. A question-answering method, comprising:
acquiring a problem characterization vector corresponding to a user problem and document characterization vectors corresponding to a plurality of document names;
determining at least one candidate name matching the user question from the plurality of document names based on a similarity between the question-characterizing vector and the document-characterizing vector;
inputting the at least one candidate name and the user question as first prompt information into a language model to select a target name of a document to which an answer belongs from the at least one candidate name;
and generating an answer to the user question according to the document content corresponding to the target name.
2. The method of claim 1, wherein the generating an answer to the user question according to the document content corresponding to the target name comprises:
Filling the target name, the corresponding document content and the user problem into the corresponding filling position in a second prompt template to obtain the second prompt information;
and inputting the second prompt information into the language model to obtain an answer output by the language model.
3. The method of claim 2, wherein the second hint template further includes a first fill position in which to fix the reply text, the method further comprising:
and filling the set fixed reply text into the first filling position, wherein the fixed reply text is used for indicating the language model to output when the answer of the user question is not queried in the document content corresponding to the target name.
4. The method of claim 1, wherein the inputting the at least one candidate name and the user question as the first prompt information into the language model to select a target name of a document to which the answer belongs from the at least one candidate name comprises:
filling the at least one candidate name and the user problem into corresponding filling positions in a first prompt template to obtain the first prompt information;
And inputting the first prompt information into the language model to obtain the target name of the document to which the corresponding answer belongs from the at least one candidate name based on the user question by the language model.
5. The method of claim 4, wherein the first hint template further includes a second fill location therein, the method further comprising:
and filling the set fixed number into the second filling position, wherein the fixed number is used for indicating the number of target names which are required to be selected by the language model in the at least one candidate name.
6. The method of claim 4, wherein the first hint template further includes a third fill location therein, the method further comprising:
and filling the domain to which the user problem belongs into the third filling position, wherein the domain is used for selecting the target name from the at least one candidate name by the language model based on the domain.
7. The method according to any one of claims 1-6, wherein before obtaining a question characterization vector corresponding to a user question and document characterization vectors corresponding to a plurality of document names, further comprising:
Acquiring a plurality of original documents;
for any original document, splitting the original document according to each title in the original document to split document contents of a plurality of documents, wherein the document name corresponding to each document content is a combination of the name of the original document and the corresponding title.
8. The method of any of claims 1-6, wherein the obtaining a question-characterizing vector for a user question and document-characterizing vectors for a plurality of document names comprises:
encoding the user problem by adopting an embedded model to obtain a problem representation vector of the user problem;
and encoding the plurality of document names by adopting the embedded model to obtain the document characterization vector of each document name.
9. The method of claim 8, wherein said encoding said plurality of document names with said embedded model to obtain said document characterization vector for each said document name comprises:
comparing the words in the document names with proper nouns in a proper noun dictionary aiming at any one of the document names;
in the case that the proper noun is contained in the document name, replacing the proper noun with a generic word explaining the proper noun to obtain a replaced document name;
Inputting the document name before replacement into the embedded model for coding to obtain a document characterization vector corresponding to the document name before replacement, and inputting the document name after replacement into the embedded model for coding to obtain a document characterization vector corresponding to the document name after replacement.
10. The method of claim 9, wherein the determining at least one candidate name from the plurality of document names that matches the user question based on a similarity between the question-characterizing vector and the document-characterizing vector comprises:
and determining the document name before replacement as the candidate name if at least one of the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector and the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector is larger than a set similarity threshold.
11. A question answering apparatus comprising:
the first acquisition module is used for acquiring a problem characterization vector corresponding to a user problem and document characterization vectors corresponding to a plurality of document names;
a determining module configured to determine at least one candidate name matching the user question from the plurality of document names based on a similarity between the question characterization vector and the document characterization vector;
The processing module is used for inputting the at least one candidate name and the user question as first prompt information into a language model so as to select a target name of a document to which an answer belongs from the at least one candidate name;
and the generating module is used for generating an answer to the user question according to the document content corresponding to the target name.
12. The apparatus of claim 11, wherein the generating module is specifically configured to:
filling the target name, the corresponding document content and the user problem into the corresponding filling position in a second prompt template to obtain the second prompt information;
and inputting the second prompt information into the language model to obtain an answer output by the language model.
13. The apparatus of claim 12, wherein the second alert template further includes therein a first fill location for fixing reply text, the apparatus further comprising:
the first filling module is used for filling the set fixed reply text into the first filling position, wherein the fixed reply text is used for indicating the language model to output when the answer of the user question is not queried in the document content corresponding to the target name.
14. The apparatus of claim 11, wherein the processing module is specifically configured to:
filling the at least one candidate name and the user problem into corresponding filling positions in a first prompt template to obtain the first prompt information;
and inputting the first prompt information into the language model to obtain the target name of the document to which the corresponding answer belongs from the at least one candidate name based on the user question by the language model.
15. The apparatus of claim 14, wherein the first hint template further includes a second fill location therein, the apparatus further comprising:
and the second filling module is used for filling the set fixed number into the second filling position, wherein the fixed number is used for indicating the number of target names which are required to be selected by the language model in the at least one candidate name.
16. The apparatus of claim 14, wherein the first hint template further includes a third fill location therein, the apparatus further comprising:
and a third filling module, configured to fill a domain to which the user problem belongs into the third filling location, where the domain is used for the language model to select the target name from the at least one candidate name based on the domain.
17. The apparatus of any of claims 11-16, wherein the apparatus further comprises:
the second acquisition module is used for acquiring a plurality of original documents;
the splitting module is used for splitting any original document according to each title in the original document to split document contents of a plurality of documents, wherein the document name corresponding to each document content is a combination of the name of the original document and the corresponding title.
18. The apparatus of any one of claims 11-16, wherein the first acquisition module is specifically configured to:
encoding the user problem by adopting an embedded model to obtain a problem representation vector of the user problem;
and encoding the plurality of document names by adopting the embedded model to obtain the document characterization vector of each document name.
19. The apparatus of claim 18, wherein the first acquisition module is specifically configured to:
comparing the words in the document names with proper nouns in a proper noun dictionary aiming at any one of the document names;
in the case that the proper noun is contained in the document name, replacing the proper noun with a generic word explaining the proper noun to obtain a replaced document name;
Inputting the document name before replacement into the embedded model for coding to obtain a document characterization vector corresponding to the document name before replacement, and inputting the document name after replacement into the embedded model for coding to obtain a document characterization vector corresponding to the document name after replacement.
20. The apparatus of claim 19, wherein the determining module is specifically configured to:
and determining the document name before replacement as the candidate name if at least one of the similarity between the document characterization vector corresponding to the document name before replacement and the problem characterization vector and the similarity between the document characterization vector corresponding to the document name after replacement and the problem characterization vector is larger than a set similarity threshold.
21. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the question-answering method according to any one of claims 1-10.
22. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the question-answering method according to any one of claims 1-10.
23. A computer program product comprising a computer program which, when executed by a processor, implements the steps of the question-answering method according to any one of claims 1 to 10.
CN202311141388.2A 2023-09-05 2023-09-05 Question answering method, device, equipment and medium Pending CN117236340A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311141388.2A CN117236340A (en) 2023-09-05 2023-09-05 Question answering method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311141388.2A CN117236340A (en) 2023-09-05 2023-09-05 Question answering method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN117236340A true CN117236340A (en) 2023-12-15

Family

ID=89081749

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311141388.2A Pending CN117236340A (en) 2023-09-05 2023-09-05 Question answering method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN117236340A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117828050A (en) * 2023-12-29 2024-04-05 北京智谱华章科技有限公司 Traditional Chinese medicine question-answering method, equipment and medium based on long-document retrieval enhancement generation

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117828050A (en) * 2023-12-29 2024-04-05 北京智谱华章科技有限公司 Traditional Chinese medicine question-answering method, equipment and medium based on long-document retrieval enhancement generation

Similar Documents

Publication Publication Date Title
CN112685565B (en) Text classification method based on multi-mode information fusion and related equipment thereof
CN112560479A (en) Abstract extraction model training method, abstract extraction device and electronic equipment
CN112287069B (en) Information retrieval method and device based on voice semantics and computer equipment
CN112100332A (en) Word embedding expression learning method and device and text recall method and device
CN112528001B (en) Information query method and device and electronic equipment
CN111382260A (en) Method, device and storage medium for correcting retrieved text
CN111611805A (en) Auxiliary writing method, device, medium and equipment based on image
CN115062134B (en) Knowledge question-answering model training and knowledge question-answering method, device and computer equipment
CN116186200B (en) Model training method, device, electronic equipment and storage medium
US11880664B2 (en) Identifying and transforming text difficult to understand by user
CN110795541A (en) Text query method and device, electronic equipment and computer readable storage medium
CN116152833B (en) Training method of form restoration model based on image and form restoration method
US20230215203A1 (en) Character recognition model training method and apparatus, character recognition method and apparatus, device and storage medium
CN117236340A (en) Question answering method, device, equipment and medium
CN115062718A (en) Language model training method and device, electronic equipment and storage medium
CN116796730A (en) Text error correction method, device, equipment and storage medium based on artificial intelligence
CN116913278B (en) Voice processing method, device, equipment and storage medium
CN116662583B (en) Text generation method, place retrieval method and related devices
CN111930891B (en) Knowledge graph-based search text expansion method and related device
CN113850383A (en) Text matching model training method and device, electronic equipment and storage medium
CN113360683A (en) Method for training cross-modal retrieval model and cross-modal retrieval method and device
CN114841471B (en) Knowledge point prediction method and device, electronic equipment and storage medium
CN115510203B (en) Method, device, equipment, storage medium and program product for determining answers to questions
CN116719918A (en) Question answering method and device, electronic equipment and storage medium
CN113704466B (en) Text multi-label classification method and device based on iterative network and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination