Text processing method, apparatus, computer program product, device, and storage medium

By clustering candidate input texts obtained from text input logs and selecting representative target input texts to construct text pairs, the problems of low coverage and high resource consumption in existing technologies are solved, and a more efficient text response service is achieved.

CN116136867BActive Publication Date: 2026-03-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-18
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively improve coverage and consume significant resources when constructing text pairs in a database, resulting in low response efficiency.

Method used

By obtaining candidate input texts from text input logs, performing clustering processing, selecting representative target input texts, and combining them with response texts to construct text pairs, the repetitive construction operation is reduced.

Benefits of technology

It improves the coverage of text pairs and the database, while saving processing resources and improving the efficiency of response services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116136867B_ABST
    Figure CN116136867B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a text processing method, device, computer program product, equipment and storage medium, wherein the text processing method comprises: obtaining a text input log generated in a process of historically providing a text response service; obtaining M candidate input texts from the text input log, M being an integer greater than 1; performing clustering processing on the M candidate input texts to obtain one or more clustered text groups; selecting one or more candidate input texts in each clustered text group as target input texts; obtaining a response text set and selecting one or more response texts for each target input text in the response text set; constructing a plurality of text pairs by using each target input text and the corresponding response text respectively, and providing a text response service based on the plurality of text pairs. Embodiments of the present application can select representative and high-coverage target input texts to construct a plurality of text pairs.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, in particular to the technical field of computer, and especially to a text processing method and device, a computer program product, equipment and a storage medium. BACKGROUND

[0002] At present, with the continuous development of Internet technology, human-computer interaction (HCI) has been widely applied. The so-called human-computer interaction refers to the information exchange process between a person and a computer using a certain dialogue language and in a certain interactive manner to complete a certain task. In the process of human-computer interaction, the user can input the input text into the computer device, and then the computer device can detect the input text input by the user, so as to query and output the response text for responding to the input text in all text pairs contained in the database. Based on this, how to construct the text pairs stored in the database has become a research hotspot. SUMMARY

[0003] The embodiments of the present application provide a text processing method, device, computer program product, equipment and storage medium, which can select a target input text with representativeness and high coverage to construct a plurality of text pairs, so as to provide a text response service based on the constructed plurality of text pairs.

[0004] In one aspect, the embodiments of the present application provide a text processing method, which comprises:

[0005] Obtaining a text input log generated in the process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1;

[0006] Performing clustering processing on the M candidate input texts to obtain one or more clustering text groups; and selecting one or more candidate input texts in each clustering text group as a target input text;

[0007] Obtaining a response text set, and selecting one or more response texts for each target input text in the response text set;

[0008] Respectively constructing a text pair by using each target input text and the corresponding response text, obtaining a plurality of text pairs, and providing the text response service based on the plurality of text pairs.

[0009] In another aspect, the embodiments of the present application provide a text processing device, which comprises:

[0010] obtaining a text input log generated in a process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1;

[0011] clustering the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts in each clustered text group as a target input text, respectively;

[0012] The obtaining unit is further configured to obtain a response text set, and select one or more response texts for each target input text in the response text set;

[0013] The constructing unit is configured to construct a text pair by using each target input text and a corresponding response text, respectively, to obtain a plurality of text pairs, and provide the text response service based on the plurality of text pairs.

[0014] In another aspect, an embodiment of the present application provides a computer program product, which, when executed by a processor, implements the following steps:

[0015] obtaining a text input log generated in a process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1;

[0016] clustering the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts in each clustered text group as a target input text, respectively;

[0017] obtaining a response text set, and selecting one or more response texts for each target input text in the response text set;

[0018] constructing a text pair by using each target input text and a corresponding response text, respectively, to obtain a plurality of text pairs, and providing the text response service based on the plurality of text pairs.

[0019] In another aspect, an embodiment of the present application provides a computer device, which comprises a processor and a memory, wherein the memory is configured to store a computer program, and the computer program, when executed by the processor, implements the following steps:

[0020] obtaining a text input log generated in a process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1;

[0021] clustering the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts in each of the clustered text groups as target input texts, respectively;

[0022] obtaining a set of response texts, and selecting one or more response texts for each target input text in the set of response texts;

[0023] constructing text pairs by using each target input text and the corresponding response text, respectively, to obtain a plurality of text pairs, and providing the text response service based on the plurality of text pairs.

[0024] In yet another aspect, an embodiment of the present application provides a computer storage medium storing one or more instructions adapted to be loaded and executed by a processor to perform the following steps:

[0025] obtaining a set of response texts, and selecting one or more response texts for each target input text in the set of response texts;

[0026] clustering the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts in each of the clustered text groups as target input texts, respectively;

[0027] obtaining a set of response texts, and selecting one or more response texts for each target input text in the set of response texts;

[0028] constructing text pairs by using each target input text and the corresponding response text, respectively, to obtain a plurality of text pairs, and providing the text response service based on the plurality of text pairs.

[0029] The embodiment of the present application can obtain M candidate input texts from the text input log, and perform clustering processing on the M candidate input texts, so as to select one or more candidate input texts in each clustering text group obtained by clustering as a target input text, and each target input text is used to represent each candidate input text under the category corresponding to the corresponding clustering text group. Then, one or more response texts can be selected for each target input text in the response text set, so as to construct a text pair by using each target input text and the corresponding response text, and obtain a plurality of text pairs. It can be seen that, in the construction process of the text pair, the selection optimization of the input text can be realized by the clustering processing and the text selection operation. By selecting the representative target input text to construct the text pair, the text pair obtained by construction can be suitable for each input text under the category to which the target input text belongs, and the coverage of the text pair is improved to a certain extent. Moreover, this can avoid performing the text pair construction operation on each input text under the same category, and the processing resources can be effectively saved. Further, since the text input log is generated in the process of providing the text response service historically, the text input log can cover a large number of real input texts, so that the target input text obtained based on the text input log is not only real, but also has a high coverage, thereby improving the coverage of the text pair constructed based on the target input text, and further improving the coverage of the database after adding the plurality of text pairs to the database. BRIEF DESCRIPTION OF DRAWINGS

[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0031] Figure 1a is a flow diagram of a text processing scheme provided by an embodiment of the present application;

[0032] Figure 1b is a schematic diagram of a text response service provided by an embodiment of the present application;

[0033] Figure 2 is a flow diagram of a text processing method provided by an embodiment of the present application;

[0034] Figure 3 is a flow diagram of another text processing method provided by an embodiment of the present application;

[0035] Figure 4 is a schematic diagram of a semantic component analysis process provided by an embodiment of the present application;

[0036] Figure 5 is a flowchart of a candidate input text recall provided by an embodiment of the present application;

[0037] Figure 6 is a flowchart of a computing model loss value provided by an embodiment of the present application;

[0038] Figure 7 is a structural diagram of a text processing device provided by an embodiment of the present application;

[0039] Figure 8 is a structural diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0040] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.

[0041] With the continuous development of Internet technology, artificial intelligence (AI) technology has also been better developed. The so-called artificial intelligence technology refers to the use of digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science; it mainly simulates the essence of intelligence, produces a new intelligent machine that can react in a similar way to human intelligence, so that the intelligent machine has the functions of perception, reasoning and decision making. Correspondingly, AI technology is a comprehensive discipline, which mainly includes computer vision technology (CV), speech processing technology, natural language processing technology (NLP) and machine learning (ML) / deep learning and several other directions.

[0042] Among them, natural language processing is an important direction in the field of computer science and artificial intelligence, which studies various theories and methods that can realize effective communication between people and computers with natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics, so the research in this field will involve natural language, i.e. the language used in daily life, so it is closely related to the study of linguistics. It can be understood that natural language processing is the field of computer science, artificial intelligence and linguistics focusing on the interaction between computers and human (natural) language.

[0043] Based on natural language processing technology, an embodiment of the present application proposes a text processing scheme, which mainly realizes the construction of multiple text pairs by obtaining a target input text with representativeness and high coverage. In specific implementation, the text processing scheme can be executed by a computer device, which can be a terminal or a server; the terminal can include but is not limited to a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, a smart television, a smart vehicle terminal, etc.; various kinds of clients (application, APP) can be run in the terminal, such as a video playing client, a social client, a browser client, an information flow client, an education client, etc. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platform, etc.

[0044] It should be noted that in other embodiments, the text processing scheme can also be executed by the server and the terminal together; the server and the terminal are connected through a network (such as a wired network, a wireless network, etc.), which is not limited. Moreover, the computer device mentioned in the embodiments of the present application can be located outside the blockchain network or inside the blockchain network, which is not limited; the so-called blockchain network is a network composed of a point-to-point network (P2P network) and a blockchain, and the blockchain refers to a new application mode of distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. computer technology, which is essentially a decentralized database, a series of data blocks (or blocks) associated using cryptographic methods.

[0045] It is worth noting that the text in the embodiments of the present application can refer to the form of written language, and from the literary point of view, it is usually a complete and systematic meaning of a sentence or a combination of multiple sentences. A text can be a sentence, a paragraph, or a chapter. It can be understood that the above-mentioned text can include but is not limited to: declarative sentences, interrogative sentences, imperative sentences, etc. Among them, the so-called declarative sentence refers to a sentence type that states a fact or the speaker's opinion, and the declarative sentence is divided into affirmative declarative sentence (i.e. affirmative sentence, such as "this year is 2021") and negative declarative sentence (i.e. negative sentence, such as "this year is not 2021"); the so-called interrogative sentence refers to a sentence type used to express interrogative mood, such as "What is the year of this year?"; the so-called imperative sentence refers to a sentence type used to express the mood of asking the other party to do or not to do something, i.e. a sentence type used to express the mood of request, command, advice, etc., such as "Please query the current year!" Further, the above-mentioned text can include one or more of the declarative sentence, interrogative sentence or imperative sentence, which is not limited in the present application.

[0046] Referring to Figure 1a The general principle of the text processing scheme proposed in the embodiments of the present application is as follows:

[0047] ①Obtain the target input text. In a specific implementation, the computer device can obtain candidate input texts under multiple categories from the text input log, and select one or more candidate input texts from the candidate input texts under each category as the target input text. Among them, the text input log can be generated by the computer device in the process of providing the text response service in history, and the text response service here can refer to the function of querying and outputting response information for responding to the query input text when detecting the query input text. The so-called query input text can refer to the text input by the user to the computer device. It should be noted that the computer device can store the detected query input text into the text input log when detecting the query input text input by the user.

[0048] For example, as Figure 1b shown, assuming that the user inputs "today is what day?" to the computer device, i.e. when the query input text is "today is what day?", the computer device can detect the query input text input by the user, and save the query input text "today is what day?" to the text input log in the process of providing the text response service. Further, assuming that today is November 8, then the computer device can output the response information "November 8" in the process of providing the text response service. It should be noted that Figure 1bThe description of the computer device's performance when providing a text response service is merely illustrative. For example, when the computer device detects the above-mentioned query input text, the response information could also be "Today's date is November 8th," etc. This application does not limit the specific performance of the text response service.

[0049] It should be noted that in the specific embodiments of this application, the query input text involved by the user is required. When the embodiments of this application are applied to specific products or technologies, the acquisition of user-related data (such as input text) requires the user's permission or consent, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0050] ② Obtain the response text set, and select one or more response texts from the response text set for each target input text. Here, response text can refer to the text output when responding to the target input text.

[0051] ③ Extract text segments corresponding to each target input text from the response text corresponding to each target input text. Specifically, for any target input text and any response text corresponding to that target input text, the computer device can extract text segments corresponding to that target input text from the aforementioned response text. It should be noted that the number of text segments corresponding to any target input text is equal to the number of response texts corresponding to that target input text.

[0052] ④ Construct a text pair corresponding to each target input text and save the constructed text pairs to the database. Specifically, the computer device can construct a text pair corresponding to each target input text based on the text fragments obtained in step ③. A text pair includes a target input text and a text fragment.

[0053] It is worth noting that the above is only an example of the general principles of the text processing scheme, and does not limit it. For example, in the above process, after the computer device obtains the response text corresponding to each target input text through step ②, it can extract the text segment corresponding to each target input text from the response text corresponding to each target input text through step ③, and then construct the text pair corresponding to each target input text through step ④. A text pair can include a target input text and a text segment; but in other embodiments, the computer device can directly use each target input text and the corresponding response text to construct a text pair after obtaining the response text corresponding to each target input text through step ②. A text pair can include a target input text and a response text; for example, the computer device can also execute steps ①-④ every preset time interval to update the text pairs included in the database, and so on. Optionally, the above preset time interval can be one week, one month, etc.

[0054] It has been found through practice that the text processing scheme proposed in the embodiments of the present application can have at least the following advantages:

[0055] First, candidate input texts under multiple categories can be obtained from the text input log, and representative target input texts can be selected from the candidate input texts under each category. Each target input text can be used to represent the candidate input texts under the corresponding category. Second, the construction of text pairs through representative target input texts can improve the coverage of text pairs to some extent. Third, since the text input log can save a large number of query input texts, the target input texts obtained can be real input texts with high coverage, thereby improving the coverage of the constructed text pairs and further improving the coverage of the database.

[0056] Further, the above text processing scheme can be applied to various application scenarios, such as medical insurance consultation scenarios, poetry search scenarios, etc.

[0057] For example, when the above text processing scheme is applied to a medical insurance consultation scenario, the target input text mentioned above can be a target medical insurance question such as "Method for logging into an electronic medical insurance card by mobile phone", "What are the off-site designated medical institutions", and the like; correspondingly, the response text mentioned above can refer to a medical insurance document, which is usually an unstructured document published by a local or national medical insurance bureau, and is used to introduce medical insurance-related policies. The content of the medical insurance document is usually lengthy and has a large amount of information; and the text segment corresponding to each target input text obtained by the computer device can refer to a medical insurance answer corresponding to each target input text. In this case, the computer device can provide a text response service for the medical insurance consultation scenario, and the query input text at this time can refer to a query medical insurance question, and the response information responding to the query medical insurance question can refer to a medical insurance answer. The query medical insurance question input by the user to the computer device, and the text input log can include the medical insurance question input by the user.

[0058] Further, the computer device can obtain candidate medical insurance questions under each category from the text input log, and obtain one or more target medical insurance questions from the candidate medical insurance questions under each category; secondly, one or more medical insurance documents are selected for each target medical insurance question from the medical insurance document set, and for any target medical insurance question, a medical insurance answer corresponding to the any target medical insurance question is extracted from each medical insurance document corresponding to the any target medical insurance question. After obtaining the medical insurance answer corresponding to each target medical insurance question, the computer device can construct a question-answer pair (i.e., a text pair) based on each target medical insurance question and the corresponding medical insurance answer, and one question-answer pair includes one target medical insurance question and one corresponding medical insurance answer; and save the constructed question-answer pair to a database to provide a text response service based on the question-answer pair in the database.

[0059] For another example, when the above text processing scheme is applied to a poem search scenario, the target input text mentioned above can be a target poem such as "Moonlight in front of the bed", "Think of home more often during the holidays", and the like, and the response text mentioned above can refer to a poem document. The poem document contains information about one or more poems, and the text segment corresponding to each target input text obtained by the computer device can refer to poem information corresponding to each target input text. In this case, the computer device can provide a text response service for the poem search scenario, and the query input text at this time can refer to a query poem, and the response information responding to the query poem can refer to poem information. The query poem input by the user to the computer device, and the text input log can include the poem input by the user.

[0060] Further, the computer device can obtain candidate poems under each category from the text input log, and obtain one or more target poems from the candidate poems under each category; secondly, select one or more poem literatures for each target poem from the poem literature set, and for any target poem, extract the poem information corresponding to the any target poem in each poem literature corresponding to the any target poem. After obtaining the poem information corresponding to each target poem, the computer device can construct a poem pair (i.e. a text pair) based on each target poem and the corresponding poem information, and save the constructed poem pair to the database to provide a text response service based on the poem pair in the database.

[0061] Based on the above description of the text processing scheme, the embodiment of the present application proposes a text processing method, which can be executed by the above-mentioned computer device, which can be a terminal or a server; or the text processing method can be executed by the terminal and the server together. For convenience of description, the text processing method executed by the computer device is taken as an example for description hereinafter; please refer to Figure 2 The text processing method can include the following steps S201-S204:

[0062] S201, obtaining a text input log generated in the process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1.

[0063] In the process of providing a text response service, the computer device can detect a query input text input by a user; after detecting the query input text, query and output corresponding response information from the database. Specifically, after detecting the query input text, the computer device can determine a matching input text in the database that matches the query input text, take the information of the matching input text and the input text in the database that constitutes a text pair as the above-mentioned response information, and output the corresponding response information. It can be understood that the matching input text matched with the response information and the query input text can constitute one or more text pairs in the database. Wherein, the matching input text refers to the input text of the text pair already constructed in the database, and the response information refers to the information output for responding to the query input text.

[0064] Further, the computer device can save the detected query input text to the text input log each time the computer device detects the query input text input by the user; the computer device can also first determine whether there is an input text identical to the query input text in the text input log, if not, save the query input text to the text input log, otherwise do not perform the saving operation.

[0065] It should be noted that in the process of obtaining M candidate input texts from the text input log, the computer device can obtain all the input texts in the text input log as the M candidate input texts, that is, the value of M is equal to the number of all the input texts in the text input log; the computer device can also first determine the paired input texts in the database, and then obtain all the input texts in the text input log except the paired input texts as the M candidate input texts, that is, the value of M is equal to the difference between the number of all the input texts in the text input log and the number of the paired input texts in the database. The specific obtaining manner of the M candidate input texts is not limited in the present application.

[0066] S202, performing clustering processing on the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts in each clustered text group as target input texts.

[0067] It should be noted that the target input text includes but is not limited to: target question, target article paragraph, target poem, etc. In other words, the sentence type contained in the target input text can include but is not limited to: interrogative sentence, declarative sentence, imperative sentence, etc.

[0068] Optionally, the computer device can select one candidate input text in each clustered text group as a target input text, in which case the number of target input texts is equal to the number of clustered text groups; the computer device can also determine the number of candidate input texts selected in each clustered text group according to the number of candidate input texts included in each clustered text group, in which case the number of candidate input texts selected from any clustered text group is positively correlated with the number of all candidate input texts in the any clustered text group. The specific selection manner of the candidate input text is not limited in the present application, that is, the specific obtaining manner of the target input text is not limited in the present application.

[0069] S203, obtaining a response text set, and selecting one or more response texts for each target input text in the response text set.

[0070] The above-mentioned response text can refer to the text output when responding to the target input text; the response text can be a response article or a response paragraph, and the specific form of the response text is not limited in the present application.

[0071] Optionally, the computer device can download the response text set from the cloud according to a user instruction, or obtain the response text set from a mobile storage provided by the user, which can be a mobile hard disk or a USB flash disk, etc. The computer device can also obtain the response text set from a storage space of the computer device, for example, when the response text set is stored in a read-only memory (ROM) of the computer device, the computer device can obtain the response text set from the ROM, etc.

[0072] S204, respectively, using each target input text and the corresponding response text to construct a text pair, obtaining a plurality of text pairs to provide a text response service based on the plurality of text pairs.

[0073] In a specific implementation, the computer device can directly use each target input text and the corresponding response text to construct a text pair, that is, any text pair in the plurality of text pairs can include one target input text and one corresponding response text. The computer device can also extract corresponding text segments for each target input text from the corresponding response text, and use each target input text and the corresponding text segment to construct a text pair, that is, any text pair in the plurality of text pairs can include one target input text and one corresponding text segment, which is not limited in the present application.

[0074] It should be noted that when the computer device constructs the plurality of text pairs based on each target input text and the corresponding text segment, for any target input text, the computer device can use all text segments corresponding to the any target input text to construct a text pair corresponding to the any target input text, at this time, the number of text pairs corresponding to the any target input text is equal to the number of response texts corresponding to the any target input text. The computer device can also use one or more text segments in all text segments corresponding to the any target input text to construct a text pair corresponding to the any target input text, at this time, the number of text pairs corresponding to the any target input text is less than the number of response texts corresponding to the any target input text.

[0075] Further, the computer device can save the plurality of text pairs to the database, so as to update the text pairs in the database, and take the target input text as the pairing input text of the text pairs in the database. Optionally, in the process of updating the database, the computer device can take the plurality of text pairs as all the text pairs contained in the database, and in this case, the pairing input text in the database only includes the target input text, that is, the computer device can first clear the historical text pairs in the database, and then save the plurality of text pairs; or the computer device can add the plurality of text pairs to the database, and in this case, the pairing input text in the database includes the target input text and the historical input text. The historical text pairs can refer to the text pairs contained in the database before the plurality of text pairs are saved to the database, and correspondingly, the historical input text can refer to the pairing input text contained in the database before the plurality of text pairs are saved to the database, that is, the historical input text can refer to the input text in the text pairs contained in the database before the plurality of text pairs are saved to the database.

[0076] It should be noted that before saving the constructed text pairs, the constructed text pairs can also be quickly checked and corrected by manual operation, so as to obtain corrected text pairs, and then the computer device can save the corrected text pairs to the database.

[0077] It can be understood that if any of the plurality of text pairs includes a target input text and a corresponding response text, any of the text pairs in the database includes a pairing input text and a corresponding response text; and then in the process of providing the text response service, the computer device can output the response text in the text pair corresponding to the pairing input text matched with the query input text when detecting the query input text input by the user, that is, the response information can be the response text in the text pair corresponding to the pairing input text matched with the query input text. If any of the plurality of text pairs includes a target input text and a corresponding text segment, any of the text pairs in the database includes a pairing input text and a corresponding text segment; and then in the process of providing the text response service, the computer device can output the text segment in the text pair corresponding to the pairing input text matched with the query input text when detecting the query input text input by the user, that is, the response information can be the text segment in the text pair corresponding to the pairing input text matched with the query input text.

[0078] The embodiment of the present application can obtain M candidate input texts from the text input log, and perform clustering processing on the M candidate input texts, so as to select one or more candidate input texts in each clustering text group obtained by clustering as a target input text, and each target input text is used to represent each candidate input text in the category corresponding to the corresponding clustering text group. Then, one or more response texts can be selected for each target input text in the response text set, so as to construct a text pair by using each target input text and the corresponding response text, and obtain a plurality of text pairs. It can be seen that, in the construction process of the text pair, the embodiment of the present application can realize the optimization of the selection of the input text through the clustering processing and the text selection operation. By selecting the representative target input text to construct the text pair, the text pair obtained by construction can be suitable for each input text in the category to which the target input text belongs, and the coverage of the text pair is improved to a certain extent. Moreover, this can avoid performing the construction operation of the text pair for each input text in the same category, and can effectively save the processing resources. Further, since the text input log is generated in the process of providing the historical text response service, the text input log can cover a large number of real input texts, so that the target input text obtained based on the text input log is not only real, but also has a high coverage, thereby improving the coverage of the text pair constructed based on the target input text, and further improving the coverage of the database after adding the plurality of text pairs to the database.

[0079] Please refer to Figure 3 is a flowchart of another text processing method provided by the embodiment of the present application. The text processing method can be executed by the computer device mentioned above, which can be a terminal or a server. Alternatively, the text processing method can be executed by the terminal and the server together. For the convenience of description, the computer device executes the text processing method is taken as an example for description hereinafter. Please refer to Figure 3 The text processing method can include the following steps S301-S308:

[0080] S301, obtaining a text input log generated in the process of providing the historical text response service; and obtaining M candidate input texts from the text input log, M is an integer greater than 1.

[0081] For example, the computer device can provide a text response service through an intelligent question answering system, which can automatically answer the query input text input by the user by using a machine algorithm; correspondingly, the text pair in the database can refer to a question-answer pair, a question-answer pair including a question and a corresponding answer content, wherein the question in the question-answer pair can refer to the paired input text, and the answer content in the question-answer pair can refer to information such as response text, text segment, etc. which forms a text pair with the paired input text, and the answer content is a precise answer around the query input text, which is usually concise and focused. It can be understood that the answering effect not only depends on the semantic matching effect, that is, the accuracy of determining the paired input text matched with the query input text; the answering effect also depends on the coverage of the text pair in the database.

[0082] It should be noted that the database for providing a text response service can include but is not limited to question-answer pairs, poem pairs, article paragraph pairs, etc.; correspondingly, the paired input text in the database can include but is not limited to paired questions, paired poems, paired article paragraphs, etc. Further, if the query input text input by the user is a query question, the response information output by the computer device can be the answer content corresponding to the paired question matched with the query input text; if the query input text input by the user is a query poem, the response information output by the computer device can be poem information (such as the poet of the poem, the complete content corresponding to the poem) corresponding to the paired poem matched with the query input text; if the query input text input by the user is a query article paragraph, the response information output by the computer device can be article information (such as the author of the article, the publication date of the article) corresponding to the paired article paragraph matched with the query input text, etc.

[0083] In a specific implementation, the user can directly input characters in the computer device, and then the computer device can directly take the characters input by the user as the query input text; the user can also input voice to the computer device, and then the computer device can convert the voice input by the user into the query input text, and the specific acquisition method of the query input text is not limited in the present application.

[0084] S302, clustering processing is performed on the M candidate input texts to obtain one or more clustered text groups; and one or more candidate input texts are selected as target input texts in each clustered text group, respectively.

[0085] In an embodiment, the computer device performs clustering processing on the M candidate input texts to obtain one or more clustered text groups, and the specific implementation process can be: performing vector coding on each of the M candidate input texts to obtain a text vector of each candidate input text; and performing clustering processing on the M candidate input texts by using the text vector of each candidate input text to obtain one or more clustered text groups. In this case, the distance between candidate input texts in the same clustered text group is smaller than the distance between candidate input texts in different clustered text groups.

[0086] In another embodiment, the computer device performs clustering processing on the M candidate input texts to obtain one or more clustered text groups, and the specific implementation process can be: performing semantic component analysis on each of the M candidate input texts to obtain a semantic component of each candidate input text, wherein the semantic component of any candidate input text includes at least one of the following: an intent type and entity information; and performing grouping processing on the M candidate input texts according to the semantic components of the candidate input texts to obtain one or more clustered text groups, according to the principle that candidate input texts with matching semantic components are divided into a text group. In this case, the semantic components of candidate input texts in the same clustered text group are the same or similar, and the semantic components of candidate input texts in different clustered text groups are different or dissimilar, that is, the above-mentioned candidate input texts with matching semantic components can refer to candidate input texts with the same or similar semantic components.

[0087] Optionally, the computer device can select one candidate input text as a target input text from the candidate input texts under the same semantic component; for any semantic component, the computer device can also determine the number of candidate input texts under the semantic component, and select one or more candidate input texts as target input texts from the candidate input texts under the semantic component according to the number of candidate input texts under the semantic component, in which case, the number of candidate input texts selected by the computer device is positively correlated with the number of candidate input texts under the semantic component. The specific selection manner of the candidate input texts is not limited in the present application.

[0088] For example, assuming that the M candidate input texts include "How to log in to the electronic medical insurance card by using the mobile phone", "How to log in to the electronic medical insurance card by the mobile phone", "Method of logging in to the electronic medical insurance card by the mobile phone", etc., the computer device can perform semantic component analysis on each candidate input text, so as to determine that the semantic components of the candidate input texts "How to log in to the electronic medical insurance card by using the mobile phone", "How to log in to the electronic medical insurance card by the mobile phone", and "Method of logging in to the electronic medical insurance card by the mobile phone" match each other. In this case, when clustering the M candidate input texts, the computer device can divide the candidate input texts "How to log in to the electronic medical insurance card by using the mobile phone", "How to log in to the electronic medical insurance card by the mobile phone", and "Method of logging in to the electronic medical insurance card by the mobile phone" into the same cluster text group, and then the computer device can select one or more candidate input texts from the candidate input texts "How to log in to the electronic medical insurance card by using the mobile phone", "How to log in to the electronic medical insurance card by the mobile phone", and "Method of logging in to the electronic medical insurance card by the mobile phone" as the target input text, so as to avoid selecting a large number of candidate input texts with the same or similar semantic components as the target input text.

[0089] Further, the above-mentioned entity information can be used to represent information of one or more entity indications in the preset entity set. For example, assuming that the preset entity set includes a target entity, an action entity, and a target entity attribute, wherein the target entity can refer to a thing name, the action entity can refer to an implemented behavior, and the target entity attribute can refer to a type corresponding to the target entity; when performing semantic component analysis on the candidate input text "How to buy a resident medical insurance", the computer device can obtain the entity information of the candidate input text, and the entity information can be used to represent information of a target entity indication "medical insurance", information of an action entity indication "buy", and information of a target entity attribute indication "resident".

[0090] Correspondingly, the intent type of any candidate input text can be any intent type in the preset intent type set, that is, the computer device can determine the intent type of any candidate input text, and the intent type of the any candidate input text belongs to the preset intent type set, and the preset intent type set includes one or more intent types. For example, the preset intent type set can include the seven intent types shown in Table 1:

[0091] Table 1

[0092] Intention type Candidate input text examples Time (when) When is the payment period for urban and rural residents' medical insurance? Location (where) Where can medical insurance payment be handled? Method (how) How to claim for chronic diseases? Reason (why) Why should I bind a bank card? What (what) What are the designated medical institutions in other places? Which (which) Is medical insurance paid monthly or annually? Whether (whether) Can registration fees be reimbursed?

[0093] In this case, if the preset intent type set includes all the intent types shown in Table 1, then the intent type of any candidate input text determined by the computer device is any intent type in all the intent types shown in Table 1, such as a reason.

[0094] Optionally, the preset intent type set can also include reasons, effects, methods, etc. The specific content of the preset intent type set is not limited in the present application. Correspondingly, the above-mentioned preset entity set can also contain time entities, location entities, etc. The specific content of the preset entity set is not limited in the present application. It can be understood that the computer device can perform semantic component analysis on each candidate input text according to different preset intent type sets and different preset entity sets, thereby obtaining the semantic components of each candidate input text.

[0095] It should be noted that when the semantic components of any candidate input text include an intent type, the specific implementation process of the computer device performing semantic component analysis on each of the M candidate input texts to obtain the semantic components of each candidate input text can include: performing character splitting on the mth candidate input text in the M candidate input texts to obtain a plurality of characters, m∈[1, M]; performing vector encoding of context semantic analysis on the mth candidate input text and each character in the plurality of characters to obtain a text vector of the mth candidate input text and a plurality of character vectors; performing intent classification on the mth candidate input text based on the text vector of the mth candidate input text and the plurality of character vectors to obtain an intent type of the mth candidate input text.

[0096] Optionally, the computer device can use BERT (Bidirectional Encoder Representation from Transformers, a language model based on bidirectional attention), ELMo (Embeddings from Language Models, a language model based on bidirectional long short-term memory network), etc. Model to perform vector encoding of context semantic analysis on the mth candidate input text and each character in the plurality of characters, i.e. the obtained text vector of the mth candidate input text and the plurality of character vectors can contain rich semantic information. The specific implementation of the vector encoding of the context semantic analysis is not limited in the present application.

[0097] Furthermore, when the semantic components of any of the aforementioned candidate input texts include entity information, the specific implementation process of the computer device performing semantic component analysis on each of the M candidate input texts to obtain the semantic components of each candidate input text may include: splitting the m-th candidate input text among the M candidate input texts into multiple characters, m∈[1,M]; performing context semantic analysis and vector encoding on the multiple characters to obtain multiple character vectors; and using the multiple character vectors to perform named entity recognition on the m-th candidate input text to obtain the entity information of the m-th candidate input text. Here, named entity recognition refers to recognizing entities with specific meanings in the text, mainly including personal names, place names, organization names, proper nouns, etc.

[0098] Optionally, the computer device can perform named entity recognition on the m-th candidate input text using CRF (Conditional Random Field), LSTM (Long Short-Term Memory), etc. This application does not limit the specific implementation of named entity recognition.

[0099] It should be noted that during the named entity recognition process for the m-th candidate input text, the computer device can use BIO annotation, BIOSE annotation, etc., to perform sequence labeling on multiple characters in the m-th candidate input text, thereby obtaining the predicted label corresponding to each character in the m-th candidate input text; and based on the predicted label corresponding to each character, the entity information in the m-th candidate input text is determined. For example, assuming the computer device uses BIOSE annotation for sequence labeling, the computer device can use B to represent the beginning of a word, I to represent the middle character of a word, O to represent other characters (i.e., used to mark irrelevant characters), S to represent a single character, and E to represent the end of a word; after completing the sequence labeling, the computer device can merge the characters labeled B, I, and E in the predicted labels to obtain the corresponding entity information.

[0100] For example, such as Figure 4 As shown, the computer device can employ a BERT-based multi-task recognition scheme to obtain the intent type and entity information of each candidate input text. When the computer device obtains the intent type and entity information of the m-th candidate input text, [CLS] is used to represent the m-th candidate input text, Tok1 to Tok... N This is used to represent each character in the m-th candidate input text. The computer device can convert the m-th candidate input text into a vector representation, obtaining vector E. [CLS]and convert each character of the mth candidate input text into a vector representation to obtain vectors E1-E N In this case, the computer device can perform context semantic analysis on the vectors E [CLS] and the vector encoding of the vectors E1-E N to obtain a text vector C and a plurality of character vectors T1-T N Further, the computer device can perform intent classification and named entity recognition using the text vector C and the plurality of character vectors T1-T N to obtain semantic components of the mth candidate input text. Assuming that the mth candidate input text is "Why bind the bank card", the intent type in the semantic components obtained by the computer device is reason, and the entity information of the semantic components includes "bind" and "bank card". That is, assuming that the above-mentioned preset entity set includes target entity, action entity, target entity attribute, etc., the entity information here can include the action entity "bind" and the target entity "bank card", that is, the entity information here can be used to represent the information indicated by the action entity as "bind" and the information indicated by the target entity as "bank card".

[0101] S303, obtaining a response text set, and selecting one or more response texts for each target input text in the response text set.

[0102] Specifically, the computer device can traverse each target input text, and take the currently traversed target input text as a current target input text. Next, the computer device can perform semantic analysis on the current target input text to obtain a semantic vector of the current target input text, and perform semantic analysis on each response text in the response text set to obtain a semantic vector of each response text. Then, the computer device can calculate the matching degree between the current target input text and each response text based on the semantic vector of the current target input text and the semantic vector of each response text; recall the response text with a matching degree greater than a matching degree threshold from the response text set as the response text corresponding to the current target input text. The matching degree between the current target input text and each response text can refer to the Euclidean distance between the current target input text and each response text, or the Mahalanobis distance between the current target input text and each response text, etc.

[0103] It should be noted that the computer device can use models such as BERT and ELMo to perform semantic analysis on the current target input text to obtain the semantic vector of the current target input text; and use models such as BERT and ELMo to perform semantic analysis on each response text in the response text set to obtain the semantic vector of each response text. This application does not limit the specific implementation method of semantic analysis. It can be understood that the computer device can use BERT to perform vector encoding for contextual semantic analysis on the m-th candidate input text and each character among the above-mentioned multiple characters, and use BERT to perform semantic analysis on the current target input text; it can use ELMo to perform vector encoding for contextual semantic analysis on the m-th candidate input text and each character among the above-mentioned multiple characters, and use ELMo to perform semantic analysis on the current target input text, and so on; in this case, the vector acquisition method in step S302 is the same as the vector acquisition method here, that is, the vector encoding for contextual semantic analysis performed by the computer device and the method for performing semantic analysis by the computer device are the same. Correspondingly, the computer device can also use ELMo to perform contextual semantic analysis vector encoding on the m-th candidate input text and each character among the above-mentioned multiple characters, and use BERT to perform semantic analysis on the current target input text. In this case, the vector acquisition method in step S302 is different from the vector acquisition method here.

[0104] For example, such as Figure 5 As shown, a computer device can use vector retrieval to select one or more response texts from a set of response texts for the current target input text. Assuming the computer device uses BERT for semantic analysis (i.e., BERT for vector encoding), it can obtain the semantic vector of the current target input text and the semantic vectors of each response text in the response text set. Next, the computer device can perform vector retrieval on each response text to obtain the vector retrieval results, and use these results as the response texts corresponding to the current target input text. In other words, the computer device can calculate the matching degree between the current target input text and each response text based on the semantic vector of the current target input text and the semantic vectors of each response text, and recall the k response texts with a matching degree greater than a matching degree threshold as the vector retrieval results. That is, the k closest response texts to the current target input text are used as the response texts corresponding to the current target input text, where k is a positive integer. It should be noted that the computer device can also use an inverted index recall method to recall the corresponding response texts from the set of response texts for the current target input text; this application does not limit the recall method for response texts.

[0105] Optionally, the matching degree threshold can be a fixed threshold set by the computer device, or a dynamic threshold obtained according to the matching degrees between the current target input text and the respective response texts, which is not limited in the present application. For example, assuming that the value of k is a fixed value, the computer device can sort the respective response texts in descending order of the matching degrees between the current target input text and the respective response texts to obtain a response text sorting result. In this case, the computer device can select a value between the matching degree corresponding to the kth response text and the matching degree corresponding to the k+1th response text in the response text sorting result as the matching degree threshold, k being a positive integer. In other words, the matching degree threshold is less than the matching degree corresponding to the kth response text, and greater than or equal to the matching degree corresponding to the k+1th response text.

[0106] In an implementation, the semantic vector of the current target input text and the semantic vectors of the respective response texts are obtained by a vector calculation model. The computer device can obtain one or more training sample sets, each training sample set including a training input text, a first training response text and a second training response text. The first training response text in any training sample set refers to a response text having an association relationship with the training input text in the training sample set, and the second training response text in any training sample set refers to a response text not having an association relationship with the training input text in the training sample set. The one or more training sample sets and a preset distance threshold are used to determine a model loss value of the vector calculation model, and the vector calculation model is optimized in a direction of reducing the model loss value.

[0107] Specifically, when obtaining the one or more training sample sets, for any training sample set, the computer device can randomly select a training input text in a text relationship log as the training input text in the training sample set. The text relationship log includes one or more training input texts and response texts having an association relationship with the respective training input texts. Correspondingly, the computer device can select a response text having an association relationship with the corresponding training input text in the text relationship log as the first training response text in the training sample set, and randomly select a response text from a database as the second training response text in the training sample set. Optionally, the text relationship log can be set by the computer device, or when detecting a query input text input by a user and a corresponding browsing operation, the computer device can save the query input text as a training input text in the text relationship log, and save a response text acted on by the corresponding browsing operation as a response text having an association relationship with the training input text, which is not limited in the present application.

[0108] It should be noted that in the specific embodiments of the present application, the data related to the query input text input by the user and the corresponding response text acted on by the browsing operation, when the embodiments of the present application are applied to specific products or technologies, the acquisition of the data related to the user (such as the input text) needs to obtain the permission or consent of the user, and the collection, use and processing of the related data need to comply with the relevant laws, regulations and standards of the country and region.

[0109] In this case, the computer device can use formula 1.1 to obtain the model loss value L of the vector calculation model:

[0110]

[0111] Wherein, Q is the number of training sample sets, q (i) is the semantic vector of the training input text in the i-th training sample set, d + (i) is the semantic vector of the first training response text in the i-th training sample set, d - (i) is the semantic vector of the second training response text in the i-th training sample set, D(u, v) is used to measure the distance between two semantic vectors. It can be understood that when the distance between the training input text in any training sample set and the second training response text in the any training sample set is greater than or equal to the preset distance threshold n than the distance between the training input text in the any training sample set and the first training response text in the any training sample set, the computer device can stop updating the model parameters of the vector calculation model. Optionally, the above-mentioned preset distance threshold can be 60, or 70, etc.

[0112] It should be noted that the computer device can use the Euclidean distance to calculate the distance between two semantic vectors, or use the cosine similarity to calculate the distance between two semantic vectors, and the present application does not limit the distance calculation method between two semantic vectors.

[0113] For example, as Figure 6As shown, assuming that the cosine similarity between two semantic vectors is taken as the distance between the two semantic vectors, and the semantic vectors are obtained by using the BERT, for any training sample set, the computer device can perform semantic analysis on the training input text, the first training response text and the second training response text in the any training sample set based on the BERT, i.e., BERT vector encoding, to obtain the semantic vector of the training input text, the semantic vector of the first training response text and the semantic vector of the second training response text in the any training sample set; calculate the cosine similarity between the training input text and the first training response text in the any training sample set, and calculate the cosine similarity between the training input text and the second training response text in the any training sample set, so as to determine the model loss value of the vector calculation model. It should be noted that the model loss value of the vector calculation model can also be referred to as the boundary triple loss value.

[0114] In S304, for any target input text, each response text corresponding to the target input text is scanned, and a currently scanned current response text is determined.

[0115] In S305, the current response text is subjected to reading comprehension to extract a text segment for responding to the target input text from the current response text.

[0116] Optionally, the computer device can use a reading comprehension model to perform reading comprehension on the current response text, where the reading comprehension model can be a BERT-based reading comprehension model, or an ASReader model (AttentiveSum Reader, a language model based on an attention mechanism), etc.; the specific implementation of reading comprehension is not limited in the present application.

[0117] It should be noted that the text segment corresponding to the target input text is output by calling the optimized reading comprehension model to perform reading comprehension on the current response text. In this case, the computer device can obtain a pseudo corpus for model optimization of the reading comprehension model, and the pseudo corpus includes one or more training sample groups; a training sample group includes a sample input text, a sample text segment and a sample response text; wherein any sample response text is obtained by text reconstruction based on the sample text segment in the same training sample group; and each training sample group in the pseudo corpus is used to perform supervised model training on the reading comprehension model to optimize the model parameters of the reading comprehension model, thereby obtaining the optimized reading comprehension model.

[0118] In a specific implementation, the specific implementation process in which the computer device obtains the pseudo-corpus for model optimization of the reading comprehension model can include: obtaining a sample text pair as a benchmark sample text pair from a plurality of preset sample text pairs, wherein each sample text pair includes a sample input text and a sample text segment; selecting one or more sample text segments from each sample text pair other than the benchmark sample text pair; splicing each selected sample text segment and the sample text segment in the benchmark sample text pair, and generating a sample response text based on the splicing result; and constructing a training sample group using the benchmark sample text pair and the generated sample response text. Optionally, the plurality of preset sample text pairs can be obtained by the computer device from its own storage space or downloaded from the cloud, and the present application does not limit this.

[0119] For example, assuming that the plurality of preset sample text pairs include sample text pairs (a1, c1), (a2, c2), and (a3, c3), and the benchmark sample text pair is (a1, c1), wherein a1, a2, and a3 represent a sample input text, and c1, c2, and c3 represent a sample text segment; then the computer device can select one or more sample text segments from the sample text pairs (a2, c2) and (a3, c3), and splice the selected sample text segments with the sample text segment in the benchmark sample text pair. Assuming that the sample text segment selected by the computer device is c2, the computer device can splice the sample text segments c1 and c2, and generate a sample response text based on the splicing result; assuming that the sample text segments selected by the computer device are c2 and c3, the computer device can splice the sample text segments c1, c2, and c3, and generate a sample response text based on the splicing result. Further, the computer device can construct a training sample group using the benchmark sample text pair and the generated sample response text.

[0120] Optionally, the computer device can directly use the splicing result as the generated sample response text, or can insert the splicing result into a preset response text to obtain the generated sample response text, and the present application does not limit this. For example, assuming that the computer device directly uses the splicing result as the generated sample response text, and the selected sample text segment is c2, the computer device can splice the sample text segments c1 and c2 to obtain the generated sample response text b1, where b1 is (c1+c2), and the training sample group constructed by the computer device is (a1, b1, c1).

[0121] It can be understood that the computer device can obtain a plurality of benchmark sample text pairs from the plurality of preset sample text pairs, and determine a sample response text corresponding to each benchmark sample text pair respectively, so as to construct a plurality of training sample groups.

[0122] In another implementation, the specific implementation process in which the computer device obtains the pseudo corpus for model optimization of the reading comprehension model can include: obtaining a sample text pair from the plurality of preset sample text pairs as a benchmark sample text pair, the sample text pair including a sample input text and a sample text segment; randomly selecting a response text from the database, and inserting the sample text segment in the benchmark sample text pair into the randomly selected response text to obtain a sample response text; and constructing a training sample group by using the benchmark sample text pair and the obtained sample response text.

[0123] For example, assuming that the plurality of preset sample text pairs include sample text pairs (a1, c1), (a2, c2), and (a3, c3), and the benchmark sample text pair is (a1, c1), where a1, a2, and a3 represent a sample input text respectively, and c1, c2, and c3 represent a sample text segment respectively, the computer device can randomly select a response text x1 from the database, and insert the sample text segment c1 into the randomly selected response text x1 to obtain a sample response text b1. Further, the computer device can construct a training sample group (a1, b1, c1) by using the benchmark sample text pair (a1, c1) and the obtained sample response text b1.

[0124] Similarly, the computer device can obtain a plurality of benchmark sample text pairs from the plurality of preset sample text pairs, and determine a sample response text corresponding to each benchmark sample text pair respectively, so as to construct a plurality of training sample groups.

[0125] S306, after scanning each response text corresponding to any target input text pair, H text segments are obtained, and the value of H is equal to the number of response texts corresponding to the target input text pair.

[0126] It can be understood that the computer device can extract a text segment from any response text corresponding to any target input text pair, so as to obtain H text segments.

[0127] S307, at least one text pair is constructed by using the H text segments and the target input text pair. A text pair includes a text segment and the target input text pair.

[0128] Specifically, each of the H text segments has a confidence degree, and the computer device uses the H text segments and the any target input text to construct at least one text pair, and the specific implementation process can include: selecting P text segments with a confidence degree greater than a confidence degree threshold from the H text segments, P∈[1, H]; and using each of the P text segments and the any target input text to construct a text pair to obtain P text pairs.

[0129] Optionally, the confidence degree threshold can be a fixed threshold set by the computer, or a dynamic threshold obtained according to the confidence degrees of the text segments in the H text segments, and the present application does not limit this. For example, assuming that the value of P is a fixed value, the computer device can sort the H text segments in descending order of the confidence degrees of the text segments to obtain a text segment sorting result. In this case, if the value of P is less than the value of H, the computer device can select a value between the confidence degree of the Pth text segment and the confidence degree of the P+1th text segment in the text segment sorting result as the confidence degree threshold, that is, the confidence degree threshold is less than the confidence degree of the Pth text segment and greater than or equal to the confidence degree of the P+1th text segment; if the value of P is equal to the value of H, the computer device can select a value less than the confidence degree of the Pth text segment in the text segment sorting result as the confidence degree threshold.

[0130] S308, after using each target input text and the corresponding text segment to construct a text pair to obtain a plurality of text pairs, providing a text response service based on the plurality of text pairs.

[0131] The embodiment of the present application can obtain M candidate input texts from a text input log, and perform clustering processing on the M candidate input texts, so as to select a representative target input text in each clustering text group obtained by clustering. Since each target input text can represent each candidate input text under the category corresponding to the corresponding clustering text group, the construction of a text pair based on each target input text can improve the coverage of the text pair to a certain extent. Moreover, the text input log can include a large amount of real input texts, so that the target input texts obtained based on the text input log not only have authenticity, but also have high coverage, thereby improving the coverage of the constructed text pair, and further enabling the database for saving the text pair to have high coverage. In addition, one or more training sample sets and a preset distance threshold can be used to optimize the vector calculation model, thereby improving the recall ability of the response text with similar semantics, and thereby optimizing the retrieval of the response text. The reading comprehension model can also be optimized by the pseudo corpus for optimizing the reading comprehension model, the processing capability of the reading comprehension model is enhanced, the accuracy of extracting the text segment is improved, and the extraction capability of the long text segment is optimized.

[0132] Based on the description of the related embodiments of the above text processing method, the embodiment of the present application further proposes a text processing device, which can be a computer program (including program code) running in a computer device. The text processing device can perform the text processing method shown in Figure 2 or Figure 3 ; please refer to Figure 7 , the text processing device can run the following units:

[0133] The acquisition unit 701 is configured to acquire a text input log generated in the process of historically providing a text response service, and obtain M candidate input texts from the text input log, where M is an integer greater than 1.

[0134] The clustering unit 702 is configured to perform clustering processing on the M candidate input texts to obtain one or more clustering text groups, and select one or more candidate input texts in each clustering text group as target input texts.

[0135] The acquisition unit 701 is further configured to acquire a response text set, and select one or more response texts for each target input text in the response text set.

[0136] The construction unit 703 is configured to construct a text pair by using each target input text and the corresponding response text respectively, to obtain a plurality of text pairs, and to provide the text response service based on the plurality of text pairs.

[0137] In an implementation, the clustering unit 702, when used to cluster the M candidate input texts to obtain one or more clustered text groups, can be specifically used for:

[0138] performing semantic component analysis on each of the M candidate input texts to obtain a semantic component of the each candidate input text; the semantic component of any candidate input text comprises at least one of an intent type and entity information;

[0139] grouping the M candidate input texts according to the semantic components of the each candidate input text to obtain one or more clustered text groups according to a principle that candidate input texts with matching semantic components are divided into a text group.

[0140] In another implementation, the obtaining unit 701, when used to select one or more response texts for each target input text in the set of response texts, can be specifically used for:

[0141] traversing each target input text and taking a currently traversed target input text as a current target input text;

[0142] performing semantic analysis on the current target input text to obtain a semantic vector of the current target input text; and performing semantic analysis on each response text in the set of response texts to obtain a semantic vector of the each response text;

[0143] calculating a matching degree between the current target input text and the each response text based on the semantic vector of the current target input text and the semantic vector of the each response text;

[0144] recalling, from the set of response texts, a response text with a matching degree greater than a matching degree threshold as a response text corresponding to the current target input text.

[0145] In another implementation, the constructing unit 703, when used to construct a plurality of text pairs respectively using each target input text and a corresponding response text, can be specifically used for:

[0146] for any target input text, scanning each response text corresponding to the any target input text and determining a currently scanned current response text;

[0147] performing reading comprehension on the current response text to extract a text segment for responding to the any target input text from the current response text;

[0148] after scanning each response text corresponding to the any target input text, obtaining H text segments, where H is equal to a number of response texts corresponding to the any target input text.

[0149] adopting the H text segments and the any target input text, to construct at least one text pair; one text pair includes one text segment and the any target input text.

[0150] In another implementation, any text segment in the H text segments has a confidence; the constructing unit 703, in operation of adopting the H text segments and the any target input text, to construct at least one text pair, can be specifically configured to:

[0151] selecting P text segments with a confidence greater than a confidence threshold from the H text segments, P e [1, H];

[0152] adopting each text segment in the P text segments and the any target input text, respectively, to construct one text pair, to obtain P text pairs.

[0153] In another implementation, the text processing apparatus further includes an optimization unit 704, and the text segment corresponding to the any target input text is output by calling the optimized reading comprehension model to perform reading comprehension on the current response text; the obtaining unit 701 can be further configured to:

[0154] obtain pseudo corpus for model optimization of the reading comprehension model, the pseudo corpus including one or more training sample groups; one training sample group includes a sample input text, a sample text segment, and a sample response text; wherein any sample response text is obtained by text reconstruction based on the sample text segment in the same training sample group;

[0155] The optimization unit 704 is configured to adopt each training sample group in the pseudo corpus to perform supervised model training on the reading comprehension model, to optimize the model parameters of the reading comprehension model, and to obtain the optimized reading comprehension model.

[0156] In another implementation, the obtaining unit 701, in operation of obtaining pseudo corpus for model optimization of the reading comprehension model, can be specifically configured to:

[0157] obtain a sample text pair from a plurality of preset sample text pairs as a benchmark sample text pair, the sample text pair including a sample input text and a sample text segment;

[0158] select one or more sample text segments from each sample text pair except the benchmark sample text pair in the plurality of sample text pairs;

[0159] splicing the selected sample text segments and the sample text segment in the reference sample text pair, and generating a sample response text based on a splicing result;

[0160] adopting the reference sample text pair and the generated sample response text to construct a training sample group.

[0161] In another implementation, the obtaining unit 701 can be specifically configured to, when obtaining pseudo-corpus for model optimization of the reading comprehension model:

[0162] obtain a sample text pair from a plurality of preset sample text pairs as a reference sample text pair, the sample text pair including a sample input text and a sample text segment;

[0163] randomly select a response text from a database, and insert the sample text segment in the reference sample text pair into the randomly selected response text to obtain a sample response text;

[0164] adopting the reference sample text pair and the obtained sample response text to construct a training sample group.

[0165] According to an embodiment of the present application, Figure 2 or Figure 3 The steps involved in the method shown in the figure can be executed by Figure 7 the units in the text processing apparatus shown in the figure. For example, Figure 2 The steps S201 and S203 shown in the figure can be executed by Figure 7 the obtaining unit 701 shown in the figure, and the step S202 can be executed by Figure 7 the clustering unit 702 shown in the figure, and the step S204 can be executed by Figure 7 the constructing unit 703 shown in the figure. For another example, Figure 3 The steps S301 and S303 shown in the figure can be executed by Figure 7 the obtaining unit 701 shown in the figure, and the step S303 can be executed by Figure 7 the clustering unit 702 shown in the figure, and the steps S304-S308 can be executed by Figure 7 the constructing unit 703 shown in the figure, and so on.

[0166] According to another embodiment of the present application, Figure 7The units in the text processing apparatus shown can be combined into one or several other units respectively or all, or some of the units can be further split into a plurality of units with smaller functions to constitute, which can achieve the same operation without affecting the implementation of the technical effects of the embodiments of the present application. The above units are divided based on logical functions. In actual applications, the functions of a unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the text processing apparatus can also include other units. In actual applications, these functions can also be assisted by other units, and can be implemented by multiple units in cooperation.

[0167] According to another embodiment of the present application, the text processing apparatus as shown in Figure 2 or the text processing method of the embodiments of the present application can be constructed by running a computer program (including program codes) related to each step of the corresponding method as shown in Figure 3 on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), read-only memory (ROM), etc., and implementing the text processing method of the embodiments of the present application. The computer program can be recorded on, for example, a computer readable storage medium, loaded into the above computing device through the computer readable storage medium, and run therein. Figure 7

[0168] ​The embodiment of the present application can obtain M candidate input texts from the text input log, and perform clustering processing on the M candidate input texts, so as to select one or more candidate input texts in each clustering text group obtained by clustering as a target input text, and each target input text is used to represent each candidate input text under the category corresponding to the corresponding clustering text group. Then, one or more response texts can be selected for each target input text in the response text set, so as to construct a text pair by using each target input text and the corresponding response text, and obtain a plurality of text pairs. It can be seen that, in the construction process of the text pair, the embodiment of the present application can realize the optimization of the selection of the input text through the clustering processing and the text selection operation. By selecting the representative target input text to construct the text pair, the text pair obtained by construction can be suitable for each input text under the category to which the target input text belongs, and the coverage of the text pair is improved to a certain extent. Moreover, this can avoid performing the construction operation of the text pair for each input text under the same category, and the processing resources can be effectively saved. Further, since the text input log is generated in the process of providing the text response service historically, the text input log can cover a large number of real input texts, so that the target input text obtained based on the text input log is not only real, but also has a high coverage, thereby improving the coverage of the text pair constructed based on the target input text, and further improving the coverage of the database after adding the plurality of text pairs to the database.

[0169] Based on the description of the method embodiment and the device embodiment, the embodiment of the present application further provides a computer device. Please refer to Figure 8 The computer device at least includes a processor 801, an input interface 802, an output interface 803 and a computer storage medium 804. Wherein, the processor 801, the input interface 802, the output interface 803 and the computer storage medium 804 in the computer device can be connected through a bus or other ways.

[0170] The computer storage medium 804 can be stored in the memory of the computer device, and is used to store a computer program including program instructions. The processor 801 is used to execute the program instructions stored in the computer storage medium 804. The processor 801 (or CPU (Central Processing Unit, central processor)) is the computing core and control core of the computer device, and is adapted to implement one or more instructions, and is specifically adapted to load and execute one or more instructions to implement a corresponding method flow or a corresponding function. In one embodiment, the processor 801 of the embodiment of the present application can be used to perform a series of text processing, specifically including: obtaining a text input log generated in the process of historically providing a text response service; and obtaining M candidate input texts from the text input log, M being an integer greater than 1; performing clustering processing on the M candidate input texts to obtain one or more clustered text groups; and selecting one or more candidate input texts as target input texts in each clustered text group, respectively; obtaining a response text set, and selecting one or more response texts for each target input text in the response text set; respectively using each target input text and the corresponding response text to construct a text pair to obtain a plurality of text pairs, and providing the text response service based on the plurality of text pairs.

[0171] The embodiment of the present application further provides a computer storage medium (Memory). The computer storage medium is a memory device in a computer device, and is used to store programs and data. It can be understood that the computer storage medium herein can include an internal storage medium in the computer device, and of course can include an extended storage medium supported by the computer device. The computer storage medium provides a storage space, and the storage space stores an operating system of the computer device. Furthermore, one or more instructions adapted to be loaded and executed by the processor are stored in the storage space, and the instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium herein can be a high-speed RAM memory, or a non-volatile memory such as at least one disk memory. Optionally, the computer storage medium can also be at least one computer storage medium located away from the aforementioned processor. In one embodiment, one or more instructions stored in the computer storage medium can be loaded and executed by the processor to implement the embodiments of the text processing method shown in the above Figure 2 or Figure 3 the method steps in the embodiments of the text processing method shown.

[0172] The embodiment of the present application can obtain M candidate input texts from a text input log, and perform clustering processing on the M candidate input texts, so as to select one or more candidate input texts in each clustering text group obtained by clustering as a target input text, and each target input text is used to represent each candidate input text in the category corresponding to the corresponding clustering text group. Then, one or more response texts can be selected for each target input text in the response text set, so as to construct a text pair by using each target input text and the corresponding response text, and obtain a plurality of text pairs. It can be seen that, in the construction process of the text pair, the selection optimization of the input text can be realized by the clustering processing and the text selection operation. By selecting the representative target input text to construct the text pair, the text pair obtained by construction can be suitable for each input text in the category to which the target input text belongs, and the coverage of the text pair is improved to a certain extent. Moreover, this can avoid performing the construction operation of the text pair for each input text in the same category, and the processing resources can be effectively saved. Further, since the text input log is generated in the process of providing the text response service historically, the text input log can cover a large number of real input texts, so that the target input text obtained based on the text input log is not only real, but also has a high coverage, thereby improving the coverage of the text pair constructed based on the target input text, and further improving the coverage of the database after adding the plurality of text pairs to the database.

[0173] It should be noted that, according to an aspect of the present application, a computer program product or computer program is also provided, which includes computer instructions stored in a computer storage medium. The processor of the computer device reads the computer instructions from the computer storage medium, and the processor executes the computer instructions, so that the computer device executes the various optional manners provided by the text processing method embodiment aspects shown in the above Figure 2 , or Figure 3 .

[0174] It should be understood that the above disclosure is only the preferred embodiment of the present application, and of course cannot limit the scope of the rights of the present application, so the equivalent changes made by the claims of the present application still fall within the scope of the present application.

Claims

1. A text processing method, characterized in that, include: Retrieve text input logs generated during the historical provision of text response services; And obtain M candidate input texts from the text input log, where M is an integer greater than 1; The M candidate input texts are clustered to obtain one or more clustered text groups; and one or more candidate input texts are selected from each clustered text group as the target input text. Obtain the response text set, and select one or more response texts for each target input text from the response text set; Text pairs are constructed using each target input text and its corresponding response text to obtain multiple text pairs, which are then used to provide the text response service. Each text pair includes a target input text and a corresponding text fragment. The text fragment corresponding to the target input text is output after the optimized reading comprehension model performs reading comprehension on the response text corresponding to the target input text. The optimized reading comprehension model is obtained through supervised model training using training sample groups from pseudo-predictions to optimize its model parameters. The pseudo-prediction acquisition process includes: obtaining a sample text pair as a baseline sample text pair from a set of multiple sample text pairs; each sample text pair includes a sample input text and a sample text fragment; randomly selecting a response text from a database and inserting the sample text fragment from the baseline sample text pair into the randomly selected response text to obtain a sample response text; and constructing a training sample group using the baseline sample text pair and the obtained sample response text.

2. The method according to claim 1, characterized in that, The clustering process of the M candidate input texts to obtain one or more clustered text groups includes: Semantic component analysis is performed on each of the M candidate input texts to obtain the semantic components of each candidate input text; the semantic components of any candidate input text include at least one of the following: intent type and entity information; Based on the principle that candidate input texts with matching semantic components are grouped into a text group, the M candidate input texts are grouped according to the semantic components of each candidate input text to obtain one or more clustered text groups.

3. The method according to claim 1, characterized in that, The step of selecting one or more response texts for each target input text in the response text set includes: Iterate through each target input text and use the currently iterated target input text as the current target input text; Semantic analysis is performed on the current target input text to obtain the semantic vector of the current target input text; and semantic analysis is performed on each response text in the response text set to obtain the semantic vector of each response text. Based on the semantic vector of the current target input text and the semantic vector of each response text, calculate the matching degree between the current target input text and each response text; Retrieve response texts with a matching degree greater than the matching degree threshold from the response text set, and use them as the response texts corresponding to the current target input text.

4. The method according to claim 1, characterized in that, The process involves constructing text pairs using each target input text and its corresponding response text, resulting in multiple text pairs, including: For any target input text, scan each response text corresponding to that target input text and determine the current response text being scanned; The current response text is read and understood in order to extract a text segment from the current response text that is used to respond to any of the target input texts; After scanning all the response texts corresponding to any target input text, H text fragments are obtained, where the value of H is equal to the number of response texts corresponding to any target input text. Using the H text fragments and any target input text, at least one text pair is constructed; a text pair includes a text fragment and any target input text.

5. The method according to claim 4, characterized in that, Each of the H text fragments has a confidence level; the step of constructing at least one text pair using the H text fragments and any target input text includes: From the H text fragments, select P text fragments with a confidence level greater than the confidence threshold, where P∈[1,H]; Each of the P text fragments and any target input text is used to construct a text pair to obtain P text pairs.

6. The method according to claim 4, characterized in that, The method further includes: Obtain pseudo-corpus for optimizing the reading comprehension model. The pseudo-corpus includes one or more training sample groups. A training sample group includes: a sample input text, a sample text segment, and a sample response text. Each sample response text is obtained by reconstructing text based on the sample text segment in the same training sample group. The reading comprehension model is trained in a supervised manner using the training sample groups in the pseudo-expectation to optimize the model parameters and obtain an optimized reading comprehension model.

7. A text processing method, characterized in that, include: Retrieve text input logs generated during the historical provision of text response services; And obtain M candidate input texts from the text input log, where M is an integer greater than 1; The M candidate input texts are clustered to obtain one or more clustered text groups; and one or more candidate input texts are selected from each clustered text group as the target input text. Obtain the response text set, and select one or more response texts for each target input text from the response text set; Text pairs are constructed using each target input text and its corresponding response text to obtain multiple text pairs, which are then used to provide the text response service. Each text pair includes a target input text and a corresponding text fragment. The text fragment corresponding to the target input text is output after the optimized reading comprehension model performs reading comprehension on the response text corresponding to the target input text. The optimized reading comprehension model is obtained through supervised model training using training sample groups from pseudo-predictions to optimize its model parameters. The pseudo-prediction acquisition process includes: obtaining a sample text pair as a baseline sample text pair from a set of multiple sample text pairs; selecting one or more sample text fragments from each sample text pair other than the baseline sample text pair; concatenating the selected sample text fragments with the sample text fragments from the baseline sample text pair, and generating a sample response text based on the concatenation result; and constructing a training sample group using the baseline sample text pair and the generated sample response text.

8. A text processing device, characterized in that, include: The acquisition unit is used to acquire text input logs generated during the historical provision of text response services; And obtain M candidate input texts from the text input log, where M is an integer greater than 1; A clustering unit is used to perform clustering processing on the M candidate input texts to obtain one or more clustered text groups; and to select one or more candidate input texts as target input texts in each clustered text group. The acquisition unit is also used to acquire a set of response texts and select one or more response texts for each target input text in the set of response texts; A construction unit is used to construct text pairs using each target input text and corresponding response text to obtain multiple text pairs, and to provide the text response service based on the multiple text pairs. Each text pair includes a target input text and a corresponding text fragment. The text fragment corresponding to the target input text is output after the optimized reading comprehension model performs reading comprehension on the response text corresponding to the target input text. The optimized reading comprehension model is obtained by supervising the training sample groups in the pseudo-predictions to optimize the model parameters. The pseudo-prediction acquisition process includes: obtaining a sample text pair as a baseline sample text pair from a preset set of multiple sample text pairs; each sample text pair includes a sample input text and a sample text fragment; randomly selecting a response text from the database and inserting the sample text fragment from the baseline sample text pair into the randomly selected response text to obtain a sample response text; and constructing a training sample group using the baseline sample text pair and the obtained sample response text.

9. A text processing device, characterized in that, include: The acquisition unit is used to acquire text input logs generated during the historical provision of text response services; And obtain M candidate input texts from the text input log, where M is an integer greater than 1; A clustering unit is used to perform clustering processing on the M candidate input texts to obtain one or more clustered text groups; and to select one or more candidate input texts as target input texts in each clustered text group. The acquisition unit is also used to acquire a set of response texts and select one or more response texts for each target input text in the set of response texts; A construction unit is used to construct text pairs using each target input text and corresponding response text to obtain multiple text pairs, and to provide the text response service based on the multiple text pairs. Each text pair includes a target input text and a corresponding text fragment. The text fragment corresponding to the target input text is output after the optimized reading comprehension model performs reading comprehension on the response text corresponding to the target input text. The optimized reading comprehension model is obtained by supervising the training sample groups in the pseudo-predictions to optimize the model parameters. The pseudo-prediction acquisition process includes: obtaining a sample text pair as a baseline sample text pair from a set of multiple sample text pairs, each sample text pair including a sample input text and a sample text fragment; selecting one or more sample text fragments from each sample text pair other than the baseline sample text pair; concatenating the selected sample text fragments with the sample text fragments in the baseline sample text pair, and generating a sample response text based on the concatenation result; and constructing a training sample group using the baseline sample text pair and the generated sample response text.

10. A computer storage medium, characterized in that, The computer storage medium stores one or more instructions, which are adapted for a processor to load and execute the steps of the method as described in any one of claims 1-6, or the instructions are adapted for a processor to load and execute the steps of the method as described in claim 7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1-6, or when the computer program is executed by a processor, it implements the steps of the method as described in claim 7.

12. A computer device, characterized in that, It includes a processor and a memory, wherein the memory is used to store a computer program, which, when executed by the processor, implements the method as described in any one of claims 1-6, or, when executed by the processor, implements the steps of the method as described in claim 7.

Citation Information

Patent Citations

  • E-commerce dialogue corpus-based question and answer knowledge base construction method

    CN112905785A