CN116975315A - Text matching method, device, computer equipment and storage medium - Google Patents

Text matching method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN116975315A
CN116975315A CN202211501064.0A CN202211501064A CN116975315A CN 116975315 A CN116975315 A CN 116975315A CN 202211501064 A CN202211501064 A CN 202211501064A CN 116975315 A CN116975315 A CN 116975315A
Authority
CN
China
Prior art keywords
text
entity
semantic representation
vector
character
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211501064.0A
Other languages
Chinese (zh)
Inventor
杨韬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202211501064.0A priority Critical patent/CN116975315A/en
Publication of CN116975315A publication Critical patent/CN116975315A/en
Pending legal-status Critical Current

Links

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/38Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • G06F16/383Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
    • 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/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • 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/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Abstract

The present application relates to a text matching method, apparatus, computer device, storage medium and computer program product. The method comprises the following steps: acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text; determining entity position information of an entity pair in which entity relation information exists from the first text and the second text; performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation; performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features; and calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text. By adopting the method, the accuracy of text matching can be improved.

Description

Text matching method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technology, and in particular, to a text matching method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of natural semantic processing (NLP, natural Language Processing) technology, a text matching technology has emerged, in which text matching is used to determine whether the semantics of two texts are identical, and when the semantics are identical, two text matching is described, and when the semantics are not identical, two text matching is described. Text matching is generally classified into long text-based matching and short text-based matching.
Currently, when matching text, semantic features of the text are usually extracted for matching. However, when the text contains less semantic information, the extracted semantic features are not obvious, so that the accuracy of text matching is reduced.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a text matching method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve accuracy.
In a first aspect, the present application provides a text matching method. The method comprises the following steps:
acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text;
determining an entity pair in which entity relationship information exists from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text;
Performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
In a second aspect, the application further provides a text matching device. The device comprises:
the acquisition module is used for acquiring the first text and the second text and acquiring entity relationship information between the entity in the first text and the entity in the second text;
a position determining module for determining an entity pair having entity relationship information from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text;
the semantic representation module is used for carrying out context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
The fusion module is used for carrying out correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and carrying out fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and the matching module is used for calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text;
determining an entity pair in which entity relationship information exists from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text;
performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
And calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text;
determining an entity pair in which entity relationship information exists from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text;
performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
the text matching method, the text matching device, the computer equipment, the storage medium and the computer program product are used for acquiring the first text and the second text and acquiring entity relationship information between entities in the first text and the second text. An entity pair for which entity relationship information exists is determined from the first text and the second text, and entity location information of the entity pair is determined based on the first text and the second text. And carrying out context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation, namely carrying out semantic representation extraction by using entity conceptual information and entity position information corresponding to the first text and the second text when carrying out semantic representation extraction, so that more information can be extracted when carrying out semantic representation extraction, and the extracted semantic representation is more accurate. And then, carrying out correlation calculation by using the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and carrying out fusion feature extraction based on the semantic representation correlation to obtain target fusion features, so that the accuracy of the obtained target fusion features is improved. And finally, calculating the matching degree corresponding to the first text and the second text by using the target fusion characteristic, thereby improving the accuracy of the matching degree, namely improving the accuracy of text matching.
Drawings
FIG. 1 is an application environment diagram of a text matching method in one embodiment;
FIG. 2 is a flow diagram of a text matching method in one embodiment;
FIG. 3 is a flow diagram of determining semantic representations in one embodiment;
FIG. 4 is a flow diagram of obtaining a target semantic representation in one embodiment;
FIG. 5 is a flow diagram of obtaining a target fusion feature in one embodiment;
FIG. 6 is a flow diagram of obtaining a current character fusion feature in one embodiment;
FIG. 7 is a flow diagram of obtaining weights for each target character in one embodiment;
FIG. 8 is a flow diagram of model matching in one embodiment;
FIG. 9 is a schematic diagram of an architecture of a target text matching model in one embodiment;
FIG. 10 is a flow diagram of training a target text matching model in one embodiment;
FIG. 11 is a flow diagram of text matching in one embodiment;
FIG. 12 is a block diagram of a text matching device in one embodiment;
FIG. 13 is an internal block diagram of a computer device in one embodiment;
fig. 14 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Natural language processing (Nature Language processing, NLP) is an important direction in the fields of computer science and artificial intelligence. It is studying various theories and methods that enable effective communication between a person and a computer in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Thus, the research in this field will involve natural language, i.e. language that people use daily, so it has a close relationship with the research in linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic questions and answers, knowledge graph techniques, and the like.
The scheme provided by the embodiment of the application relates to the technology of text processing and the like of artificial intelligence, and is specifically described by the following embodiments:
the text matching method provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on the cloud or other servers. The server 102 may obtain the first text and the second text from the terminal 102 and obtain entity relationship information between the entity in the first text and the entity in the second text from the data storage system. The server 102 determines an entity pair in which entity relationship information exists from the first text and the second text, and determines entity location information of the entity pair based on the first text and the second text. The server 102 performs context fusion semantic representation extraction on the first text, the second text, the entity relationship information and the entity position information to obtain a first text semantic representation and a second text semantic representation. The server 102 performs correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performs fusion feature extraction based on the semantic representation correlation to obtain target fusion features. The server 102 calculates the matching degree based on the target fusion feature to obtain the matching degree corresponding to the first text and the second text, and the server 102 can return the matching degree corresponding to the first text and the second text to the terminal 102 for display. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing services. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the present application is not limited herein.
In one embodiment, as shown in fig. 2, a text matching method is provided, and the method is applied to the server in fig. 1 for illustration, and this embodiment is applied to the terminal for illustration, it is understood that the method may also be applied to the terminal, and may also be applied to a system including the terminal and the server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the steps of:
step 202, acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text.
The first text refers to a text to be matched with the first text, and the second text refers to a text to be matched with the first text. The first text and the second text may be text of various language types, for example, chinese text, english text, japanese text, russian text, and the like. The first text and the second text may be texts of different fields, for example, a text of a medical field, a text of a financial field, a text of a news field, and the like. The first text and the second text may also be text obtained by speech conversion. The first text and the second text may also be text resulting from identifying information in the image. The entity refers to words, phrases and the like with specific meanings in the text, mainly comprising personal names, place names, organization names, proper nouns and the like, and the entity relation information is used for representing the relation between two entities. The relationship between the entities may be preset. For example, two entities, a "company" and a "company business person A" have an "contain" relationship, i.e., the "company" entity contains a "company business person A" entity.
Specifically, the server may obtain, from the database, a first text and a second text that need to be text matched. The server can also obtain the first text and the second text which need text matching from the terminal. The server may also obtain the first text from a service party providing the business service and then obtain the second text from the database. And then determining two entities of the entity relationship from the first text and the second text according to the preset relationship between the entities, wherein one of the two entities of the entity relationship is an entity in the first text, and the other entity is an entity in the second text. And acquiring entity relationship information corresponding to the two entities with the entity relationship.
In one embodiment, named entity recognition may be performed on the first text and the second text to obtain an entity included in the first text and an entity included in the second text. And searching entity relation information of two entities with entity relation in a stored dictionary, wherein each preset triplet can be stored in the dictionary, the triplet is stored in a form of (entity A, relation C and entity B), and when the entity A is an entity in a first text and the entity B is an entity in a second text, the obtained entity conceptual information is the relation C.
Step 204, determining an entity pair having entity relationship information from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text.
Wherein the entity pair is composed of a first text entity and a second text entity, and the first text entity and the second text entity have entity relation information. The entity location information is used for representing the specific location of the entity in the text, and comprises the location of the entity corresponding to the first text in the entity pair and the location of the entity corresponding to the second text in the entity pair.
Specifically, the server determines an entity pair in which entity relationship information exists from the entity of the first text and the entity of the second text. Entity location information for the entity in the entity pair is then determined by the text order of the first text and the second text.
In one embodiment, the server may splice the first text and the second text, determine entity positions corresponding to two entities in the entity pair from the spliced text, and obtain entity position information of the entity pair.
In one embodiment, the server determines that there are a plurality of entity pairs for which entity relationship information is determined to exist from the entity of the first text and the entity of the second text. I.e. there are at least two of the entity pairs. At this time, the server acquires entity position information corresponding to each entity pair.
And 206, extracting context fusion semantic representation from the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation.
Wherein the first text semantic representation is used to characterize the semantics of the first text. The semantic representation of the first text fuses the semantics corresponding to the entity relation information, the semantics of the first text and the semantics of the second text. The second text semantic representation is used to characterize the semantics of the second text. The semantic meaning of the first text and the semantic meaning of the second text are fused in the semantic meaning representation of the second text.
Specifically, the server uses the first text, the second text, the entity relation information and the entity position information to perform context fusion semantic representation extraction on the first text, the second text and the entity relation information to obtain extracted semantic representations, and determines a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the extracted semantic representations.
And step 208, performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features.
Wherein, semantic representation correlation is used to indicate the degree of correlation and degree of dependency between semantic representations. The higher the semantic representation correlation, the more relevant the text corresponding to the semantic representation is. The target fusion feature is a feature obtained after semantic characterization fusion.
Specifically, the server performs correlation calculation on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation corresponding to each semantic representation, wherein the correlation between the first text semantic representation calculation and the second text semantic representation is calculated, and the correlation between the first text semantic representation calculation and the server is calculated. And calculating the correlation between the second text semantic representation and the first text semantic representation, and simultaneously calculating the correlation between the second text semantic representation and the second text semantic representation to obtain the correlation of each semantic representation. And then extracting fusion features by using each semantic representation correlation to obtain target fusion features. The server can use a self-attention mechanism to extract fusion features of the first text semantic representation and the second text semantic representation to obtain target fusion features.
And 210, calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
The matching degree is used for representing the degree of consistency of the semantics of the first text and the second text, and the higher the matching degree is, the more consistent the semantics of the first text and the second text are.
Specifically, the server may use the target fusion feature to perform matching degree calculation, so as to obtain matching degrees corresponding to the first text and the second text. The server may also use the target fusion feature to classify to obtain a classification result of the first text and the second text, where the classification result includes a matching category of the first text and the second text and a non-matching category of the first text and the second text.
According to the text matching method, the first text and the second text are acquired, and entity relation information between the entities in the first text and the entities in the second text is acquired. An entity pair for which entity relationship information exists is determined from the first text and the second text, and entity location information of the entity pair is determined based on the first text and the second text. And carrying out context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation, namely carrying out semantic representation extraction by using entity conceptual information and entity position information corresponding to the first text and the second text when carrying out semantic representation extraction, so that more information can be extracted when carrying out semantic representation extraction, and the extracted semantic representation is more accurate. And then, carrying out correlation calculation by using the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and carrying out fusion feature extraction based on the semantic representation correlation to obtain target fusion features, so that the accuracy of the obtained target fusion features is improved. And finally, calculating the matching degree corresponding to the first text and the second text by using the target fusion characteristic, thereby improving the accuracy of the matching degree, namely improving the accuracy of text matching.
In one embodiment, step 204, determining an entity pair in which entity relationship information exists from the first text and the second text, and determining entity location information of the entity pair based on the first text and the second text, includes:
determining entity pairs with entity relation information from the first text and the second text, and splicing the first text and the second text to obtain spliced texts; determining first entity position information of a first entity in the spliced text in the entity pair according to the character sequence in the spliced text; determining second entity position information of a second entity in the spliced text in the entity pair according to the character sequence in the spliced text; entity location information of the entity pair is obtained based on the first entity location information and the second entity location information.
The spliced text is a text obtained by splicing the first text and the second text end to end. The first text may be spliced with the second text as a header and the second text as a trailer, or the second text may be spliced with the first text as a trailer. The first entity refers to an entity corresponding to a first text in the entity pair, and the second entity refers to an entity corresponding to a second text in the entity pair. The first entity location information refers to the location of the first entity in the spliced text. The second entity location information refers to the location of the second entity in the spliced text.
Specifically, the server determines entity pairs with entity relation information from the first text and the second text, and splices the first text and the second text to obtain spliced texts. And then the server acquires the first entity position information of the first entity in the spliced text in the entity pair according to the character sequence in the spliced text. The position of the corresponding character of the initial character in the spliced text in the first entity can be obtained to obtain the position information of the first entity, the position of the corresponding character of the termination character in the spliced text in the first entity can be obtained to obtain the position information of the first entity, and the position of the corresponding character of the first entity in the spliced text can be obtained to obtain the position information of the first entity. And then the server acquires second entity position information of a second entity in the spliced text in the entity pair according to the character sequence in the spliced text, wherein the position of a start character in the second entity corresponding to the character in the spliced text can be acquired to obtain the second entity position information, the position of a stop character in the second entity corresponding to the character in the spliced text can be acquired to obtain the second entity position information, and the position of the second entity corresponding to the spliced text can be acquired to obtain the second entity position information. The server takes the first entity position information and the second entity position information as entity position information of the entity pair. In one embodiment, the first entity location information includes location information of each character in the spliced text and location information of the first entity in the spliced text. The second entity position information comprises position information of each character in the spliced text and position information of the second entity in the spliced text.
In the above embodiment, the first entity position information and the second entity position information are determined according to the character sequence in the spliced text, so that the accuracy of the obtained entity position information is improved.
In one embodiment, as shown in fig. 3, step 206, performing context fusion semantic representation extraction on the first text, the second text, the entity relationship information, and the entity location information to obtain a first text semantic representation and a second text semantic representation, including:
step 302, vectorizing the first text, the second text, the entity relationship information and the entity position information to obtain a first text vector, a second text vector, an entity relationship vector and an entity position vector.
Specifically, the server divides the first text to obtain each character, and vectorizes each character by using a vectorization algorithm to obtain a first text vector. The server divides the second text at the same time to obtain each character, and vectorizes each character by using a vectorization algorithm to obtain a second text vector. And the server simultaneously uses a vectorization algorithm to vectorize the entity relation information and the entity position information to obtain an entity relation vector and an entity position vector. The vectorization algorithm may be a bag of words model, word2vec technique, neural network model, or the like.
And 304, splicing the first text vector, the second text vector and the entity relation vector to obtain a relation splicing vector, and calculating the sum of the relation splicing vector and the entity position vector to obtain a vector to be extracted.
Specifically, the server performs head-to-tail splicing on the first text vector, the second text vector and the entity relation vector to obtain a spliced vector comprising the entity relation vector, namely a relation spliced vector, wherein the entity relation vector is spliced as a tail part or a head part. And then adding the relation splicing vector of the server and the entity position vector to obtain a vector to be extracted.
And 306, carrying out context fusion semantic representation extraction based on the vector to be extracted to obtain a target semantic representation corresponding to the vector to be extracted.
The target semantic representation is a semantic representation corresponding to a vector to be extracted, the target semantic representation comprises semantic representations corresponding to all characters, each character comprises a character corresponding to a first text, a character corresponding to a second text and a character corresponding to entity relation information, namely the target semantic representation comprises semantic representations corresponding to the first text, semantic representations corresponding to the second text and semantic representations corresponding to the entity relation information.
Specifically, the server performs context fusion semantic representation extraction on the vector to be extracted, and a deep neural network can be used for performing context fusion semantic representation extraction to obtain a target semantic representation corresponding to the vector to be extracted. The server can divide the vector to be extracted according to the vector corresponding to the character, and respectively perform context fusion semantic annotation extraction on each character vector to obtain semantic representation corresponding to each character vector, namely obtain the target semantic representation.
Step 308, determining a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the target semantic representations.
Specifically, the server determines a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the target semantic representations according to the position information of the characters in the spliced text.
In the above embodiment, the first text vector, the second text vector and the entity relation vector are obtained through vectorization, then the first text vector, the second text vector and the entity relation vector are spliced to obtain the relation splicing vector, the sum of the relation splicing vector and the entity position vector is calculated to obtain the vector to be extracted, and then the vector to be extracted is used for carrying out context fusion semantic representation extraction to obtain the target semantic representation.
In one embodiment, the entity location vector includes a first entity location vector and a second entity location vector;
step 304, calculating the sum of the relation splicing vector and the entity position vector to obtain a vector to be extracted, comprising the steps of:
and calculating the sum of the relation splicing vector, the first entity position vector and the second entity position vector to obtain a vector to be extracted.
The first entity position vector is a vector for representing the position of the first entity, and the first entity position vector can comprise a vector of each character position in the spliced text and a vector corresponding to the initial character position of the first entity in the spliced text. The second entity position vector is a vector for representing the position of the second entity, and the second entity position vector can comprise a vector of each character position in the spliced text and a vector corresponding to the initial character position of the second entity in the spliced text.
Specifically, the server calculates the sum of vectors, namely, vector sum operation is carried out on the relation splicing vector, the first entity position vector and the second entity position vector, and the vector to be extracted is obtained. In a specific embodiment, the vector to be extracted may be calculated using the following formula (1).
V in =V token +V begin_pos +V end_pos Formula (1)
Wherein V is token Refers to a relationship splice vector. V (V) begin_pos Refers to a first entity location vector. V (V) end_pos Refers to a second entity location vector.
In the above embodiment, the vector to be extracted is obtained by summing the calculated relation splicing vector, the first entity position vector and the second entity position vector, so that the vector to be extracted contains the position information of the entity, and the accuracy of the subsequent semantic representation extraction can be improved.
In one embodiment, the vector to be extracted includes a text vector and an entity relationship vector;
as shown in fig. 4, step 306 of extracting the context fusion semantic representation based on the vector to be extracted, to obtain a target semantic representation corresponding to the vector to be extracted, includes:
and 302, carrying out context fusion semantic representation extraction on the text vector based on the text vector and the entity relation vector to obtain a text semantic representation corresponding to the text vector.
The text vector refers to a vector corresponding to the first text and the second text in the vector to be extracted. The entity relation vector refers to a vector corresponding to the entity relation information in the vector to be extracted. The text semantic representation refers to semantic representation obtained by extracting context fusion semantic representation from text vectors.
Specifically, when extracting semantic representation of a text vector, the server needs to fuse the semantic of the text vector and the semantic corresponding to the entity relation vector, so as to obtain the text semantic representation corresponding to the text vector. The server uses the text vector and the entity relation vector to perform context fusion semantic representation extraction on the text vector through a deep neural network algorithm, and obtains the text semantic representation corresponding to the text vector.
Step 302, extracting the context fusion semantic representation of the entity relation vector based on the text vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector.
Step 302, obtaining a target semantic representation corresponding to the vector to be extracted based on the text semantic representation and the relation semantic representation.
The relation semantic representation refers to semantic representation obtained by extracting context fusion semantic representation from entity relation vectors.
Specifically, the server may fuse the text vector and the semantic information of the entity relationship vector when extracting the semantic representation of the entity relationship vector, so as to obtain the relationship semantic representation corresponding to the entity relationship vector. The server uses the text vector and the entity relation vector to extract the context fusion semantic representation of the entity relation vector through a deep neural network algorithm, and the relation semantic representation corresponding to the entity relation vector is obtained. The deep neural network algorithm may be a BERT (general semantic representation model) network, among others. Then, the text semantic representation and the relation semantic representation are used as target semantic representations corresponding to the vectors to be extracted
In the above embodiment, the text vector and the entity relationship vector are used to perform context fusion semantic representation extraction on the text vector, so as to obtain the text semantic representation corresponding to the text vector. And then, extracting the context fusion semantic representation of the entity relation vector by using the text vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector, wherein the extracted text semantic representation can comprise the semantic information of the text and the semantic information of the entity relation, so that the accuracy of the obtained text semantic representation and the relation semantic representation is improved, and the accuracy of the obtained target semantic representation is further improved.
In one embodiment, extracting the context fusion semantic representation of the entity relationship vector based on the text vector and the entity relationship vector to obtain the relationship semantic representation corresponding to the entity relationship vector comprises:
obtaining a preset covering weight corresponding to the entity relation vector, and weighting the text vector by using the preset covering weight to obtain a text weighting vector; and extracting the context fusion semantic representation of the entity relation vector based on the text weighting vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector.
The preset masking weight refers to a preset weight for masking the semantics corresponding to the text vector when the context fusion semantic representation extraction is performed, so that the entity relation vector cannot be fused to the semantics corresponding to the text vector when the context fusion semantic representation extraction is performed. The relation semantic representation refers to semantic representation obtained by semantic representation extraction of entity conceptual vectors.
Specifically, the server may obtain a preset coverage weight corresponding to the entity relationship vector from the database, or may obtain a preset coverage weight uploaded by the terminal. And then weighting the text vector by using a preset covering weight to obtain a text weighting vector. And extracting the context fusion semantic representation of the entity relation vector by using the text weighting vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector. In yet another embodiment, when extracting the context fusion semantic representation of the entity relationship vector, the server weights the semantic of the text vector obtained by extracting the preset masking weight to obtain the semantic of the weighted text vector, and then fuses the semantic of the weighted text vector with the semantic of the entity relationship vector to obtain the relationship semantic representation corresponding to the entity relationship vector.
In a specific embodiment, the following formula may be used to calculate a relational semantic representation corresponding to the entity-relationship vector.
V i,att =α i,1 V 1 +…+α i,n V n Formula (4)
Wherein V refers to a vector to be extracted. V (V) i Refers to entity relationship vector, V j The text vector is referred to, j is taken from 1 to n, n is a positive integer, n is the number of character vectors in the text vector, namely the number of characters in the spliced text, and each text character corresponds to a vector. dot refers to performing a dot product operation. d is a preset parameter. S is S i,j Refers to the similarity of entity relation vector and text vector, alpha i,j Refer to the attention weight of an entity relationship vector relative to a text vector, including the attention weight of all text characters. INF refers to a preset masking weight for masking text characters so that entity relationship vectors are not fused to the semantics of the text vectors, which masking weight can be set to minus infinity. V (V) i,att The text semantic features corresponding to the entity relation vectors are extracted. Then use the V i,att And carrying out semantic fusion on the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector.
In the above embodiment, the text weighting vector is obtained by weighting the text vector by using the preset masking weight; the semantic representation extraction is fused on the context of the entity relation vector based on the text weighting vector and the entity relation vector, so that the relation semantic representation corresponding to the entity relation vector is obtained, the semantic representation extraction of the entity relation can be weakened by semantic information of the text, and the obtained relation semantic representation improves the accuracy.
In one embodiment, as shown in fig. 5, step 208, performing a correlation calculation based on the first text semantic representation and the second text semantic representation to obtain a semantic representation correlation, performing a fusion feature extraction based on the semantic representation correlation to obtain a target fusion feature, including:
step 502, determining a current character semantic representation and each target character semantic representation from the first text semantic representation and the second text semantic representation.
The current character semantic representation refers to a character semantic representation to be subjected to fusion feature extraction at present, and the character semantic representation is a semantic representation corresponding to any one character in the first text semantic representation and the second text semantic representation. The target character semantic representation refers to semantic representations corresponding to characters in the first text semantic representation and the second text semantic representation, each target character semantic representation refers to semantic representations corresponding to all characters in the first text and the second text, and each target character semantic representation comprises a current character semantic representation. The number of semantic representations of each target character is the same as the number of characters in the first text and the second text.
Specifically, the server sequentially selects semantic representations corresponding to each character from the first text semantic representation and the second text semantic representation to obtain the current character semantic representation. And then taking all character semantic representations in the first text semantic representation and the second text semantic representation as the semantic representations of all target characters.
Step 504, performing correlation calculation based on the current character semantic representation and each target character semantic representation to obtain a current character semantic representation correlation, and performing self-attention feature extraction based on the current character semantic representation correlation to obtain a current character fusion feature corresponding to the current character semantic representation.
The semantic representation correlation of the current character is used for representing the correlation between the semantic representation of the current character and the semantic representation of the target character, and the higher the correlation is, the closer the current character is related to the target character. The current character fusion feature is a feature obtained by carrying out knowledge fusion on the current character semantic representation and each target character semantic representation, namely, a feature obtained by carrying out self-attention feature extraction on the current character semantic representation and each target character semantic representation.
Specifically, the server calculates the correlation between the semantic representation of the current character and the semantic representation of each target character to obtain the semantic representation correlation of each current character, and then uses the semantic representation correlation of each current character to extract self-attention features through a self-attention neural network to obtain the fusion features of the current character corresponding to the semantic representation of the current character.
And step 506, traversing each character semantic representation in the first text semantic representation and the second text semantic representation to obtain each character fusion feature, and obtaining the target fusion feature based on each character fusion feature.
Specifically, the server sequentially takes each character semantic representation in the first text semantic representation and the second text semantic representation as the current character semantic representation, and respectively extracts self-attention features to obtain each character fusion feature. And taking the fusion characteristics of the characters as target fusion characteristics finally extracted.
In the embodiment, the current character fusion feature corresponding to the current character semantic representation is obtained by performing correlation calculation on the current character semantic representation and each target character semantic representation and then performing self-attention feature extraction, so that the obtained current character fusion feature fuses knowledge in a text, the accuracy of the current character fusion feature is improved, and the accuracy of the obtained target fusion feature is further improved.
In one embodiment, as shown in fig. 6, step 504, performing correlation calculation based on the current character semantic representation and each target character semantic representation to obtain a current character semantic representation correlation, and performing self-attention feature extraction based on the current character semantic representation correlation to obtain a current character fusion feature corresponding to the current character semantic representation, including:
Step 602, calculating the correlation between the semantic representation of the current character and the semantic representation of each target character to obtain the correlation of each target character, and performing weight calculation based on the correlation of each target character to obtain the weight of each target character.
The target character correlation refers to the correlation between the semantic representation of the current character and the semantic representation of the target character, different characters have different correlations with the current character, and the current character also has correlation with the current character. The target character weight is used to characterize the proportion of the relevance of the target character to the sum of the relevance of all characters.
Specifically, the server may calculate, using a similarity algorithm, correlations between the semantic representations of the current character and the semantic representations of the respective target characters, to obtain correlations of the respective target characters. The similarity algorithm may be a dot product operation, a distance similarity, or the like. And then sequentially comparing the proportion of each target character correlation to the sum of all character correlations to obtain the weight of each target character.
In a specific embodiment, the target character correlation may be calculated using equation (5) as shown below.
Wherein F is i Refers to the semantic representation of the current character, F j Refers to the semantic representation of the jth target character. H i,j The correlation between the semantic representation of the current character and the semantic representation of the jth target character is calculated.
Step 604, weighting each target character semantic representation in the first text semantic representation and the second text semantic representation based on each target character weight to obtain each target character weighted semantic representation, and calculating the sum of each target character weighted semantic representation to obtain a target character fusion representation.
The target character weighted semantic representation is obtained by weighting the semantic representation corresponding to the target character by using the target character weight. The target character refers to any character in the first text and the second text. The target character fusion characterization refers to the characterization of the semantics related to the current character semantic characterization in the first text and the second text obtained through extraction.
Specifically, weighting each target character semantic representation in the first text semantic representation and the second text semantic representation based on each target character weight to obtain each target character weighted semantic representation, and calculating the sum of each target character weighted semantic representation to obtain a target character fusion representation.
In one particular embodiment, the target character fusion token may be calculated using equation (6) as shown below.
F i,att =β i,1 F 1 +…+β i,n F n Formula (6)
Wherein F is 1 Refers to the first target character semantic representation. F (F) n Refers to the semantic representation of the nth target character. F (F) i,att Refers to a fusion characterization of target characters. Beta i,1 Refers to the target character weight calculated using the current character and the first target character. Beta i,n The target character weight obtained by calculating the semantic representation of the current character and the semantic representation of the nth target character is used.
Step 606, extracting residual features based on the target character fusion representation and the current character semantic representation to obtain residual features, and performing full-connection operation based on the residual features to obtain the current character fusion features corresponding to the current character semantic representation.
The residual characteristics refer to characteristics extracted through a residual network.
Specifically, the server extracts residual features from the target character fusion representation and the current character semantic representation through a residual network to obtain residual features, and then carries out full-connection operation on the residual features through a full-connection neural network to obtain the current character fusion features corresponding to the current character semantic representation, wherein the residual network and the full-connection neural network are trained neural networks in advance.
In a specific embodiment, the server may calculate the residual signature using equation (7) as shown below.
F i '=layer_norm(F i +F i,att ) Formula (7)
Wherein F is i ' refers to the residual feature. layer_norm refers to performing a layer normalization operation.
In a specific embodiment, the server may calculate the current character fusion feature using equation (8) as shown below.
F repre =relu(W1*F i ' +b1) formula (8)
Wherein F is repre Refers to the current character fusion feature. relu refers to an activation function. W1 and b1 are weight parameters and bias parameters of the fully connected network, are obtained through training, and are parameters used when fully connected operation is carried out on residual characteristics.
In the above embodiment, the target character fusion characterization is obtained by calculating the weights of the target characters and then weighting and calculating the semantic characterizations of the target characters by using the weights of the target characters, so that the accuracy of the obtained target character fusion characterization is improved, and then the residual feature and the full-connection operation are performed by using the target character fusion characterization and the semantic characterizations of the current character, so that the current character fusion feature is obtained, so that the accuracy of the current character fusion feature is improved.
In one embodiment, as shown in fig. 7, step 602, performing weight calculation based on the relevance of each target character to obtain the weight of each target character, includes:
step 702, determining the entity character correlation and the non-entity character correlation of the entity pair from the target character correlations, and obtaining the relationship weight corresponding to the entity character correlation.
The entity character correlation refers to the character correlation when the target character is the character corresponding to the entity in the entity pair. Non-entity character relevance refers to character relevance when the target character is not the character corresponding to the entity in the entity pair. The relation weight refers to a preset weight for weighting the relevance of the entity characters, and the relation weight can be obtained through training.
Specifically, the server determines an entity character relevance and a non-entity character relevance from the respective target character relevance according to the position of the entity in the text in the entity pair. And then the server acquires the relation weight corresponding to the entity character correlation from the database.
And step 704, performing sum calculation based on the correlation of each target character to obtain a correlation sum, and calculating the ratio of the correlation of the non-entity character to the correlation sum to obtain the non-entity character weight.
Wherein the correlation sum is the sum of all target character correlations. The non-entity character weight is used to characterize the specific gravity of the non-entity character relevance to the sum of all target character relevance.
Specifically, the server adds the correlations of the respective target characters to obtain a correlation sum. And then comparing the correlation of the non-entity character with the correlation sum to obtain the weight of the non-entity character.
Step 706, calculating the sum of the correlation and the relation weight of the entity character to obtain the weighted correlation of the entity character, calculating the ratio of the weighted correlation and the sum of the correlation of the entity character to obtain the weight of the entity character, and obtaining each target character weight based on the weight of the non-entity character and the weight of the entity character.
Wherein, the weighted relevance of the entity characters refers to the relevance of the entity characters weighted by the relation weight. The entity character weight is used to characterize the weight of the entity character relevance to the sum of all target character relevance.
Specifically, the server adds the entity character correlation and the relation weight to obtain an entity character weighted correlation, and the server can calculate the product of the entity character correlation and the relation weight to obtain the entity character weighted correlation. And then comparing the weighted relevance of the entity characters with the relevance sum to obtain the weight of the entity characters. And the server calculates the character weight corresponding to each character in the first text and the second text, so as to obtain the weight of each target character.
In a specific embodiment, the entity character weight may be calculated using equation (9) as shown below.
Wherein beta is i,j The method is characterized in that the weight of the jth target character obtained by calculating through semantic representation of the current character is calculated, wherein the jth target character is a character corresponding to an entity in the entity pair. The entity corresponding to the current character and the entity corresponding to the jth target character are entity pairs with entity relations. W (W) relation Refers to the relationship weights. H i,j Refers to the correlation of the jth target character calculated by using the semantic representation of the current character.
In the above embodiment, the accuracy of the obtained entity character weights is improved by obtaining the relation weights and then calculating the entity character weights using the relation weights.
In one embodiment, step 210, performing a matching degree calculation based on the target fusion feature to obtain a matching degree corresponding to the first text and the second text, includes the steps of:
performing full-connection operation on the target fusion characteristics to obtain full-connection characteristics; and carrying out normalization operation on the full-connection features to obtain the matching degree corresponding to the first text and the second text.
The full connection feature is obtained by performing full connection operation on the target fusion feature.
Specifically, the server performs full-connection operation on the target fusion feature by using full-connection parameters, so as to obtain the full-connection feature, wherein the full-connection parameters can be obtained through pre-training and can be parameters in a full-connection neural network, and the full-connection neural network can be a dense network. And then the server performs normalization operation on the full-connection characteristics to obtain the matching degree corresponding to the first text and the second text.
In a specific embodiment, the server may calculate the full connection feature using equation (10) as shown below, and then calculate the matching degree corresponding to the first text and the second text using equation (11) as shown below.
Logits=W2*V repre +b2 equation (10)
Probs= softmax (Logits) formula (11)
Where Logits refers to full connection features. W2 and b2 refer to weight parameters and bias parameters in the fully connected network, are pre-trained, and are parameters used when fully connected operation is performed on the target fusion characteristics. Softmax is a normalization function. Probs refers to the matching degree of the first text and the second text, and the matching degree is expressed by probability.
In the above embodiment, the full connection feature is obtained by performing the full connection operation on the target fusion feature; and then carrying out normalization operation on the full-connection features to obtain the matching degree corresponding to the first text and the second text, thereby improving the accuracy of the obtained matching degree.
In one embodiment, as shown in fig. 8, the text matching method further includes:
step 802, inputting the first text, the second text, the entity relationship information and the entity location information into a target text matching model.
The target text matching model refers to a pre-trained deep neural network model for text matching, and the deep neural network can be a convolutional neural network, a cyclic neural network, a time sequence neural network and the like.
Specifically, the server may directly splice the first text, the second text and the entity relation information to obtain a spliced text, then divide the spliced text into characters to obtain each character, determine the position information of each character according to the entity position information, vectorize each character to obtain each character vector, vectorize the position information of each character to obtain each position vector, add each character vector to the corresponding position vector to obtain each target character vector, input each target character vector as a target text matching model, and perform text matching through the target matching model.
And step 802, performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information through a target text matching model to obtain a first text semantic representation and a second text semantic representation.
And step 804, performing correlation calculation based on the first text semantic representation and the second text semantic representation through the target text matching model to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features.
And step 806, calculating the matching degree based on the target fusion characteristic through the target text matching model to obtain the matching degree corresponding to the first text and the second text.
Specifically, the server uses the target text matching model to perform context fusion semantic representation extraction on each input target character vector, and each character semantic representation corresponding to the first text and each character semantic representation corresponding to the second text are obtained. And then, extracting self-attention features by using each character semantic representation corresponding to the first text and each character semantic representation corresponding to the second text to obtain target fusion features, and then, calculating matching probability by using the target fusion features to obtain the matching probability corresponding to the first text and the second text.
In the above embodiment, the efficiency and accuracy of obtaining the matching degree can be improved by inputting the first text, the second text, the entity relationship information and the entity position information into the target text matching model, and then obtaining the matching degree corresponding to the first text and the second text through calculation of the target text matching model.
In one embodiment, the text matching model includes a context fusion semantic representation network, a fusion feature extraction network, and a matching network;
Step 802, inputting the first text, the second text, the entity relationship information, and the entity location information into a target text matching model, including:
inputting the first text, the second text, the entity relation information and the entity position information into a context fusion semantic representation network to perform context fusion semantic representation extraction, so as to obtain a first text semantic representation and a second text semantic representation; inputting the first text semantic representation and the second text semantic representation into a fusion feature extraction network to perform correlation calculation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features; and inputting the target fusion characteristics into a matching network to perform matching degree calculation, and obtaining the matching degree corresponding to the first text and the second text.
The context fusion semantic representation network is a neural network for extracting context fusion semantic representations, and the neural network architecture can be a network architecture of a BERT model. The fusion feature extraction network is a neural network that performs knowledge fusion, and the neural network architecture may be a network architecture of a self-attention network. The matching network is a neural network for performing matching calculation, and the neural network architecture may be a classified neural network architecture for performing two classifications.
The server performs context fusion semantic representation extraction by using a context fusion semantic representation network, performs self-attention feature extraction by using a fusion feature extraction network, namely performs knowledge fusion, and then performs matching degree calculation by using a matching network to obtain the matching degree corresponding to the first text and the second text.
In a specific embodiment, as shown in fig. 9, an architectural diagram of a target text matching model is provided, specifically: the server obtains the first text "which peak of the world is the highest" and the second text "which peak of country a is the highest". And splicing the highest mountain of the world with the highest mountain of the world A of the second text to obtain a spliced text [ CLS ] which mountain of the world A of the world highest is the highest [ SEP ] ", wherein the entity position information is determined according to the sequence of the initial characters of the entities corresponding to the entity relation text in the spliced text, the obtained first entity position information can be '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1', the obtained second entity position information can be '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,11', wherein the last 1 is used for representing the initial character position of the first text entity in the entity pair with the entity relation, and the last 11 is used for representing the initial character position of the second text entity in the entity pair with the entity relation. Then converting the spliced text and entity position information into vectors, then calculating by using a formula (1) to obtain vectors to be extracted, inputting the vectors to be extracted into a target text matching model, extracting context fusion semantic representation by a context fusion semantic representation network (BERT) in the target text matching model, extracting self-attention features by using a fusion feature extraction network (self-attention network of knowledge fusion), namely carrying out knowledge fusion, and then calculating the matching degree by using a matching network (dense network and softmax normalization function) to obtain the matching degree corresponding to the first text and the second text.
In the above embodiment, text matching is performed by using the context fusion semantic representation network, the fusion feature extraction network and the matching network, so as to obtain the matching degree corresponding to the first text and the second text, and improve the accuracy of text matching.
In one embodiment, as shown in FIG. 10, training of the target text matching model includes the steps of:
step 1002, a training sample and a training matching tag are obtained, the training sample including a first training text and a second training text.
The first training text refers to a first text used in training. The second training text refers to a second text used in training. The training matching label is used for representing whether the first training text and the second training text are matched or not, and the bag is matched with the label and the unmatched label.
Specifically, the server may obtain training samples and training matching tags from a database. The server may also obtain the first training text and the second training text and the training matching tag from a service party providing the data service. The server can also acquire training samples and training matching labels uploaded by the terminal.
Step 1004, obtaining training entity relationship information of the entities in the first training text and the second training text, determining training entity pairs with the training entity relationship information from the first training text and the second training text, and determining training entity position information of the training entity pairs based on the first training text and the second training text.
The training entity pair refers to an entity pair determined from the first training text and the second training text during training. Training entity relationship information refers to training entity pair corresponding entity relationship information. The training entity position information refers to entity position information of an entity in the training entity pair in the first training text and the second training text.
Specifically, the server determines a training entity pair with training entity relation information from the first training text and the second training text, and then acquires the training entity relation information and determines training entity position information.
Step 1006, inputting the first training text, the second training text, the training entity relation information and the training entity position information into an initial text matching model, performing context fusion semantic representation extraction on the first training text, the second training text, the training entity relation information and the training entity position information through the initial text matching model to obtain a first training text semantic representation and a second training text semantic representation, performing correlation calculation based on the first training text semantic representation and the second training text semantic representation to obtain training semantic representation correlation, performing fusion feature extraction based on the training semantic representation correlation to obtain training fusion features, and performing matching degree calculation based on the training fusion features to obtain training matching degrees corresponding to the first training text and the second training text.
The initial text matching model refers to a text matching model initialized by model parameters. The first training text semantic representation and the second training text semantic representation refer to semantic representations extracted during training. Training semantic representation correlation refers to semantic representation correlation extracted during training. The training fusion feature refers to a target fusion feature extracted during training. The training matching degree is the matching degree of the first training text and the second training text, which are calculated by using the initial text matching model.
Specifically, the server inputs the first training text, the second training text, training entity relation information and training entity position information into an initial text matching model, and matches the first training text and the second training text through the initial text matching model to obtain the matching degree corresponding to the first training text and the second training text, wherein the matching can be performed by using any embodiment of the text matching method when the matching is performed, and the parameters used in the matching are parameters of the initial text matching model.
And step 1008, performing loss calculation based on the training matching label and the training matching degree to obtain model loss information, reversely updating the initial text matching model based on the model loss information, and returning to the iterative execution of the step of obtaining the training sample and the training matching label until the training completion condition is reached to obtain the target text matching model.
The model loss information is used for representing errors between training matching labels and training matching degrees.
Specifically, the server calculates an error between the training matching label and the training matching degree by using the loss function, and model loss information is obtained. The loss function may be a classification loss function, for example, a cross entropy loss function, a logarithmic loss function, and so on. The server then determines whether the training has reached a training completion condition including, but not limited to, the training loss reaching a preset threshold, the model parameters no longer changing, and the iteration reaching a maximum number of iterations, etc. When the training completion condition is not reached, the server reversely updates the initial text matching model by using the model loss information to obtain an updated initial text matching model, takes the updated initial text matching model as the initial text matching model, returns the step of taking the training sample and the training matching label to be executed in an iterative manner, and takes the initial text matching model reaching the training completion condition as the final training to obtain the target text matching model when the training completion condition is reached.
In the above embodiment, the training sample and the training matching label are obtained, and then the training sample is used to determine the training entity relationship information and the training entity position information, and the training sample, the training entity relationship information and the training entity position information are used to train the initial text matching model, and when the training is completed, the target text matching model is obtained, so that the accuracy of text matching can be adjusted by the target text matching model obtained by training. The target text matching model can be deployed and used, so that the text matching efficiency can be improved.
In one embodiment, the first text comprises query text and the second text comprises standard question text;
after step 210, that is, after the matching degree calculation is performed based on the target fusion feature, the matching degree corresponding to the first text and the second text is obtained, the method further includes the steps of:
when the matching degree exceeds a preset matching threshold, obtaining a standard answer corresponding to the standard question text; and taking the standard answer as a reply text corresponding to the query text, returning the reply text to the sending end of the query text, and displaying the reply text through the sending end.
The preset matching threshold is a threshold of preset matching degree, and when the matching degree does not exceed the preset matching threshold, the text is not matched, namely the semantics are inconsistent. The query text refers to text used for making a query, and may be a question. The standard question text is a preset text for making a query. The standard answer is a preset answer corresponding to the standard question text.
Specifically, when the server obtains the query text from the sending end, the query text and each standard question text can be matched to obtain the matching degree of the query text and each standard question text, then each matching degree is compared with a preset matching threshold, and when the matching degree exceeds the preset matching threshold, the semantic consistency of the query text and the standard question text is indicated. At this time, the server may directly obtain, from the database, a standard answer corresponding to a standard question text whose matching degree exceeds a preset matching threshold. And then taking the standard answer as a reply text corresponding to the query text, returning the reply text to the sender of the query text, and displaying the reply text through the sender.
In the embodiment, the query text is matched with the standard question text, when the matching degree exceeds the preset matching threshold, the standard answer corresponding to the standard question text is used as the reply text corresponding to the query text, so that the accuracy and the efficiency of obtaining the reply text can be improved, the reply text is returned to the sending end of the query text, the reply text is displayed through the sending end, the accuracy of the reply text can be improved, and the use experience is improved.
In a specific embodiment, as shown in fig. 11, a text matching method is provided, which is executed by a computer device, and specifically includes the following steps;
step 1102, acquiring a first text and a second text, and acquiring entity relation information between an entity in the first text and an entity in the second text;
step 1104, determining entity pairs with entity relation information from the first text and the second text, and splicing the first text and the second text to obtain spliced texts; determining first entity position information of a first entity in the spliced text in the entity pair according to the character sequence in the spliced text; and determining second entity position information of a second entity in the spliced text in the entity pair according to the character sequence in the spliced text.
Step 1106, vectorizing the first text, the second text, the entity relationship information, the first entity position information and the second entity position information, respectively, to obtain a first text vector, a second text vector, an entity relationship vector, a first entity position vector and a second entity position vector;
and step 1108, stitching the first text vector, the second text vector and the entity relation vector to obtain a relation stitching vector, and calculating the sum of the relation stitching vector, the first entity position vector and the second entity position vector to obtain a vector to be extracted.
Step 1110, inputting the vector to be extracted into a target text matching model, extracting context fusion semantic representation of the vector to be extracted through a context fusion semantic representation network in the target text matching model to obtain a target semantic representation corresponding to the vector to be extracted, and determining a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the target semantic representation.
Step 1112, performing correlation calculation on the first text semantic representation and the second text semantic representation through the target text matching model to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
And step 1114, calculating the matching degree of the target fusion feature through the target text matching model to obtain the matching degree corresponding to the first text and the second text.
In the above embodiment, the vector to be extracted is obtained by calculating the sum of the relation splicing vector, the first entity position vector and the second entity position vector, so that the vector to be extracted contains entity relation information, that is, knowledge fusion is performed before text matching is performed on the target text matching model, then text matching is performed on the target text matching model by using the vector to be extracted, and the matching degree corresponding to the first text and the second text is obtained, thereby improving the accuracy of the obtained matching degree.
In a specific embodiment, the text matching method is applied to an information recommendation platform, specifically: when the information recommendation platform receives the information recommendation request sent again by the user, the information recommendation platform server obtains the information theme text to be recommended according to the information recommendation request, simultaneously acquiring a recommended information subject text, splicing the information subject text to be recommended and the recommended information subject text to obtain a spliced subject text, and then determining the included entity relationship from the information subject text to be recommended and the recommended information subject text, simultaneously recording the position information of two entities with entity relationship in the spliced topic text, then splicing the spliced subject text and each entity relation to obtain a final spliced text, then vectorizing the spliced text and the position information to obtain a spliced text vector and two entity position vectors, then calculating the sum of the spliced text vector and the two entity position vectors to obtain a model input vector, then the model input vector is input into a deployed target text matching model to carry out text matching, so as to obtain the matching degree of the output information subject text to be recommended and the recommended information subject text, when the matching degree does not exceed the preset threshold, the information corresponding to the information subject text to be recommended can be recommended to the terminal of the user, when the matching degree exceeds a preset threshold value, the information subject text to be recommended is repeatedly shown with the information which is already recommended, at the moment, the information to be recommended is not required to be recommended any more, thereby avoiding the duplication of recommended information, saving the resources of an information recommendation platform, improving the experience of users, the information recommendation platform may be a video recommendation platform, a news recommendation platform, an image recommendation platform, a live broadcast platform, and the like.
In a specific embodiment, the text matching method is applied to an intelligent question-answering platform, specifically: the intelligent question-answering platform receives an inquiry statement that a bank card drops the unique loss sent by a user, and the intelligent question-answering platform server acquires all standard questions to be matched according to the information inquiry statement. The server carries out text matching on the query sentences and the standard problems respectively to obtain the matching degree of the query sentences and the standard problems respectively, then selects the standard problem with the largest matching degree, for example, the standard problem that how the bank card is lost has the largest matching degree obtained by calculation of the query sentences, obtains the reply sentences corresponding to the standard problem that how the bank card is lost with the largest matching degree, returns the reply sentences to the terminal of the user for display, and therefore the accuracy of the obtained reply sentences can be improved.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a text matching device for realizing the above related text matching method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the text matching device provided below may refer to the limitation of the text matching method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 12, there is provided a text matching apparatus 1200 comprising: an acquisition module 1202, a location determination module 1204, a semantic representation module 1206, a fusion module 1208, and a matching module 1210, wherein:
an obtaining module 1202, configured to obtain a first text and a second text, and obtain entity relationship information between an entity in the first text and an entity in the second text;
a location determining module 1204, configured to determine an entity pair in which entity relationship information exists from the first text and the second text, and determine entity location information of the entity pair based on the first text and the second text;
the semantic representation module 1206 is configured to perform context fusion semantic representation extraction on the first text, the second text, the entity relationship information and the entity location information, so as to obtain a first text semantic representation and a second text semantic representation;
The fusion module 1208 is configured to perform correlation computation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and perform fusion feature extraction based on the semantic representation correlation to obtain a target fusion feature;
and the matching module 1210 is configured to perform matching degree calculation based on the target fusion feature, so as to obtain matching degrees corresponding to the first text and the second text.
In one embodiment, the location determining module 1204 is further configured to determine an entity pair having entity relationship information from the first text and the second text, and splice the first text and the second text to obtain a spliced text; determining first entity position information of a first entity in the spliced text in the entity pair according to the character sequence in the spliced text; determining second entity position information of a second entity in the spliced text in the entity pair according to the character sequence in the spliced text; entity location information of the entity pair is obtained based on the first entity location information and the second entity location information.
In one embodiment, the semantic characterization module 1206 includes:
the vectorization unit is used for vectorizing the first text, the second text, the entity relation information and the entity position information respectively to obtain a first text vector, a second text vector, an entity relation vector and an entity position vector;
The vector calculation unit is used for splicing the first text vector, the second text vector and the entity relation vector to obtain a relation splicing vector, and calculating the sum of the relation splicing vector and the entity position vector to obtain a vector to be extracted;
the representation extraction unit is used for carrying out context fusion semantic representation extraction based on the vector to be extracted to obtain a target semantic representation corresponding to the vector to be extracted;
the representation determining unit is used for determining a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the target semantic representations.
In one embodiment, the entity location vector includes a first entity location vector and a second entity location vector; the vector calculation unit is further configured to calculate a sum of the relation stitching vector, the first entity position vector, and the second entity position vector, to obtain a vector to be extracted.
In one embodiment, the vector to be extracted includes a text vector and an entity relationship vector; the representation extraction unit is also used for carrying out context fusion semantic representation extraction on the text vector based on the text vector and the entity relation vector to obtain a text semantic representation corresponding to the text vector; extracting the context fusion semantic representation of the entity relation vector based on the text vector and the entity relation vector to obtain a relation semantic representation corresponding to the entity relation vector; and obtaining a target semantic representation corresponding to the vector to be extracted based on the text semantic representation and the relation semantic representation.
In one embodiment, the token extraction unit is further configured to obtain a preset coverage weight corresponding to the entity relationship vector, and weight the text vector by using the preset coverage weight to obtain a text weighted vector; and extracting the context fusion semantic representation of the entity relation vector based on the text weighting vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector.
In one embodiment, the fusion module 1208 is further configured to determine a current character semantic representation and respective target character semantic representations from the first text semantic representation and the second text semantic representation; performing correlation calculation based on the current character semantic representation and each target character semantic representation to obtain a current character semantic representation correlation, and performing self-attention feature extraction based on the current character semantic representation correlation to obtain a current character fusion feature corresponding to the current character semantic representation; traversing each character semantic representation in the first text semantic representation and the second text semantic representation to obtain each character fusion feature, and obtaining the target fusion feature based on each character fusion feature.
In one embodiment, the fusion module 1208 is further configured to calculate correlations between the semantic representation of the current character and the semantic representation of each target character, obtain correlations of each target character, and perform weight calculation based on the correlations of each target character, so as to obtain weights of each target character; weighting each target character semantic representation in the first text semantic representation and the second text semantic representation based on each target character weight to obtain each target character weighted semantic representation, and calculating the sum of each target character weighted semantic representation to obtain a target character fusion representation; and carrying out residual feature extraction based on the target character fusion representation and the current character semantic representation to obtain residual features, and carrying out full-connection operation based on the residual features to obtain the current character fusion features corresponding to the current character semantic representation.
In one embodiment, the fusion module 1208 is further configured to determine an entity character relevance and a non-entity character relevance of the entity pair from each target character relevance, and obtain a relationship weight corresponding to the entity character relevance; performing sum calculation based on the correlation of each target character to obtain a correlation sum, and calculating the ratio of the correlation of the non-entity character to the correlation sum to obtain the weight of the non-entity character; calculating the sum of the entity character correlation and the relation weight to obtain an entity character weighted correlation, calculating the ratio of the entity character weighted correlation to the correlation sum to obtain an entity character weight, and obtaining each target character weight based on the non-entity character weight and the entity character weight.
In one embodiment, the matching module 1210 is further configured to perform a full-connection operation on the target fusion feature to obtain a full-connection feature; and carrying out normalization operation on the full-connection features to obtain the matching degree corresponding to the first text and the second text.
In one embodiment, the text matching apparatus 1200 further includes:
the model matching module is used for inputting the first text, the second text, the entity relation information and the entity position information into the target text matching model; performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information through a target text matching model to obtain a first text semantic representation and a second text semantic representation; performing correlation calculation based on the first text semantic representation and the second text semantic representation through a target text matching model to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features; and calculating the matching degree based on the target fusion characteristic through the target text matching model to obtain the matching degree corresponding to the first text and the second text.
In one embodiment, the text matching model includes a context fusion semantic representation network, a fusion feature extraction network, and a matching network;
the model matching module is also used for inputting the first text, the second text, the entity relation information and the entity position information into a context fusion semantic representation network to perform context fusion semantic representation extraction, so as to obtain a first text semantic representation and a second text semantic representation; inputting the first text semantic representation and the second text semantic representation into a fusion feature extraction network to perform correlation calculation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features; and inputting the target fusion characteristics into a matching network to perform matching degree calculation, and obtaining the matching degree corresponding to the first text and the second text.
In one embodiment, the text matching apparatus 1200 further includes:
the model training module is used for acquiring training samples and training matching labels, wherein the training samples comprise a first training text and a second training text; acquiring training entity relation information of entities in a first training text and entities in a second training text, determining training entity pairs with the training entity relation information from the first training text and the second training text, and determining training entity position information of the training entity pairs based on the first training text and the second training text; inputting the first training text, the second training text, the training entity relation information and the training entity position information into an initial text matching model, carrying out context fusion semantic representation extraction on the first training text, the second training text, the training entity relation information and the training entity position information through the initial text matching model to obtain a first training text semantic representation and a second training text semantic representation, carrying out correlation calculation based on the first training text semantic representation and the second training text semantic representation to obtain training semantic representation correlation, carrying out fusion feature extraction based on the training semantic representation correlation to obtain training fusion features, and carrying out matching degree calculation based on the training fusion features to obtain training matching degree corresponding to the first training text and the second training text; and carrying out loss calculation based on the training matching label and the training matching degree to obtain model loss information, reversely updating an initial text matching model based on the model loss information, and returning to the step of obtaining a training sample and the training matching label for iterative execution until reaching the training completion condition to obtain a target text matching model.
In one embodiment, the first text comprises query text and the second text comprises standard question text; the text matching apparatus 1200 further includes:
the reply module is used for acquiring a standard answer corresponding to the standard question text when the matching degree exceeds a preset matching threshold; and taking the standard answer as a reply text corresponding to the query text, returning the reply text to the sending end of the query text, and displaying the reply text through the sending end.
The respective modules in the above text matching device may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 13. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing first text, second text, entity relationship data, and the like. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a text matching method.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure thereof may be as shown in fig. 14. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a XXX method. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structures shown in fig. 13 and 14 are merely block diagrams of portions of structures associated with aspects of the present application and are not intended to limit the computer device to which aspects of the present application may be applied, and that a particular computer device may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region. The user may reject or may conveniently reject the advertisement push information, etc.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (18)

1. A method of text matching, the method comprising:
acquiring a first text and a second text, and acquiring entity relationship information between an entity in the first text and an entity in the second text;
determining an entity pair in which the entity relationship information exists from the first text and the second text, and determining entity position information of the entity pair based on the first text and the second text;
Performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
performing correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and calculating the matching degree based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
2. The method of claim 1, wherein the determining the entity pair for which the entity relationship information exists from the first text and the second text, and determining the entity location information of the entity pair based on the first text and the second text, comprises:
determining entity pairs with the entity relation information from the first text and the second text, and splicing the first text and the second text to obtain spliced texts;
determining first entity position information of a first entity in the spliced text in the entity pair according to the character sequence in the spliced text;
Determining second entity position information of a second entity in the spliced text in the entity pair according to the character sequence in the spliced text;
and obtaining the entity position information of the entity pair based on the first entity position information and the second entity position information.
3. The method of claim 1, wherein performing context fusion semantic representation extraction on the first text, the second text, the entity relationship information, and the entity location information to obtain a first text semantic representation and a second text semantic representation comprises:
vectorizing the first text, the second text, the entity relation information and the entity position information respectively to obtain a first text vector, a second text vector, an entity relation vector and an entity position vector;
splicing the first text vector, the second text vector and the entity relation vector to obtain a relation splicing vector, and calculating the sum of the relation splicing vector and the entity position vector to obtain a vector to be extracted;
performing context fusion semantic representation extraction based on the vector to be extracted to obtain a target semantic representation corresponding to the vector to be extracted;
And determining a first text semantic representation corresponding to the first text and a second text semantic representation corresponding to the second text from the target semantic representations.
4. A method according to claim 3, wherein the entity location vector comprises a first entity location vector and a second entity location vector;
the calculating the sum of the relation splicing vector and the entity position vector to obtain a vector to be extracted comprises the following steps:
and calculating the sum of the relation splicing vector, the first entity position vector and the second entity position vector to obtain the vector to be extracted.
5. A method according to claim 3, wherein the vectors to be extracted comprise text vectors and entity relationship vectors;
the extracting of the context fusion semantic representation based on the vector to be extracted to obtain a target semantic representation corresponding to the vector to be extracted comprises the following steps:
performing context fusion semantic representation extraction on the text vector based on the text vector and the entity relation vector to obtain a text semantic representation corresponding to the text vector;
extracting the context fusion semantic representation of the entity relation vector based on the text vector and the entity relation vector to obtain a relation semantic representation corresponding to the entity relation vector;
And obtaining a target semantic representation corresponding to the vector to be extracted based on the text semantic representation and the relation semantic representation.
6. The method of claim 3, wherein the extracting the semantic representation of the entity relationship vector based on the text vector and the context fusion of the entity relationship vector to obtain the semantic representation of the relationship corresponding to the entity relationship vector comprises:
acquiring a preset covering weight corresponding to the entity relation vector, and weighting the text vector by using the preset covering weight to obtain a text weighting vector;
and extracting the context fusion semantic representation of the entity relation vector based on the text weighting vector and the entity relation vector to obtain the relation semantic representation corresponding to the entity relation vector.
7. The method of claim 1, wherein the performing a correlation calculation based on the first text semantic representation and the second text semantic representation to obtain a semantic representation correlation, performing a fusion feature extraction based on the semantic representation correlation to obtain a target fusion feature, comprises:
determining a current character semantic representation and each target character semantic representation from the first text semantic representation and the second text semantic representation;
Performing correlation calculation based on the current character semantic representation and each target character semantic representation to obtain a current character semantic representation correlation, and performing self-attention feature extraction based on the current character semantic representation correlation to obtain a current character fusion feature corresponding to the current character semantic representation;
traversing each character semantic representation in the first text semantic representation and the second text semantic representation to obtain each character fusion feature, and obtaining a target fusion feature based on each character fusion feature.
8. The method according to claim 7, wherein the performing correlation calculation based on the current character semantic representation and the target character semantic representations to obtain a current character semantic representation correlation, and performing self-attention feature extraction based on the current character semantic representation correlation to obtain a current character fusion feature corresponding to the current character semantic representation, includes:
calculating the correlation between the semantic representation of the current character and the semantic representation of each target character to obtain the correlation of each target character, and performing weight calculation based on the correlation of each target character to obtain the weight of each target character;
Weighting each target character semantic representation in the first text semantic representation and the second text semantic representation based on each target character weight to obtain each target character weighted semantic representation, and calculating the sum of each target character weighted semantic representation to obtain a target character fusion representation;
and carrying out residual feature extraction based on the target character fusion representation and the current character semantic representation to obtain residual features, and carrying out full-connection operation based on the residual features to obtain current character fusion features corresponding to the current character semantic representation.
9. The method of claim 8, wherein the calculating weights based on the respective target character correlations to obtain respective target character weights comprises:
determining the entity character correlation and the non-entity character correlation of the entity pair from the target character correlations, and acquiring the corresponding relation weight of the entity character correlation;
performing sum calculation based on the correlation of each target character to obtain a correlation sum, and calculating the ratio of the correlation of the non-entity character to the correlation sum to obtain a non-entity character weight;
And calculating the sum of the entity character correlation and the relation weight to obtain an entity character weighted correlation, calculating the ratio of the entity character weighted correlation to the correlation sum to obtain an entity character weight, and obtaining each target character weight based on the non-entity character weight and the entity character weight.
10. The method according to claim 1, wherein the calculating the matching degree based on the target fusion feature to obtain the matching degree corresponding to the first text and the second text includes:
performing full-connection operation on the target fusion characteristics to obtain full-connection characteristics;
and carrying out normalization operation on the full-connection feature to obtain the matching degree corresponding to the first text and the second text.
11. The method according to claim 1, characterized in that the method further comprises:
inputting the first text, the second text, the entity relationship information and the entity position information into a target text matching model;
performing context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information through the target text matching model to obtain a first text semantic representation and a second text semantic representation;
Performing correlation calculation based on the first text semantic representation and the second text semantic representation through the target text matching model to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and calculating the matching degree based on the target fusion characteristic through the target text matching model to obtain the matching degree corresponding to the first text and the second text.
12. The method of claim 11, wherein the text matching model comprises a context fusion semantic representation network, a fusion feature extraction network, and a matching network;
the inputting the first text, the second text, the entity relationship information, and the entity location information into a target text matching model includes:
inputting the first text, the second text, the entity relation information and the entity position information into the context fusion semantic representation network to perform context fusion semantic representation extraction, so as to obtain a first text semantic representation and a second text semantic representation;
inputting the first text semantic representation and the second text semantic representation into the fusion feature extraction network to perform correlation calculation to obtain semantic representation correlation, and performing fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
And inputting the target fusion characteristics into the matching network to perform matching degree calculation, and obtaining the matching degree corresponding to the first text and the second text.
13. The method of claim 1, wherein the training of the target text matching model comprises the steps of:
acquiring a training sample and a training matching label, wherein the training sample comprises a first training text and a second training text;
acquiring training entity relation information of entities in the first training text and the second training text, determining training entity pairs with the training entity relation information from the first training text and the second training text, and determining training entity position information of the training entity pairs based on the first training text and the second training text;
inputting the first training text, the second training text, the training entity relation information and the training entity position information into an initial text matching model, carrying out context fusion semantic representation extraction on the first training text, the second training text, the training entity relation information and the training entity position information through the initial text matching model to obtain a first training text semantic representation and a second training text semantic representation, carrying out correlation calculation on the basis of the first training text semantic representation and the second training text semantic representation to obtain training semantic representation correlation, carrying out fusion feature extraction on the basis of the training semantic representation correlation to obtain training fusion features, carrying out matching degree calculation on the basis of the training fusion features to obtain training matching degrees corresponding to the first training text and the second training text;
And carrying out loss calculation based on the training matching label and the training matching degree to obtain model loss information, reversely updating the initial text matching model based on the model loss information, and returning to the step of obtaining a training sample and the training matching label for iterative execution until the training completion condition is reached to obtain the target text matching model.
14. The method of claim 1, wherein the first text comprises query text and the second text comprises standard question text;
after the matching degree calculation is performed based on the target fusion feature to obtain the matching degree corresponding to the first text and the second text, the method further comprises the following steps:
when the matching degree exceeds a preset matching threshold, obtaining a standard answer corresponding to the standard question text;
and taking the standard answer as a reply text corresponding to the inquiry text, returning the reply text to the sending end of the inquiry text, and displaying the reply text through the sending end.
15. A text matching device, the device comprising:
the acquisition module is used for acquiring a first text and a second text and acquiring entity relationship information between an entity in the first text and an entity in the second text;
A location determining module, configured to determine an entity pair in which the entity relationship information exists from the first text and the second text, and determine entity location information of the entity pair based on the first text and the second text;
the semantic representation module is used for carrying out context fusion semantic representation extraction on the first text, the second text, the entity relation information and the entity position information to obtain a first text semantic representation and a second text semantic representation;
the fusion module is used for carrying out correlation calculation based on the first text semantic representation and the second text semantic representation to obtain semantic representation correlation, and carrying out fusion feature extraction based on the semantic representation correlation to obtain target fusion features;
and the matching module is used for carrying out matching degree calculation based on the target fusion characteristics to obtain the matching degree corresponding to the first text and the second text.
16. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 14 when the computer program is executed.
17. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 14.
18. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any one of claims 1 to 14.
CN202211501064.0A 2022-11-28 2022-11-28 Text matching method, device, computer equipment and storage medium Pending CN116975315A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211501064.0A CN116975315A (en) 2022-11-28 2022-11-28 Text matching method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211501064.0A CN116975315A (en) 2022-11-28 2022-11-28 Text matching method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116975315A true CN116975315A (en) 2023-10-31

Family

ID=88471924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211501064.0A Pending CN116975315A (en) 2022-11-28 2022-11-28 Text matching method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116975315A (en)

Similar Documents

Publication Publication Date Title
US9807473B2 (en) Jointly modeling embedding and translation to bridge video and language
CN112819023B (en) Sample set acquisition method, device, computer equipment and storage medium
CN111061856A (en) Knowledge perception-based news recommendation method
CN113011186B (en) Named entity recognition method, named entity recognition device, named entity recognition equipment and computer readable storage medium
CN113761153B (en) Picture-based question-answering processing method and device, readable medium and electronic equipment
CN111582409A (en) Training method of image label classification network, image label classification method and device
CN114332680A (en) Image processing method, video searching method, image processing device, video searching device, computer equipment and storage medium
CN114298121A (en) Multi-mode-based text generation method, model training method and device
CN116580257A (en) Feature fusion model training and sample retrieval method and device and computer equipment
CN111783903A (en) Text processing method, text model processing method and device and computer equipment
CN114330966A (en) Risk prediction method, device, equipment and readable storage medium
CN116226785A (en) Target object recognition method, multi-mode recognition model training method and device
CN115062134B (en) Knowledge question-answering model training and knowledge question-answering method, device and computer equipment
CN112131345A (en) Text quality identification method, device, equipment and storage medium
CN110969005B (en) Method and device for determining similarity between entity corpora
CN113627550A (en) Image-text emotion analysis method based on multi-mode fusion
CN113761151A (en) Synonym mining method, synonym mining device, synonym question answering method, synonym question answering device, computer equipment and storage medium
CN113536784A (en) Text processing method and device, computer equipment and storage medium
CN110851629A (en) Image retrieval method
CN113723111B (en) Small sample intention recognition method, device, equipment and storage medium
CN115129863A (en) Intention recognition method, device, equipment, storage medium and computer program product
CN114328894A (en) Document processing method, document processing device, electronic equipment and medium
CN116975315A (en) Text matching method, device, computer equipment and storage medium
WO2022141855A1 (en) Text regularization method and apparatus, and electronic device and storage medium
CN115525740A (en) Method and device for generating dialogue response sentence, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40098102

Country of ref document: HK