WO2022088671A1 - Automated question answering method and apparatus, device, and storage medium - Google Patents

Automated question answering method and apparatus, device, and storage medium Download PDF

Info

Publication number
WO2022088671A1
WO2022088671A1 PCT/CN2021/097419 CN2021097419W WO2022088671A1 WO 2022088671 A1 WO2022088671 A1 WO 2022088671A1 CN 2021097419 W CN2021097419 W CN 2021097419W WO 2022088671 A1 WO2022088671 A1 WO 2022088671A1
Authority
WO
WIPO (PCT)
Prior art keywords
entity
attribute
name
predicted
question
Prior art date
Application number
PCT/CN2021/097419
Other languages
French (fr)
Chinese (zh)
Inventor
侯丽
刘翔
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022088671A1 publication Critical patent/WO2022088671A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/242Dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities

Definitions

  • the present application relates to the technical field of artificial intelligence, and in particular, to an automatic question answering method, apparatus, computer equipment, and computer-readable storage medium.
  • Knowledge graph technology is an important part of artificial intelligence technology, which describes the relationship between concepts, entities and their keys in the objective world in a structured way.
  • Knowledge graph technology provides a better ability to organize, manage and understand the massive information on the Internet, expressing the information on the Internet into a form that is closer to human cognition of the world. Therefore, establishing a knowledge base with semantic processing capability and open interconnection capability can generate application value in intelligent information services such as intelligent search, intelligent question answering, and personalized recommendation.
  • the methods used in the current mainstream knowledge base-based automatic question answering can be divided into two categories: semantic parsing-based (SP-based) methods and information retrieval-based (IR-based) methods.
  • SP-based semantic parsing-based
  • IR-based information retrieval-based
  • the inventors realized that the method based on semantic analysis first converts the question in the form of natural language into a certain type of logical expression form.
  • Traditional semantic analysis needs to be supervised by logical forms marked with part-of-speech information, and is limited by only a few narrow domains of logical predicates.
  • the method of information retrieval first obtains a series of candidate answers from the knowledge base through a relatively rough method, and then extracts features from the questions and candidate answers, uses them to sort the candidate answers, and selects the one with the highest score as the final answer.
  • information retrieval methods lack the understanding of deep semantics, resulting in low accuracy of automatic question answering.
  • the main purpose of the present application is to provide an automatic question answering method, device, computer equipment and computer readable storage medium, which aims to solve the problem that traditional semantic analysis requires a marked logical form as supervision data, and relies on a small number of logical predicates, and Information retrieval lacks the understanding of deep semantics, which leads to technical problems with low accuracy of automatic question answering for semantic analysis and information retrieval.
  • the present application provides an automatic question answering method, which includes the following steps:
  • the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted.
  • the target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
  • the present application also provides an automatic question answering device, the automatic question answering device comprising:
  • the obtaining module is used to obtain the entity alias of each word in the question to be predicted according to the preset alias dictionary, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
  • the determination module is used to determine the entity name corresponding to the to-be-predicted problem according to the to-be-predicted problem and a plurality of the candidate entities based on the preset entity recognition model;
  • the second determination module is used to determine the entity name corresponding to the to-be-predicted problem according to the setting a map database, determining the triplet corresponding to the entity name in the preset map database, wherein the triplet includes an attribute name and an attribute value, and the triplet is multiple;
  • the third determining module using Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the
  • the present application also provides a computer device, the computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program is executed by the When the processor executes, it implements the following steps:
  • the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted.
  • the target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
  • the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, wherein when the computer program is executed by the processor, the following steps are implemented:
  • the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted.
  • the target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
  • the present application provides an automatic question answering method, device, computer equipment and computer-readable storage medium, by obtaining entity aliases in each word of a question to be predicted according to a preset alias dictionary, and using the entity alias as a candidate entity; problem and multiple candidate entities, determine the entity name corresponding to the problem to be predicted; according to the entity name and the preset map database, determine the triplet corresponding to the entity name in the preset map database; determine the to-be-predicted according to each attribute name and the problem to be predicted
  • the target attribute name corresponding to the question, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted, so as to realize the entity recognition of the question and the semantic encoding of the attribute mapping of the question, and improve the representation ability and generalization ability of the reading text. Thereby improving the accuracy of automatic question answering.
  • FIG. 1 is a schematic flowchart of an automatic question answering method provided by an embodiment of the present application.
  • Fig. 2 is the sub-step flowchart schematic diagram of the automatic question answering method in Fig. 1;
  • Fig. 3 is the sub-step flow schematic diagram of the automatic question answering method in Fig. 1;
  • FIG. 4 is a schematic flow chart of the steps of training a preset entity recognition model
  • FIG. 5 is a schematic flowchart of steps for training a preset attribute mapping model
  • FIG. 6 is a schematic block diagram of an automatic question answering device provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural block diagram of a computer device according to an embodiment of the present application.
  • Embodiments of the present application provide an automatic question answering method, apparatus, computer device, and computer-readable storage medium.
  • the automatic question answering method can be applied to a computer device, and the computer device can be an electronic device such as a notebook computer and a desktop computer.
  • FIG. 1 is a schematic flowchart of an automatic question answering method provided by an embodiment of the present application.
  • the automatic question answering method includes steps S101 to S104.
  • Step S101 obtaining entity aliases of each word in the question to be predicted according to a preset alias dictionary, and using the entity aliases as candidate entities, wherein there are multiple entity aliases and candidate entities.
  • the question to be predicted is acquired, and the entity alias of each word in the question to be predicted is acquired according to the alias list of the preset alias dictionary, wherein the alias list includes multiple entity aliases.
  • the entity aliases in the alias list are compared with each word in the question to be predicted, if the word in the question to be predicted is the same as Any entity alias in the alias list is the same, then all entity aliases in the alias list corresponding to the entity name are determined, and all the entity aliases are the entity aliases of the word in the problem to be predicted.
  • the obtained entity alias is used as a candidate entity, wherein the number of entity aliases and candidate entities is multiple.
  • Step S102 Determine the entity name corresponding to the problem to be predicted according to the problem to be predicted and a plurality of candidate entities based on a preset entity recognition model.
  • the preset entity recognition model is obtained by training the first preset pre-trained language model through the data to be trained in advance. Based on the preset entity recognition model, the problem to be predicted is determined according to the problem to be predicted and a plurality of candidate entities. The corresponding entity name. Among them, the entity name is the common name of the name in the question, the candidate entity is the entity alias, and the entity alias is the special name or the former name, etc.
  • the question to be predicted is “Who is the author of A Dream of Red Mansions?”, where "Dream of Red Mansions” is the entity name; or, the question to be predicted is "Who is the author of The Story of the Stone?" where "The Story of the Stone” is the entity alias, and " The "Dream of Red Mansions” corresponding to "The Story of the Stone” is the entity name.
  • the problem to be predicted is input into the preset entity recognition model, the name corresponding to the problem to be predicted is identified based on the preset entity recognition model, and the name corresponding to the problem to be predicted is determined based on the name and multiple candidate entities.
  • entity name For example, the name is compared with each candidate entity, and if the name is the same as any one of the multiple candidate entities, the name is used as the entity name of the problem to be predicted.
  • step S102 includes: sub-step S1021 to sub-step S1023 .
  • Sub-step S1021 respectively replace the corresponding words in the question to be predicted according to the plurality of candidate entities to generate a plurality of text records.
  • multiple candidate entities corresponding to each word in the question to be predicted are obtained, and based on the candidate entities, the words corresponding to the question to be predicted are respectively replaced to generate multiple text records.
  • determine whether any word in the question to be predicted corresponds to multiple candidate entities; if multiple candidate entities are candidate entities of the same word, then determine that the multiple candidate entities correspond to the word positions in the question to be predicted, and replace the word with each candidate entity at the position of the word in the problem to be predicted, and generate a plurality of corresponding text records.
  • the to-be-predicted question is "Who is the author of The Story of the Stone?" and the Dream of Red Mansions is a candidate entity for the word "Story of the Stone” in the question to be predicted "Who is the author of the Story of the Stone?" Who is the author of Shishiji?”, replace the word “Stoneji” with the candidate entity "Dream of Red Mansions" at the position of Shishiji in the question to be predicted "Who is the author of Shishiji?”.
  • multiple candidate entities are not candidates for the same word, determine that each candidate entity corresponds to the word position in the question to be predicted, and replace the word with the corresponding word at the position of each word in the question to be predicted.
  • the candidate entities of generate corresponding text records, that is, the number of text records is the same as the number of candidate entities.
  • Sub-step S1022 Input the plurality of text records into a preset entity recognition model respectively, and predict the predicted value of the candidate entity in each of the text records.
  • each text record is input into a preset entity recognition model, and the predicted value of the candidate entity in each text record is predicted by the preset entity recognition model.
  • each text record is input into a preset entity recognition model
  • the preset entity recognition model includes a dictionary file, and each text record is split through the dictionary text to obtain text sequences corresponding to multiple text records.
  • vectorized representation is performed on the text sequence to obtain corresponding text vector information.
  • the preset entity recognition model includes a multi-head attention mechanism model, and the text vector information is input into the multi-head attention mechanism model, and the multi-head attention mechanism model obtains a vector corresponding to each word in the text vector information fused with context information.
  • the preset entity recognition model includes a linear conversion layer, and perform linear conversion on the text semantic vector information corresponding to each text record through the linear conversion layer, and obtain each text record.
  • the predicted value of the candidate entity is a linear conversion layer
  • Sub-step S1023 Determine the candidate entity in the target text record as the entity name according to the predicted value of the candidate entity in each of the text records, and use the entity name as the entity name corresponding to the problem to be predicted.
  • the predicted values of the candidate entities in each text record are obtained, the predicted values of the candidate entities in each text record are compared, and the text record with the highest predicted value of the candidate alias is determined.
  • the target text record with the highest predicted value of the candidate alias output by the preset entity recognition model, and use the candidate entity in the target text record with the highest predicted value of the candidate alias as the entity name in the problem to be predicted.
  • Step S103 according to the entity name and the preset map database, determine the triplet corresponding to the entity name in the preset map database; wherein, the triplet includes the entity name, the attribute name and the attribute value, and the The triples described above are multiple groups.
  • a preset graph database is queried based on the entity name, and the preset graph database includes multiple groups of triples, wherein each group of triples is structured in a way stored in the graph data.
  • the preset graph database is queried by the entity name, and multiple sets of triples corresponding to the entity name in the preset graph database are obtained, and the triples include the entity name, the attribute name and the attribute value.
  • the preset map database is searched based on the Xiaoao Jianghu, and the triplet corresponding to the Xiaoao Jianghu ""Xiaoao Jianghu"
  • Step S104 Determine the target attribute name corresponding to the to-be-predicted problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model, and use the attribute value corresponding to the target attribute name as the to-be-predicted problem 's Q&A.
  • each attribute text pair is obtained by combining the to-be-predicted question with the attribute values in each set of triples. Input each attribute text pair into a preset attribute mapping model, the preset attribute mapping model predicts the predicted score of each attribute text pair, determines the attribute text pair with the highest predicted score, and then determines the attribute text pair with the highest predicted score.
  • the target attribute text pair the target attribute text pair output by the preset attribute mapping model is obtained.
  • the target attribute text pair determine the attribute name in the target data text pair as the target attribute name, determine the triplet corresponding to the target attribute name in the graph database based on the target attribute name, and determine the target attribute name based on the target attribute name.
  • the attribute value in the corresponding triple is used as the question and answer corresponding to the question to be predicted.
  • step S104 includes: sub-step S1041 to sub-step S1043 .
  • Sub-step S1041 each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs.
  • multiple groups of triples corresponding to entity names are obtained, and the attribute names in each group of triples are obtained.
  • the acquired attribute names are combined with the questions to be predicted, respectively, to obtain attribute text pairs corresponding to the combination of each attribute name and the question to be predicted, wherein the number of attribute text pairs and attribute values is the same.
  • Sub-step S1042 Input each of the attribute-text pairs into a preset attribute mapping model to obtain the predicted score of the attribute name in each of the attribute-text pairs.
  • each obtained attribute text pair is input into a preset attribute mapping model
  • the preset attribute mapping model includes a dictionary file
  • each attribute text pair is split through the dictionary file to obtain each attribute text pair.
  • the word sequence of each question and attribute name is filled with the word sequence of each question and the word sequence of each attribute name to obtain a uniform fixed-length word sequence.
  • the question and the segmentation position of each attribute value are marked with special symbols, and the attribute text sequence is marked.
  • the attribute text sequence is vectorized to obtain the corresponding text vector information.
  • the preset attribute mapping model includes a multi-head attention network model, the text vector information is input into the multi-head attention network model, and the multi-head attention network model obtains the vector representation corresponding to each word in the input text vector fused with context information , so as to obtain the text semantic vector information output by the multi-head attention network model. Mark the segmentation position of the question and each attribute name in the text semantic vector information based on the special symbol, and obtain the semantic vector corresponding to each attribute text in the text semantic vector information.
  • the preset entity recognition model includes a linear transformation layer. Through the linear transformation layer The semantic vector of each attribute text pair is linearly transformed to obtain the predicted score of the attribute name in each attribute text pair.
  • Sub-step S1043 according to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest predicted score output by the preset attribute mapping model.
  • the predicted score of the attribute name in each attribute text pair is obtained, the predicted score of the attribute name in each attribute text pair is compared, and the attribute with the highest predicted score of the attribute name in the multiple attribute text pairs is determined. Text pair, the attribute text pair with the highest predicted score is taken as the target attribute text pair, and the target attribute text pair with the highest predicted score output by the preset attribute mapping model is obtained.
  • Sub-step S1044 Use the attribute name in the target attribute text pair as the target attribute name corresponding to the question to be predicted.
  • the target attribute text pair with the highest output prediction score from the preset attribute mapping model when the target attribute text pair with the highest output prediction score from the preset attribute mapping model is obtained, the target attribute text pair includes the question to be predicted and the attribute name, and the attribute name in the target attribute text pair is used as the target attribute. name.
  • the method before determining the triplet corresponding to the entity name according to the entity name and the preset graph database, the method includes: acquiring any triplet in the preset knowledge base, and obtaining the triplet based on the preset alias.
  • the dictionary obtains the alias list of entity names in the triplet; according to the alias list, it is determined whether the triplet exists in the preset graph knowledge base; if it is determined that the triplet exists, the preset
  • the graph knowledge base is used as a preset graph database; if it is determined that the triplet does not exist, a node is created in the preset knowledgebase and the triplet is imported at the node to generate a preset graph database.
  • a preset knowledge base is obtained, where the preset knowledge base includes multiple groups of triples. Get any triple in the preset knowledge base, the triple includes entity name, attribute name and attribute value.
  • a preset alias dictionary is queried based on the entity name, where the alias dictionary includes multiple entity aliases corresponding to the entity name, wherein the entity name is also an entity alias.
  • the preset graph knowledge base is searched to determine whether there is a node with the entity alias in the preset graph knowledge base, and if there is a node with the entity alias, determine whether the node with the entity alias has the three
  • the attribute name node in the tuple if there is an attribute name node in the triplet, the preset graph knowledge base is used as the preset graph database. If there is no node of the entity alias, create a node of the entity alias, and import the triplet corresponding to the node of the entity alias in the node of the entity alias, and generate the triplet corresponding to the node of the entity alias.
  • Pre-built graph database Pre-built graph database.
  • the method before acquiring the entity alias in the question to be predicted according to the preset alias dictionary, and using the entity alias as the candidate entity, the method further includes: acquiring each text in the preset knowledge base, and identifying each The entity name in the text is extracted; the entity alias of the entity name is extracted based on the preset attribute rules, and the preset alias dictionary is generated.
  • each text in the knowledge base is acquired, and the entity name in each text is identified.
  • the entity name is the common name of the name
  • the entity alias is the former name of the name.
  • the identification method includes labeling, obtaining all the names of the same semantic name, extracting the entity name in all the names according to the preset attribute rules, and the entity alias of the entity name, generating the alias list of the entity name, and the alias of each entity name.
  • Lists form a dictionary of aliases.
  • the preset attribute rules may be extracted in a probabilistic manner, for example, the probabilities of all names of the same semantic name are obtained, the name with the highest probability is used as the entity name, and the other names are used as entity aliases.
  • the candidate entities of the entity names in the problem to be predicted are obtained through a preset alias dictionary, and each candidate entity and the problem to be predicted are input into the preset entity recognition model to obtain the entity name of the problem to be predicted.
  • Set the map database and entity name obtain each attribute name in the triplet corresponding to the entity name, input each attribute name and the problem to be predicted into the preset attribute mapping model, get the target attribute name corresponding to the predicted problem, so as to obtain the target attribute name corresponding to the predicted problem.
  • Predict the question and answer corresponding to the question thereby improving the accuracy of the machine reading multiple documents.
  • FIG. 4 is a schematic flowchart of training a preset entity recognition model.
  • the training preset entity recognition model includes steps S201 to S204.
  • Step S201 Acquire the data to be trained, and determine the target entity name and candidate entity name of the problem in the to-be-trained data, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple.
  • data to be trained is obtained, and the data to be trained includes a question to be trained, a question and answer of the question to be trained, and a triplet corresponding to the question to be trained.
  • the data to be trained is the question to be trained "Who is the author of Meihualuo?”, the triplet "Plumblossom
  • the candidate entity name in the problem to be trained the candidate entity name may be the candidate entity name of the same word, or the candidate entity name of each word. For example, by dividing the problem to be trained into each word, the candidate entity name of each word is obtained through the alias dictionary.
  • Step S202 Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label of the positive example data The value is 1.
  • the first character of the target entity name is obtained, and the first character is a preset character.
  • the character is [MASK].
  • the question is "Who is the author of Meihualuo?”, where "Plumblossom" is the target entity name of the question, and the position of the "Meihualuo" in "Who is the author of Meihualuo?" is determined.
  • replace the "Plum Blossoms" with [MASK] to generate the corresponding positive data, where the question in the positive data is "Who is the author of [MASK]?" and label the positive data, the The label value of the positive data is 1.
  • Step S203 Obtain the second character of the candidate entity name, replace the second character with each candidate entity name in the question, and generate multiple negative example data of the data to be trained, wherein each negative The label value of the example data is 0.
  • a second character of the candidate entity name is obtained, and the second character is a preset character.
  • the second character is [MASK].
  • the question is "Who is the author of Plum Blossom?", in which "Plum Blossom” and "Hua Luo" are candidate entity names for the question.
  • Step S204 according to the positive example data and the label value of the positive example data, as well as the multiple negative example data and the label value of each negative example data, train the first pre-training language model, and generate a corresponding preset Entity Recognition Model.
  • the positive example data and multiple negative example data are input into the first preset pre-training language model, wherein, the first preset pre-training language model (Bidirectional Encoder Representations from Transformers BERT), including dictionary files vocab.txt, through the dictionary file vocab.txt, the questions in the positive data and the negative data are divided according to words, and the word sequence of the questions in each positive and negative data is obtained, and the word sequence of the question is obtained.
  • the preset padding rules or truncation rules a sequence of characters and words of uniform length is generated.
  • the divided questions are spliced to obtain the corresponding text sequence, wherein the text sequence includes the type symbol and the position symbol of each question.
  • the [CLS] character is used as the classification symbol of the text sequence, and the [SEP] Split symbols as the position of each question.
  • the obtained text sequence is vectorized to obtain the text vector information corresponding to the text sequence.
  • each word in the input text sequence is represented by a pre-trained word feature vector to obtain text vector information, where the text vector information includes semantic representation information, location representation information, and segment representation information of each word in the text sequence. Addition information.
  • the first preset pre-trained language model includes a multi-head attention network model, and the acquired text vector information is input into the multi-head attention network model, and the multi-head attention network model acquires each word in the input text vector fused with context information
  • the corresponding vector representation is used to obtain the text semantic vector information output by the multi-head attention network model.
  • the acquired text vector information is input into a multi-head attention network model
  • the multi-head attention network model includes a first linear mapping layer
  • the text vector information is mapped to different semantic spaces through the first linear mapping layer.
  • the semantic vector captures semantic information of different dimensions. And perform self-attention operations on semantic vectors in different semantic spaces, and output text semantic vectors in different semantic spaces.
  • the text semantic vectors in different semantic spaces are spliced, and the spliced vector information is mapped back to the original semantic space through the first linear mapping layer to obtain the output text semantic vector information.
  • the acquired text vector information is input into a multi-head attention network model
  • the multi-head attention network model includes a first linear mapping layer
  • the text vector information is mapped to the semantics of different semantic spaces through the first linear mapping layer.
  • Vector capturing semantic information of different dimensions.
  • Concat is a vector splicing operation
  • W is the linear term that maps different semantic spaces back to the initial semantic space
  • C is the second text semantic vector output by the multi-head self-attention network model.
  • the spliced vector information is mapped back to the original semantic space through the first linear mapping layer, and the output text semantic vector information is obtained.
  • the semantic vector of the entity name and each entity alias is obtained from the text semantic vector information.
  • the second linear mapping layer based on the first preset pre-trained language model performs linear transformation on the entity name and the semantic vector of each entity alias to obtain the probability score value of the entity name and the probability score value of each entity alias. After normalizing the obtained probability score value of the entity name and the probability score value of each entity alias as softmax, calculate the cross entropy loss of the label value (1 or 0), and use the cross entropy loss as loss function. When multiple loss functions are obtained, corresponding model parameters are obtained through a back-propagation mechanism, and the model parameters of the first and first preset pre-trained language models are updated through the model parameters to generate a corresponding preset entity recognition model.
  • a pre-trained language model is trained to obtain a preset entity recognition model, which realizes the entity recognition of the problem by the preset entity recognition model, thereby semantically encoding the entity name, improving the representation ability and Generalization ability, thereby improving the accuracy of the preset entity recognition model.
  • FIG. 5 is a schematic flowchart of a preset attribute mapping model.
  • the preset attribute mapping model includes steps S301 to S304.
  • Step S301 Acquire data to be trained, determine target attribute names of the questions in the data to be trained, and acquire candidate attribute names associated with the target attribute names, wherein the candidate attribute names are multiple.
  • data to be trained is obtained, and the data to be trained includes a question to be trained, a question and answer of the question to be trained, and a triplet corresponding to the question to be trained.
  • the data to be trained is the question to be trained "Who is the author of Meihualuo?", the triplet "Plumblossom
  • the target attribute name can be manually annotated. Obtain the associated candidate attribute name through the target attribute name.
  • the method of obtaining the candidate attribute name includes querying a preset map database through the target attribute name, and the preset map database includes multiple groups of triples, and each group of triples includes an entity name, an attribute name and an attribute value. Obtain the attribute names in each triplet of the same node of the target attribute, and use the obtained attribute name as the candidate attribute name of the target attribute name.
  • Step S302 Generate positive example data of the to-be-trained data for the question including the target attribute name, wherein the label value of the positive example data is 1.
  • positive example data of the data to be trained is generated, wherein the positive example data includes the question to be trained, the answer to the question to be trained and the corresponding Triad. And label the positive example data, the label value of the positive example data is 1.
  • Step S303 replacing each candidate attribute name with the target attribute name in the question, to generate multiple negative example data of the to-be-trained data, wherein the label value of each negative example data is 0.
  • An example is, when determining multiple candidate attribute names of the problem to be trained in the to-be-trained data, determine the position of the target attribute name in the problem, and replace the target attribute name with each candidate attribute name.
  • the question is "What language is the TV series in Xiaoao Jianghu?”, where "language” is the target attribute name of the question, and "dialect", "starring", “director”, etc. are the candidate attribute names of the target attribute name.
  • Step S304 according to the positive example data and the label value of the positive example data, as well as the multiple negative example data and the label value of each negative example data, train the second pre-training language model, and generate a corresponding preset Attribute Mapping Model.
  • the positive example data and multiple negative example data are input into the second preset pre-training language model, wherein the second preset pre-training language model (Bidirectional Encoder Representations from Transformers BERT), including dictionary files vocab.txt, through the dictionary file vocab.txt, the questions in the positive data and the negative data are divided according to words, and the word sequence of the questions in each positive and negative data is obtained, and the word sequence of the question is obtained.
  • the preset padding rules or truncation rules a sequence of characters and words of uniform length is generated.
  • the divided questions are spliced to obtain the corresponding text sequence, wherein the text sequence includes the type symbol and the position symbol of each question.
  • the [CLS] character is used as the classification symbol of the text sequence, and the [SEP] Split symbols as the position of each question.
  • the obtained text sequence is vectorized to obtain the text vector information corresponding to the text sequence.
  • each word in the input text sequence is represented by a pre-trained word feature vector to obtain text vector information, where the text vector information includes semantic representation information, location representation information, and segment representation information of each word in the text sequence. Addition information.
  • the second preset pre-trained language model includes a multi-head attention network model, and the acquired text vector information is input into the multi-head attention network model, and the multi-head attention network model acquires each word in the input text vector fused with context information
  • the corresponding vector representation is used to obtain the text semantic vector information output by the multi-head attention network model.
  • the acquired text vector information is input into a multi-head attention network model
  • the multi-head attention network model includes a first linear mapping layer
  • the text vector information is mapped to different semantic spaces through the first linear mapping layer.
  • the semantic vector captures semantic information of different dimensions. And perform self-attention operations on semantic vectors in different semantic spaces, and output text semantic vectors in different semantic spaces.
  • the text semantic vectors in different semantic spaces are spliced, and the spliced vector information is mapped back to the original semantic space through the first linear mapping layer to obtain the output text semantic vector information.
  • the acquired text vector information is input into a multi-head attention network model
  • the multi-head attention network model includes a first linear mapping layer
  • the text vector information is mapped to the semantics of different semantic spaces through the first linear mapping layer.
  • Vector capturing semantic information of different dimensions.
  • Concat is a vector splicing operation
  • W is the linear term that maps different semantic spaces back to the initial semantic space
  • C is the second text semantic vector output by the multi-head self-attention network model.
  • the spliced vector information is mapped back to the original semantic space through the first linear mapping layer, and the output text semantic vector information is obtained.
  • the semantic vector of the entity name and each entity alias is obtained from the text semantic vector information.
  • the second linear mapping layer based on the first preset pre-trained language model performs linear transformation on the entity name and the semantic vector of each entity alias to obtain the probability score value of the attribute name and the probability score value of each other attribute name. After normalizing the obtained probability score value of the attribute name and the probability score value of each other attribute name as softmax, calculate the cross entropy loss of the label value (1 or 0), and the cross entropy loss as a loss function.
  • corresponding model parameters are obtained through a back-propagation mechanism, and the model parameters of the first and first preset pre-trained language models are updated through the model parameters to generate a corresponding preset attribute mapping model.
  • a pre-trained language model is trained to obtain a preset attribute mapping model, which realizes the attribute mapping of the preset attribute mapping model to the question, thereby semantically encoding the attribute name, and improving the representation ability and performance of the preset attribute mapping model.
  • Generalization ability thereby improving the accuracy of the preset attribute mapping model.
  • FIG. 6 is a schematic block diagram of an automatic question answering apparatus provided by an embodiment of the present application.
  • the automatic question answering device 400 includes: an acquisition module 401 , a first determination module 402 , a second determination module 403 , and a third determination module 404 .
  • the obtaining module 401 is configured to obtain the entity alias of each word in the question to be predicted according to the preset alias dictionary, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
  • a first determination module 402 configured to determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model;
  • the second determining module 403 is configured to determine, according to the entity name and the preset map database, the triplet corresponding to the entity name in the preset map database; wherein the triplet includes the entity name, attribute name and attribute value, the triplet is multiple groups;
  • the third determining module 404 is configured to determine the target attribute name corresponding to the to-be-predicted problem according to each of the attribute names and the to-be-predicted problem based on the preset attribute mapping model, and use the attribute value corresponding to the target attribute name as the target attribute name. The question and answer of the question to be predicted.
  • the first determining module 402 is further used for:
  • the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records
  • the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
  • the third determining module 404 is also specifically used for:
  • Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
  • the attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
  • the automatic question and answer device is also used for:
  • the first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
  • the automatic question answering device is also used for:
  • Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
  • Each candidate attribute name is respectively replaced with the target attribute name in the problem, and a plurality of negative example data of the to-be-trained data is generated, wherein the label value of each negative example data is 0;
  • a second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
  • the automatic question answering device is also used for:
  • the preset graph knowledge base is used as a preset graph database
  • a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
  • the automatic question answering device is also used for:
  • the entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
  • the apparatuses provided by the above embodiments may be implemented in the form of a computer program, and the computer program may be executed on the computer device as shown in FIG. 7 .
  • FIG. 7 is a schematic block diagram of the structure of a computer device according to an embodiment of the present application.
  • the computer device may be a terminal.
  • the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
  • the nonvolatile storage medium can store operating systems and computer programs.
  • the computer program includes program instructions that, when executed, can cause the processor to execute any automatic question-answering method.
  • the processor is used to provide computing and control capabilities to support the operation of the entire computer equipment.
  • the internal memory provides an environment for running the computer program in the non-volatile storage medium.
  • the processor can execute any automatic question-answering method.
  • the network interface is used for network communication, such as sending assigned tasks.
  • the network interface is used for network communication, such as sending assigned tasks.
  • FIG. 7 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
  • the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSP), application specific integrated circuits (Application Specific Integrated circuits) Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor can be a microprocessor or the processor can also be any conventional processor or the like.
  • the processor is configured to run a computer program stored in the memory to implement the following steps:
  • the preset alias dictionary obtain the entity alias of each word in the question to be predicted, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
  • the triplet corresponding to the entity name in the preset graph database is determined; wherein, the triplet includes the entity name, attribute name and attribute value, and the triplet group is multi-group;
  • the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question.
  • the processor determines the entity name corresponding to the problem to be predicted according to the problem to be predicted and a plurality of candidate entities based on a preset entity recognition model, the processor is used to realize:
  • the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records
  • the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
  • the processor determines the target attribute name corresponding to the problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model, the processor is used to realize:
  • Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
  • the attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
  • the processor automatic question answering method further includes when implementing, for implementing:
  • the first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
  • the processor automatic question answering method further includes when implementing, for implementing:
  • Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
  • Each candidate attribute name is respectively replaced with the target attribute name in the problem, and a plurality of negative example data of the to-be-trained data is generated, wherein the label value of each negative example data is 0;
  • a second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
  • the processor determines, according to the entity name and the preset graph database, when the triplet corresponding to the entity name is previously implemented, to implement:
  • the preset graph knowledge base is used as a preset graph database
  • a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
  • the processor obtains entity aliases in the problem to be predicted according to a preset alias dictionary, and uses the entity aliases as candidate entities when implemented before, for implementing:
  • the entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
  • Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, the computer program includes program instructions, and the method implemented when the program instructions are executed may refer to this document Various embodiments of automated question answering methods are claimed.
  • the computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or a memory of the computer device.
  • the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) ) card, Flash Card, etc.
  • the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function, and the like; The data created by the use of the node, etc.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.

Abstract

An automated question answering method and apparatus, a computer device, and a computer-readable storage medium. The method comprises: according to a preconfigured alias dictionary, acquiring candidate entities of each word in a question to be predicted; on the basis of a preconfigured entity identification model, according to the question to be predicted and the plurality of candidate entities, determining an entity name corresponding to the question to be predicted; according to the entity name and a preconfigured graph database, determining triplets corresponding to the entity name; and on the basis of a preconfigured attribute mapping model, according to attribute names and the question to be predicted, determining a target attribute name corresponding to the question to be predicted, and using the attribute value corresponding to the target attribute name as an answer of the question to be predicted. Semantic encoding is implemented in both entity identification for a question using a preconfigured entity identification model and attribute mapping for the question using an attribute mapping model, so that the representation capability and the generalization capability of machine read text are improved, and thus the accuracy of the preconfigured entity identification model and the preconfigured attribute mapping model is improved.

Description

自动问答方法、装置、设备及存储介质Automatic question answering method, device, equipment and storage medium
本申请要求于2020年10月29日提交中国专利局、申请号为2020111873609、发明名称为“自动问答方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on October 29, 2020 with the application number 2020111873609 and titled "Automatic Question Answering Method, Apparatus, Equipment and Storage Medium", the entire contents of which are incorporated by reference in in this application.
技术领域technical field
本申请涉及人工智能技术领域,尤其涉及一种自动问答方法、装置、计算机设备及计算机可读存储介质。The present application relates to the technical field of artificial intelligence, and in particular, to an automatic question answering method, apparatus, computer equipment, and computer-readable storage medium.
背景技术Background technique
知识图谱技术是人工智能技术的重要组成部分,以结构化的方式描述客观世界中的概念、实体及其键的关系。知识图谱技术提供了一种更好的组织、管理和理解互联网海量信息的能力,将互联网的信息表达成更接近于人类认知世界的形式。因此,建立一个具有语义处理能力与开放互联能力的知识库,可以在智能搜索、智能问答、个性化推荐等智能信息服务中产生应用价值。Knowledge graph technology is an important part of artificial intelligence technology, which describes the relationship between concepts, entities and their keys in the objective world in a structured way. Knowledge graph technology provides a better ability to organize, manage and understand the massive information on the Internet, expressing the information on the Internet into a form that is closer to human cognition of the world. Therefore, establishing a knowledge base with semantic processing capability and open interconnection capability can generate application value in intelligent information services such as intelligent search, intelligent question answering, and personalized recommendation.
目前主流的基于知识库的自动问答中采用的方法可以分为两类:基于语义分析(semantic parsingbased,SP-based)方法和基于信息检索(information retrieve-based,IR-based)方法。发明人意识到基于语义分析的方法首先将自然语言形式的问句转换为某种特定类型的逻辑表达形式。传统的语义分析其需要通过词性系信息标注好的逻辑形式作为监督,并且受制于只有少量逻辑谓词狭窄域。而信息检索的方法首先通过比较粗糙的方法,从知识库中获取一系列的候选答案,然后对问句和候选答案进行特征抽取,利用它们对候选答案进行排序,选择得分最高的作为最终答案,但信息检索的方法缺少对深层语义的理解,导致自动问答准确率较低。The methods used in the current mainstream knowledge base-based automatic question answering can be divided into two categories: semantic parsing-based (SP-based) methods and information retrieval-based (IR-based) methods. The inventors realized that the method based on semantic analysis first converts the question in the form of natural language into a certain type of logical expression form. Traditional semantic analysis needs to be supervised by logical forms marked with part-of-speech information, and is limited by only a few narrow domains of logical predicates. The method of information retrieval first obtains a series of candidate answers from the knowledge base through a relatively rough method, and then extracts features from the questions and candidate answers, uses them to sort the candidate answers, and selects the one with the highest score as the final answer. However, information retrieval methods lack the understanding of deep semantics, resulting in low accuracy of automatic question answering.
发明内容SUMMARY OF THE INVENTION
本申请的主要目的在于提供一种自动问答方法、装置、计算机设备及计算机可读存储介质,旨在解决传统的语义分析其需要标注好的逻辑形式作为监督数据,并且依赖少量的逻辑谓词,而信息检索缺少对深层语义的理解,从而导致语义分析和信息检索的自动问答准确率较低的技术问题。The main purpose of the present application is to provide an automatic question answering method, device, computer equipment and computer readable storage medium, which aims to solve the problem that traditional semantic analysis requires a marked logical form as supervision data, and relies on a small number of logical predicates, and Information retrieval lacks the understanding of deep semantics, which leads to technical problems with low accuracy of automatic question answering for semantic analysis and information retrieval.
第一方面,本申请提供一种自动问答方法,所述自动问答方法包括以下步骤:In a first aspect, the present application provides an automatic question answering method, which includes the following steps:
根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;基于预置实体识别模型,根据所 述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多个;基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。According to the preset alias dictionary, the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted. The target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
第二方面,本申请还提供一种自动问答装置,所述自动问答装置包括:In a second aspect, the present application also provides an automatic question answering device, the automatic question answering device comprising:
获取模块,用于根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;第一确定模块,用于基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;第二确定模块,用于根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括属性名和属性值,所述三元组为多个;第三确定模块,用于基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。The obtaining module is used to obtain the entity alias of each word in the question to be predicted according to the preset alias dictionary, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple; first The determination module is used to determine the entity name corresponding to the to-be-predicted problem according to the to-be-predicted problem and a plurality of the candidate entities based on the preset entity recognition model; the second determination module is used to determine the entity name corresponding to the to-be-predicted problem according to the setting a map database, determining the triplet corresponding to the entity name in the preset map database, wherein the triplet includes an attribute name and an attribute value, and the triplet is multiple; the third determining module, using Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question. .
第三方面,本申请还提供一种计算机设备,所述计算机设备包括处理器、存储器、以及存储在所述存储器上并可被所述处理器执行的计算机程序,其中所述计算机程序被所述处理器执行时,实现以下步骤:In a third aspect, the present application also provides a computer device, the computer device comprising a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program is executed by the When the processor executes, it implements the following steps:
根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多个;基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。According to the preset alias dictionary, the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted. The target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
第四方面,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,其中所述计算机程序被处理器执行时,实现以下步骤:In a fourth aspect, the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, wherein when the computer program is executed by the processor, the following steps are implemented:
根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多个;基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。According to the preset alias dictionary, the entity alias of each word in the question to be predicted is obtained, and the entity alias is used as a candidate entity, wherein the entity alias and the candidate entity are multiple; based on the preset entity recognition model, Determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities; tuple, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet is multiple; based on a preset attribute mapping model, determine the attribute name according to each attribute name and the problem to be predicted. The target attribute name corresponding to the question to be predicted is described, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted.
本申请提供一种自动问答方法、装置、计算机设备及计算机可读存储介质,通过根据预置别名词典,获取待预测问题各个字词中的实体别名,并将实体别名作为候选实体;根 据待预测问题和多个候选实体,确定待预测问题对应的实体名;根据实体名和预置图数据库,确定预置图数据库中所述实体名对应的三元组;根据各个属性名和待预测问题确定待预测问题对应的目标属性名,并将目标属性名对应的属性值作为待预测问题的问答,实现对问题的实体识别和对问题的属性映射进行语义编码,提高阅读文本的表示能力和泛化能力,从而提高自动问答的准确率。The present application provides an automatic question answering method, device, computer equipment and computer-readable storage medium, by obtaining entity aliases in each word of a question to be predicted according to a preset alias dictionary, and using the entity alias as a candidate entity; problem and multiple candidate entities, determine the entity name corresponding to the problem to be predicted; according to the entity name and the preset map database, determine the triplet corresponding to the entity name in the preset map database; determine the to-be-predicted according to each attribute name and the problem to be predicted The target attribute name corresponding to the question, and the attribute value corresponding to the target attribute name is used as the question and answer of the question to be predicted, so as to realize the entity recognition of the question and the semantic encoding of the attribute mapping of the question, and improve the representation ability and generalization ability of the reading text. Thereby improving the accuracy of automatic question answering.
附图说明Description of drawings
图1为本申请实施例提供的一种自动问答方法的流程示意图;1 is a schematic flowchart of an automatic question answering method provided by an embodiment of the present application;
图2为图1中的自动问答方法的子步骤流程示意图;Fig. 2 is the sub-step flowchart schematic diagram of the automatic question answering method in Fig. 1;
图3为图1中的自动问答方法的子步骤流程示意图;Fig. 3 is the sub-step flow schematic diagram of the automatic question answering method in Fig. 1;
图4为训练预置实体识别模型的步骤流程示意图;FIG. 4 is a schematic flow chart of the steps of training a preset entity recognition model;
图5为训练预置属性映射模型的步骤流程示意图;5 is a schematic flowchart of steps for training a preset attribute mapping model;
图6为本申请实施例提供的一种自动问答装置的示意性框图;6 is a schematic block diagram of an automatic question answering device provided by an embodiment of the present application;
图7为本申请一实施例涉及的计算机设备的结构示意框图。FIG. 7 is a schematic structural block diagram of a computer device according to an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
附图中所示的流程图仅是示例说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解、组合或部分合并,因此实际执行的顺序有可能根据实际情况改变。The flowcharts shown in the figures are for illustration only, and do not necessarily include all contents and operations/steps, nor do they have to be performed in the order described. For example, some operations/steps can also be decomposed, combined or partially combined, so the actual execution order may be changed according to the actual situation.
本申请实施例提供一种自动问答方法、装置、计算机设备及计算机可读存储介质。其中,该自动问答方法可应用于计算机设备中,该计算机设备可以是笔记本电脑、台式电脑等电子设备。Embodiments of the present application provide an automatic question answering method, apparatus, computer device, and computer-readable storage medium. Wherein, the automatic question answering method can be applied to a computer device, and the computer device can be an electronic device such as a notebook computer and a desktop computer.
请参照图1,图1为本申请的实施例提供的一种自动问答方法的流程示意图。Please refer to FIG. 1 , which is a schematic flowchart of an automatic question answering method provided by an embodiment of the present application.
如图1所示,该自动问答方法包括步骤S101至步骤S104。As shown in FIG. 1 , the automatic question answering method includes steps S101 to S104.
步骤S101、根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个。Step S101 , obtaining entity aliases of each word in the question to be predicted according to a preset alias dictionary, and using the entity aliases as candidate entities, wherein there are multiple entity aliases and candidate entities.
示范例的,获取待预测问题,根据预置别名词典的别名列表,获取待预测问题中各个字词的实体别名,其中,该别名列表包括多个实体别名。例如,在获取待预测问题时,基于预置别名词典的别名列表,将该别名列表中的实体别名与该待预测问题中的各个字词进行比对,若该待预测问题中的字词与该别名列表中的任意一个实体别名相同,则确定该实体名对应的别名列表中所有的实体别名,并将该所有的实体别名都为待预测问题该字词的 实体别名。或者,将待预测问题拆分为多个字词,将各个字词作为搜索信息搜索别名列表,若该确定该别名列表中的任意一个实体别名与待预测问题中的字词相同,则确定该别名列表中所有的实体别名都为待预测问题中该字词的实体别名。将获取到的实体别名作为候选实体,其中,实体别名和候选实体的数量为多个。In an exemplary example, the question to be predicted is acquired, and the entity alias of each word in the question to be predicted is acquired according to the alias list of the preset alias dictionary, wherein the alias list includes multiple entity aliases. For example, when acquiring the question to be predicted, based on the alias list of the preset alias dictionary, the entity aliases in the alias list are compared with each word in the question to be predicted, if the word in the question to be predicted is the same as Any entity alias in the alias list is the same, then all entity aliases in the alias list corresponding to the entity name are determined, and all the entity aliases are the entity aliases of the word in the problem to be predicted. Or, split the question to be predicted into multiple words, and use each word as search information to search the alias list, if it is determined that any entity alias in the alias list is the same as the word in the question to be predicted, then determine the All entity aliases in the alias list are the entity aliases of the word in the question to be predicted. The obtained entity alias is used as a candidate entity, wherein the number of entity aliases and candidate entities is multiple.
步骤S102、基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名。Step S102: Determine the entity name corresponding to the problem to be predicted according to the problem to be predicted and a plurality of candidate entities based on a preset entity recognition model.
示范例的,预置实体识别模型为预先通过待训练数据训练第一预置预训练语言模型得到的,基于该预置实体识别模型,根据待预测问题和多个候选实体,确定该待预测问题对应的实体名。其中,实体名为问题中名称常用名,候选实体为实体别名,而实体别名为特殊名或曾用名等。例如,待预测问题为“红楼梦的作者是谁?”其中,“红楼梦”为实体名;或者,待预测问题为“石头记的作者是谁?”其中,“石头记”为实体别名,而“石头记”对应的“红楼梦”为实体名。In an exemplary example, the preset entity recognition model is obtained by training the first preset pre-trained language model through the data to be trained in advance. Based on the preset entity recognition model, the problem to be predicted is determined according to the problem to be predicted and a plurality of candidate entities. The corresponding entity name. Among them, the entity name is the common name of the name in the question, the candidate entity is the entity alias, and the entity alias is the special name or the former name, etc. For example, the question to be predicted is "Who is the author of A Dream of Red Mansions?", where "Dream of Red Mansions" is the entity name; or, the question to be predicted is "Who is the author of The Story of the Stone?" where "The Story of the Stone" is the entity alias, and " The "Dream of Red Mansions" corresponding to "The Story of the Stone" is the entity name.
示范性的,将待预测问题输入该预置实体识别模型中,基于该预置实体识别模型识别出该待预测问题对应的名称,基于该名称和多个候选实体,确定该待预测问题对应的实体名。例如,将该名称与各个候选实体进行比对,若该名称与多个候选实体中的任意一个候选实体相同,则将该名称作为该待预测问题的实体名。Exemplarily, the problem to be predicted is input into the preset entity recognition model, the name corresponding to the problem to be predicted is identified based on the preset entity recognition model, and the name corresponding to the problem to be predicted is determined based on the name and multiple candidate entities. entity name. For example, the name is compared with each candidate entity, and if the name is the same as any one of the multiple candidate entities, the name is used as the entity name of the problem to be predicted.
在一实施例中,具体地,参照图2,步骤S102包括:子步骤S1021至子步骤S1023。In an embodiment, specifically, referring to FIG. 2 , step S102 includes: sub-step S1021 to sub-step S1023 .
子步骤S1021、根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录。Sub-step S1021, respectively replace the corresponding words in the question to be predicted according to the plurality of candidate entities to generate a plurality of text records.
示例性的,获取待预测问题中各个字词对应的多个候选实体,基于该各个候选实体分别对该待预测问题中对应的字词进行替换,生成多个文本记录。示范性的,确定待预测问题中任意一个字词是否对应多个候选实体;若多个候选实体为同一个字词的候选实体,则确定多个候选实体对应待预测问题中的字词位置,并在该待预测问题中该字词位置处将该字词替换为各个候选实体,生成对应的多个文本记录。例如,待预测问题是“石头记的作者是谁?”而红楼梦是该待预测问题“石头记的作者是谁?”中字词“石头记”的候选实体,确定该待预测问题“石头记的作者是谁?”中石头记的位置,在待预测问题“石头记的作者是谁?”中石头记的位置处将字词“石头记”替换为候选实体“红楼梦”。或者,若多个候选实体不是同一个字词的候选实体,则确定各个候选实体对应待预测问题中的字词位置,并在该待预测问题中各个字词位置处将该字词替换为对应的候选实体,生成对应的文本记录,即文本记录的数量与候选实体的数量相同。Exemplarily, multiple candidate entities corresponding to each word in the question to be predicted are obtained, and based on the candidate entities, the words corresponding to the question to be predicted are respectively replaced to generate multiple text records. Exemplarily, determine whether any word in the question to be predicted corresponds to multiple candidate entities; if multiple candidate entities are candidate entities of the same word, then determine that the multiple candidate entities correspond to the word positions in the question to be predicted, and replace the word with each candidate entity at the position of the word in the problem to be predicted, and generate a plurality of corresponding text records. For example, the to-be-predicted question is "Who is the author of The Story of the Stone?" and the Dream of Red Mansions is a candidate entity for the word "Story of the Stone" in the question to be predicted "Who is the author of the Story of the Stone?" Who is the author of Shishiji?", replace the word "Stoneji" with the candidate entity "Dream of Red Mansions" at the position of Shishiji in the question to be predicted "Who is the author of Shishiji?". Or, if multiple candidate entities are not candidates for the same word, determine that each candidate entity corresponds to the word position in the question to be predicted, and replace the word with the corresponding word at the position of each word in the question to be predicted. The candidate entities of , generate corresponding text records, that is, the number of text records is the same as the number of candidate entities.
子步骤S1022、将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值。Sub-step S1022: Input the plurality of text records into a preset entity recognition model respectively, and predict the predicted value of the candidate entity in each of the text records.
示范例的,在获取到多个文本记录时,将各个文本记录分别输入到预置实体识别模型中,通过该预置实体识别模型预测各个文本记录中候选实体的预测值。示范性的,将各个文本记录输入到预置实体识别模型中,该预置实体识别模型包括字典文件,通过该字典文 本对各个文本记录进行拆分,得到多个文本记录对应的文本序列。在得到该文本序列时,对该文本序列进行向量化表示,得到对应的文本向量信息。该预置实体识别模型包括多头注意力机制模型,将该文本向量信息输入到该多头注意力机制模型中,该多头注意力机制模型获取文本向量信息中融合上下文信息的每个单词所对应的向量表示,输出文本语义向量信息。获取该文本语义向量信息中各个文本记录对应的语义向量,该预置实体识别模型包括线性转换层,通过该线性转换层对各个文本记录对应的文本语义向量信息进行线性转换,得到各个文本记录中候选实体的预测值。In an exemplary example, when multiple text records are acquired, each text record is input into a preset entity recognition model, and the predicted value of the candidate entity in each text record is predicted by the preset entity recognition model. Exemplarily, each text record is input into a preset entity recognition model, the preset entity recognition model includes a dictionary file, and each text record is split through the dictionary text to obtain text sequences corresponding to multiple text records. When the text sequence is obtained, vectorized representation is performed on the text sequence to obtain corresponding text vector information. The preset entity recognition model includes a multi-head attention mechanism model, and the text vector information is input into the multi-head attention mechanism model, and the multi-head attention mechanism model obtains a vector corresponding to each word in the text vector information fused with context information. Representation, output text semantic vector information. Obtain the semantic vector corresponding to each text record in the text semantic vector information, the preset entity recognition model includes a linear conversion layer, and perform linear conversion on the text semantic vector information corresponding to each text record through the linear conversion layer, and obtain each text record. The predicted value of the candidate entity.
子步骤S1023、根据所述各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。Sub-step S1023: Determine the candidate entity in the target text record as the entity name according to the predicted value of the candidate entity in each of the text records, and use the entity name as the entity name corresponding to the problem to be predicted.
实施例的,在获取到各个文本记录中候选实体的预测值时,将各个文本记录中候选实体的预测值进行比对,确定候选别名的预测值最高的文本记录。获取预置实体识别模型输出该候选别名的预测值最高的目标文本记录,将该候选别名预测值最高的目标文本记录中的候选实体作为该待预测问题中的实体名。In the embodiment, when the predicted values of the candidate entities in each text record are obtained, the predicted values of the candidate entities in each text record are compared, and the text record with the highest predicted value of the candidate alias is determined. Obtain the target text record with the highest predicted value of the candidate alias output by the preset entity recognition model, and use the candidate entity in the target text record with the highest predicted value of the candidate alias as the entity name in the problem to be predicted.
步骤S103、根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组;其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组。Step S103, according to the entity name and the preset map database, determine the triplet corresponding to the entity name in the preset map database; wherein, the triplet includes the entity name, the attribute name and the attribute value, and the The triples described above are multiple groups.
示范例的,在获取到待预测问题的实体名时,基于该实体名查询预置图数据库,该预置图数据库包括多组三元组,其中每一组三元组都是通过结构的方式存储在图数据中。通过该实体名查询预置图数据库,获取该预置图数据库中该实体名对应的多组三元组,该三元组包括该实体名、属性名和属性值。示范性的,当该实体名为笑傲江湖时,基于该笑傲江湖在预置图数据库中进行搜索,得到该笑傲江湖对应的三元组“《笑傲江湖》|||语言版本|||粤语、普通话”,其中,该语言版本作为属性名;粤语、普通话作为属性值,笑傲江湖对应的三元组为多组。As an example, when the entity name of the problem to be predicted is obtained, a preset graph database is queried based on the entity name, and the preset graph database includes multiple groups of triples, wherein each group of triples is structured in a way stored in the graph data. The preset graph database is queried by the entity name, and multiple sets of triples corresponding to the entity name in the preset graph database are obtained, and the triples include the entity name, the attribute name and the attribute value. Exemplarily, when the entity is named Xiaoao Jianghu, the preset map database is searched based on the Xiaoao Jianghu, and the triplet corresponding to the Xiaoao Jianghu ""Xiaoao Jianghu"|||language version| || Cantonese, Putonghua", where the language version is used as the attribute name; Cantonese and Putonghua are used as the attribute value, and the triples corresponding to Xiaoao Jianghu are multiple groups.
步骤S104、基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。Step S104: Determine the target attribute name corresponding to the to-be-predicted problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model, and use the attribute value corresponding to the target attribute name as the to-be-predicted problem 's Q&A.
示范例的,在获取到实体名对应的多组三元组时,通过将该待预测问题与各组三元组中的属性值进行组合,得到各个属性文本对。将各个属性文本对输入到预置属性映射模型中,该预置属性映射模型预测各个属性文本对的预测分值,确定预测分值最高的属性文本对,将该预测分值最高的属性文本对作为目标属性文本对,获取预置属性映射模型输出的该目标属性文本对。在获取到该目标属性文本对时,确定该目标数据文本对中的属性名为目标属性名,基于该目标属性名确定该图数据库中该目标属性名对应的三元组,将该目标属性名对应的三元组中的属性值作为该待预测问题对应的问答。As an example, when multiple sets of triples corresponding to entity names are obtained, each attribute text pair is obtained by combining the to-be-predicted question with the attribute values in each set of triples. Input each attribute text pair into a preset attribute mapping model, the preset attribute mapping model predicts the predicted score of each attribute text pair, determines the attribute text pair with the highest predicted score, and then determines the attribute text pair with the highest predicted score. As the target attribute text pair, the target attribute text pair output by the preset attribute mapping model is obtained. When the target attribute text pair is obtained, determine the attribute name in the target data text pair as the target attribute name, determine the triplet corresponding to the target attribute name in the graph database based on the target attribute name, and determine the target attribute name based on the target attribute name. The attribute value in the corresponding triple is used as the question and answer corresponding to the question to be predicted.
在一实施例中,具体地,参照图3,步骤S104包括:子步骤S1041至子步骤S1043。In an embodiment, specifically, referring to FIG. 3 , step S104 includes: sub-step S1041 to sub-step S1043 .
子步骤S1041、各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对。Sub-step S1041, each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs.
示范例的,获取实体名对应的多组三元组,并获取各组三元组中的属性名。将获取到各个属性名分别与待预测问题进行组合,得到各个属性名与待预测问题进行组合对应的属性文本对,其中,属性文本对与属性值的数量相同。As an example, multiple groups of triples corresponding to entity names are obtained, and the attribute names in each group of triples are obtained. The acquired attribute names are combined with the questions to be predicted, respectively, to obtain attribute text pairs corresponding to the combination of each attribute name and the question to be predicted, wherein the number of attribute text pairs and attribute values is the same.
子步骤S1042、将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的预测分值。Sub-step S1042: Input each of the attribute-text pairs into a preset attribute mapping model to obtain the predicted score of the attribute name in each of the attribute-text pairs.
实施例的,将得到的各个属性文本对输入到预置属性映射模型中,该预置属性映射模型包括字典文件,通过该字典文件对该各个属性文本对进行拆分,得到各个属性文本对中各个问题和属性名的单词序列,将各个问题的单词序列和各个属性名的单词序列进行填充,得到统一固定长度的单词序列。将问题的单词序列和属性名的单词序列进行拼接,生成对应的属性文本序列。其中,该属性文本序列中通过特殊符号标记问题和各个属性值的分割位置,并对该属性文本序列进行标记。在得到属性文本序列时,对该属性文本序列进行向量化表示,得到对应的文本向量信息。该预置属性映射模型包括多头注意力网络模型,将该文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型获取输入文本向量中融合上下文信息的每个单词所对应的向量表示,从而获取多头注意力网络模型输出的文本语义向量信息。基于特殊符号标记该文本语义向量信息中问题与各个属性名的分割位置,获取该文本语义向量信息中各个属性文本对应的语义向量,该预置实体识别模型包括线性转换层,通过该线性转换层对各个属性文本对的语义向量进行线性转换,得到各个属性文本对中属性名的预测分值。In the embodiment, each obtained attribute text pair is input into a preset attribute mapping model, the preset attribute mapping model includes a dictionary file, and each attribute text pair is split through the dictionary file to obtain each attribute text pair. The word sequence of each question and attribute name is filled with the word sequence of each question and the word sequence of each attribute name to obtain a uniform fixed-length word sequence. Concatenate the word sequence of the question and the word sequence of the attribute name to generate the corresponding attribute text sequence. Wherein, in the attribute text sequence, the question and the segmentation position of each attribute value are marked with special symbols, and the attribute text sequence is marked. When the attribute text sequence is obtained, the attribute text sequence is vectorized to obtain the corresponding text vector information. The preset attribute mapping model includes a multi-head attention network model, the text vector information is input into the multi-head attention network model, and the multi-head attention network model obtains the vector representation corresponding to each word in the input text vector fused with context information , so as to obtain the text semantic vector information output by the multi-head attention network model. Mark the segmentation position of the question and each attribute name in the text semantic vector information based on the special symbol, and obtain the semantic vector corresponding to each attribute text in the text semantic vector information. The preset entity recognition model includes a linear transformation layer. Through the linear transformation layer The semantic vector of each attribute text pair is linearly transformed to obtain the predicted score of the attribute name in each attribute text pair.
子步骤S1043、根据各个所述属性文本对中属性名的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对。Sub-step S1043, according to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest predicted score output by the preset attribute mapping model.
示范例的,在得到各个属性文本对中属性名的预测分值时,比对各个各个属性文本对中属性名的预测分值,确定多个属性文本对中属性名的预测分值最高的属性文本对,将该预测分值最高的属性文本对作为目标属性文本对,获取预置属性映射模型输出预测分值最高的目标属性文本对。As an example, when the predicted score of the attribute name in each attribute text pair is obtained, the predicted score of the attribute name in each attribute text pair is compared, and the attribute with the highest predicted score of the attribute name in the multiple attribute text pairs is determined. Text pair, the attribute text pair with the highest predicted score is taken as the target attribute text pair, and the target attribute text pair with the highest predicted score output by the preset attribute mapping model is obtained.
子步骤S1044、将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。Sub-step S1044: Use the attribute name in the target attribute text pair as the target attribute name corresponding to the question to be predicted.
示范例的,在获取到预置属性映射模型输出预测分值最高的目标属性文本对时,该目标属性文本对包括待预测问题和属性名,将该目标属性文本对中的属性名作为目标属性名。For example, when the target attribute text pair with the highest output prediction score from the preset attribute mapping model is obtained, the target attribute text pair includes the question to be predicted and the attribute name, and the attribute name in the target attribute text pair is used as the target attribute. name.
在一实施例中,所述根据所述实体名和预置图数据库,确定所述实体名对应的三元组之前,包括:获取预置知识库中的任意一个三元组,以及基于预置别名词典获取所述三元组中实体名的别名列表;根据所述别名列表,确定预置图知识库中是否存在所述三元组;若确定存在所述三元组,则将所述预置图知识库作为预置图数据库;若确定不存在所述三元组,则在所述预置知识库中创建节点并在所述节点处导入所述三元组,生成预置图数据库。In one embodiment, before determining the triplet corresponding to the entity name according to the entity name and the preset graph database, the method includes: acquiring any triplet in the preset knowledge base, and obtaining the triplet based on the preset alias. The dictionary obtains the alias list of entity names in the triplet; according to the alias list, it is determined whether the triplet exists in the preset graph knowledge base; if it is determined that the triplet exists, the preset The graph knowledge base is used as a preset graph database; if it is determined that the triplet does not exist, a node is created in the preset knowledgebase and the triplet is imported at the node to generate a preset graph database.
实施例的,获取预置知识库,该预置知识库中包括多组三元组。获取预置知识库中的任意一个三元组,该三元组包括实体名、属性名和属性值。基于该实体名查询预置别名词典,该别名词典中包括该实体名对应的多个实体别名,其中,该实体名也为实体别名。在获取到该实体别名时,搜索预置图知识库,确定该预置图知识库是否存在该实体别名的节点,若存在该实体别名的节点,则确定该该实体别名的节点是否存在该三元组中的属性名节点,若存在该三元组中的属性名节点,则将该预置图知识库作为预置图数据库。若不存在该实体别名的节点,则创建一个实体别名的节点,并在该实体别名的节点中导入该实体别名的节点对应的三元组,将导入该实体别名的节点对应的三元组生成预置图数据库。In an embodiment, a preset knowledge base is obtained, where the preset knowledge base includes multiple groups of triples. Get any triple in the preset knowledge base, the triple includes entity name, attribute name and attribute value. A preset alias dictionary is queried based on the entity name, where the alias dictionary includes multiple entity aliases corresponding to the entity name, wherein the entity name is also an entity alias. When the entity alias is obtained, the preset graph knowledge base is searched to determine whether there is a node with the entity alias in the preset graph knowledge base, and if there is a node with the entity alias, determine whether the node with the entity alias has the three The attribute name node in the tuple, if there is an attribute name node in the triplet, the preset graph knowledge base is used as the preset graph database. If there is no node of the entity alias, create a node of the entity alias, and import the triplet corresponding to the node of the entity alias in the node of the entity alias, and generate the triplet corresponding to the node of the entity alias. Pre-built graph database.
在一实施例中,所述根据预置别名词典,获取待预测问题中的实体别名,并将所述实体别名作为候选实体之前,还包括:获取预置知识库中各个文本,并识别各个所述文本中的实体名;基于预设属性规则抽取所述实体名的实体别名,生成预置别名词典。In one embodiment, before acquiring the entity alias in the question to be predicted according to the preset alias dictionary, and using the entity alias as the candidate entity, the method further includes: acquiring each text in the preset knowledge base, and identifying each The entity name in the text is extracted; the entity alias of the entity name is extracted based on the preset attribute rules, and the preset alias dictionary is generated.
实施例的,获取知识库中各个文本,识别各个文本中的实体名。该实体名为名称的常见名,实体别名该名称的曾用名。该识别方式包括认为进行标注,获取同一语义名称的所有名称,按照预设属性规则抽取所有名称中的实体名,以及该实体名的实体别名,生成该实体名的别名列表,各个实体名的别名列表组成别名词典。其中,预设属性规则可以为概率方式抽取,例如,获取同一语义名称的所有名称的概率,将概率最高的名称作为实体名,其它名称作为实体别名。In the embodiment, each text in the knowledge base is acquired, and the entity name in each text is identified. The entity name is the common name of the name, and the entity alias is the former name of the name. The identification method includes labeling, obtaining all the names of the same semantic name, extracting the entity name in all the names according to the preset attribute rules, and the entity alias of the entity name, generating the alias list of the entity name, and the alias of each entity name. Lists form a dictionary of aliases. The preset attribute rules may be extracted in a probabilistic manner, for example, the probabilities of all names of the same semantic name are obtained, the name with the highest probability is used as the entity name, and the other names are used as entity aliases.
在本申请实施例中,通过预置别名词典获取待预测问题中的实体名的候选实体,将各个候选实体和待预测问题输入到预置实体识别模型中得到待预测问题的实体名,基于预置图数据库和实体名,得到该实体名对应的三元组中的各个属性名,将各个属性名和待预测问题输入到预置属性映射模型中,得到预测问题对应的目标属性名,从而获取待预测问题对应的问答,从而提高机器阅读多文档的准确率。In the embodiment of the present application, the candidate entities of the entity names in the problem to be predicted are obtained through a preset alias dictionary, and each candidate entity and the problem to be predicted are input into the preset entity recognition model to obtain the entity name of the problem to be predicted. Set the map database and entity name, obtain each attribute name in the triplet corresponding to the entity name, input each attribute name and the problem to be predicted into the preset attribute mapping model, get the target attribute name corresponding to the predicted problem, so as to obtain the target attribute name corresponding to the predicted problem. Predict the question and answer corresponding to the question, thereby improving the accuracy of the machine reading multiple documents.
在一实施例中,具体地,参照图4,图4为训练预置实体识别模型的流程示意图。In an embodiment, specifically, referring to FIG. 4 , FIG. 4 is a schematic flowchart of training a preset entity recognition model.
如图4所示,该训练预置实体识别模型包括步骤S201至步骤S204。As shown in FIG. 4 , the training preset entity recognition model includes steps S201 to S204.
步骤S201、获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个。Step S201: Acquire the data to be trained, and determine the target entity name and candidate entity name of the problem in the to-be-trained data, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple.
示范例的,获取待训练数据,该待训练数据包括待训练问题、待训练问题的问答、以及该待训练问题对应的三元组。例如,待训练数据为待训练问题“梅花落作者是谁来着?”、三元组“梅花落|||作者|||鲍照”、待训练问题的问答“鲍照”。确定该待训练问题中的目标实体名,该实体名可以是人工进行标注。以及确定该待训练问题中的候选实体名,该候选实体名可以是同一个字词的候选实体名,也可以各个字词的候选实体名。例如,通过将该该待训练问题切分为各个字词,通过别名词典获取各个字词的候选实体名。In an exemplary example, data to be trained is obtained, and the data to be trained includes a question to be trained, a question and answer of the question to be trained, and a triplet corresponding to the question to be trained. For example, the data to be trained is the question to be trained "Who is the author of Meihualuo?", the triplet "Plumblossom|||Author||| Bao Zhao", and the question-and-answer "Bao Zhao" of the question to be trained. Determine the target entity name in the problem to be trained, and the entity name can be manually annotated. And determine the candidate entity name in the problem to be trained, the candidate entity name may be the candidate entity name of the same word, or the candidate entity name of each word. For example, by dividing the problem to be trained into each word, the candidate entity name of each word is obtained through the alias dictionary.
步骤S202、获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1。Step S202: Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label of the positive example data The value is 1.
示范例的,在确定该待训练数据中待训练问题的目标实体名时,获取该目标实体名的 第一字符,该第一字符为预置字符。例如,该字符为[MASK]。确定该目标实体名在该问题中的位置,将该第一字符替换该目标实体名。例如,问题为“梅花落作者是谁来着?”,其中,“梅花落”为该问题的目标实体名,在确定该“梅花落”在“梅花落作者是谁来着?”中的位置时,将[MASK]替换该“梅花落”,生成对应的正例数据,其中,正例数据中的问题为“[MASK]作者是谁来着?”并对该正例数据进行标签,该该正例数据的标签值为1。For example, when determining the target entity name of the problem to be trained in the to-be-trained data, the first character of the target entity name is obtained, and the first character is a preset character. For example, the character is [MASK]. Determine the position of the target entity name in the question, and replace the first character with the target entity name. For example, the question is "Who is the author of Meihualuo?", where "Plumblossom" is the target entity name of the question, and the position of the "Meihualuo" in "Who is the author of Meihualuo?" is determined. , replace the "Plum Blossoms" with [MASK] to generate the corresponding positive data, where the question in the positive data is "Who is the author of [MASK]?" and label the positive data, the The label value of the positive data is 1.
步骤S203、获取所述候选实体名的第二字符,将所述第二字符替换所述问题中的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0。Step S203: Obtain the second character of the candidate entity name, replace the second character with each candidate entity name in the question, and generate multiple negative example data of the data to be trained, wherein each negative The label value of the example data is 0.
示范例的,在确定该待训练数据中待训练问题的多个候选实体名时,获取该候选实体名的第二字符,该第二字符为预置字符。例如,该第二字符为[MASK]。确定该各个候选实体名在该问题中的位置,将该第二字符替换该目标实体名。例如,问题为“梅花落作者是谁来着?”,其中,“梅花”和“花落”为该问题的候选实体名,在分别确定该“梅花”和“花落”在“梅花落作者是谁来着?”的位置时,将[MASK]替换该“梅花”,生成对应的负例数据,其中,负例数据中的问题为“[MASK]落作者是谁来着?”或者,将[MASK]“花落”,替换该生成对应的负例数据,其中,负例数据中的问题为“梅[MASK]作者是谁来着?”并对该正例数据进行标签,该该正例数据的标签值为0。Exemplarily, when multiple candidate entity names of the problem to be trained in the to-be-trained data are determined, a second character of the candidate entity name is obtained, and the second character is a preset character. For example, the second character is [MASK]. Determine the position of each candidate entity name in the question, and replace the second character with the target entity name. For example, the question is "Who is the author of Plum Blossom?", in which "Plum Blossom" and "Hua Luo" are candidate entity names for the question. Who is it from?", replace the "Plum Blossom" with [MASK] to generate the corresponding negative data, where the question in the negative data is "Who is the author of [MASK]?" Or, Replace [MASK] with the corresponding negative data, where the question in the negative data is "Who is the author of Mei [MASK]?" The label value of positive data is 0.
步骤S204、根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。Step S204, according to the positive example data and the label value of the positive example data, as well as the multiple negative example data and the label value of each negative example data, train the first pre-training language model, and generate a corresponding preset Entity Recognition Model.
示范例的,将该正例数据和多个负例数据输入到第一预置预训练语言模型中,其中,该第一预置预训练语言模型(Bidirectional Encoder Representations from Transformers BERT),包括字典文件vocab.txt,通过该字典文件vocab.txt将正例数据和负例数据中的问题按照字词切分,得到各个正例数据和负例数据中的问题的单词序列,且将问题的单词序列时按照预置填充规则或截断规则,生成统一长度的字符单词序列。其中,切分后的各个问题进行拼接,得到对应的文本序列,其中,文本序列中包括类型符号和各个问题的位置符号,例如,将[CLS]字符作为文本序列的分类符号,将[SEP]作为各个问题的位置分割符号。将得到的文本序列进行向量化表示,得到该文本序列对应的文本向量信息。示范例的,将输入文本序列中每个单词用预训练的单词特征向量表示,得到文本向量信息,该文本向量信息包括文本序列中每个单词的语义表示信息、位置表示信息、分段表示的加和信息。For example, the positive example data and multiple negative example data are input into the first preset pre-training language model, wherein, the first preset pre-training language model (Bidirectional Encoder Representations from Transformers BERT), including dictionary files vocab.txt, through the dictionary file vocab.txt, the questions in the positive data and the negative data are divided according to words, and the word sequence of the questions in each positive and negative data is obtained, and the word sequence of the question is obtained. At the same time, according to the preset padding rules or truncation rules, a sequence of characters and words of uniform length is generated. Among them, the divided questions are spliced to obtain the corresponding text sequence, wherein the text sequence includes the type symbol and the position symbol of each question. For example, the [CLS] character is used as the classification symbol of the text sequence, and the [SEP] Split symbols as the position of each question. The obtained text sequence is vectorized to obtain the text vector information corresponding to the text sequence. As an example, each word in the input text sequence is represented by a pre-trained word feature vector to obtain text vector information, where the text vector information includes semantic representation information, location representation information, and segment representation information of each word in the text sequence. Addition information.
该第一预置预训练语言模型包括多头注意力网络模型,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型获取输入文本向量中融合上下文信息的每个单词所对应的向量表示,获取多头注意力网络模型输出的文本语义向量信息。示范性的,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型包括第一线性映射层,通该第一线性映射层将该文本向量信息映射到不同语义空间的语义向 量,捕捉不同维度的语义信息。并在不同语义空间语义向量上进行self-attention操作,输出不同语义空间的文本语义向量。将不同语义空间的文本语义向量进行拼接,将拼接后的向量信息通过第一线性映射层映射回原语义空间,得到输出的文本语义向量信息。The first preset pre-trained language model includes a multi-head attention network model, and the acquired text vector information is input into the multi-head attention network model, and the multi-head attention network model acquires each word in the input text vector fused with context information The corresponding vector representation is used to obtain the text semantic vector information output by the multi-head attention network model. Exemplarily, the acquired text vector information is input into a multi-head attention network model, the multi-head attention network model includes a first linear mapping layer, and the text vector information is mapped to different semantic spaces through the first linear mapping layer. The semantic vector captures semantic information of different dimensions. And perform self-attention operations on semantic vectors in different semantic spaces, and output text semantic vectors in different semantic spaces. The text semantic vectors in different semantic spaces are spliced, and the spliced vector information is mapped back to the original semantic space through the first linear mapping layer to obtain the output text semantic vector information.
例如,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型包括第一线性映射层,通该第一线性映射层将该文本向量信息映射到不同语义空间的语义向量,捕捉不同维度的语义信息。例如,第一线性映射层中的线性项公式为Q' i=QW i Q,K' i=KW t k,V i'=VW i V,其中Q为查询值、K为键值、V为值向量,i为映射到i个语义空间的线性项,Q′,i,K′i,V′。i为第i个语义空间的语义向量。 For example, the acquired text vector information is input into a multi-head attention network model, the multi-head attention network model includes a first linear mapping layer, and the text vector information is mapped to the semantics of different semantic spaces through the first linear mapping layer. Vector, capturing semantic information of different dimensions. For example, the linear term formulas in the first linear mapping layer are Q' i =QW i Q , K' i =KW t k , Vi '=VW i V , where Q is the query value, K is the key value, and V is the Value vector, i is a linear term mapped to i semantic spaces, Q', i, K'i, V'. i is the semantic vector of the i-th semantic space.
通过在不同语义空间语义向量上进行self-attention操作,输出不同语义空间的文本语
Figure PCTCN2021097419-appb-000001
的文本语义向量。在得到不同语义空间的文本语义向量时,将不同语义空间的文本语义向量进行拼接,例如c=Concat(hend 1,......,hend i)W,其中,Concat为向量拼接操作,W为不同语义空间映射回初始语义空间的线性项,C为多头自注意力网络模型输出的第二文本语义向量。将拼接后的向量信息通过第一线性映射层映射回原语义空间,得到输出的文本语义向量信息。
By performing self-attention operations on semantic vectors in different semantic spaces, output text language in different semantic spaces
Figure PCTCN2021097419-appb-000001
text semantic vector. When obtaining text semantic vectors in different semantic spaces, the text semantic vectors in different semantic spaces are spliced, for example, c=Concat(hend 1 ,...,hend i )W, where Concat is a vector splicing operation, W is the linear term that maps different semantic spaces back to the initial semantic space, and C is the second text semantic vector output by the multi-head self-attention network model. The spliced vector information is mapped back to the original semantic space through the first linear mapping layer, and the output text semantic vector information is obtained.
在获取到文本语义向量信息时,从该文本语义向量信息中获取实体名和各个实体别名的语义向量。基于该第一预置预训练语言模型的第二线性映射层对实体名和各个实体别名的语义向量做线性变换,得到实体名的概率得分值以及各个实体别名的概率得分值。将获取到的实体名的概率得分值分别与各个实体别名的概率得分值作为softmax归一化处理后,计算其于标签值(1或者0)的交差熵损失,将该交差熵损失作为损失函数。在得到多个损失函数时,通过反向传播机制,得到对应的模型参数,通过该模型参数更新第一第一预置预训练语言模型的模型参数,生成对应的预置实体识别模型。When the text semantic vector information is obtained, the semantic vector of the entity name and each entity alias is obtained from the text semantic vector information. The second linear mapping layer based on the first preset pre-trained language model performs linear transformation on the entity name and the semantic vector of each entity alias to obtain the probability score value of the entity name and the probability score value of each entity alias. After normalizing the obtained probability score value of the entity name and the probability score value of each entity alias as softmax, calculate the cross entropy loss of the label value (1 or 0), and use the cross entropy loss as loss function. When multiple loss functions are obtained, corresponding model parameters are obtained through a back-propagation mechanism, and the model parameters of the first and first preset pre-trained language models are updated through the model parameters to generate a corresponding preset entity recognition model.
在本实施例中,通过训练预训练语言模型,得到预置实体识别模型,实现预置实体识别模型对问题的实体识别,从而对实体名进行语义编码,提高预置实体识别模型的表示能力和泛化能力,从而提升了预置实体识别模型的准确率。In this embodiment, a pre-trained language model is trained to obtain a preset entity recognition model, which realizes the entity recognition of the problem by the preset entity recognition model, thereby semantically encoding the entity name, improving the representation ability and Generalization ability, thereby improving the accuracy of the preset entity recognition model.
在一实施例中,具体地,参照图5,图5为预置属性映射模型的流程示意图。In an embodiment, specifically, referring to FIG. 5 , FIG. 5 is a schematic flowchart of a preset attribute mapping model.
如图5所示,该预置属性映射模型包括步骤S301至步骤S304。As shown in FIG. 5 , the preset attribute mapping model includes steps S301 to S304.
步骤S301、获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个。Step S301: Acquire data to be trained, determine target attribute names of the questions in the data to be trained, and acquire candidate attribute names associated with the target attribute names, wherein the candidate attribute names are multiple.
示范例的,获取待训练数据,该待训练数据包括待训练问题、待训练问题的问答、以及该待训练问题对应的三元组。例如,待训练数据为待训练问题“梅花落作者是谁来着?”、三元组“梅花落|||作者|||鲍照”、待训练问题的问答“鲍照”。通过确定该问题中的目标属性名,该目标属性名可以是人工进行标注。通过该目标属性名获取关联的候选属性名。获取候选属性名的方式包括,通过该目标属性名查询预置图数据库,该预置图数据 库包括多组三元组,每一组三元组包括实体名、属性名和属性值。获取该目标属性同一节点的各个三元组中的属性名,将获取到的属性名作为该目标属性名的候选属性名。In an exemplary example, data to be trained is obtained, and the data to be trained includes a question to be trained, a question and answer of the question to be trained, and a triplet corresponding to the question to be trained. For example, the data to be trained is the question to be trained "Who is the author of Meihualuo?", the triplet "Plumblossom|||Author||| Bao Zhao", and the question-and-answer "Bao Zhao" of the question to be trained. By determining the target attribute name in the problem, the target attribute name can be manually annotated. Obtain the associated candidate attribute name through the target attribute name. The method of obtaining the candidate attribute name includes querying a preset map database through the target attribute name, and the preset map database includes multiple groups of triples, and each group of triples includes an entity name, an attribute name and an attribute value. Obtain the attribute names in each triplet of the same node of the target attribute, and use the obtained attribute name as the candidate attribute name of the target attribute name.
步骤S302、将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1。Step S302: Generate positive example data of the to-be-trained data for the question including the target attribute name, wherein the label value of the positive example data is 1.
示范例的,在确定该待训练数据中待训练问题的属性名为目标属性名时,生成待训练数据的正例数据,其中,正例数据包括待训练问题、待训练问题的答案以及对应的三元组。并对该正例数据进行标签,该该正例数据的标签值为1。As an example, when it is determined that the attribute name of the question to be trained in the data to be trained is named the target attribute name, positive example data of the data to be trained is generated, wherein the positive example data includes the question to be trained, the answer to the question to be trained and the corresponding Triad. And label the positive example data, the label value of the positive example data is 1.
步骤S303、将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0。Step S303 , replacing each candidate attribute name with the target attribute name in the question, to generate multiple negative example data of the to-be-trained data, wherein the label value of each negative example data is 0.
示范例为,在确定该待训练数据中待训练问题的多个候选属性名时,确定该目标属性名在该问题中的位置,将该各个候选属性名替换该目标属性名。例如,问题为“笑傲江湖是什么语种的电视剧?”,其中,“语种”为该问题的目标属性名,而“方言”、“主演”、“导演”等为目标属性名的候选属性名时,在确定该“语种”在“笑傲江湖是什么语种的电视剧?”中的位置时,将“方言”、“主演”、“导演”等替换该“语种”,生成对应的负例数据,其中,负例数据中的问题为“笑傲江湖是什么方言的电视剧?”,或,“笑傲江湖是什么主演的电视剧?”等。并对该负例数据进行标签,该该负例数据的标签值为0。An example is, when determining multiple candidate attribute names of the problem to be trained in the to-be-trained data, determine the position of the target attribute name in the problem, and replace the target attribute name with each candidate attribute name. For example, the question is "What language is the TV series in Xiaoao Jianghu?", where "language" is the target attribute name of the question, and "dialect", "starring", "director", etc. are the candidate attribute names of the target attribute name. When determining the position of the "language" in "What language is the TV series of Xiaoao Jianghu?", replace the "language" with "dialect", "starring role", "director", etc., and generate the corresponding negative example data , among which, the question in the negative data is "What dialect TV series is Xiaoao Jianghu?", or, "What is Xiaoao Jianghu TV series starring in?" and so on. And label the negative example data, and the label value of the negative example data is 0.
步骤S304、根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。Step S304, according to the positive example data and the label value of the positive example data, as well as the multiple negative example data and the label value of each negative example data, train the second pre-training language model, and generate a corresponding preset Attribute Mapping Model.
示范例的,将该正例数据和多个负例数据输入到第二预置预训练语言模型中,其中,该第二预置预训练语言模型(Bidirectional Encoder Representations from Transformers BERT),包括字典文件vocab.txt,通过该字典文件vocab.txt将正例数据和负例数据中的问题按照字词切分,得到各个正例数据和负例数据中的问题的单词序列,且将问题的单词序列时按照预置填充规则或截断规则,生成统一长度的字符单词序列。其中,切分后的各个问题进行拼接,得到对应的文本序列,其中,文本序列中包括类型符号和各个问题的位置符号,例如,将[CLS]字符作为文本序列的分类符号,将[SEP]作为各个问题的位置分割符号。将得到的文本序列进行向量化表示,得到该文本序列对应的文本向量信息。示范例的,将输入文本序列中每个单词用预训练的单词特征向量表示,得到文本向量信息,该文本向量信息包括文本序列中每个单词的语义表示信息、位置表示信息、分段表示的加和信息。For example, the positive example data and multiple negative example data are input into the second preset pre-training language model, wherein the second preset pre-training language model (Bidirectional Encoder Representations from Transformers BERT), including dictionary files vocab.txt, through the dictionary file vocab.txt, the questions in the positive data and the negative data are divided according to words, and the word sequence of the questions in each positive and negative data is obtained, and the word sequence of the question is obtained. At the same time, according to the preset padding rules or truncation rules, a sequence of characters and words of uniform length is generated. Among them, the divided questions are spliced to obtain the corresponding text sequence, wherein the text sequence includes the type symbol and the position symbol of each question. For example, the [CLS] character is used as the classification symbol of the text sequence, and the [SEP] Split symbols as the position of each question. The obtained text sequence is vectorized to obtain the text vector information corresponding to the text sequence. As an example, each word in the input text sequence is represented by a pre-trained word feature vector to obtain text vector information, where the text vector information includes semantic representation information, location representation information, and segment representation information of each word in the text sequence. Addition information.
该第二预置预训练语言模型包括多头注意力网络模型,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型获取输入文本向量中融合上下文信息的每个单词所对应的向量表示,获取多头注意力网络模型输出的文本语义向量信息。示范性的,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型包括第一线性映射层,通该第一线性映射层将该文本向量信息映射到不同语义空间的语义向 量,捕捉不同维度的语义信息。并在不同语义空间语义向量上进行self-attention操作,输出不同语义空间的文本语义向量。将不同语义空间的文本语义向量进行拼接,将拼接后的向量信息通过第一线性映射层映射回原语义空间,得到输出的文本语义向量信息。The second preset pre-trained language model includes a multi-head attention network model, and the acquired text vector information is input into the multi-head attention network model, and the multi-head attention network model acquires each word in the input text vector fused with context information The corresponding vector representation is used to obtain the text semantic vector information output by the multi-head attention network model. Exemplarily, the acquired text vector information is input into a multi-head attention network model, the multi-head attention network model includes a first linear mapping layer, and the text vector information is mapped to different semantic spaces through the first linear mapping layer. The semantic vector captures semantic information of different dimensions. And perform self-attention operations on semantic vectors in different semantic spaces, and output text semantic vectors in different semantic spaces. The text semantic vectors in different semantic spaces are spliced, and the spliced vector information is mapped back to the original semantic space through the first linear mapping layer to obtain the output text semantic vector information.
例如,将获取到的文本向量信息输入到多头注意力网络模型中,该多头注意力网络模型包括第一线性映射层,通该第一线性映射层将该文本向量信息映射到不同语义空间的语义向量,捕捉不同维度的语义信息。例如,第一线性映射层中的线性项公式为Q' i=QW i Q,K' i=KW t k,V i'=VW i V,其中Q为查询值、K为键值、V为值向量,i为映射到i个语义空间的线性项,Q′,i,K′i,V′i为第i个语义空间的语义向量。 For example, the acquired text vector information is input into a multi-head attention network model, the multi-head attention network model includes a first linear mapping layer, and the text vector information is mapped to the semantics of different semantic spaces through the first linear mapping layer. Vector, capturing semantic information of different dimensions. For example, the linear term formulas in the first linear mapping layer are Q' i =QW i Q , K' i =KW t k , Vi '=VW i V , where Q is the query value, K is the key value, and V is the Value vector, i is the linear term mapped to the i semantic space, Q', i, K'i, V'i are the semantic vector of the i-th semantic space.
通过在不同语义空间语义向量上进行self-attention操作,输出不同语义空间的文本语
Figure PCTCN2021097419-appb-000002
的文本语义向量。在得到不同语义空间的文本语义向量时,将不同语义空间的文本语义向量进行拼接,例如c=Concat(hend 1,......,hend i)W,其中,Concat为向量拼接操作,W为不同语义空间映射回初始语义空间的线性项,C为多头自注意力网络模型输出的第二文本语义向量。将拼接后的向量信息通过第一线性映射层映射回原语义空间,得到输出的文本语义向量信息。
By performing self-attention operations on semantic vectors in different semantic spaces, output text language in different semantic spaces
Figure PCTCN2021097419-appb-000002
text semantic vector. When obtaining text semantic vectors in different semantic spaces, the text semantic vectors in different semantic spaces are spliced, for example, c=Concat(hend 1 ,...,hend i )W, where Concat is a vector splicing operation, W is the linear term that maps different semantic spaces back to the initial semantic space, and C is the second text semantic vector output by the multi-head self-attention network model. The spliced vector information is mapped back to the original semantic space through the first linear mapping layer, and the output text semantic vector information is obtained.
在获取到文本语义向量信息时,从该文本语义向量信息中获取实体名和各个实体别名的语义向量。基于该第一预置预训练语言模型的第二线性映射层对实体名和各个实体别名的语义向量做线性变换,得到属性名的概率得分值以及各个其它属性名的概率得分值。将获取到的属性名的概率得分值分别与各个其它属性名的概率得分值作为softmax归一化处理后,计算其于标签值(1或者0)的交差熵损失,将该交差熵损失作为损失函数。在得到多个损失函数时,通过反向传播机制,得到对应的模型参数,通过该模型参数更新第一第一预置预训练语言模型的模型参数,生成对应的预置属性映射模型。When the text semantic vector information is obtained, the semantic vector of the entity name and each entity alias is obtained from the text semantic vector information. The second linear mapping layer based on the first preset pre-trained language model performs linear transformation on the entity name and the semantic vector of each entity alias to obtain the probability score value of the attribute name and the probability score value of each other attribute name. After normalizing the obtained probability score value of the attribute name and the probability score value of each other attribute name as softmax, calculate the cross entropy loss of the label value (1 or 0), and the cross entropy loss as a loss function. When multiple loss functions are obtained, corresponding model parameters are obtained through a back-propagation mechanism, and the model parameters of the first and first preset pre-trained language models are updated through the model parameters to generate a corresponding preset attribute mapping model.
在本实施例中,通过训练预训练语言模型,得到预置属性映射模型,实现预置属性映射模型对问题的属性映射,从而对属性名进行语义编码,提高预置属性映射模型的表示能力和泛化能力,从而提升了预置属性映射模型的准确率。In this embodiment, a pre-trained language model is trained to obtain a preset attribute mapping model, which realizes the attribute mapping of the preset attribute mapping model to the question, thereby semantically encoding the attribute name, and improving the representation ability and performance of the preset attribute mapping model. Generalization ability, thereby improving the accuracy of the preset attribute mapping model.
请参照图6,图6为本申请实施例提供的一种自动问答装置的示意性框图。Please refer to FIG. 6 , which is a schematic block diagram of an automatic question answering apparatus provided by an embodiment of the present application.
如图6所示,该自动问答装置400,包括:获取模块401、第一确定模块402、第二确定模块403、第三确定模块404。As shown in FIG. 6 , the automatic question answering device 400 includes: an acquisition module 401 , a first determination module 402 , a second determination module 403 , and a third determination module 404 .
获取模块401,用于根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;The obtaining module 401 is configured to obtain the entity alias of each word in the question to be predicted according to the preset alias dictionary, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
第一确定模块402,用于基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;a first determination module 402, configured to determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model;
第二确定模块403,用于用于根据所述实体名和预置图数据库,确定所述预置图数据库中述实体名对应的三元组;其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组;The second determining module 403 is configured to determine, according to the entity name and the preset map database, the triplet corresponding to the entity name in the preset map database; wherein the triplet includes the entity name, attribute name and attribute value, the triplet is multiple groups;
第三确定模块404,用于基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。The third determining module 404 is configured to determine the target attribute name corresponding to the to-be-predicted problem according to each of the attribute names and the to-be-predicted problem based on the preset attribute mapping model, and use the attribute value corresponding to the target attribute name as the target attribute name. The question and answer of the question to be predicted.
其中,第一确定模块402具体还用于:Wherein, the first determining module 402 is further used for:
根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录;According to the plurality of candidate entities, the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records;
将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值;Inputting a plurality of the text records into a preset entity recognition model respectively, and predicting the predicted values of candidate entities in each of the text records;
根据各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。According to the predicted value of the candidate entity in each of the text records, the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
其中,第三确定模块404具体还用于:Wherein, the third determining module 404 is also specifically used for:
各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对;Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的的预测分值;Inputting each of the attribute text pairs into a preset attribute mapping model to obtain the predicted scores of the attribute names in each of the attribute text pairs;
根据各个所述属性文本对中属性名的的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对;According to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest output predicted score of the preset attribute mapping model;
将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。The attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
其中,确自动问答装置具体还用于:Among them, the automatic question and answer device is also used for:
获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个;Obtain the data to be trained, and determine the target entity name and candidate entity name of the problem in the data to be trained, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple;
获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label value of the positive example data is 1 ;
获取所述候选实体名的第二字符,将所述第二字符替换所述问题中对应的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Obtain the second character of the candidate entity name, replace the second character with each candidate entity name corresponding to the question, and generate multiple negative example data of the to-be-trained data, wherein the each negative example data The label value is 0;
根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。The first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
其中,自动问答装置具体还用于:Among them, the automatic question answering device is also used for:
获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个;Acquire the data to be trained, determine the target attribute name of the problem in the data to be trained, and obtain candidate attribute names associated with the target attribute name, wherein the candidate attribute names are multiple;
将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Each candidate attribute name is respectively replaced with the target attribute name in the problem, and a plurality of negative example data of the to-be-trained data is generated, wherein the label value of each negative example data is 0;
根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。A second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
其中,自动问答装置具体还用于:Among them, the automatic question answering device is also used for:
获取预置知识库中任意一个三元组,以及基于预置别名词典获取所述三元组中实体名的别名列表;Obtain any triplet in the preset knowledge base, and obtain the alias list of entity names in the triplet based on the preset alias dictionary;
根据所述别名列表,确定预置图知识库中是否存在所述三元组;According to the alias list, determine whether the triplet exists in the preset graph knowledge base;
若确定存在所述三元组,则将所述预置图知识库作为预置图数据库;If it is determined that the triplet exists, the preset graph knowledge base is used as a preset graph database;
若确定不存在所述三元组,则在所述预置知识库中创建节点并在所述节点处导入所述三元组,生成预置图数据库。If it is determined that the triplet does not exist, a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
其中,自动问答装置具体还用于:Among them, the automatic question answering device is also used for:
获取预置知识库中各个文本,并识别各个所述文本中的实体名;Obtain each text in the preset knowledge base, and identify the entity name in each of the texts;
基于预设属性规则抽取所述实体名的实体别名,生成预置别名词典。The entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
需要说明的是,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的装置和各模块及单元的具体工作过程,可以参考前述自动问答方法实施例中的对应过程,在此不再赘述。It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module and unit may refer to the corresponding process in the foregoing automatic question answering method embodiment, It is not repeated here.
上述实施例提供的装置可以实现为一种计算机程序的形式,该计算机程序可以在如图7所示的计算机设备上运行。The apparatuses provided by the above embodiments may be implemented in the form of a computer program, and the computer program may be executed on the computer device as shown in FIG. 7 .
请参阅图7,图7为本申请实施例提供的一种计算机设备的结构示意性框图。该计算机设备可以为终端。Please refer to FIG. 7 , which is a schematic block diagram of the structure of a computer device according to an embodiment of the present application. The computer device may be a terminal.
如图7所示,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口,其中,存储器可以包括非易失性存储介质和内存储器。As shown in FIG. 7, the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
非易失性存储介质可存储操作系统和计算机程序。该计算机程序包括程序指令,该程序指令被执行时,可使得处理器执行任意一种自动问答方法。The nonvolatile storage medium can store operating systems and computer programs. The computer program includes program instructions that, when executed, can cause the processor to execute any automatic question-answering method.
处理器用于提供计算和控制能力,支撑整个计算机设备的运行。The processor is used to provide computing and control capabilities to support the operation of the entire computer equipment.
内存储器为非易失性存储介质中的计算机程序的运行提供环境,该计算机程序被处理器执行时,可使得处理器执行任意一种自动问答方法。The internal memory provides an environment for running the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any automatic question-answering method.
该网络接口用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图7中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface is used for network communication, such as sending assigned tasks. Those skilled in the art can understand that the structure shown in FIG. 7 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. Include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
应当理解的是,处理器可以是中央处理单元(Central Processing Unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列 (Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor may be a central processing unit (Central Processing Unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSP), application specific integrated circuits (Application Specific Integrated circuits) Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Wherein, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor or the like.
其中,在一个实施例中,所述处理器用于运行存储在存储器中的计算机程序,以实现如下步骤:Wherein, in one embodiment, the processor is configured to run a computer program stored in the memory to implement the following steps:
根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;According to the preset alias dictionary, obtain the entity alias of each word in the question to be predicted, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;Based on the preset entity recognition model, according to the to-be-predicted question and a plurality of the candidate entities, determine the entity name corresponding to the to-be-predicted question;
根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组;其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组;According to the entity name and the preset graph database, the triplet corresponding to the entity name in the preset graph database is determined; wherein, the triplet includes the entity name, attribute name and attribute value, and the triplet group is multi-group;
基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question.
在一个实施例中,所述处理器所述基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名实现时,用于实现:In one embodiment, when the processor determines the entity name corresponding to the problem to be predicted according to the problem to be predicted and a plurality of candidate entities based on a preset entity recognition model, the processor is used to realize:
根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录;According to the plurality of candidate entities, the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records;
将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值;Inputting a plurality of the text records into a preset entity recognition model respectively, and predicting the predicted values of candidate entities in each of the text records;
根据各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。According to the predicted value of the candidate entity in each of the text records, the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
在一个实施例中,所述处理器基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述问题对应的目标属性名实现时,用于实现:In one embodiment, when the processor determines the target attribute name corresponding to the problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model, the processor is used to realize:
各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对;Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的的预测分值;Inputting each of the attribute text pairs into a preset attribute mapping model to obtain the predicted scores of the attribute names in each of the attribute text pairs;
根据各个所述属性文本对中属性名的的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对;According to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest output predicted score of the preset attribute mapping model;
将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。The attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
在一个实施例中,所述处理器自动问答方法还包括实现时,用于实现:In one embodiment, the processor automatic question answering method further includes when implementing, for implementing:
获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个;Obtain the data to be trained, and determine the target entity name and candidate entity name of the problem in the data to be trained, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple;
获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label value of the positive example data is 1 ;
获取所述候选实体名的第二字符,将所述第二字符替换所述问题中对应的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Obtain the second character of the candidate entity name, replace the second character with each candidate entity name corresponding to the question, and generate multiple negative example data of the to-be-trained data, wherein the each negative example data The label value is 0;
根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。The first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
在一个实施例中,所述处理器自动问答方法还包括实现时,用于实现:In one embodiment, the processor automatic question answering method further includes when implementing, for implementing:
获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个;Acquire the data to be trained, determine the target attribute name of the problem in the data to be trained, and obtain candidate attribute names associated with the target attribute name, wherein the candidate attribute names are multiple;
将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Each candidate attribute name is respectively replaced with the target attribute name in the problem, and a plurality of negative example data of the to-be-trained data is generated, wherein the label value of each negative example data is 0;
根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。A second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
在一个实施例中,所述处理器根据所述实体名和预置图数据库,确定所述实体名对应的三元组之前实现时,用于实现:In one embodiment, the processor determines, according to the entity name and the preset graph database, when the triplet corresponding to the entity name is previously implemented, to implement:
获取预置知识库中任意一个三元组,以及基于预置别名词典获取所述三元组中实体名的别名列表;Obtain any triplet in the preset knowledge base, and obtain the alias list of entity names in the triplet based on the preset alias dictionary;
根据所述别名列表,确定预置图知识库中是否存在所述三元组;According to the alias list, determine whether the triplet exists in the preset graph knowledge base;
若确定存在所述三元组,则将所述预置图知识库作为预置图数据库;If it is determined that the triplet exists, the preset graph knowledge base is used as a preset graph database;
若确定不存在所述三元组,则在所述预置知识库中创建节点并在所述节点处导入所述三元组,生成预置图数据库。If it is determined that the triplet does not exist, a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
在一个实施例中,所述处理器根据预置别名词典,获取待预测问题中的实体别名,并将所述实体别名作为候选实体之前实现时,用于实现:In one embodiment, the processor obtains entity aliases in the problem to be predicted according to a preset alias dictionary, and uses the entity aliases as candidate entities when implemented before, for implementing:
获取预置知识库中各个文本,并识别各个所述文本中的实体名;Obtain each text in the preset knowledge base, and identify the entity name in each of the texts;
基于预设属性规则抽取所述实体名的实体别名,生成预置别名词典。The entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序中包括程序指令,所述程序指令被执行时所实现的方法可参照本申请自动问答方法的各个实施例。Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, the computer program includes program instructions, and the method implemented when the program instructions are executed may refer to this document Various embodiments of automated question answering methods are claimed.
其中,所述计算机可读存储介质可以是前述实施例所述的计算机设备的内部存储单元,例如所述计算机设备的硬盘或内存。所述计算机可读存储介质也可以是所述计算机设备的外部存储设备,例如所述计算机设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as a hard disk or a memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) ) card, Flash Card, etc.
进一步地,所述计算机可读存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function, and the like; The data created by the use of the node, etc.
本申请所指区块链预置别名词典、预置实体识别模型、预置图数据库和预置属性映射模型的存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。This application refers to a new application mode of computer technology such as the storage, point-to-point transmission, consensus mechanism, and encryption algorithm of the blockchain preset alias dictionary, preset entity recognition model, preset graph database and preset attribute mapping model. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments. The above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalents within the technical scope disclosed in the present application. Modifications or substitutions shall be covered by the protection scope of this application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (20)

  1. 一种自动问答方法,其中,包括:An automatic question answering method, which includes:
    根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;According to the preset alias dictionary, obtain the entity alias of each word in the question to be predicted, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
    基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;Based on the preset entity recognition model, according to the to-be-predicted question and a plurality of the candidate entities, determine the entity name corresponding to the to-be-predicted question;
    根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组;According to the entity name and the preset graph database, the triplet corresponding to the entity name in the preset graph database is determined, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet group is multi-group;
    基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question.
  2. 如权利要求1所述的自动问答方法,其中,所述基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名,包括:The automatic question answering method according to claim 1, wherein, determining the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model, comprising:
    根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录;According to the plurality of candidate entities, the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records;
    将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值;Inputting a plurality of the text records into a preset entity recognition model respectively, and predicting the predicted values of candidate entities in each of the text records;
    根据各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。According to the predicted value of the candidate entity in each of the text records, the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
  3. 如权利要求1所述的自动问答方法,其中,所述基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述问题对应的目标属性名,包括:The automatic question answering method according to claim 1, wherein, determining the target attribute name corresponding to the question according to each of the attribute names and the to-be-predicted question based on a preset attribute mapping model, comprising:
    各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对;Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
    将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的预测分值;Inputting each of the attribute text pairs into a preset attribute mapping model to obtain the predicted scores of the attribute names in each of the attribute text pairs;
    根据各个所述属性文本对中属性名的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对;According to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest output predicted score of the preset attribute mapping model;
    将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。The attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
  4. 如权利要求1所述的自动问答方法,其中,所述方法还包括:The automatic question answering method of claim 1, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个;Obtain the data to be trained, and determine the target entity name and candidate entity name of the problem in the data to be trained, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple;
    获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label value of the positive example data is 1 ;
    获取所述候选实体名的第二字符,将所述第二字符替换所述问题中对应的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Obtain the second character of the candidate entity name, replace the second character with each candidate entity name corresponding to the question, and generate multiple negative example data of the to-be-trained data, wherein the each negative example data The label value is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。The first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
  5. 如权利要求1所述的自动问答方法,其中,所述方法还包括:The automatic question answering method of claim 1, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个;Acquire the data to be trained, determine the target attribute name of the problem in the data to be trained, and obtain candidate attribute names associated with the target attribute name, wherein the candidate attribute names are multiple;
    将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
    将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Each candidate attribute name is respectively replaced with the target attribute name in the problem, and a plurality of negative example data of the to-be-trained data is generated, wherein the label value of each negative example data is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。A second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
  6. 如权利要求1所述的自动问答方法,其中,所述根据所述实体名和预置图数据库,确定所述实体名对应的三元组之前,还包括:The automatic question answering method according to claim 1, wherein before determining the triplet corresponding to the entity name according to the entity name and a preset graph database, the method further comprises:
    获取预置知识库中的任意一个三元组,以及基于预置别名词典获取所述三元组中实体名的别名列表;Obtaining any triplet in the preset knowledge base, and obtaining the alias list of entity names in the triplet based on the preset alias dictionary;
    根据所述别名列表,确定预置图知识库中是否存在所述三元组;According to the alias list, determine whether the triplet exists in the preset graph knowledge base;
    若确定存在所述三元组,则将所述预置图知识库作为预置图数据库;If it is determined that the triplet exists, the preset graph knowledge base is used as a preset graph database;
    若确定不存在所述三元组,则在所述预置知识库中创建节点并在所述节点处导入所述三元组,生成预置图数据库。If it is determined that the triplet does not exist, a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
  7. 如权利要求1所述的自动问答方法,其中,所述根据预置别名词典,获取待预测问题中的实体别名,并将所述实体别名作为候选实体之前,还包括:The automatic question answering method according to claim 1, wherein, before acquiring an entity alias in the question to be predicted according to a preset alias dictionary, and using the entity alias as a candidate entity, the method further comprises:
    获取预置知识库中各个文本,并识别各个所述文本中的实体名;Obtain each text in the preset knowledge base, and identify the entity name in each of the texts;
    基于预设属性规则抽取所述实体名的实体别名,生成预置别名词典。The entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
  8. 一种自动问答装置,所述装置包括:An automatic question and answer device, the device includes:
    获取模块,用于根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;an acquisition module, configured to acquire entity aliases of each word in the question to be predicted according to a preset alias dictionary, and use the entity aliases as candidate entities, wherein the entity aliases and the candidate entities are multiple;
    第一确定模块,用于基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;a first determination module, configured to determine the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model;
    第二确定模块,用于根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多个;The second determining module is configured to determine, according to the entity name and the preset map database, the triplet corresponding to the entity name in the preset map database, wherein the triplet includes the entity name, the attribute name and the attribute value, the triplet is multiple;
    第三确定模块,用于基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。The third determining module is configured to, based on the preset attribute mapping model, determine the target attribute name corresponding to the to-be-predicted problem according to each of the attribute names and the to-be-predicted problem, and use the attribute value corresponding to the target attribute name as the target attribute name. Questions and answers describing the problem to be predicted.
  9. 一种计算机设备,其中,所述计算机设备包括处理器、存储器、以及存储在所述 存储器上并可被所述处理器执行的计算机程序,其中所述计算机程序被所述处理器执行时,实现如下步骤:A computer device, wherein the computer device includes a processor, a memory, and a computer program stored on the memory and executable by the processor, wherein the computer program, when executed by the processor, implements Follow the steps below:
    根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;According to the preset alias dictionary, obtain the entity alias of each word in the question to be predicted, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
    基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;Based on the preset entity recognition model, according to the to-be-predicted question and a plurality of the candidate entities, determine the entity name corresponding to the to-be-predicted question;
    根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组;According to the entity name and the preset graph database, the triplet corresponding to the entity name in the preset graph database is determined, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet group is multi-group;
    基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question.
  10. 如权利要求9所述的计算机设备,其中,所述基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名,包括:The computer device according to claim 9, wherein, determining the entity name corresponding to the to-be-predicted question according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model, comprising:
    根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录;According to the plurality of candidate entities, the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records;
    将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值;Inputting a plurality of the text records into a preset entity recognition model respectively, and predicting the predicted values of candidate entities in each of the text records;
    根据各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。According to the predicted value of the candidate entity in each of the text records, the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
  11. 如权利要求9所述的计算机设备,其中,所述基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述问题对应的目标属性名,包括:The computer device according to claim 9, wherein, determining the target attribute name corresponding to the problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model, comprising:
    各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对;Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
    将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的预测分值;Inputting each of the attribute text pairs into a preset attribute mapping model to obtain the predicted scores of the attribute names in each of the attribute text pairs;
    根据各个所述属性文本对中属性名的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对;According to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest output predicted score of the preset attribute mapping model;
    将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。The attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
  12. 如权利要求9所述的计算机设备,其中,所述方法还包括:The computer device of claim 9, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个;Obtain the data to be trained, and determine the target entity name and candidate entity name of the problem in the data to be trained, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple;
    获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label value of the positive example data is 1 ;
    获取所述候选实体名的第二字符,将所述第二字符替换所述问题中对应的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Obtain the second character of the candidate entity name, replace the second character with each candidate entity name corresponding to the question, and generate multiple negative example data of the to-be-trained data, wherein the each negative example data The label value is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。The first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
  13. 如权利要求9所述的计算机设备,其中,所述方法还包括:The computer device of claim 9, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个;Acquire the data to be trained, determine the target attribute name of the problem in the data to be trained, and obtain candidate attribute names associated with the target attribute name, wherein the candidate attribute names are multiple;
    将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Generating the positive example data of the data to be trained will include the question of the target attribute name, wherein the label value of the positive example data is 1;
    将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Replace each candidate attribute name with the target attribute name in the problem, and generate a plurality of negative example data of the to-be-trained data, wherein the label value of each negative example data is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。A second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
  14. 如权利要求9所述的计算机设备,其中,所述根据所述实体名和预置图数据库,确定所述实体名对应的三元组之前,还包括:The computer device according to claim 9, wherein before determining the triplet corresponding to the entity name according to the entity name and a preset graph database, the method further comprises:
    获取预置知识库中的任意一个三元组,以及基于预置别名词典获取所述三元组中实体名的别名列表;Obtaining any triplet in the preset knowledge base, and obtaining the alias list of entity names in the triplet based on the preset alias dictionary;
    根据所述别名列表,确定预置图知识库中是否存在所述三元组;According to the alias list, determine whether the triplet exists in the preset graph knowledge base;
    若确定存在所述三元组,则将所述预置图知识库作为预置图数据库;If it is determined that the triplet exists, the preset graph knowledge base is used as a preset graph database;
    若确定不存在所述三元组,则在所述预置知识库中创建节点并在所述节点处导入所述三元组,生成预置图数据库。If it is determined that the triplet does not exist, a node is created in the preset knowledge base and the triplet is imported at the node to generate a preset graph database.
  15. 如权利要求9所述的计算机设备,其中,所述根据预置别名词典,获取待预测问题中的实体别名,并将所述实体别名作为候选实体之前,还包括:The computer device according to claim 9, wherein, before acquiring an entity alias in the problem to be predicted according to a preset alias dictionary, and using the entity alias as a candidate entity, the method further comprises:
    获取预置知识库中各个文本,并识别各个所述文本中的实体名;Obtain each text in the preset knowledge base, and identify the entity name in each of the texts;
    基于预设属性规则抽取所述实体名的实体别名,生成预置别名词典。The entity alias of the entity name is extracted based on the preset attribute rule, and a preset alias dictionary is generated.
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有计算机程序,其中所述计算机程序被处理器执行时,实现如下步骤:A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
    根据预置别名词典,获取待预测问题中各个字词的实体别名,并将所述实体别名作为候选实体,其中,所述实体别名和所述候选实体为多个;According to the preset alias dictionary, obtain the entity alias of each word in the question to be predicted, and use the entity alias as a candidate entity, wherein the entity alias and the candidate entity are multiple;
    基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名;Based on the preset entity recognition model, according to the to-be-predicted question and a plurality of the candidate entities, determine the entity name corresponding to the to-be-predicted question;
    根据所述实体名和预置图数据库,确定所述预置图数据库中所述实体名对应的三元组,其中,所述三元组包括所述实体名、属性名和属性值,所述三元组为多组;According to the entity name and the preset graph database, the triplet corresponding to the entity name in the preset graph database is determined, wherein the triplet includes the entity name, attribute name and attribute value, and the triplet group is multi-group;
    基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述待预测问题对应的目标属性名,并将所述目标属性名对应的属性值作为所述待预测问题的问答。Based on the preset attribute mapping model, the target attribute name corresponding to the to-be-predicted question is determined according to each of the attribute names and the to-be-predicted question, and the attribute value corresponding to the target attribute name is used as the question and answer of the to-be-predicted question.
  17. 如权利要求16所述的计算机可读存储介质,其中,所述基于预置实体识别模型,根据所述待预测问题和多个所述候选实体,确定所述待预测问题对应的实体名,包括:The computer-readable storage medium according to claim 16, wherein the entity name corresponding to the to-be-predicted question is determined according to the to-be-predicted question and a plurality of the candidate entities based on a preset entity recognition model, comprising: :
    根据多个所述候选实体分别对所述待预测问题中对应的字词进行替换,生成多个文本记录;According to the plurality of candidate entities, the corresponding words in the to-be-predicted question are respectively replaced to generate a plurality of text records;
    将多个所述文本记录分别输入预置实体识别模型,预测各个所述文本记录中候选实体的预测值;Inputting a plurality of the text records into a preset entity recognition model respectively, and predicting the predicted values of candidate entities in each of the text records;
    根据各个所述文本记录中候选实体的预测值,确定目标文本记录中的候选实体为实体名,将所述实体名作为所述待预测问题对应的实体名。According to the predicted value of the candidate entity in each of the text records, the candidate entity in the target text record is determined as the entity name, and the entity name is used as the entity name corresponding to the problem to be predicted.
  18. 如权利要求16所述的计算机可读存储介质,其中,所述基于预置属性映射模型,根据各个所述属性名和所述待预测问题确定所述问题对应的目标属性名,包括:The computer-readable storage medium according to claim 16, wherein the determining the target attribute name corresponding to the problem according to each of the attribute names and the to-be-predicted problem based on a preset attribute mapping model comprises:
    各个所述属性名分别与所述待预测问题进行组合,生成多个属性文本对;Each of the attribute names is combined with the to-be-predicted question to generate a plurality of attribute text pairs;
    将各个所述属性文本对输入预置属性映射模型,得到各个所述属性文本对中属性名的预测分值;Inputting each of the attribute text pairs into a preset attribute mapping model to obtain the predicted scores of the attribute names in each of the attribute text pairs;
    根据各个所述属性文本对中属性名的预测分值,获取所述预置属性映射模型输出预测分值最高的目标属性文本对;According to the predicted score of the attribute name in each of the attribute text pairs, obtain the target attribute text pair with the highest output predicted score of the preset attribute mapping model;
    将所述目标属性文本对中的属性名作为所述待预测问题对应的目标属性名。The attribute name in the target attribute text pair is used as the target attribute name corresponding to the question to be predicted.
  19. 如权利要求16所述的计算机可读存储介质,其中,所述方法还包括:The computer-readable storage medium of claim 16, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标实体名和候选实体名,其中,所述目标实体名与所述候选实体名不相同,所述候选实体名为多个;Obtain the data to be trained, and determine the target entity name and candidate entity name of the problem in the data to be trained, wherein the target entity name is different from the candidate entity name, and the candidate entity names are multiple;
    获取所述目标实体名的第一字符,将所述第一字符替换所述问题中的目标实体名,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Obtain the first character of the target entity name, replace the first character with the target entity name in the question, and generate positive example data of the data to be trained, wherein the label value of the positive example data is 1 ;
    获取所述候选实体名的第二字符,将所述第二字符替换所述问题中对应的各个候选实体名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Obtain the second character of the candidate entity name, replace the second character with each candidate entity name corresponding to the question, and generate multiple negative example data of the data to be trained, wherein the each negative example data The label value is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第一预训练语言模型,生成对应的预置实体识别模型。The first pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the plurality of negative example data and the label values of the respective negative example data, and a corresponding preset entity recognition model is generated .
  20. 如权利要求16所述的计算机可读存储介质,其中,所述方法还包括:The computer-readable storage medium of claim 16, wherein the method further comprises:
    获取待训练数据,确定待训练数据中问题的目标属性名,并获取所述目标属性名关联的候选属性名,其中,所述候选属性名为多个;Acquire the data to be trained, determine the target attribute name of the problem in the data to be trained, and obtain candidate attribute names associated with the target attribute name, wherein the candidate attribute names are multiple;
    将包含所述目标属性名的问题,生成所述待训练数据的正例数据,其中,所述正例数据的标签值为1;Will include the question of the target attribute name, generate the positive example data of the to-be-trained data, wherein, the label value of the positive example data is 1;
    将各个候选属性名分别替换所述问题中的目标属性名,生成所述待训练数据的多个负例数据,其中,所述各个负例数据的标签值为0;Replace each candidate attribute name with the target attribute name in the problem, and generate a plurality of negative example data of the to-be-trained data, wherein the label value of each negative example data is 0;
    根据所述正例数据和所述正例数据的标签值,以及所述多个负例数据和所述各个负例数据的标签值训练第二预训练语言模型,生成对应的预置属性映射模型。A second pre-trained language model is trained according to the positive example data and the label values of the positive example data, as well as the multiple negative example data and the label values of the respective negative example data, and a corresponding preset attribute mapping model is generated .
PCT/CN2021/097419 2020-10-29 2021-05-31 Automated question answering method and apparatus, device, and storage medium WO2022088671A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011187360.9 2020-10-29
CN202011187360.9A CN112328759A (en) 2020-10-29 2020-10-29 Automatic question answering method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022088671A1 true WO2022088671A1 (en) 2022-05-05

Family

ID=74296400

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/097419 WO2022088671A1 (en) 2020-10-29 2021-05-31 Automated question answering method and apparatus, device, and storage medium

Country Status (2)

Country Link
CN (1) CN112328759A (en)
WO (1) WO2022088671A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114723073A (en) * 2022-06-07 2022-07-08 阿里健康科技(杭州)有限公司 Language model pre-training method, language model pre-training device, language model searching device and computer equipment
CN116991875A (en) * 2023-09-26 2023-11-03 海信集团控股股份有限公司 SQL sentence generation and alias mapping method and device based on big model
CN117149985A (en) * 2023-10-31 2023-12-01 海信集团控股股份有限公司 Question and answer method, device, equipment and medium based on large model

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112328759A (en) * 2020-10-29 2021-02-05 平安科技(深圳)有限公司 Automatic question answering method, device, equipment and storage medium
CN113761940B (en) * 2021-09-09 2023-08-11 杭州隆埠科技有限公司 News main body judging method, equipment and computer readable medium
CN114817510B (en) * 2022-06-23 2022-10-14 清华大学 Question and answer method, question and answer data set generation method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107748757A (en) * 2017-09-21 2018-03-02 北京航空航天大学 A kind of answering method of knowledge based collection of illustrative plates
US20190065576A1 (en) * 2017-08-23 2019-02-28 Rsvp Technologies Inc. Single-entity-single-relation question answering systems, and methods
CN110502621A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Answering method, question and answer system, computer equipment and storage medium
CN110765257A (en) * 2019-12-30 2020-02-07 杭州识度科技有限公司 Intelligent consulting system of law of knowledge map driving type
CN110837550A (en) * 2019-11-11 2020-02-25 中山大学 Knowledge graph-based question and answer method and device, electronic equipment and storage medium
CN112328759A (en) * 2020-10-29 2021-02-05 平安科技(深圳)有限公司 Automatic question answering method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190065576A1 (en) * 2017-08-23 2019-02-28 Rsvp Technologies Inc. Single-entity-single-relation question answering systems, and methods
CN107748757A (en) * 2017-09-21 2018-03-02 北京航空航天大学 A kind of answering method of knowledge based collection of illustrative plates
CN110502621A (en) * 2019-07-03 2019-11-26 平安科技(深圳)有限公司 Answering method, question and answer system, computer equipment and storage medium
CN110837550A (en) * 2019-11-11 2020-02-25 中山大学 Knowledge graph-based question and answer method and device, electronic equipment and storage medium
CN110765257A (en) * 2019-12-30 2020-02-07 杭州识度科技有限公司 Intelligent consulting system of law of knowledge map driving type
CN112328759A (en) * 2020-10-29 2021-02-05 平安科技(深圳)有限公司 Automatic question answering method, device, equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114723073A (en) * 2022-06-07 2022-07-08 阿里健康科技(杭州)有限公司 Language model pre-training method, language model pre-training device, language model searching device and computer equipment
CN114723073B (en) * 2022-06-07 2023-09-05 阿里健康科技(杭州)有限公司 Language model pre-training method, product searching method, device and computer equipment
CN116991875A (en) * 2023-09-26 2023-11-03 海信集团控股股份有限公司 SQL sentence generation and alias mapping method and device based on big model
CN116991875B (en) * 2023-09-26 2024-03-08 海信集团控股股份有限公司 SQL sentence generation and alias mapping method and device based on big model
CN117149985A (en) * 2023-10-31 2023-12-01 海信集团控股股份有限公司 Question and answer method, device, equipment and medium based on large model
CN117149985B (en) * 2023-10-31 2024-03-19 海信集团控股股份有限公司 Question and answer method, device, equipment and medium based on large model

Also Published As

Publication number Publication date
CN112328759A (en) 2021-02-05

Similar Documents

Publication Publication Date Title
WO2022088672A1 (en) Machine reading comprehension method and apparatus based on bert, and device and storage medium
WO2022088671A1 (en) Automated question answering method and apparatus, device, and storage medium
US11327978B2 (en) Content authoring
CN108959246B (en) Answer selection method and device based on improved attention mechanism and electronic equipment
US10650102B2 (en) Method and apparatus for generating parallel text in same language
US10740678B2 (en) Concept hierarchies
US9373075B2 (en) Applying a genetic algorithm to compositional semantics sentiment analysis to improve performance and accelerate domain adaptation
WO2020147238A1 (en) Keyword determination method, automatic scoring method, apparatus and device, and medium
US20170330084A1 (en) Clarification of Submitted Questions in a Question and Answer System
US11017301B2 (en) Obtaining and using a distributed representation of concepts as vectors
US20170161619A1 (en) Concept-Based Navigation
CN110929125B (en) Search recall method, device, equipment and storage medium thereof
US10108661B2 (en) Using synthetic events to identify complex relation lookups
CN112287069B (en) Information retrieval method and device based on voice semantics and computer equipment
US9684726B2 (en) Realtime ingestion via multi-corpus knowledge base with weighting
CN115668168A (en) Method and system for processing data records
US20220300543A1 (en) Method of retrieving query, electronic device and medium
US11669679B2 (en) Text sequence generating method and apparatus, device and medium
WO2022141872A1 (en) Document abstract generation method and apparatus, computer device, and storage medium
CN115600605A (en) Method, system, equipment and storage medium for jointly extracting Chinese entity relationship
CN116821373A (en) Map-based prompt recommendation method, device, equipment and medium
CN114842982B (en) Knowledge expression method, device and system for medical information system
CN112529743B (en) Contract element extraction method, device, electronic equipment and medium
WO2022073341A1 (en) Disease entity matching method and apparatus based on voice semantics, and computer device
CN114942981A (en) Question-answer query method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21884414

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21884414

Country of ref document: EP

Kind code of ref document: A1