CN117033613B - Response text generation method, electronic equipment and storage medium - Google Patents

Response text generation method, electronic equipment and storage medium Download PDF

Info

Publication number
CN117033613B
CN117033613B CN202311049585.1A CN202311049585A CN117033613B CN 117033613 B CN117033613 B CN 117033613B CN 202311049585 A CN202311049585 A CN 202311049585A CN 117033613 B CN117033613 B CN 117033613B
Authority
CN
China
Prior art keywords
text
preset
target
matched
training
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311049585.1A
Other languages
Chinese (zh)
Other versions
CN117033613A (en
Inventor
李斯蕊
姜炜
刘丰
张丽颖
何凯
谭智隆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Travelsky Mobile Technology Co Ltd
Original Assignee
China Travelsky Mobile Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Travelsky Mobile Technology Co Ltd filed Critical China Travelsky Mobile Technology Co Ltd
Priority to CN202311049585.1A priority Critical patent/CN117033613B/en
Publication of CN117033613A publication Critical patent/CN117033613A/en
Application granted granted Critical
Publication of CN117033613B publication Critical patent/CN117033613B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/335Filtering based on additional data, e.g. user or group profiles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a method for generating a response text, electronic equipment and a storage medium, and relates to the field of response text generation, wherein the method comprises the following steps: acquiring a question text A input by a target user; inputting A to a preset text retrieval model, so that the text retrieval model outputs a text list TA matched with A according to A; splicing the A and the TA according to a preset text splicing template to generate a target problem text QA corresponding to the A; inputting QA into a preset target text generation model so that the target text generation model outputs a response text matched with A according to QA; the target text matching model can combine texts which belong to the preset field and are matched with the problem text to generate a response text, so that the perpendicularity between the generated response text and the corresponding problem text is improved, and the accuracy of generating the response text is improved.

Description

Response text generation method, electronic equipment and storage medium
Technical Field
The present invention relates to the field of answer text generation, and in particular, to a method for generating an answer text, an electronic device, and a storage medium.
Background
With the rapid development of artificial intelligence, more and more natural language processing models are entering into the daily life of people, for example ChatGPT; the user inputs a question text to the natural language processing model, and the natural language processing model can output an answer corresponding to the question to the user according to the question input by the user; but similar to ChatGPT's natural language processing model, it aims at users in all fields, when processing the problem that the user puts forward that the correlation with a certain field is high, such as professional problem in civil aviation field; the output answers are wider, and the accuracy of the answers is lower.
Disclosure of Invention
Aiming at the technical problems, the invention adopts the following technical scheme:
According to a first aspect of the present application, there is provided a method of generating a response text, comprising the steps of:
s100, acquiring a question text A input by a target user;
S200, inputting a to a preset text retrieval model, so that the text retrieval model outputs a text list ta= (TA 1,TA2,…,TAn,…,TAm), n=1, 2, …, m matched with a according to a; wherein TA n is the nth text matched with A, and m is the number of texts matched with A; the text retrieval model comprises a preset text library and a text matching module, wherein the text matching module can match a plurality of texts matched with A from the text library according to A; each text in the text library belongs to the preset field;
S300, splicing the A and the TA according to a preset text splicing template to generate a target problem text QA corresponding to the A; wherein QA includes matching text within A and TA;
s400, inputting QA into a preset target text generation model, so that the target text generation model outputs a response text matched with A according to QA.
According to another aspect of the present application, there is also provided a non-transitory computer readable storage medium having stored therein at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the above-described method for generating a response text.
According to another aspect of the present application, there is also provided an electronic device comprising a processor and the above-described non-transitory computer-readable storage medium.
The invention has at least the following beneficial effects:
for a problem text input by a user, firstly, inputting the problem text into a preset text retrieval model, wherein the preset text retrieval model comprises a preset text library, and each text in the preset text library belongs to the preset field; therefore, the text matched by the text retrieval model according to the problem text is also the text belonging to the preset collar; then, splicing the question text and the text in the preset field matched with the question text according to a preset splicing template to obtain a target question text corresponding to the question text, wherein the target question text comprises the question text input by a user and the text matched with the question text in the preset field; inputting the target question text into a preset target text generation model, so that the target text generation model can output a response text matched with the question text input by a user according to the target question text; because the target question text comprises the question text input by the user and the text matched with the question text in the preset field, the target text matching model can combine the text matched with the question text in the preset field to generate the response text, so that the perpendicularity between the generated response text and the corresponding question text is improved, and the accuracy of generating the response text is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for generating a response text according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
It is noted that various aspects of the embodiments are described below within the scope of the following claims. It should be apparent that the aspects described herein may be embodied in a wide variety of forms and that any specific structure and/or function described herein is merely illustrative. Based on the present disclosure, one skilled in the art will appreciate that one aspect described herein may be implemented independently of any other aspect, and that two or more of these aspects may be combined in various ways. For example, an apparatus may be implemented and/or a method practiced using any number of the aspects set forth herein. In addition, such apparatus may be implemented and/or such methods practiced using other structure and/or functionality in addition to one or more of the aspects set forth herein.
A method of generating a response text will be described with reference to a flowchart of the method of generating a response text described in fig. 1.
The method for generating the response text comprises the following steps:
s100, acquiring a question text A input by a target user.
In this embodiment, it can be understood that a is a question text currently input by the target user; for example, "no pet can be carried by a flight? ".
S200, inputting a to a preset text retrieval model, so that the text retrieval model outputs a text list ta= (TA 1,TA2,…,TAn,…,TAm), n=1, 2, …, m matched with a according to a; wherein TA n is the nth text matched with A, and m is the number of texts matched with A; the text retrieval model comprises a preset text library and a text matching module, wherein the text matching module can match a plurality of texts matched with A from the text library according to A; each text in the text library belongs to the preset field.
In this embodiment, the preset text retrieval model includes a preset text library, i.e., a corpus; the text library belongs to a preset field, for example, a text library in the civil aviation field, wherein each text in the text library is a text related to the civil aviation and comprises announcements issued by each navigation driver and a history response text corresponding to a history problem text input by a user; the preset text retrieval model can retrieve a plurality of texts which are wanted to be matched with the question text from a preset text library according to the question text input by the user, so that TA can be obtained.
It should be noted that, for any problem input by the user, the preset text retrieval model can be matched with the text matched with the problem text, and the matched text is the text in the preset field; the text library in the preset field is set, so that the text matched by the preset text retrieval model according to the problem text is the text related to the problem text, and the text which is not related to the problem text in other fields is prevented from being matched, so that the accuracy of generating the follow-up response text is improved.
And S300, splicing the A and the TA according to a preset text splicing template to generate a target question text QA corresponding to the A.
In this embodiment, after obtaining the TA, a problem text input by a user and each text matched by a text retrieval model need to be spliced through a preset text splicing template to form a target problem text corresponding to the problem text; it can be understood that the target question text includes the question text input by the user and a plurality of texts which are matched by the text retrieval model according to the question text and belong to the preset field.
For a preset splicing template, a preset json format structure body can be adopted, and different fields are used for corresponding to A and TA; and filling the A and the TA into the corresponding positions by adopting a preset text template to form a text with semantics.
Compared with the independent problem text, the spliced target problem text comprises a plurality of texts matched with the problem text in the preset field, and then the subsequent target text generation model can be combined with the plurality of texts matched with the problem text in the preset field to generate a response text; the single question text is input into a target text generation model, and the target text generation model can combine relevant texts in all fields to generate response texts, so that the generated response texts are wider or wrong response texts are generated; therefore, in the embodiment, the text matching the question text input by the user and the text retrieval model is spliced, so that the accuracy of generating the response text subsequently can be improved.
S400, inputting QA into a preset target text generation model, so that the target text generation model outputs a response text matched with A according to QA.
In this embodiment, the preset target text generation model is obtained by training an original natural language processing model, and training samples used for training the original natural language processing model, that is, a corpus, which also belongs to a corpus in the preset field; therefore, the capability of the target text generation model for processing the problem text in the preset field can be improved, so that the perpendicularity of the response text corresponding to the problem text output by the target text generation model in the preset field is higher, and the accuracy of the generated response text is improved.
For a question text input by a user, firstly, inputting the question text into a preset text retrieval model, wherein the preset text retrieval model comprises a preset text library, and each text in the preset text library belongs to the preset field; therefore, the text matched by the text retrieval model according to the problem text is also the text belonging to the preset collar; then, splicing the question text and the text in the preset field matched with the question text according to a preset splicing template to obtain a target question text corresponding to the question text, wherein the target question text comprises the question text input by a user and the text matched with the question text in the preset field; inputting the target question text into a preset target text generation model, so that the target text generation model can output a response text matched with the question text input by a user according to the target question text; because the target question text comprises the question text input by the user and the text matched with the question text in the preset field, the target text matching model can combine the text matched with the question text in the preset field to generate the response text, so that the perpendicularity between the generated response text and the corresponding question text is improved, and the accuracy of generating the response text is improved.
Optionally, the step S300 includes the steps of:
S310, acquiring a preset text splicing template; the text splicing template comprises a preset first text segment T 1, a preset second text segment T 2, a preset first text space W 1,T2 and a preset second text space W 2 between a preset third text segment T 3,T1 and a preset third text segment T 2 which are sequentially arranged.
In this embodiment, the first text segment T 1, the second text segment T 2, and the third text segment T 3 are preset text segments with certain semantics; specifically, T 1 is "please combine the following text: ", T 2 is" help me find: ", T 3 is the answer to" T 3. A first text space for filling in a text list is preset between T 1 and T 2, and a second text space for filling in a question text input by a user is preset between T 2 and T 3; it should be noted that, T 1 is located before T 2, and T 2 is located before T 3, thereby enabling to ensure that the finally generated target question text is semantically correct.
In this embodiment, W 1 and W 2 can be determined by:
S311, obtaining the text length of each text in the TA to obtain the total text length QTA of each text in the TA.
S312, determining the text length of the text which can be accommodated by the W 1 according to the QTAWherein, beta 1 is a preset first ratio coefficient, beta 1 is more than 1,/>Is a preset upward valued function.
S313, acquiring the text length FA of A.
S314, determining the text length of the text which can be accommodated by the W 2 according to the FAWherein, beta 2 is a preset second proportionality coefficient; beta 2 > 1.
By determining the text lengths corresponding to W 1 and W 2 through the method, the space sizes of W 1 and W 2 can be dynamically set according to the text lengths required to be occupied by each text in A and TA, beta 1 and beta 2, the situation that the generated target problem text is large due to the large space size settings of W 1 and W 2 and the situation that the space sizes of W 1 and W 2 cannot be completely added to A and/or TA occurs can be avoided; beta 1 is more than 1, and can ensure that each text in TA can be completely added to W 12 to be more than 1, and the value range of A which is completely added to W 21 is 1.05-1.1, and the value and range of beta 2 are 1.1-1.3.
S320, adding TA to W 1 and A to W 2 to generate QA.
In this embodiment, QA is a text with semantics, and the target text model can generate a response text corresponding to a according to the specific semantics of QA, that is, the target text generation model can combine the text in TA to generate the response text of a; thus, the accuracy of generating the response text can be improved.
Optionally, the step S300 includes the steps of:
S330, acquiring a preset text splicing template; the text splicing template comprises a preset first character string, a preset second character string, a preset third text space W 3 associated with the first character string and a preset fourth text space W 4 associated with the second character string; the first character string is different from the second character string.
In this embodiment, the preset text splicing template is a structure body with a preset format, for example, a json format structure body; the first character string is used for representing a question text A input by a user, and the second character string is used for representing a text list TA matched with the A; when training the target text generation model, the meaning of the first character string and the meaning of the second character string are marked, so that the target text generation model can identify the meaning represented by the first character string and the second character string; the first string and the second string may take the form of shorter strings or single characters, e.g., the first string is "question: "or" q: "; the shorter first character string and the shorter second character string can save a part of space to add more texts, so that more information is contained in the target problem text, and further, the information which can be combined by the target text generation model is more abundant.
S340, adding A to W 3 and TA to W 4 to generate QA.
In this embodiment, the QA includes each text in a and TA, and the target text model can identify each text in a and TA in the QA, so that the target text generation model can combine the text in TA to generate a response text of a; thus, the accuracy of generating the response text can be improved.
In an exemplary embodiment, the text retrieval model includes a first text matching module, the text library includes several texts with different text lengths, and the step S200 includes the following steps:
S210, inputting A into a first text matching module of a preset text retrieval model, so that the first text matching module matches m first target texts from the text library according to A to obtain a text list TA= (TA 1,TA2,…,TAn,…,TAm) matched with A; the text length of the TA n is smaller than or equal to a preset text length threshold.
In this embodiment, the text library of the preset text retrieval model includes a plurality of types of texts in a preset field, for example, announcements issued by some pilots in the civil aviation field, and the types of texts can be understood as long texts; and answer text matching the history question text entered by the user, which type of text may be understood as short text; the first text matching module is a short text matching module, and can match a plurality of short texts in a text library according to A so as to obtain TA; under normal conditions, most of the problem texts input by the user can be matched to short texts with higher relativity through the first text matching module, so that the requirement of text matching can be met by only adopting the first text matching module, and the matching efficiency is higher.
Optionally, the text retrieval model includes a first text matching module and a second text matching module, the text library includes several texts with different text lengths, and the step S200 includes the following steps:
S220, inputting A into a first text matching module of a preset text retrieval model, so that the first text matching module matches a plurality of first target texts from the text library according to A to obtain a first target text set B1= (B1 1,B12,…,B1p,…,B1q), and p=1, 2, … and q; wherein B1 p is a first text matching module, the p first target text is matched from the text library according to A, q is the number of the first target texts in B1; b1 p is less than or equal to a preset text length threshold.
In this embodiment, the first text matching module in the step is the same as the first text matching module in the step S210, and a detailed description is omitted here.
S230, inputting A to a second text matching module of a preset text retrieval model, so that the second text matching module matches a plurality of second target texts from the text library according to A to obtain a second target text set B2= (B2 1,B22,…,B2j,…,B2k), j=1, 2, … and k; wherein B2 j is a second text matching module, a j second target text is matched from the text library according to A, and k is the number of the second target texts in B2; b2 j is greater than a preset text length threshold.
In this embodiment, the difference from step S210 is that the preset text retrieval model further includes a second text matching module, which may be understood as a long text matching module, for example, a distributed search engine (elastsearch); the second text matching module can search out long texts matched with the problem text input by the user from all long texts contained in the text library; it can be understood that the long text searched by the second text matching module is a fixed text related to a preset field, for example, a bulletin issued by a navigation driver, etc.; when the problem input by the user is a problem aiming at the announcement of the navigation driver, the text matched by the first text matching module possibly does not contain the text related to the announcement of the navigation driver, namely long text; in this case, then, only the first text matching module is used to match the text, and it may not be possible to overlay the content related to the problematic text; therefore, the present embodiment sets the second text matching module to avoid the occurrence of the above-described problem.
S240, adding each first target text in the B1 and each second target text in the B2 into a preset list TA' to obtain a text list TA matched with the A; wherein the initial state of TA' is null.
In this embodiment, the TA includes both long text and short text, and regardless of the type of question text input by the user, the TA can fully cover the content of the response text corresponding to the question text input by the user, thereby improving the accuracy of generating the response text.
In an exemplary embodiment, the preset target text generation model is obtained by the following steps:
S410, acquiring a preset first text generation model; the first text generation model is obtained by training a preset first training sample set for the initial text generation model, and the first training sample set comprises training samples in a plurality of fields.
In this embodiment, the preset first text generation model is obtained after training an initial natural language processing model, and the first text generation model may select an existing natural language processing model; it will be appreciated that the first text generation model is specific to users in all fields, the training samples used in training are from various fields, and the answer text generated for the question text input by the user is relatively broad in content.
S420, acquiring a preset second training sample set; the second training sample set comprises a plurality of training samples belonging to a target field, wherein the target field is one of a plurality of fields.
In this embodiment, since the first text generation model obtained in step S410 is a general-purpose natural language processing model, the processing capability of the answer text in the vertical domain is poor, and the content of the answer text generated may not be the content in the domain corresponding to the question text.
In view of the above, in this embodiment, the first text generation model is pre-trained, and the second training sample set used for the pre-training is obtained from the target field; for example, training samples, i.e., a corpus, used for pre-training are obtained from the civil aviation field, and the content of the training samples is related to the civil aviation.
And S430, training the first text generation model by using a second training sample set to obtain the target text generation model.
It can be appreciated that each training sample in the second training sample set is related to a target domain such that the first text generation model learns a significant amount of knowledge within the target domain; the target problem text input to the first text generation model is a text with semantics and is equivalent to an instruction; then, when the first text generation model processes the problem text in the target field, on one hand, the semantics of the target problem text can be understood, and on the other hand, the knowledge in the target field learned by the first text generation model can be combined, so that the accuracy of generating the response text by the first text generation model is greatly improved.
Optionally, the first text generation model includes a pre-training module and a fine tuning module, an output end of the pre-training module is connected to an input end of the fine tuning module, the pre-training module is configured to pre-train the first text generation model, the fine tuning module is configured to adjust a text output by the pre-training module, and the step S430 includes the following steps:
s431, acquiring a second training sample set; the second training sample set includes a second pre-training sample set corresponding to the pre-training module and a second fine tuning sample set corresponding to the fine tuning module.
S432, inputting the second pre-training sample set to the pre-training module, inputting the second fine-tuning sample set to the fine-tuning module, and training the first text generation model to obtain the target text generation model.
In this embodiment, the first text generation model includes two parts, one part is a pre-training module, and the other part is a fine-tuning module; when training the first text generation model, a second pre-training sample set and a second fine-tuning sample set are required to be preset so as to train the pre-training module and the fine-tuning module respectively, so that the first text generation model achieves a good training effect.
For a question text input by a user, firstly, inputting the question text into a preset text retrieval model, wherein the preset text retrieval model comprises a preset text library, and each text in the preset text library belongs to the preset field; therefore, the text matched by the text retrieval model according to the problem text is also the text belonging to the preset collar; then, splicing the question text and the text in the preset field matched with the question text according to a preset splicing template to obtain a target question text corresponding to the question text, wherein the target question text comprises the question text input by a user and the text matched with the question text in the preset field; inputting the target question text into a preset target text generation model, so that the target text generation model can output a response text matched with the question text input by a user according to the target question text; because the target question text comprises the question text input by the user and the text matched with the question text in the preset field, the target text matching model can combine the text matched with the question text in the preset field to generate the response text, so that the perpendicularity between the generated response text and the corresponding question text is improved, and the accuracy of generating the response text is improved.
In an exemplary embodiment, a method for obtaining B1 is provided, where the method is applied to a preset text retrieval model, where the text retrieval model includes a preset text library belonging to a preset field and a first text matching module, where the first text matching module includes d text ranking sub-models and one text recall sub-model, the text ranking sub-models are capable of ranking each text in the text library according to a relative confidence level between a question text input by a user and each text in the text library, and the text recall sub-models are capable of determining an absolute confidence level between each text input to the text recall sub-models and the question text.
In this embodiment, the preset text retrieval model includes a text library in a preset field, that is, a corpus; for example, a text library in the civil aviation field, wherein each text in the text library is a text related to the civil aviation and comprises a notice issued by each aviation driver and a history response text corresponding to a history problem text input by a user; the preset text retrieval model further comprises a first text matching module, wherein the first text matching module comprises d text sorting sub-models, such as a BM25 model, a BERT model, a text classification model and the like; also included is a text recall sub-model, e.g., simCSE model; it can be appreciated that the relative confidence is used to characterize the relative confidence between each matching text output by any text ranking sub-model, which is not capable of characterizing the true confidence between the matching text and the question text; while absolute confidence is used to characterize the true confidence between the matching text and the question text.
The text matching method comprises the following steps:
s510, acquiring a question text A input by a target user.
In this embodiment, it can be understood that a is a question text currently input by the target user; for example, "no pet can be carried by a flight? ".
S520, inputting a to the first text matching module to match f matching texts through each text ranking sub-model, thereby obtaining a matching text list set h= (H 1,H2,…,Hc,…,Hd), c=1, 2, …, d; h c is a matched text list output by the c text matching module; h c=(Hc,1,Hc,2,…,Hc,e,…,Hc,f), e=1, 2, …, f; wherein H c,e is the e-th matching text within H c.
In this embodiment, after inputting a to the first text matching module, any text sorting sub-module can determine the relative confidence between each text in the text library and a according to a, then sort each text in the text library from large to small according to the confidence corresponding to each text, and take the first f texts as matching texts; thus, a matched text list output by each text sequencing submodel can be obtained.
It should be noted that, when each text sorting sub-model sorts each text in the text library according to the problem text, the dimensions of the problem text and the text in the text library are different, so that each matching text in any two matching text lists is not identical; when each text sequencing sub-model sequences each text in the text library according to the problem text, sequencing is carried out according to the relative confidence level of each text in the text library, so that each text sequencing sub-model can output f matched texts in the corresponding dimension; therefore, the number and types of the obtained matching texts are rich.
S530, inputting H into a text recall sub-model, so that the text recall sub-model determines absolute confidence coefficient of each matched text in H, and a matched text absolute confidence coefficient list TH= (TH 1,TH2,…,THx,…,THy), x=1, 2, … and y corresponding to H is obtained; wherein TH x is the absolute confidence coefficient of the matching text of the xth matching text in TH, and y is the number of the absolute confidence coefficients of the matching text in TH; y=d×f.
In this embodiment, the text recall sub-model can score absolute confidence levels of the matching texts according to the semantics of the question text and the semantics of the matching text; according to the absolute confidence corresponding to each matching text, TH can be obtained; the text recall sub-model may select simCSE models.
S540, according to TH, obtaining each matching text matched with a as a first target text, so as to obtain a first target text set b1= (b1 1,B12,…,B1p,…,B1q), p=1, 2, …, q; wherein, B1 p is the p first target text matched with A, q is the number of the first target texts in B1; ηB1 p≥η0,ηB1p is the absolute confidence of B1 p and η0 is a preset absolute confidence threshold.
In this embodiment, for the matching texts with absolute confidence degrees greater than the preset absolute confidence degree threshold, it may be determined that the matching texts have higher correlation or similarity to the standard response text corresponding to the question text, and these matching texts are used as the first target text of the question text, so as to obtain B1; it should be noted that, the number of the first target texts in B1 is less than y, and B1 may be an empty set, and when B1 is an empty set, the absolute confidence coefficient of each matching text is less than a preset absolute confidence coefficient threshold, and the correlation degree or similarity between each matching text and the standard response text corresponding to the question text is low, so that each matching text cannot be used as the first target text of the question text; therefore, the situation that the matched text output by the text recall sub-model has larger semantic difference with the standard response text corresponding to the question text can be avoided.
According to the text matching method, f matched texts are output by each text sorting sub-model in the preset text retrieval model according to the problem text, and a matched text list corresponding to each text sorting sub-model is obtained; the text recall sub-model sorts the absolute confidence coefficient of each matched text output by each text sorting sub-model, and takes the matched text with the absolute confidence coefficient larger than a preset absolute confidence coefficient threshold value as a first target text matched with the problem text; because the absolute confidence coefficient can measure the matching degree between the question text and the matching text, the matching text with higher absolute confidence coefficient can be judged to be the response text corresponding to the question text, so that the accuracy of outputting the first target text corresponding to the question text is ensured.
Further, when each text sequencing sub-model sequences each text in the text library according to the problem text, the dimensions of the problem text according to the text in the text library are different, so that each matched text in any two matched text lists is not identical, and compared with a single text sequencing sub-model, the matched text output by the text sequencing sub-models improves the coverage rate of response texts corresponding to the problem text; when each text sequencing sub-model sequences each text in the text library according to the problem text, sequencing is carried out according to the relative confidence level of each text in the text library, so that each text sequencing sub-model can output f matched texts in the corresponding dimension; therefore, the number and types of the matched texts input to the text recall sub-model can be ensured to be more, and the accuracy of the first target text corresponding to the output problem text is further improved.
Optionally, f is determined by:
S521, obtaining the number of the first target texts in each first target text set in the preset sliding time window W, so as to obtain a first target text number set s= (S 1,S2,…,Su,…,Sv), u=1, 2, …, v in the first target text set in the current W; s u is the number of first target texts in the first target text set of the u-th current W; v is the number of first target text sets in the current W; the end time of W is the current time.
In this embodiment, in the sliding time window W, there are a plurality of historical problem texts input by a plurality of users, each of the historical problem texts corresponds to a first target text set, and the number of first target texts in the first target text set corresponding to each of the historical problem texts in the sliding time window W can be obtained, so as to obtain S; the length of time of W is a preset value, for example, 72 hours; the end time of W is the current time, so that the number of the first target texts in each first target text set in the acquired S can be ensured to be up to date, and the number of the first target texts in the first target text set under the current condition can be accurately reflected; the step size of the W movement may be set to a preset value, for example, 10 minutes; thereby, the time interval for acquiring S is made to be 10 minutes, thereby reducing the calculation effort occupation.
S522, according to S, determineWherein alpha is a preset proportionality coefficient, and alpha is more than 1; /(I)Is a preset round-up function.
As an example, f may also be set directly to a fixed value; in practical application, when f is set to be 50, a better effect can be obtained.
In this embodiment, the number of the first target texts in each first target text set in S is summed, and then, according to the number of the first target text sets in W, the average value of the number of the first target texts in each first target text set in W can be determined, where the average value can reflect the level of the number of the first target texts in the first target text set in the current situation; f is determined according to the average value and a preset proportion coefficient alpha; it can be understood that f is a dynamic value, and f can be changed according to the change of the number of the first target texts in each first target text set in the current W, so that the situation that the time consumption of matching the first target texts by the subsequent text recall sub-models is long or the number of the matching texts by the first text recall sub-models is too small and the first target texts matched by the subsequent text recall sub-models are inaccurate is avoided.
Furthermore, although the steps of the methods in the present disclosure are depicted in a particular order in the drawings, this does not require or imply that the steps must be performed in that particular order, or that all illustrated steps be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
Embodiments of the present invention also provide a non-transitory computer readable storage medium that may be disposed in an electronic device to store at least one instruction or at least one program for implementing one of the methods embodiments, the at least one instruction or the at least one program being loaded and executed by the processor to implement the methods provided by the embodiments described above.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
Embodiments of the present invention also provide an electronic device comprising a processor and the aforementioned non-transitory computer-readable storage medium.
An electronic device according to this embodiment of the application. The electronic device is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present application.
The electronic device is in the form of a general purpose computing device. Components of an electronic device may include, but are not limited to: the at least one processor, the at least one memory, and a bus connecting the various system components, including the memory and the processor.
Wherein the memory stores program code that is executable by the processor to cause the processor to perform steps according to various exemplary embodiments of the application described in the "exemplary methods" section of this specification.
The storage may include readable media in the form of volatile storage, such as Random Access Memory (RAM) and/or cache memory, and may further include Read Only Memory (ROM).
The storage may also include a program/utility having a set (at least one) of program modules including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The bus may be one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
The electronic device may also communicate with one or more external devices (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device, and/or with any device (e.g., router, modem, etc.) that enables the electronic device to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface. And, the electronic device may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through a network adapter. The network adapter communicates with other modules of the electronic device via a bus. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with an electronic device, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, including several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Embodiments of the present invention also provide a computer program product comprising program code for causing an electronic device to carry out the steps of the method according to the various exemplary embodiments of the invention as described in the specification, when said program product is run on the electronic device.
While certain specific embodiments of the invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the invention. Those skilled in the art will also appreciate that many modifications may be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

Claims (7)

1. A method of generating a response text, the method comprising the steps of:
s100, acquiring a question text A input by a target user;
S200, inputting a to a preset text retrieval model, so that the text retrieval model outputs a text list ta= (TA 1,TA2,…,TAn,…,TAm), n=1, 2, …, m matched with a according to a; wherein TA n is the nth text matched with A, and m is the number of texts matched with A; the text retrieval model comprises a preset text library and a text matching module, wherein the text matching module can match a plurality of texts matched with A from the text library according to A; each text in the text library belongs to the preset field;
S300, splicing the A and the TA according to a preset text splicing template to generate a target problem text QA corresponding to the A;
S400, inputting QA into a preset target text generation model so that the target text generation model outputs a response text matched with A according to QA;
The step S300 includes the steps of:
S310, acquiring a preset text splicing template; the text splicing template comprises a preset first text segment T 1, a preset second text segment T 2, a preset first text space W 1,T2 and a preset second text space W 2 between a preset third text segment T 3,T1 and a preset third text segment T 2 which are sequentially arranged;
S320, adding TA to W 1 and A to W 2 to generate QA;
W 1 and W 2 are determined by the following steps:
S311, obtaining the text length of each text in the TA to obtain the total text length QTA of each text in the TA;
S312, determining the text length of the text which can be accommodated by the W 1 according to the QTA Wherein, beta 1 is a preset first ratio coefficient, beta 1 is more than 1,/>Is a preset upward valued function;
s313, acquiring a text length FA of A;
s314, determining the text length of the text which can be accommodated by the W 2 according to the FA Wherein, beta 2 is a preset second proportionality coefficient; beta 2 > 1;
The text retrieval model comprises a first text matching module and a second text matching module, the text library comprises a plurality of texts with different text lengths, and the step S200 comprises the following steps:
S220, inputting A into a first text matching module of a preset text retrieval model, so that the first text matching module matches a plurality of first target texts from the text library according to A to obtain a first target text set B1= (B1 1,B12,…,B1p,…,B1q), and p=1, 2, … and q; wherein B1 p is a first text matching module, the p first target text is matched from the text library according to A, q is the number of the first target texts in B1; b1 p is less than or equal to a preset text length threshold;
S230, inputting A to a second text matching module of a preset text retrieval model, so that the second text matching module matches a plurality of second target texts from the text library according to A to obtain a second target text set B2= (B2 1,B22,…,B2j,…,B2k), j=1, 2, … and k; wherein B2 j is a second text matching module, a j second target text is matched from the text library according to A, and k is the number of the second target texts in B2; b2 j is greater than a preset text length threshold;
S240, adding each first target text in the B1 and each second target text in the B2 into a preset list TA' to obtain a text list TA matched with the A; wherein the initial state of TA' is null.
2. The method for generating a response text according to claim 1, wherein the step S300 includes the steps of:
S330, acquiring a preset text splicing template; the text splicing template comprises a preset first character string, a preset second character string, a preset third text space W 3 associated with the first character string and a preset fourth text space W 4 associated with the second character string; the first character string is different from the second character string;
S340, adding A to W 3 and TA to W 4 to generate QA.
3. The method for generating response text according to claim 1, wherein the text retrieval model includes a first text matching module, the text library includes several texts with different text lengths, and the step S200 includes the steps of:
S210, inputting A into a first text matching module of a preset text retrieval model, so that the first text matching module matches m first target texts from the text library according to A to obtain a text list TA= (TA 1,TA2,…,TAn,…,TAm) matched with A; the text length of the TA n is smaller than or equal to a preset text length threshold.
4. The method for generating a response text according to claim 1, wherein the target text generation model is obtained by:
s410, acquiring a preset first text generation model; the first text generation model is obtained by training a preset first training sample set for the initial text generation model, wherein the first training sample set comprises training samples in a plurality of fields;
s420, acquiring a preset second training sample set; the second training sample set comprises a plurality of training samples belonging to a target field, wherein the target field is one of a plurality of fields;
And S430, training the first text generation model by using a second training sample set to obtain the target text generation model.
5. The method for generating a response text according to claim 4, wherein the first text generation model includes a pre-training module and a fine-tuning module, an output end of the pre-training module is connected to an input end of the fine-tuning module, the pre-training module is used for pre-training the first text generation model, the fine-tuning module is used for adjusting the text output by the pre-training module, and the step S430 includes the following steps:
s431, acquiring a second training sample set; the second training sample set comprises a second pre-training sample set corresponding to the pre-training module and a second fine-tuning sample set corresponding to the fine-tuning module;
s432, inputting the second pre-training sample set to the pre-training module, inputting the second fine-tuning sample set to the fine-tuning module, and training the first text generation model to obtain the target text generation model.
6. A non-transitory computer readable storage medium having stored therein at least one instruction or at least one program, wherein the at least one instruction or the at least one program is loaded and executed by a processor to implement the method of generating a reply text according to any one of claims 1-5.
7. An electronic device comprising a processor and the non-transitory computer-readable storage medium of claim 6.
CN202311049585.1A 2023-08-18 2023-08-18 Response text generation method, electronic equipment and storage medium Active CN117033613B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311049585.1A CN117033613B (en) 2023-08-18 2023-08-18 Response text generation method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311049585.1A CN117033613B (en) 2023-08-18 2023-08-18 Response text generation method, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117033613A CN117033613A (en) 2023-11-10
CN117033613B true CN117033613B (en) 2024-05-14

Family

ID=88644676

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311049585.1A Active CN117033613B (en) 2023-08-18 2023-08-18 Response text generation method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117033613B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046244A (en) * 2019-04-24 2019-07-23 中国人民解放军国防科技大学 Answer selection method for question-answering system
CN111737443A (en) * 2020-08-14 2020-10-02 支付宝(杭州)信息技术有限公司 Answer text processing method and device and key text determining method
CN113220864A (en) * 2021-07-08 2021-08-06 中航信移动科技有限公司 Intelligent question-answering data processing system
CN115169364A (en) * 2022-06-17 2022-10-11 北京百度网讯科技有限公司 Intelligent question answering method, device, equipment and storage medium
CN115203388A (en) * 2022-06-15 2022-10-18 腾讯科技(深圳)有限公司 Machine reading understanding method and device, computer equipment and storage medium
CN115757725A (en) * 2022-11-15 2023-03-07 中国平安财产保险股份有限公司 Question and answer processing method and device, computer equipment and storage medium
CN116303929A (en) * 2023-01-10 2023-06-23 中国工商银行股份有限公司 Machine reading and understanding method and device, electronic equipment and storage medium
CN116383366A (en) * 2023-06-06 2023-07-04 中航信移动科技有限公司 Response information determining method, electronic equipment and storage medium
CN116561271A (en) * 2023-04-10 2023-08-08 阿里巴巴(中国)有限公司 Question and answer processing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11893060B2 (en) * 2020-02-06 2024-02-06 Naver Corporation Latent question reformulation and information accumulation for multi-hop machine reading

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110046244A (en) * 2019-04-24 2019-07-23 中国人民解放军国防科技大学 Answer selection method for question-answering system
CN111737443A (en) * 2020-08-14 2020-10-02 支付宝(杭州)信息技术有限公司 Answer text processing method and device and key text determining method
CN113220864A (en) * 2021-07-08 2021-08-06 中航信移动科技有限公司 Intelligent question-answering data processing system
CN115203388A (en) * 2022-06-15 2022-10-18 腾讯科技(深圳)有限公司 Machine reading understanding method and device, computer equipment and storage medium
CN115169364A (en) * 2022-06-17 2022-10-11 北京百度网讯科技有限公司 Intelligent question answering method, device, equipment and storage medium
CN115757725A (en) * 2022-11-15 2023-03-07 中国平安财产保险股份有限公司 Question and answer processing method and device, computer equipment and storage medium
CN116303929A (en) * 2023-01-10 2023-06-23 中国工商银行股份有限公司 Machine reading and understanding method and device, electronic equipment and storage medium
CN116561271A (en) * 2023-04-10 2023-08-08 阿里巴巴(中国)有限公司 Question and answer processing method and device
CN116383366A (en) * 2023-06-06 2023-07-04 中航信移动科技有限公司 Response information determining method, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN117033613A (en) 2023-11-10

Similar Documents

Publication Publication Date Title
CN107491547B (en) Search method and device based on artificial intelligence
US20230040095A1 (en) Method for pre-training model, device, and storage medium
US20220198327A1 (en) Method, apparatus, device and storage medium for training dialogue understanding model
CN113495900B (en) Method and device for obtaining structured query language statement based on natural language
US20190220486A1 (en) Method and apparatus for mining general tag, server, and medium
CN109086303A (en) The Intelligent dialogue method, apparatus understood, terminal are read based on machine
CN110019742B (en) Method and device for processing information
US11580299B2 (en) Corpus cleaning method and corpus entry system
CN114840671A (en) Dialogue generation method, model training method, device, equipment and medium
CN112926308B (en) Method, device, equipment, storage medium and program product for matching text
CN111930792A (en) Data resource labeling method and device, storage medium and electronic equipment
US20230186033A1 (en) Guided text generation for task-oriented dialogue
CN111339424B (en) Method, device and equipment for searching based on keywords and storage medium
CN115062718A (en) Language model training method and device, electronic equipment and storage medium
US9836450B2 (en) Methods and systems for providing universal portability in machine learning
CN116541493A (en) Interactive response method, device, equipment and storage medium based on intention recognition
CN111126073B (en) Semantic retrieval method and device
CN110750967B (en) Pronunciation labeling method and device, computer equipment and storage medium
CN112417860A (en) Training sample enhancement method, system, device and storage medium
CN117033613B (en) Response text generation method, electronic equipment and storage medium
CN116978367A (en) Speech recognition method, device, electronic equipment and storage medium
CN113807106B (en) Translation model training method and device, electronic equipment and storage medium
CN117033612B (en) Text matching method, electronic equipment and storage medium
CN111368036B (en) Method and device for searching information
CN111459959B (en) Method and apparatus for updating event sets

Legal Events

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