A method and apparatus for text response

By obtaining the similarity vector and graph embedding vector between the target text and candidate attributes, the problem of inaccurate text responses in existing technologies is solved, achieving more accurate text responses and semantic understanding.

CN117009485BActive Publication Date: 2026-02-17JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310995351.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-08
Publication Date
2026-02-17
Estimated Expiration
2043-08-08

AI Technical Summary

Technical Problem

Existing technologies often produce inaccurate text responses to colloquial questions posed by users, resulting in poor semantic parsing performance.

Method used

By obtaining the similarity vector between the target text and candidate attributes, encoding and weighting are performed, and then combined with graph embedding vectors for concatenation and mapping to generate more accurate response text.

Benefits of technology

It improves the accuracy of text responses, enhances the model's semantic understanding capabilities, and provides richer information representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117009485B_ABST
    Figure CN117009485B_ABST
Patent Text Reader

Abstract

The application discloses a text response method and device, and relates to the technical field of computers. A specific embodiment of the text response method comprises the following steps: in response to receiving a target text, obtaining a candidate attribute corresponding to the target text, and determining a similarity vector corresponding to the target text and the candidate attribute; encoding the target text and the candidate attribute to obtain a semantic vector, weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector; constructing a graph for the candidate attribute to obtain a graph embedding vector; splicing the similarity vector, the weighted semantic vector and the graph embedding vector to obtain a spliced vector, mapping and converting the spliced vector to obtain a matching degree of the candidate attribute and the target text, sorting the candidate attribute according to the matching degree to obtain an attribute sorting result; and generating a response text of the target text according to the attribute sorting result. The embodiment can output a more accurate response text and improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and in particular, to a text response method and device. BACKGROUND

[0002] With the development of artificial intelligence, the application range of knowledge base dialogue system in daily life is wider and wider, for example, in the process of commodity selection, users understand commodity details through the knowledge base dialogue system, and in the process of financial management, users understand financial product details through the knowledge base dialogue system. The knowledge base dialogue system is used to quickly answer common questions raised by users. When answering questions, the existing technology usually uses a method based on semantic analysis or information retrieval to obtain the answer to the question.

[0003] In the process of implementing the present application, the inventors have found that the prior art at least has the following problems:

[0004] The question raised by the user usually contains a large number of colloquial expressions, and there is a gap between the colloquial expressions and the standard commodity attribute description. The semantic representation effect obtained by using a conventional text matching model is poor, which leads to inaccurate text response. SUMMARY

[0005] Therefore, the embodiments of the present application provide a text response method and device, which can output more accurate response text and improve user experience.

[0006] To achieve the above-mentioned purpose, according to a first aspect of the embodiments of the present application, a text response method is provided, comprising:

[0007] In response to receiving a target text, a candidate attribute corresponding to the target text is obtained, and a similarity vector corresponding to the target text and the candidate attribute is determined;

[0008] The target text and the candidate attribute are encoded to obtain a semantic vector, and the semantic vector is weighted according to a pre-set attention mechanism to obtain a weighted semantic vector;

[0009] The candidate attribute is graphically constructed to obtain a graph embedding vector corresponding to the candidate attribute;

[0010] The similarity vector, the weighted semantic vector and the graph embedding vector are spliced to obtain a spliced vector, the spliced vector is mapped and converted to obtain a matching degree of the candidate attribute and the target text, the candidate attribute is sorted according to the matching degree to obtain an attribute sorting result;

[0011] The response text of the target text is generated according to the attribute sorting result.

[0012] Optionally, before concatenating the similarity vector, the weighted semantic vector and the graph embedding vector, the method further comprises:

[0013] determining corresponding attention weights according to the weighted semantic vector and the graph embedding vector;

[0014] enhancing the graph embedding vector according to the attention weights to obtain an enhanced graph embedding vector, and taking the enhanced graph embedding vector as the graph embedding vector for concatenation.

[0015] Optionally, the graph construction on the candidate attribute comprises:

[0016] converting the candidate attribute into a candidate attribute graph;

[0017] determining a candidate attribute node included in the candidate attribute graph, and updating a node feature of the candidate attribute node according to a node feature of a neighbor node corresponding to the candidate attribute node;

[0018] mapping the candidate attribute node after updating the node feature and a node relationship between different candidate attribute nodes to obtain the graph embedding vector corresponding to the candidate attribute.

[0019] Optionally, before the graph construction on the candidate attribute, the method further comprises:

[0020] obtaining a first historical text, and generating a data triple corresponding to the first historical text;

[0021] training a pre-set convolutional neural network and graph embedding model using the data triple to obtain a graph model, the graph model being used for the graph construction on the candidate attribute.

[0022] Optionally, before encoding the target text and the candidate attribute, the method further comprises:

[0023] obtaining a second historical text, and superimposing a text label on the second historical text to obtain a first preprocessed text;

[0024] concatenating the first preprocessed text according to a generation order of the second historical text to obtain a second preprocessed text;

[0025] training a pre-set pre-training model using the second preprocessed text to obtain a language model, the language model being used for encoding the target text and the candidate attribute.

[0026] Optionally, before training the pre-set pre-training model using the second preprocessed text, the method further comprises:

[0027] generating a corresponding position vector according to a generation order of the second historical text;

[0028] superimposing the position vector to the second preprocessed text.

[0029] Optionally, a text label is superimposed to the second historical text, including:

[0030] generating a corresponding text label according to identity information associated with the second historical text, and superimposing the text label to the second historical text.

[0031] Optionally, the second historical text includes a hyperlink; a text label is superimposed to the second historical text, including:

[0032] generating a corresponding text label according to the hyperlink, and superimposing the text label to the second historical text.

[0033] Optionally, the method further includes:

[0034] determining a link text corresponding to the hyperlink;

[0035] generating a summary text corresponding to the link text, and replacing the corresponding hyperlink in the second historical text with the summary text.

[0036] Optionally, before receiving the target text, the method further includes:

[0037] obtaining a third historical text, and taking the third historical text as a positive sample;

[0038] generating a negative sample corresponding to the positive sample according to a pre-set positive-negative sample ratio;

[0039] training a pre-set neural network using the positive sample and the negative sample, the neural network including a graph model and a language model.

[0040] Optionally, generating the negative sample corresponding to the positive sample includes:

[0041] reorganizing training texts and training attributes included in the third historical text to obtain a candidate negative sample;

[0042] determining a similarity of the training texts and the training attributes included in each candidate negative sample;

[0043] in a case where the similarity is greater than or equal to a pre-set similarity threshold, taking the corresponding candidate negative sample as a difficult negative sample, and in a case where the similarity is less than the similarity threshold, taking the corresponding candidate negative sample as an easy negative sample;

[0044] According to a pre-set difficulty ratio of negative samples, the difficult negative samples and the easy negative samples are filtered to obtain negative samples corresponding to the positive samples.

[0045] Optionally, before obtaining the candidate attribute corresponding to the target text, the method further comprises:

[0046] determining whether the target text is stored in a pre-set answer text set, and obtaining an answer text corresponding to the target text from the answer text set if the target text is stored in the pre-set answer text set.

[0047] Optionally, after generating the answer text of the target text according to the attribute sorting result, the method further comprises:

[0048] storing the target text and the answer text in association into the answer text set.

[0049] According to a second aspect of an embodiment of the present application, a device for text answering is provided, comprising:

[0050] a similarity module configured to, in response to receiving a target text, obtain a candidate attribute corresponding to the target text, and determine a similarity vector corresponding to the target text and the candidate attribute;

[0051] a semantic module configured to encode the target text and the candidate attribute to obtain a semantic vector, and weight the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector;

[0052] a graph embedding module configured to construct a graph for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute;

[0053] a sorting module configured to splice the similarity vector, the weighted semantic vector and the graph embedding vector to obtain a spliced vector, perform mapping conversion on the spliced vector to obtain a matching degree of the candidate attribute and the target text, and sort the candidate attribute according to the matching degree;

[0054] an answering module configured to generate an answer text of the target text according to an attribute sorting result.

[0055] Optionally, the device further comprises:

[0056] an attention module configured to determine a corresponding attention weight according to the weighted semantic vector and the graph embedding vector;

[0057] an enhancement module configured to enhance the graph embedding vector according to the attention weight to obtain an enhanced graph embedding vector, and use the enhanced graph embedding vector as a graph embedding vector for splicing.

[0058] Optionally, the candidate attribute is graph constructed to obtain the graph embedding vector corresponding to the candidate attribute, comprising:

[0059] The candidate attribute is converted into a candidate attribute graph;

[0060] The candidate attribute node included in the candidate attribute graph is determined, and the node feature of the candidate attribute node is updated according to the node feature of the neighbor node corresponding to the candidate attribute node;

[0061] The node relationship between the candidate attribute node after updating the node feature and different candidate attribute nodes is mapped to obtain the graph embedding vector corresponding to the candidate attribute.

[0062] Optionally, the device further comprises:

[0063] The first generation module is configured to obtain a first historical text and generate a data triple corresponding to the first historical text;

[0064] The first training module is configured to train a pre-set convolutional neural network and graph embedding model using the data triple to obtain a graph model, wherein the graph model is used for graph construction of the candidate attribute.

[0065] Optionally, the device further comprises:

[0066] The first superposition module is configured to obtain a second historical text, superimpose a text label on the second historical text, and obtain a first preprocessed text;

[0067] The splicing module is configured to splice the first preprocessed text according to the generation order of the second historical text to obtain a second preprocessed text;

[0068] The second training module is configured to train a pre-trained model using the second preprocessed text to obtain a language model, wherein the language model is used for encoding the target text and the candidate attribute.

[0069] Optionally, the device further comprises:

[0070] The second generation module is configured to generate a corresponding position vector according to the generation order of the second historical text;

[0071] The second superposition module is configured to superimpose the position vector on the second preprocessed text.

[0072] Optionally, superimposing the text label on the second historical text comprises:

[0073] generate a text label corresponding to the identity information associated with the second historical text, and superimpose the text label on the second historical text.

[0074] Optionally, the second historical text comprises a hyperlink; and superimposing the text label on the second historical text comprises:

[0075] generating a text label corresponding to the hyperlink, and superimposing the text label on the second historical text.

[0076] Optionally, the apparatus further comprises:

[0077] a determination module configured to determine a link text corresponding to the hyperlink;

[0078] a replacement module configured to generate an abstract text corresponding to the link text, and replace the corresponding hyperlink in the second historical text with the abstract text.

[0079] Optionally, the apparatus further comprises:

[0080] an acquisition module configured to acquire a third historical text, and use the third historical text as a positive sample;

[0081] a third generation module configured to generate a negative sample corresponding to the positive sample according to a pre-set positive-negative sample ratio;

[0082] a third training module configured to train a pre-set neural network using the positive sample and the negative sample, wherein the neural network comprises a graph model and a language model.

[0083] Optionally, generating the negative sample corresponding to the positive sample comprises:

[0084] reorganizing a training text and a training attribute included in the third historical text to obtain a candidate negative sample;

[0085] determining a similarity of the training text and the training attribute included in each candidate negative sample;

[0086] in a case where the similarity is greater than or equal to a pre-set similarity threshold, regarding the corresponding candidate negative sample as a difficult negative sample, and in a case where the similarity is less than the similarity threshold, regarding the corresponding candidate negative sample as an easy negative sample;

[0087] screening the difficult negative sample and the easy negative sample according to a pre-set difficult-easy negative sample ratio to obtain the negative sample corresponding to the positive sample.

[0088] Optionally, the apparatus further comprises:

[0089] The judgment module is configured to judge whether the target text is stored in the set of pre-set response texts, and acquire a response text corresponding to the target text from the set of response texts in a case where the target text is stored in the set of pre-set response texts.

[0090] Optionally, the apparatus further comprises:

[0091] The storage module is configured to store the target text and the response text in the set of response texts.

[0092] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising:

[0093] one or more processors;

[0094] a storage device configured to store one or more programs,

[0095] When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any of the above embodiments.

[0096] According to a fourth aspect of an embodiment of the present application, a computer readable medium is provided, having a computer program stored thereon, the program being executed by a processor to implement the method of any of the above embodiments.

[0097] One embodiment of the above application has the following advantages or beneficial effects: encoding the target text and the corresponding candidate attribute, and weighting the encoding result using the attention mechanism, can make the model pay more attention to the key information in the target text, and avoid semantic deviation; updating the node feature of the candidate attribute node by the node feature of the neighbor node corresponding to the candidate attribute node, and mapping the association between the candidate attribute node and different candidate attribute nodes, can make the information of the attribute representation more rich, and is conducive to providing more accurate text response; by superimposing the position vector and the text label on the historical text, the correlation between the historical text with context relationship and the corresponding attribute can be effectively learned, and the training task is ensured to be consistent with the actual task actually received, thereby improving the semantic understanding ability of the model; determining the attention weight of the weighted semantic vector and the graph embedding vector, and enhancing the graph embedding vector according to the attention weight, can determine the correlation between the weighted semantic vector and the graph embedding vector, thereby obtaining a graph embedding vector with more information, which is conducive to providing more accurate text response; obtaining the corresponding difficult negative sample and easy negative sample according to the difficult-easy negative sample ratio, and increasing the learning difficulty by sampling negative samples, thereby obtaining a model with higher precision and providing more accurate text response.

[0098] The further effects of the above non-conventional optional mode will be described in the following with reference to the specific embodiments. BRIEF DESCRIPTION OF DRAWINGS

[0099] The accompanying drawings are used to better understand the present application, and do not constitute undue limitations on the present application. Among them:

[0100] Figure 1 is a schematic diagram of the main process of the text response method according to an embodiment of the present application;

[0101] Figure 2 is a schematic diagram of text preprocessing of the text response method according to a reference embodiment of the present application;

[0102] Figure 3 is a schematic diagram of data triplets of the text response method according to a reference embodiment of the present application;

[0103] Figure 4 is a schematic diagram of a neural network of the text response method according to a reference embodiment of the present application;

[0104] Figure 5 is a schematic diagram of an application scenario of the text response method according to a reference embodiment of the present application;

[0105] Figure 6 is a schematic diagram of the main process of the text response method according to a reference embodiment of the present application;

[0106] Figure 7 is a schematic diagram of the main process of the text response method according to another reference embodiment of the present application;

[0107] Figure 8 is a schematic diagram of the main modules of the text response device according to an embodiment of the present application;

[0108] Figure 9 is an exemplary system architecture diagram to which embodiments of the present application can be applied;

[0109] Figure 10 is a structural schematic diagram of a computer system of a terminal device or a server suitable for implementing embodiments of the present application. DETAILED DESCRIPTION

[0110] Exemplary embodiments of the present application are described below with reference to the accompanying drawings, which include various details of the embodiments of the present application to help understanding, and should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Also, in order to be clear and concise, the description below omits the description of well-known functions and structures.

[0111] It should be noted that the collection, use, storage, sharing and transfer of user personal information in the technical solutions of the present application comply with relevant laws and regulations, and the user is informed and the consent or authorization of the user is obtained, and when applicable, the user personal information is subjected to de-identification and / or anonymization and / or encryption technical processing.

[0112] With the development of artificial intelligence, the application range of knowledge base dialogue system in daily life is wider and wider, for example, in the process of commodity selection, users understand commodity details through the knowledge base dialogue system, and in the process of office software, users understand the specific use method of office software through the knowledge base dialogue system. The knowledge base dialogue system is used to quickly answer the common questions raised by the user. When answering the question, the prior art usually uses a semantic analysis method or an information retrieval method to obtain a plurality of candidate answers related to the question, each candidate answer corresponds to a matching score, and the candidate answer with the highest matching score is replied to the user.

[0113] The question raised by the user usually contains a large number of colloquial expressions, and there is a gap between the colloquial expressions and the standard commodity attribute description. The semantic representation effect obtained by using a conventional text matching model is poor, which leads to inaccurate text response.

[0114] Therefore, according to a first aspect of an embodiment of the present application, a text response method is provided.

[0115] Figure 1 is a schematic diagram of the main process of the text response method according to the embodiment of the present application. As shown in Figure 1 the text response method according to the embodiment of the present application mainly includes the following steps S101 to S105.

[0116] Step S101, in response to receiving a target text, obtaining a candidate attribute corresponding to the target text, and determining a similarity vector corresponding to the target text and the candidate attribute.

[0117] The target text is a text issued by the user, and the target text is a text that needs to be responded. After receiving the target text, the execution subject of the embodiment of the present application obtains the candidate attribute corresponding to the target text. For example, the execution subject according to the embodiment of the present application pre-sets a corresponding candidate attribute for each business module. Each business module has a corresponding candidate attribute, for example, in the process of selecting and purchasing electronic products, the candidate attributes include: screen size, screen resolution, processor model, battery life, memory size, pixel size, etc., and in the process of selecting and purchasing clothes, the candidate attributes include: fabric material, size, style, color, etc. For another example, a plurality of method interfaces are pre-set to receive the target text, each method interface has a corresponding candidate attribute, and the candidate attribute corresponding to the target text is determined according to the target method interface receiving the target text.

[0118] After obtaining the target text and the corresponding candidate attribute, a plurality of methods are used to calculate the similarity between the target text and the corresponding candidate attribute, for example, using the Jaccard similarity coefficient to calculate the similarity between the target text and the candidate attribute, using the SimHash algorithm to calculate the similarity between the target text and the candidate attribute, using the edit distance algorithm to calculate the similarity between the target text and the candidate attribute, using the cosine similarity to calculate the similarity between the target text and the candidate attribute, and the like. The plurality of similarity results are spliced to obtain a corresponding similarity vector, and the dimension of the similarity vector is 1*N, where N represents the number of types of methods used to calculate the similarity. Each candidate attribute corresponds to a similarity vector.

[0119] For example, using the Jaccard similarity coefficient, the similarity between the target text and the candidate attribute A is A1, using the SimHash algorithm, the similarity between the target text and the candidate attribute A is A2, using the edit distance algorithm, the similarity between the target text and the candidate attribute A is A3, and using the cosine similarity, the similarity between the target text and the candidate attribute A is A4; the above four similarities are spliced to obtain the similarity vector corresponding to the candidate attribute A, which is “[A1 A2 A3 A4]”.

[0120] Using a plurality of similarity calculation methods to obtain a plurality of similarities, and obtaining a similarity vector according to the plurality of similarities, can enrich the vector representation of the candidate attribute, and comprehensively judge the candidate attribute according to a plurality of similarities.

[0121] In step S102, the target text and the candidate attribute are encoded to obtain a semantic vector, and the semantic vector is weighted according to a pre-set attention mechanism to obtain a weighted semantic vector.

[0122] The target text and the corresponding candidate attribute are spliced, for example, the candidate attribute is added to the end of the target text or the candidate attribute is added to the beginning of the target text. The target text and the corresponding candidate attribute are encoded using a pre-set language model to obtain a semantic vector, and the dimension of the semantic vector is 768*M, where M represents the length of the text being encoded. The pre-set language model can be a pre-trained BERT model, or a CDSSM model, and the like. Each candidate attribute corresponds to a semantic vector.

[0123] The semantic vector obtained by encoding is input into a pre-set Multi-Head Attention (multi-head attention) module, and the semantic vector is weighted using the Multi-Head Attention module to obtain a weighted semantic vector, and the dimension of the weighted semantic vector is “768*1”. Each candidate attribute corresponds to a weighted semantic vector.

[0124] The semantic vector is weighted using the attention mechanism, which can make the weighted semantic vector pay more attention to key information in the target text and the candidate attribute, reduce the attention weight of colloquial words in the target text, and is beneficial to more accurately screening the candidate attribute and improving the accuracy of the response text.

[0125] According to an embodiment of the present application, before encoding the target text and the candidate attribute, a second historical text is obtained, the second historical text including historical dialogue text between a user and a customer service personnel, for example, the second historical text being dialogue text sent by the user and the customer service personnel through a chat window on a page, or the second historical text being obtained by converting voice dialogue between the user and the customer service personnel; the user herein can be any user, and is not limited to the user sending the target text. The second historical text is superimposed with text labels, the text labels including a text source label, a text generation time label, a text tone label, and the like, wherein the text source label is used to distinguish where the second historical text comes from, the text generation time label is used to mark the generation time of the second historical text, and the text tone label is used to distinguish the tone of the second historical text (for example, the tone of the second historical text is determined by a tone word or a punctuation mark); the second historical text superimposed with the text labels is taken as the first preprocessed text.

[0126] Exemplarily, the obtained second historical text is “What is the size of this printer?”, since the second historical text comes from the e-product business field, a corresponding text source label “[e-product]” needs to be superimposed; since the second historical text is generated one week ago, a corresponding text generation time label “[1-week]” needs to be superimposed; since the second historical text contains a question mark “?”, a corresponding text tone time label “[question]” needs to be superimposed; thus, after superimposing the above text labels, the corresponding first preprocessed text is “[‘What is the size of this printer?’, [e-product], [1-week], [question]]”.

[0127] The first preprocessed texts are sorted according to generation times of the second historical texts, and a preset separator is used to splice between every two adjacent first preprocessed texts to obtain a second preprocessed text. For example, the generation time of the first preprocessed text [B1, [C1]] is 8:06 (wherein B1 represents a second historical text, C1 represents a text label corresponding to the second historical text, and other first preprocessed texts are similar), the generation time of the second historical text [B2, [C2]] is 8:01, the generation time of the second historical text [B3, [C3]] is 8:03, and the generation time of the second historical text [B4, [C4]] is 8:05; the preset separator is “[sep]”, the first preprocessed texts are sorted according to the generation times, and the second preprocessed text obtained by splicing using the separator is “[B1, [C1]] [sep] [B2, [C2]] [sep] [B3, [C3]] [sep] [B4, [C4]]”.

[0128] The preset pre-training model is trained using the second preprocessed text to obtain a language model. Specifically, according to a preset mask ratio, a corresponding number of business words in the second preprocessed text are converted into masks, so that the model predicts the business words corresponding to the masks. The business words are business-related words in the second preprocessed text, for example, the business words corresponding to the e-commerce field include product names, product attributes, etc., and the business words corresponding to the financial field include financial product names, bank operation names, etc. For example, the second preprocessed text is “[‘What type of charging interface is this mobile phone?’, [D1]] [sep] [‘Type-C’, [D2]]”, wherein “What type of charging interface is this mobile phone?” and “Type-C” are a group of second historical texts, “[D1]” and “[D2]” are corresponding text labels, and “[sep]” is a separator. The “charging interface” in the second historical text is converted into a mask to obtain “[‘What type of [Mask] is this mobile phone?’, [D1]] [sep] [‘Type-C’, [D2]]”. The preset pre-training model can be a BERT model or a derivative model of the BERT model, etc. The pre-training model after training is used as a language model for encoding the target text and the candidate attribute.

[0129] Figure 2 is a schematic diagram of text preprocessing of a text response method according to one reference embodiment of the present application. For example, as shown in FIG. 1, the text preprocessing includes the following steps: Figure 3As shown, the conversation text sent by the user is "recommend a large one [Mask] does anyone have", and the conversation text sent by the customer service personnel is "manufacturer name 1.5 new energy efficiency [Mask] cooling and heating self-cleaning wall hanging", both of which include the mask "[Mask]", and the above conversation text is input into the pre-set BERT model for training, so that the BERT model predicts the mask in the conversation text sent by the user as "air conditioner", and the mask in the conversation text sent by the customer service personnel as "variable frequency".

[0130] Superimposing the text label on the historical conversation text, splicing, and converting the mask can enable the pre-trained model to effectively learn the context relationship in the historical conversation text and the business words included in the historical conversation text, and improve the semantic understanding ability of the language model.

[0131] According to another embodiment of the present application, before the pre-set pre-trained model is trained using the second preprocessed text, a corresponding position vector is generated according to the generation order of the second historical text, each second historical text corresponds to a position vector, and the position vector is used to represent the relative position of the second historical text; the position vector is superimposed on the second preprocessed text. Exemplarily, the second preprocessed text is "[E1, [F1]] [SEP] [E2, [F2]] [SEP] [E3, [F3]] [SEP] [E4, [F4]] [SEP] [E5, [F5]]", wherein "E1, E2, E3, E4, E5" represent five second historical texts, "[F1], [F2], [F3], [F4], [F5]" represent the text label corresponding to each second historical text, and "[SEP]" represents a separator. Since the splicing order is the same as the generation order of the second historical text, the corresponding position vector is set according to the splicing order from "[0]" in sequence, and is superimposed on the second preprocessed text to obtain "[E1, [F1], [0]] [SEP] [E2, [F2], [1]] [SEP] [E3, [F3], [2]] [SEP] [E4, [F4], [3]] [SEP] [E5, [F5], [4]]". Superimposing the position vector can enable the pre-trained model to learn the text position relationship in the second historical text, which is beneficial to improve the semantic understanding ability of the language model.

[0132] According to another embodiment of the present application, when the text label is superimposed on the second historical text, the identity information associated with the second historical text is determined, that is, it is determined which role generates the second historical text. The identity information includes: ordinary user, special user, member, non-member, junior customer service, intermediate customer service, senior customer service, and the like. Different users have different questions, and different customer services have different answers to the same question. According to the identity information associated with each second historical text, the corresponding text label is generated and superimposed on the second historical text. Exemplarily, the second historical text G1 is generated by an ordinary user, the second historical text G2 is generated by a junior customer service, the second historical text G3 is generated by an ordinary user, and the second historical text G4 is generated by a junior customer service. According to the identity information associated with each second historical text, the corresponding text label is superimposed on the corresponding second historical text, and the second historical text [G1, [normalUser]], the second historical text [G2, [juniorServicer]], the second historical text [G3, [normalUser]], and the second historical text [G4, [juniorServicer]] are obtained. Superimposing the text vector corresponding to the identity information can enable the pre-training model to learn the identity information in the second historical text, which is beneficial to improve the semantic understanding ability of the language model.

[0133] According to another embodiment of the present application, the second historical text includes a hyperlink, and the hyperlink is a link to another page, for example, the hyperlink is a link to a product detail page, a link to a financial product, a link to a software user interface, and the like. The hyperlink is parsed to identify the entity information carried by the hyperlink, and the corresponding text label is generated according to the entity information, and the text label is superimposed on the second historical text. Exemplarily, the second historical text H1 includes a hyperlink "www.hhh.com / goods / 123.html", and since the hyperlink includes "goods", it is determined that the entity information carried by the hyperlink is "goods", and the text label corresponding to "goods" is superimposed on the second historical text H1, that is, "[goods]". In addition, "goods" can be further divided into "electronic products", "clothing", "fresh food", "household appliances", and the like, and each entity information corresponds to a different text label. The second historical text H2 includes a hyperlink "www.hhh.com / product / 456.html", and since the hyperlink includes "product", it is determined that the entity information carried by the hyperlink is "financial product", and the text label corresponding to "financial product" is superimposed on the second historical text H1, that is, "[product]". According to the superimposition of the corresponding text label on the hyperlink, the text relevance learning between the second historical text and the entity information included in the hyperlink can be enhanced, and the gap between the pre-training and the actual task can be reduced.

[0134] According to another embodiment of the present application, the page pointed to by the hyperlink includes text, which is the link text; and the summary text corresponding to the link text is generated. For example, when the link text includes a title, a subtitle, an abstract, a keyword, or a conclusion, the title, the subtitle, the abstract, the keyword, or the conclusion is taken as the summary text corresponding to the link text; or according to the word frequency and the inverse document frequency, the keywords appearing frequently in each paragraph and appearing infrequently in other paragraphs are selected from the link text as the summary text corresponding to the link. Exemplarily, the page pointed to by the hyperlink includes a title "1.5 new energy efficiency variable frequency cooling and heating self-cleaning wall-mounted bedroom air conditioner hanging machine (KFR-35GW / NhGe3B coral jade color) with old for new", and the title is taken as the summary text corresponding to the link text. After obtaining the summary text corresponding to the summary link text, the summary text is used to replace the corresponding hyperlink in the second historical text.

[0135] In step S103, a graph is constructed for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute.

[0136] determine the association relationship between different candidate attributes, for example, the association relationship includes: different attributes of the same commodity, different attributes of the same part of the same commodity, different attributes of different parts of the same commodity, etc. The graph corresponding to the candidate attribute is initialized, each candidate attribute is taken as a node of the graph, and the association relationship between different candidate attributes is converted into the edge between the corresponding nodes. Each candidate attribute corresponding node learns the node features of the neighbor nodes adjacent to the node, thereby enriching the attribute representation of each candidate attribute. After obtaining the attribute representation of each candidate attribute and the association relationship between different candidate attributes, the pre-set graph embedding model is used to map the above attribute representation and association relationship to a low-dimensional space to obtain the graph embedding vector corresponding to the candidate attribute. The attribute representation of each candidate attribute and the corresponding association relationship are converted into a graph embedding vector, which can further enrich the information contained in the graph embedding vector. Each candidate attribute corresponds to a graph embedding vector.

[0137] According to an embodiment of the present application, when the graph of the candidate attribute is constructed, the graph embedding vector corresponding to the candidate attribute is obtained, the candidate attribute graph is initialized, each candidate attribute is taken as an attribute node of the candidate attribute graph, and the association relationship between different candidate attributes is taken as the edge between the attribute nodes. According to the node features of the neighbor nodes corresponding to the candidate attribute node, the node features of the candidate attribute node are updated, specifically, the updating method of the node features is: wherein X (i+1) represents the i+1 layer node, that is, the node corresponding to the candidate attribute after updating i+1 times, σ represents a nonlinear activation function, for example, ReLU activation function or softmax activation function, represents the-1 / 2 power of the degree matrix corresponding to the candidate attribute graph, represents the adjacency matrix corresponding to the candidate attribute graph, X (i) represents the i layer node, that is, the node corresponding to the candidate attribute after updating i times, the i+1 layer node is obtained using the i layer node, W (i) represents the weight matrix corresponding to the candidate attribute graph.

[0138] The candidate attribute node and the node relationship between different candidate attribute nodes after updating the node features are mapped using the trained graph embedding model to obtain the graph embedding vector corresponding to the candidate attribute, wherein the graph embedding model can be TransE model, DistMult model, ConvE model, etc.

[0139] According to another embodiment of the present application, before the graph construction of the candidate attributes, the method further comprises: obtaining a first historical text, the first historical text comprising entity data in a dialogue scenario, for example, historical dialogue scenarios between a user and a customer service personnel, historical dialogue scenarios between different users, historical dialogue scenarios between different customer service personnel, and the like. The entity data in different business scenarios is different. For example, in an e-commerce business scenario, the entity data comprises commodity basic information such as commodity name, commodity price, commodity code, commodity category, commodity generation date, and multi-level attribute information, wherein the multi-level attribute information refers to that each commodity has multiple attribute groups, and each attribute group has multiple commodity attributes of the same category. For example, an attribute group J is “screen”, the attribute group comprising an attribute J1 of “screen size”, an attribute J2 of “screen resolution”, and an attribute J3 of “screen material”, and the multiple attributes included in a commodity are associated together through the multi-level attribute information. The first historical text further comprises user data such as user basic information such as user gender, user age, and user region, and user shopping information such as historical browsing commodities, historical clicked commodities, and historical purchased commodities.

[0140] The user information is associated with the corresponding entity data to generate data triples corresponding to the first historical text. For example, the data triples are “<entity, relationship, entity>”, wherein the left entity is taken as a head entity, the right entity is taken as a tail entity, and the two entities represent different attributes, and the relationship between the entities represents an association relationship between different attributes; or one of the two entities is a user and the other is a commodity, and the relationship between the user and the commodity comprises browsing, clicking, purchasing, applying for after-sales, and the like. For another example, the data triples are “<entity, attribute, attribute value>”, wherein the entity is a commodity, the attribute is a commodity attribute, and the attribute value is an attribute value of the commodity attribute, or the entity is a user, the attribute is a user attribute, and the attribute value is an attribute value of the user attribute.

[0141] Figure 3 is a schematic diagram of data triples of a text response method according to an embodiment of the present application. As shown in Figure 2 , a user 1 clicks a commodity 1, the commodity belongs to a category 1, the category 1 belongs to a category 2, the category 2 belongs to a category 3, the commodity 1 has an attribute group 1, the attribute group 1 comprises an attribute 1, an attribute 2, and an attribute 3, wherein the attribute 1 has an attribute value 1, the attribute 2 has an attribute value 2, and the attribute 3 has an attribute value 3. Figure 2The entities in the first historical text include: user 1, commodity 1, category 1, category 2, category 3, attribute group 1, attribute 1, attribute 2 and attribute 3, and the generated data triplets include: <user 1, click, commodity 1>, <commodity 1, has, attribute group 1>, <attribute group 1, includes, attribute 1>, <commodity 1, belongs to, category 1>, <commodity 1, attribute 1, attribute value 1>, <commodity 1, attribute 2, attribute value 2> and the like. It should be noted that the first historical text includes multiple users, and the relationship between each user and different commodities includes: click, browse, purchase, comparison and the like, each commodity has multiple attribute groups, each attribute group includes multiple attributes, and each attribute has one or more attribute values.

[0142] The obtained multiple data triplets are used to train a pre-set convolutional neural network and a graph embedding model to obtain a graph model. The convolutional neural network can be a GCN model, a DGCN model, a GAT model and the like, and the graph embedding model can be a TransE model, a DistMult model, a ConvE model and the like. When training the graph embedding model, the data triplets of the first historical text and the like are used as positive examples, the head entity or the tail entity in the positive examples is randomly replaced to obtain negative examples, the positive examples and the negative examples are used to train the graph embedding model, the distance between the positive examples and the negative examples is maximized, and the calculation formula of the loss function of the graph embedding model is: wherein L represents the loss function, f(e i , r, e j ) represents the distance function of the positive example, f(e′ i , r′, e′ j ) represents the distance function of the negative example, and γ represents the margin. The graph model obtained by training the convolutional neural network and the graph embedding model is used for graph construction of the candidate attribute.

[0143] In step S104, the similarity vector, the weighted semantic vector and the graph embedding vector are spliced to obtain a spliced vector, the spliced vector is mapped and converted to obtain a matching degree of the candidate attribute and the target text, the candidate attribute is sorted according to the matching degree to obtain an attribute sorting result.

[0144] The splicing is performed in a pre-set splicing order, for example, the weighted semantic vector is spliced to the similarity vector, and then the graph embedding vector is spliced to the weighted semantic vector. The spliced vector is pooled, and then passes through a pre-set fully connected layer to obtain a matching degree corresponding to the candidate attribute. Each candidate attribute corresponds to a matching degree, and the candidate attribute with the highest matching degree is taken as the target attribute, so that a corresponding response text is generated according to the target attribute.

[0145] According to one referable embodiment of the application, before splicing the similarity vector, the weighted semantic vector and the graph embedding vector, the method further comprises: inputting the weighted semantic vector and the graph embedding vector into a pre-set dynamic weighting module, calculating the attention weight between the weighted semantic vector and the graph embedding vector using the dynamic weighting module, for example, performing dot product operation on the weighted semantic vector and the graph embedding vector, or calculating using a multiplication perceptron algorithm. According to the attention weight, the graph embedding vector is enhanced to obtain an enhanced graph embedding vector, and the dimension of the enhanced graph embedding vector is 512*1. The obtained enhanced graph embedding vector is used as the graph embedding vector for splicing. Illustratively, the graph embedding vector is K1, the attention weight is K2, and the enhanced graph embedding vector is K3, K3=K1*K2. Calculating the correlation between the weighted semantic vector and the graph embedding vector, enhancing the graph embedding vector, can improve the information content of the graph embedding vector, and is conducive to more accurately evaluating whether the candidate attribute matches the target text.

[0146] Step S105, generating a response text of the target text according to the attribute ranking result.

[0147] Selecting the candidate attribute with the highest attribute ranking as the target attribute, obtaining the response text corresponding to the target attribute, illustratively, the target text is "www.iii.com / item / 789.html, how much is the capacity of this mobile phone?", the attribute ranking result is "storage space size (matching degree 0.98), memory size (matching degree 0.90), screen size (matching degree 0.75), processor model (matching degree 0.6), and endurance time (matching degree 0.4)", and the "storage space size" with the highest matching degree and the highest ranking is selected as the target attribute, and the corresponding response text is "the storage space size of this mobile phone is 128G". According to the ranking result of the candidate attribute, the corresponding target attribute is determined, and the corresponding response text is generated, which can improve the matching rate of the response text and the target text, so that the response text can timely solve the problem raised by the user, and improve the user experience.

[0148] According to one embodiment of the present application, before the target text is received, the method further comprises: obtaining a third historical text, the third historical text being a historical dialogue text, and taking the third historical text as a positive sample; generating negative samples corresponding to the positive sample according to a pre-set positive-negative sample ratio, the negative samples being dialogue texts lacking context correlation, for example, selecting a corresponding number of negative samples from an artificially constructed negative sample set, or duplicating the positive sample and adding artificially constructed negative samples to the duplicated positive sample, thereby reducing the context correlation of the dialogue text included in the positive sample. For example, the pre-set positive-negative sample ratio is 1:20, and 10 groups of historical dialogue texts are obtained, then 200 groups of negative samples need to be obtained from the artificially constructed negative sample set. The pre-set neural network is trained using the positive sample and the negative sample, the neural network comprising: a graph model and a language model, and a model for splicing a plurality of similarities.

[0149] According to another embodiment of the present application, the third historical text includes training texts, each training text having a corresponding training attribute, and the third historical text is a dialogue text generated in a real situation, so that the training text and the corresponding training attribute are matched. When generating the negative samples corresponding to the positive sample, the training text and the training attribute are recombined to obtain a candidate negative sample, for example, the training attributes in the plurality of training texts are replaced with each other, or the training attributes in the training text are removed, or additional training attributes are added to the training text, so that the recombined training text and the corresponding training attribute are mismatched, and the recombined third historical text is taken as the candidate negative sample.

[0150] The similarity of each candidate negative sample included in the training text and the training attribute is determined, and the calculation method of the similarity includes: Jaccard similarity coefficient, SimHash algorithm, edit distance algorithm, cosine similarity, etc. In the case where the similarity of the candidate negative sample is greater than or equal to a pre-set similarity threshold, the candidate negative sample is taken as a difficult negative sample (i.e. a negative sample with a larger learning difficulty), and in the case where the similarity of the candidate negative sample is less than the similarity threshold, the candidate negative sample is taken as an easy negative sample (i.e. a negative sample with a smaller learning difficulty). According to a pre-set difficult-easy negative sample ratio, a corresponding number of negative samples are selected from the difficult negative samples and the easy negative samples respectively, to obtain the negative samples corresponding to the positive sample.

[0151] For example, the pre-set difficult-easy negative sample ratio is 1:4, and the total number of negative samples is 20, then 4 negative samples are extracted from the difficult negative samples and 16 negative samples are extracted from the easy negative samples. By extracting the difficult negative samples and the easy negative samples, the learning difficulty of the model training can be increased, and the model training accuracy can be improved.

[0152] According to another embodiment of the present application, before the candidate attribute corresponding to the target text is obtained, the method further comprises: judging whether the target text is stored in the pre-set answer text set. If the target text is stored in the pre-set answer text set, it means that the subject of the embodiment of the present application has generated the answer text corresponding to the target text before, so that the corresponding answer text does not need to be generated again, and the answer text corresponding to the target text can be directly obtained from the answer text set. The data record including the target text is searched, the data field corresponding to the answer text is obtained in the data record including the target text, and the answer text corresponding to the target text is obtained. The answer text corresponding to the target text is obtained from the answer text set, so that the efficiency and accuracy of the text answer can be improved, and the system resources can be saved.

[0153] According to another embodiment of the present application, after the answer text of the target text is generated according to the attribute sorting result, the method further comprises: storing the target text and the answer text in the pre-set answer text set. The answer text set is dynamically updated. For example, the storage time point of each target text and answer text is recorded, and every certain period of time, the target text and the answer text with the storage time point earlier than the pre-set cleaning time point are removed from the answer text set, or it is judged whether the target attribute included in the target text or the answer text still exists, and in the case that the target attribute included in the target text or the answer text does not exist, the target text or the answer text is removed from the answer text set.

[0154] Figure 4 is a schematic diagram of a neural network of the text answer method according to an embodiment of the present application. Exemplarily, as shown in Figure 4As shown, the neural network includes a vocabulary module 401, a semantic module 402, and a graph enhancement module 403, a Multi-Head Attention Pooling module, a Dense module, and the like. After receiving the target text and determining the corresponding candidate attribute, the target text and the corresponding candidate attribute are input into a similarity calculation module to calculate the similarity of the target text and the candidate attribute using multiple methods. The obtained multiple similarities are input into a DNN model to obtain a corresponding similarity vector. The target text and the corresponding candidate attribute are encoded using a pre-trained BERT model to obtain a semantic vector. The semantic vector is input into a Multi-Head Attention module, and the semantic vector is weighted using an attention mechanism to obtain a weighted semantic vector. The candidate attribute is input into a graph model composed of a GCN model and a TransE model to construct a graph for the candidate attribute and obtain a corresponding graph embedding vector. The graph embedding vector is input into a dynamic enhancement module to obtain an enhanced graph embedding vector. The similarity vector, the weighted semantic vector, and the enhanced graph embedding vector are spliced to obtain a spliced vector. The spliced vector is input into a Multi-Head Attention Pooling module and a Dense module to obtain a matching probability of each candidate attribute and the target text. Wherein, “0” represents the probability of mismatching, and “1” represents the probability of matching. The candidate attributes are sorted according to the matching probability to obtain an attribute sorting result. The candidate attribute with the highest matching probability is taken as a target attribute, and a response text corresponding to the target text is generated according to the target attribute.

[0155] Figure 5 is a schematic diagram of an application scenario of a method of text response according to an embodiment of the present application. As shown in Figure 5 , the method described in the embodiment of the present application is used in a dialogue process with a user. In a dialogue page 501, the user sends a corresponding product link and the text “how many sizes” for a product of an electronic product flagship store. The execution subject of the embodiment of the present application takes the product link and the text as a target text, processes the target file, and the processing process has been described in detail in the previous embodiment, which will not be described here. After the processing is completed, the execution subject of the embodiment of the present application generates a response text corresponding to the target text “the size of this product is: 450mm long, 306mm wide, and 160mm high.” and sends the response text to the corresponding user through the dialogue page 501.

[0156] Figure 6 is a schematic diagram of the main process of a method of text response according to an embodiment of the present application. As shown in Figure 6 , the method of text response can include:

[0157] Step S601, in response to receiving the target text, traversing the pre-set answer text set;

[0158] Step S602, judging whether the target text is stored, if yes, jumping to step S603, otherwise jumping to step S604;

[0159] Step S603, obtaining the answer text corresponding to the target text from the answer text set;

[0160] Step S604, obtaining the candidate attribute corresponding to the target text, and determining the similarity vector corresponding to the target text and the candidate attribute;

[0161] Step S605, encoding the target text and the candidate attribute to obtain a semantic vector, and weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector;

[0162] Step S606, constructing a graph for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute;

[0163] Step S607, determining the corresponding attention weight according to the weighted semantic vector and the graph embedding vector;

[0164] Step S608, enhancing the graph embedding vector according to the attention weight to obtain an enhanced graph embedding vector;

[0165] Step S609, splicing the similarity vector, the weighted semantic vector and the enhanced graph embedding vector to obtain a spliced vector, mapping and converting the spliced vector to obtain a matching degree of the candidate attribute and the target text, sorting the candidate attribute according to the matching degree to obtain an attribute sorting result;

[0166] Step S610, generating the answer text of the target text according to the attribute sorting result.

[0167] The specific implementation content of the text response method of the above one reference embodiment has been described in detail in the above-described text response method, and therefore the repeated content will not be described here.

[0168] Figure 7 is a schematic diagram of the main flow of the text response method according to another reference embodiment of the present application. As shown in Figure 7 , the text response method can include:

[0169] Step S701, obtaining a first historical text, and generating a data triple corresponding to the first historical text;

[0170] Step S702, training a pre-set convolutional neural network and graph embedding model using the data triple to obtain a graph model;

[0171] In step S703, a second historical text is acquired, a text label is superimposed on the second historical text, and a first preprocessed text is obtained.

[0172] In step S704, the first preprocessed text is spliced according to a generation order of the second historical text, and a second preprocessed text is obtained.

[0173] In step S705, the second preprocessed text is used to train a pre-set pre-training model, and a language model is obtained.

[0174] In step S706, in response to receiving a target text, a candidate attribute corresponding to the target text is acquired, and a similarity vector corresponding to the target text and the candidate attribute is determined.

[0175] In step S707, the language model is used to encode the target text and the candidate attribute, a semantic vector is obtained, and the semantic vector is weighted according to a pre-set attention mechanism, and a weighted semantic vector is obtained.

[0176] In step S708, a graph model is used to construct a graph of the candidate attribute, and a graph embedding vector corresponding to the candidate attribute is obtained.

[0177] In step S709, the similarity vector, the weighted semantic vector, and the graph embedding vector are spliced to obtain a spliced vector, the spliced vector is mapped and converted to obtain a matching degree of the candidate attribute and the target text, the candidate attribute is sorted according to the matching degree, and an attribute sorting result is obtained.

[0178] In step S710, a response text of the target text is generated according to the attribute sorting result.

[0179] The specific implementation content of the text response method of the above one reference embodiment of the present application has been described in detail in the above-described text response method, and therefore repeated content will not be described here.

[0180] According to a second aspect of an embodiment of the present application, a text response device is provided.

[0181] Figure 8 is a schematic diagram of main modules of the text response device according to an embodiment of the present application, as shown in Figure 8 The text response device 800 mainly includes:

[0182] The similarity module 801 is configured to, in response to receiving a target text, acquire a candidate attribute corresponding to the target text, and determine a similarity vector corresponding to the target text and the candidate attribute.

[0183] The semantic module 802 is configured to encode the target text and the candidate attribute to obtain a semantic vector, and weight the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector.

[0184] The graph embedding module 803 is configured to perform graph construction on the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute.

[0185] The sorting module 804 is configured to splice the similarity vector, the weighted semantic vector and the graph embedding vector to obtain a spliced vector, perform mapping conversion on the spliced vector to obtain a matching degree of the candidate attribute and the target text, and sort the candidate attribute according to the matching degree.

[0186] The response module 805 is configured to generate a response text of the target text according to the attribute sorting result.

[0187] According to an embodiment of the present application, the text response device 800 further comprises:

[0188] The attention module is configured to determine corresponding attention weights according to the weighted semantic vector and the graph embedding vector.

[0189] The enhancement module is configured to enhance the graph embedding vector according to the attention weights to obtain an enhanced graph embedding vector, and take the enhanced graph embedding vector as the graph embedding vector for splicing.

[0190] According to another embodiment of the present application, the graph construction on the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute comprises:

[0191] Converting the candidate attribute into a candidate attribute graph.

[0192] Determining a candidate attribute node included in the candidate attribute graph, and updating a node feature of the candidate attribute node according to a node feature of a neighbor node corresponding to the candidate attribute node.

[0193] Mapping the node features of the updated candidate attribute node and the node relationships between different candidate attribute nodes to obtain the graph embedding vector corresponding to the candidate attribute.

[0194] According to still another embodiment of the present application, the text response device 800 further comprises:

[0195] The first generation module is configured to obtain a first historical text and generate a data triple corresponding to the first historical text.

[0196] The first training module is configured to train a pre-set convolutional neural network and graph embedding model using the data triple to obtain a graph model, and the graph model is used for graph construction on the candidate attribute.

[0197] According to another embodiment of the present application, the text response device 800 further comprises:

[0198] The first superposition module is configured to obtain a second historical text, superpose a text label to the second historical text, and obtain a first preprocessed text.

[0199] The splicing module is configured to splice the first preprocessed text according to a generation order of the second historical text, and obtain a second preprocessed text.

[0200] The second training module is configured to train a pre-set pre-training model using the second preprocessed text, and obtain a language model, wherein the language model is used to encode the target text and the candidate attribute.

[0201] According to another embodiment of the present application, the text response device 800 further comprises:

[0202] The second generation module is configured to generate a corresponding position vector according to a generation order of the second historical text.

[0203] The second superposition module is configured to superpose the position vector to the second preprocessed text.

[0204] According to an embodiment of the present application, superposing a text label to the second historical text comprises:

[0205] Generating a corresponding text label according to identity information associated with the second historical text, and superposing the text label to the second historical text.

[0206] According to another embodiment of the present application, the second historical text comprises a hyperlink; superposing a text label to the second historical text comprises:

[0207] Generating a corresponding text label according to the hyperlink, and superposing the text label to the second historical text.

[0208] According to another embodiment of the present application, the text response device 800 further comprises:

[0209] The determination module is configured to determine a link text corresponding to the hyperlink.

[0210] The replacement module is configured to generate an abstract text corresponding to the link text, and replace the corresponding hyperlink in the second historical text with the abstract text.

[0211] According to another embodiment of the present application, the text response device 800 further comprises:

[0212] The acquisition module is configured to acquire a third historical text, and take the third historical text as a positive sample;

[0213] The third generation module is configured to generate a negative sample corresponding to the positive sample according to a pre-set positive-negative sample ratio.

[0214] The third training module is configured to train a pre-set neural network using the positive sample and the negative sample, wherein the neural network comprises a graph model and a language model.

[0215] According to another embodiment of the present application, the generation of the negative sample corresponding to the positive sample comprises:

[0216] Reorganizing the training text and the training attribute included in the third historical text to obtain a candidate negative sample;

[0217] Determining the similarity of the training text and the training attribute included in each candidate negative sample;

[0218] In a case where the similarity is greater than or equal to a pre-set similarity threshold, the corresponding candidate negative sample is taken as a difficult negative sample, and in a case where the similarity is less than the similarity threshold, the corresponding candidate negative sample is taken as an easy negative sample;

[0219] According to a pre-set difficult-easy negative sample ratio, the difficult negative sample and the easy negative sample are screened to obtain the negative sample corresponding to the positive sample.

[0220] According to an embodiment of the present application, the text response device 800 further comprises:

[0221] The judgment module is configured to judge whether a pre-set response text set stores the target text, and in a case where the pre-set response text set stores the target text, acquire the response text corresponding to the target text from the response text set.

[0222] According to another embodiment of the present application, the text response device 800 further comprises:

[0223] The storage module is configured to store the target text and the response text in association to the response text set.

[0224] It should be noted that the specific implementation of the text response device in the embodiments of the present application has been described in detail in the above text response method, and therefore the repeated content will not be described here.

[0225] According to the technical scheme of the embodiment of the present application, the target text and the corresponding candidate attribute are encoded, and the attention mechanism is used to weight the encoding result, so that the model can pay more attention to the key information in the target text and avoid semantic deviation; the node features of the candidate attribute nodes are updated by the node features of the neighbor nodes corresponding to the candidate attribute nodes, and the association between the candidate attribute nodes and different candidate attribute nodes is mapped, so that the information of the attribute representation is richer, which is beneficial to provide more accurate text response; by superimposing the position vector and the text label on the historical text, the correlation between the historical text with context relationship and the corresponding attribute can be effectively learned, and the training task is consistent with the actual received actual task, so that the semantic understanding ability of the model is improved; the attention weight of the weighted semantic vector and the graph embedding vector is determined, the graph embedding vector is enhanced according to the attention weight, the correlation between the weighted semantic vector and the graph embedding vector is determined, so that the graph embedding vector with richer information is obtained, which is beneficial to provide more accurate text response; the corresponding difficult negative sample and easy negative sample are obtained according to the difficult and easy negative sample ratio, the learning difficulty is increased by sampling negative samples, so that a model with higher precision is obtained, and more accurate text response is provided.

[0226] According to a third aspect of the embodiment of the present application, an electronic device for text response is provided, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first aspect of the embodiment of the present application.

[0227] According to a fourth aspect of the embodiment of the present application, a computer readable medium is provided, which stores a computer program, and the program is executed by a processor to implement the method provided by the first aspect of the embodiment of the present application.

[0228] Figure 9 An exemplary system architecture 900 to which the method for text response or the device for text response of the embodiment of the present application can be applied is shown.

[0229] As shown in Figure 9 The system architecture 900 can include terminal devices 901, 902, 903, a network 904 and a server 905. The network 904 is used to provide a communication link medium between the terminal devices 901, 902, 903 and the server 905. The network 904 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0230] The user can use the terminal devices 901, 902, and 903 to interact with the server 905 through the network 904 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 901, 902, and 903, such as text response type applications, text retrieval type applications, search type applications, instant messaging tools, mailbox clients, social platform software, etc. (only as examples).

[0231] The terminal devices 901, 902, and 903 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.

[0232] The server 905 can be a server providing various services, such as a background management server supporting requests for text responses from upstream using terminal devices 901, 902, and 903 (only as an example). The background management server can respond to receiving a target text, obtaining a candidate attribute corresponding to the target text, determining a similarity vector corresponding to the target text and the candidate attribute; encoding the target text and the candidate attribute to obtain a semantic vector, weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector; constructing a graph for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute; concatenating the similarity vector, the weighted semantic vector, and the graph embedding vector to obtain a concatenated vector, mapping and converting the concatenated vector to obtain a matching degree of the candidate attribute and the target text, sorting the candidate attribute according to the matching degree to obtain an attribute sorting result; generating a response text for the target text according to the attribute sorting result; and feeding back the text response (only as an example) to the terminal device.

[0233] It should be noted that the method for text response provided by the embodiments of the present application is generally executed by the server 905, and accordingly, the device for text response is generally arranged in the server 905. The method for text response provided by the embodiments of the present application can also be executed by the terminal devices 901, 902, and 903, and accordingly, the device for text response can be arranged in the terminal devices 901, 902, and 903.

[0234] It should be understood that Figure 9 The number of terminal devices, networks, and servers in the above description is only illustrative. Any number of terminal devices, networks, and servers can be provided according to the needs of implementation.

[0235] Reference will now be made to Figure 10 which shows a structural schematic diagram of a computer system 1000 of a terminal device suitable for implementing the embodiments of the present application. Figure 10The terminal device shown is merely an example and should not impose any limitation on the functions and usage range of the embodiments of the present application.

[0236] As Figure 10 shown, the computer system 1000 includes a central processing unit (CPU) 1001 which can perform various appropriate actions and processes in accordance with a program stored in a read only memory (ROM) 1002 or a program loaded from the storage section 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0237] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as necessary. A removable media 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1010 as necessary, so that a computer program read out therefrom is installed in the storage section 1008 as necessary.

[0238] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program in accordance with the embodiments disclosed herein. For example, the embodiments disclosed herein include a computer program which includes a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 1009, and / or installed from the removable media 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-described functions defined in the system of the embodiments of the present application are performed.

[0239] It should be noted that the computer-readable medium in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the embodiments of the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a carrier wave in a carrier wave part, in which computer-readable program codes are carried. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, transmit, propagate or transport a program for use by or in conjunction with an instruction execution system, device or apparatus. The program codes contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0240] The flowcharts and block diagrams in the drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a segment, or a portion of codes which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks noted in succession can in fact be executed substantially concurrently or in the reverse order, depending on the functionality involved. It should also be noted that each block in the flowcharts or block diagrams and combinations of blocks in the flowcharts or block diagrams can be implemented by special-purpose hardware-based systems which perform the specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0241] The modules described in the embodiments of the present application can be implemented in the form of software or hardware. The described modules can also be arranged in a processor, for example, a processor can be described as including a similarity module, a semantic module, a graph embedding module, a sorting module, and a response module. In some cases, the names of these modules do not constitute a limitation on the modules themselves. For example, the similarity module can also be described as a module that determines a similarity vector of a target text and a corresponding candidate attribute.

[0242] As another aspect, the embodiments of the present application also provide a computer readable medium, which can be included in the device described in the above embodiments, or can exist independently without being assembled into the device. The computer readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: in response to receiving a target text, obtaining a candidate attribute corresponding to the target text, and determining a similarity vector of the target text and the candidate attribute; encoding the target text and the candidate attribute to obtain a semantic vector, weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector; constructing a graph for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute; splicing the similarity vector, the weighted semantic vector, and the graph embedding vector to obtain a spliced vector, mapping and converting the spliced vector to obtain a matching degree of the candidate attribute and the target text, sorting the candidate attribute according to the matching degree to obtain an attribute sorting result; and generating a response text of the target text according to the attribute sorting result.

[0243] According to the technical scheme of the embodiment of the present application, the target text and the corresponding candidate attribute are encoded, and the attention mechanism is used to weight the encoding result, so that the model can pay more attention to the key information in the target text and avoid semantic deviation; the node features of the candidate attribute nodes are updated by the node features of the neighbor nodes corresponding to the candidate attribute nodes, and the association between the candidate attribute nodes and different candidate attribute nodes is mapped, so that the information of the attribute representation is more abundant, which is beneficial to provide more accurate text response; by superimposing the position vector and the text label on the historical text, the correlation between the historical text with context relationship and the corresponding attribute can be effectively learned, and the training task is consistent with the actual received actual task, so as to improve the semantic understanding ability of the model; the attention weight of the weighted semantic vector and the graph embedding vector is determined, the graph embedding vector is enhanced according to the attention weight, the correlation between the weighted semantic vector and the graph embedding vector can be determined, so as to obtain the graph embedding vector with more abundant information, which is beneficial to provide more accurate text response; the corresponding difficult negative sample and easy negative sample are obtained according to the difficulty and easy negative sample ratio, the learning difficulty is increased by sampling negative samples, so as to obtain a model with higher precision and provide more accurate text response.

[0244] The above specific embodiments do not constitute a limitation on the protection scope of the embodiments of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can occur depending on design requirements and other factors. Any modification, equivalent replacement and improvement made within the spirit and principle of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A method of text answering, characterized by, The method comprises the following steps: in response to receiving the target text, obtaining a candidate attribute corresponding to the target text, and determining a similarity vector corresponding to the target text and the candidate attribute; encoding the target text and the candidate attribute to obtain a semantic vector, weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector; constructing a graph for the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute, comprising: converting the candidate attribute into a candidate attribute graph, determining the candidate attribute nodes included in the candidate attribute graph, updating the node features of the candidate attribute nodes according to the node features of the neighbor nodes corresponding to the candidate attribute nodes, and mapping the node relationships between the candidate attribute nodes and different candidate attribute nodes after updating the node features to obtain the graph embedding vector corresponding to the candidate attribute; concatenate the similarity vector, the weighted semantic vector and the graph embedding vector to obtain a concatenated vector, and map the concatenated vector to obtain a matching degree between the candidate attribute and the target text, sort the candidate attribute according to the matching degree to obtain an attribute sorting result; generating a response text of the target text according to the attribute sorting result.

2. The method of claim 1, wherein, Before concatenating the similarity vector, the weighted semantic vector and the graph embedding vector, the method further comprises: determining the corresponding attention weight according to the weighted semantic vector and the graph embedding vector; enhancing the graph embedding vector according to the attention weight to obtain an enhanced graph embedding vector, and taking the enhanced graph embedding vector as the graph embedding vector for concatenation.

3. The method of claim 1, wherein, Before constructing a graph for the candidate attribute, the method further comprises: obtaining a first historical text and generating a data triple corresponding to the first historical text; training a pre-set convolutional neural network and graph embedding model using the data triple to obtain a graph model, which is used for graph construction of the candidate attribute.

4. The method of claim 1, wherein, Before encoding the target text and the candidate attribute, the method further comprises: obtaining a second historical text, and superimposing a text label on the second historical text to obtain a first preprocessed text; concatenating the first preprocessed text according to the generation order of the second historical text to obtain a second preprocessed text; training a pre-set pre-training model using the second preprocessed text to obtain a language model, which is used for encoding the target text and the candidate attribute.

5. The method of claim 4, wherein, Before training the pre-set pre-training model using the second preprocessed text, the method further comprises: generating a corresponding position vector according to the generation order of the second historical text; superimposing the position vector on the second preprocessed text.

6. The method of claim 4, wherein, Superimposing a text label on the second historical text comprises: generating a corresponding text label according to the identity information associated with the second historical text, and superimposing the text label on the second historical text.

7. The method of claim 4, wherein, The second historical text includes a hyperlink; superimposing a text label on the second historical text comprises: According to the hyperlink, a corresponding text label is generated, and the text label is superimposed on the second historical text.

8. The method of claim 7, wherein, The method further comprises: determining the link text corresponding to the hyperlink; generating the summary text corresponding to the link text, and replacing the corresponding hyperlink in the second historical text with the summary text.

9. The method of claim 1, wherein, Before receiving the target text, the method further comprises: obtaining a third historical text, and taking the third historical text as a positive sample; According to the pre-set positive and negative sample ratio, the negative sample corresponding to the positive sample is generated; using the positive sample and the negative sample to train a pre-set neural network, the neural network comprising: a graph model and a language model.

10. The method of claim 9, wherein, Generating the negative sample corresponding to the positive sample comprises: reorganizing the training text and the training attribute included in the third historical text to obtain a candidate negative sample; determining the similarity of the training text and the training attribute included in each candidate negative sample; in the case where the similarity is greater than or equal to a pre-set similarity threshold, the corresponding candidate negative sample is taken as a difficult negative sample, and in the case where the similarity is less than the similarity threshold, the corresponding candidate negative sample is taken as an easy negative sample; According to the pre-set difficult and easy negative sample ratio, the difficult negative sample and the easy negative sample are screened to obtain the negative sample corresponding to the positive sample.

11. The method of claim 1, wherein, Before obtaining the candidate attribute corresponding to the target text, the method further comprises: determining whether the pre-set response text set stores the target text, and in the case where the pre-set response text set stores the target text, obtaining the response text corresponding to the target text from the response text set.

12. The method of claim 11, wherein, After generating the response text of the target text according to the attribute sorting result, the method further comprises: storing the target text and the response text in the response text set in association.

13. An apparatus for text answering, characterized by Comprise: a similarity module for obtaining a candidate attribute corresponding to the target text in response to receiving the target text, and determining a similarity vector corresponding to the target text and the candidate attribute; a semantic module for encoding the target text and the candidate attribute to obtain a semantic vector, and weighting the semantic vector according to a pre-set attention mechanism to obtain a weighted semantic vector; a graph embedding module for graph construction of the candidate attribute to obtain a graph embedding vector corresponding to the candidate attribute, comprising: converting the candidate attribute into a candidate attribute graph, determining the candidate attribute nodes included in the candidate attribute graph, updating the node features of the candidate attribute nodes according to the node features of the neighbor nodes corresponding to the candidate attribute nodes, mapping the node relationships between the updated node features of the candidate attribute nodes and different candidate attribute nodes to obtain the graph embedding vector corresponding to the candidate attribute; a sorting module for concatenating the similarity vector, the weighted semantic vector and the graph embedding vector to obtain a concatenated vector, mapping and converting the concatenated vector to obtain the matching degree of the candidate attribute and the target text, and sorting the candidate attribute according to the matching degree; A response module is configured to generate a response text of the target text according to the attribute ranking result.

14. An electronic device, comprising: Comprising: one or more processors; a memory device storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-12.

15. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method according to any one of claims 1-12. The program is executed by the processor to implement the method according to any one of claims 1-12.

Citation Information

Patent Citations

  • Text processing method and device

    CN113220832A

  • Answer selection method and device, equipment and storage medium

    CN114510561A