CN116226344A - Dialogue generation method, dialogue generation device, and storage medium - Google Patents

Dialogue generation method, dialogue generation device, and storage medium Download PDF

Info

Publication number
CN116226344A
CN116226344A CN202310140951.8A CN202310140951A CN116226344A CN 116226344 A CN116226344 A CN 116226344A CN 202310140951 A CN202310140951 A CN 202310140951A CN 116226344 A CN116226344 A CN 116226344A
Authority
CN
China
Prior art keywords
text
reply
dialogue
feature
history
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310140951.8A
Other languages
Chinese (zh)
Inventor
苏丽萍
胡猛
陈雨
付立波
李妍
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hubei Xingji Shidai Technology Co Ltd
Original Assignee
Hubei Xingji Shidai 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 Hubei Xingji Shidai Technology Co Ltd filed Critical Hubei Xingji Shidai Technology Co Ltd
Priority to CN202310140951.8A priority Critical patent/CN116226344A/en
Publication of CN116226344A publication Critical patent/CN116226344A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • 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)
  • Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Human Computer Interaction (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Embodiments of the present disclosure provide a dialog generation method, a dialog generation device, and a non-transitory computer-readable storage medium. The dialog generation method comprises the following steps: acquiring a current dialogue text sent by a user; based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text; processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the plurality of template feature texts and the current dialogue text to obtain a first spliced text; generating a reply text based on the first spliced text; and outputting the reply text.

Description

Dialogue generation method, dialogue generation device, and storage medium
Technical Field
Embodiments of the present disclosure relate to a dialog generation method, a dialog generation device, and a non-transitory computer-readable storage medium.
Background
Human-machine interaction (Human-Computer Interaction or Human-Machine Interaction, abbreviated as HCI or HMI) is a study of the interaction relationship between a research system and a user. In the field of man-machine interaction, man-machine conversation represents the way in which a user interacts with a computer.
Disclosure of Invention
At least one embodiment of the present disclosure provides a dialog generation method, including: acquiring a current dialogue text sent by a user; based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text; processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the template feature texts and the current dialogue text to obtain a first spliced text; generating a reply text based on the first spliced text; and outputting the reply text.
For example, in a dialog generating method provided in at least one embodiment of the present disclosure, generating a reply text based on the first spliced text includes: processing the first spliced text for N1 times through a language model to generate N1 pieces of first scores corresponding to N1 pieces of to-be-selected reply text and N1 pieces of to-be-selected reply text respectively; based on the N1 first scores, selecting N2 to-be-selected reply texts with the highest first score from the N1 to-be-selected reply texts as N2 candidate reply texts, wherein N1 and N2 are positive integers and N1 is greater than or equal to N2; calculating N2 second scores corresponding to the N2 candidate reply texts respectively based on the current dialogue text, the plurality of personality characteristics and the N2 candidate reply texts; and selecting a candidate reply text with the highest second score from the N2 candidate reply texts as the reply text based on the N2 second scores.
For example, in the dialog generating method provided in at least one embodiment of the present disclosure, calculating N2 second scores corresponding to the N2 candidate reply texts based on the current dialog text, the plurality of personality traits, and the N2 candidate reply texts, respectively, includes: for each candidate reply text: generating a plurality of feature scores and dialogue scores of the candidate reply text based on the current dialogue text, the plurality of personality features and the candidate reply text, wherein the plurality of feature scores represent scores of the candidate reply text for the plurality of personality features respectively, and the dialogue scores represent scores of the candidate reply text for the current dialogue text; and calculating a second score corresponding to the candidate reply text based on the feature scores and the dialogue scores.
For example, in a dialog generation method provided by at least one embodiment of the present disclosure, for each candidate reply text: generating a plurality of feature scores and dialogue scores for the candidate reply text based on the current dialogue text, the plurality of personality features, and the candidate reply text, including: for each candidate reply text: splicing the current dialogue text and the candidate reply text to obtain dialogue spliced text; splicing the plurality of individual features with the candidate reply text respectively to obtain a plurality of feature spliced texts; processing the dialogue splicing text through a personalized verification model to obtain the dialogue score; and respectively processing the plurality of feature spliced texts through the personalized verification model to obtain the plurality of feature scores.
For example, in a dialog generation method provided in at least one embodiment of the present disclosure, the language model is a unified pre-training language model.
For example, in the dialog generating method provided in at least one embodiment of the present disclosure, before N1 times of processing is performed on the first spliced text by using a language model to generate N1 pieces of reply text to be selected and N1 first scores corresponding to the N1 pieces of reply text to be selected respectively, generating reply text based on the first spliced text, further includes: querying a history record database based on the first spliced text, wherein the history record database comprises R pieces of history records, each history record in the R pieces of history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer; determining that the history database does not include a history having a similarity with the first spliced text greater than a recording similarity threshold.
For example, in a dialog generating method provided in at least one embodiment of the present disclosure, generating a reply text based on the first spliced text includes: querying a history record database based on the first spliced text, wherein the history record database comprises R pieces of history records, each history record in the R pieces of history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer; determining that the history database comprises at least one history record with similarity with the first spliced text being greater than a record similarity threshold; acquiring the at least one history record; splicing the first spliced text, the history spliced text in the at least one history record and the history reply text to obtain a second spliced text; and performing imitation writing processing on the second spliced text through a small sample imitation writing model to generate the reply text.
For example, in a dialog generation method provided in at least one embodiment of the present disclosure, based on the user and the current dialog text, acquiring a plurality of personality characteristics corresponding to the current dialog text includes: determining a personality characteristic set corresponding to the user based on the user, wherein the personality characteristic set comprises M1 personality characteristics; vectorizing the current dialogue text and the M1 personal characteristics to obtain a current dialogue vector and M1 characteristic vectors; calculating the similarity between the feature vector and the current dialogue vector for each feature vector in the M1 feature vectors to obtain M1 similarities respectively corresponding to the M1 feature vectors; and selecting M2 personal features with the similarity larger than a feature similarity threshold and the maximum similarity from the M1 personal features as the plurality of personal features based on the M1 similarity, wherein M1 and M2 are positive integers, and M1 is larger than or equal to M2.
For example, in a dialog generating method provided in at least one embodiment of the present disclosure, a plurality of alert templates corresponding to the plurality of personality characteristics respectively are used to process the plurality of personality characteristics respectively, so as to obtain a plurality of template feature texts, including: for each of the plurality of personality traits: determining a prompt template corresponding to the personalized features based on the feature types of the personalized features; and processing the personalized features by using the prompt templates to obtain template feature texts corresponding to the personalized features, wherein the personalized features comprise at least one user portrait feature of the user and/or at least one historical dialogue text sent by the user, and the prompt templates are prompt sentence pattern (prompt) templates.
For example, the dialog generation method provided in at least one embodiment of the present disclosure further includes: obtaining a second score of the reply text; generating a history record based on the first spliced text, the plurality of personality traits, the reply text, and the second score of the reply text; and storing the history record to a history record database.
At least one embodiment of the present disclosure provides a dialog generating apparatus including: an acquisition module configured to: acquiring a current dialogue text sent by a user; a feature selection module configured to: based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text; a dialog generation module configured to: processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the template feature texts and the current dialogue text to obtain a first spliced text; generating a reply text based on the first spliced text; and the output module is configured to output the reply text.
At least one embodiment of the present disclosure provides a dialog generating apparatus including: one or more memories non-transitory storing computer-executable instructions; one or more processors configured to execute the computer-executable instructions, wherein the computer-executable instructions, when executed by the one or more processors, implement a dialog generation method in accordance with any of the embodiments of the present disclosure.
At least one embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement a dialog generation method according to any embodiment of the present disclosure.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments will be briefly described below, and it is apparent that the drawings in the following description relate only to some embodiments of the present disclosure, not to limit the present disclosure.
FIG. 1 is a schematic flow chart diagram of a dialog generation method provided by at least one embodiment of the present disclosure;
FIG. 2 is a flow chart of a dialog generation method provided by at least one embodiment of the present disclosure;
FIG. 3 is a schematic flow chart of selecting personality traits provided by at least one embodiment of the present disclosure;
FIG. 4 is a flow chart of another dialog generation method provided by at least one embodiment of the present disclosure;
FIG. 5 is a flow diagram of a process for generating offline-online combined reply text provided by at least one embodiment of the present disclosure;
FIG. 6 is a schematic block diagram of a dialog generating apparatus provided in accordance with at least one embodiment of the present disclosure;
FIG. 7 is a schematic block diagram of another dialog generating apparatus provided in accordance with at least one embodiment of the present disclosure; and
fig. 8 is a schematic diagram of a non-transitory computer-readable storage medium provided by at least one embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present disclosure. It will be apparent that the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments, which can be made by one of ordinary skill in the art without the need for inventive faculty, are within the scope of the present disclosure, based on the described embodiments of the present disclosure.
Unless defined otherwise, technical or scientific terms used in this disclosure should be given the ordinary meaning as understood by one of ordinary skill in the art to which this disclosure belongs. The terms "first," "second," and the like, as used in this disclosure, do not denote any order, quantity, or importance, but rather are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that elements or items preceding the word are included in the element or item listed after the word and equivalents thereof, but does not exclude other elements or items. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", etc. are used merely to indicate relative positional relationships, which may also be changed when the absolute position of the object to be described is changed.
In order to keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits a detailed description of some known functions and known components.
In a man-machine interaction dialogue scene, in order to promote the real dialogue experience of a user and avoid the hard feeling brought to the user by the machine reply, personalized dialogue needs to be carried out for the user. The personalized dialogue refers to the fact that the reply dialogues generated by the man-machine dialogue system show content and style characteristic differences aiming at different user characteristics, are personalized replies related to personal information of users, can generate different reply contents according to actual conditions in reply utterances of the man-machine dialogue system, for example, can generate different personalized replies for users with different ages, sexes and professions. The personalized reply generated by combining the actual situation can enable the user to be aware of being learned and remembered, presents a one-to-one interactive sense of reality, and provides good user experience.
The technology required for personalizing conversations is very complex: firstly, in personalized dialogue, reply content generated by a man-machine dialogue system often depends on a large-scale dialogue corpus with specific individuality, and the large-scale personalized dialogue corpus is often difficult to acquire; secondly, once the cross combination is generated between the user attribute characteristics and various personal information in the user chat records, the combination forms are diversified, and the reply requirement of the personalized dialogue cannot be met through a preset dialogue library or strategy, so that the scene which can be met on the personalized dialogue based on the technical scheme of the dialogue system for searching or matching is very limited. In order to generate reply content of a personalized dialogue, the current man-machine dialogue system is mainly implemented in the following manner. Firstly, a corpus with specific individuation is built in advance, namely dialogue corpus conforming to the specific individuation is screened or built in a manual collection, auditing or labeling mode, and the replying voice constructed in the mode is high in quality, but a large number of individuation voice needs to be written manually, so that the labor cost is high; in addition, the personalized dialogue reply lacks objective standard answers, the understanding of different labeling personnel on the satisfaction of the individuality is different, and the individuality evaluation scores of the different labeling personnel on the text cannot be compared; moreover, the method can only realize single personality presentation, can only meet the high-frequency dialogue requirement of part of specific fields, and can not cope with the diversified input of users by constructing a reply utterance library in advance for more low-frequency dialogue requirements or scenes of open-field dialogue. In the second mode, the personalized style migration model is trained, in the second mode, one method learns expression characteristics from a large number of personalized dialog corpora by constructing the personalized migration/enhancement model, the requirement on training samples is high, and the other method participates in dialog generation by setting personalized hidden variables, so that hidden personalized variables can be obtained through training, but the personalized stability is poor; the method based on the personality migration model can present a certain personality, but the model can only aim at certain fixed personality characteristics, the individuation of the dialogue is not only aimed at the portrait characteristics of the user, more individuation replies can be designed aiming at the chat history of the user, the model obtained by training aiming at single personality tendency is weak in generated content diversity aiming at complex and changeable user personality characteristic combination, and the style expandability is poor, once the model is trained, the model needs to be retrained for adding new personality, and the time consumption is long; moreover, the effect of a plurality of personality migration models needs to be manually evaluated, so that the required labor cost is extremely high. The third mode is to directly train the personalized generation model, the personalized features of the user and the dialogue text are input into the generation model together, the generation model directly generates the reply content conforming to the personalized features, the existing model is still very dependent on training samples, and whether the generated content truly strengthens the fact that the personal information of the user cannot be effectively verified in time or not is caused by poor controllability of the generation model, and the personalized features are often manually specified and have a certain limitation. For the above reasons, it is difficult to implement a dialogue system that can stably implement personalized replies with good experience.
In addition, in the application of personalized dialogue, a large number of personalized dialogue data sets are required to be used as support, once the low-resource scene is faced, when the personalized dialogue data available for training is less, the dialogue system cannot always give optimal replies, and cannot adapt to various users.
To solve the above problems, at least one embodiment of the present disclosure provides a dialog generation method including: acquiring a current dialogue text sent by a user; based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text; processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the plurality of template feature texts and the current dialogue text to obtain a first spliced text; generating a reply text based on the first spliced text; and outputting the reply text.
In the embodiment of the disclosure, the dialogue generation method can be applied to any application scene in which personalized dialogue replies need to be generated to realize personalized dialogue, solve the difficulty in the process of generating reply texts in the personalized dialogue, automatically and effectively select the personalized features having key influence on the current dialogue text and accordingly generate the personalized reply texts for different users aiming at various personalized features (such as user portrait features, historical dialogue texts and the like) related to the users, present one-to-one interactive sense, improve user experience, have strong practicability and expandability, can remarkably improve the diversified experience of man-machine dialogue, and have very wide application prospects.
Embodiments of the present disclosure also provide a dialog generating apparatus and a computer-readable storage medium. The above-described dialog generation method may be applied to a dialog generation device provided in an embodiment of the present disclosure, which may be configured on an electronic apparatus. The electronic device may be a personal computer, a mobile terminal, etc., and the mobile terminal may be a mobile phone, an earphone, a tablet computer, a vehicle-mounted device, etc.
Embodiments of the present disclosure will be described in detail below with reference to the attached drawings, but the present disclosure is not limited to these specific embodiments.
FIG. 1 is a schematic flow chart diagram of a dialog generation method provided by at least one embodiment of the present disclosure; fig. 2 is a flowchart of a dialog generating method according to at least one embodiment of the present disclosure, and the embodiment shown in fig. 2 is an embodiment of generating reply text online in real time.
For example, as shown in fig. 1, a dialog generation method provided by an embodiment of the present disclosure includes steps S100 to S150.
In step S100, the current dialog text issued by the user is acquired.
In step S110, a plurality of personality characteristics corresponding to the current dialog text are acquired based on the user and the current dialog text.
In step S120, the plurality of personalized features are respectively processed by using a plurality of alert templates corresponding to the plurality of personalized features, so as to obtain a plurality of template feature texts.
In step S130, the plurality of template feature texts and the current dialog text are spliced to obtain a first spliced text.
In step S140, a reply text is generated based on the first spliced text.
In step S150, a reply text is output.
For example, in step S100, audio data sent by a single user may be acquired in real time by an audio acquisition device, and then speech recognition or the like is performed on the audio data to obtain a current dialog text. For example, the audio acquisition device may be a device that can acquire audio, such as a microphone.
For example, in some embodiments, step S110 may include: determining a personality characteristic set corresponding to the user based on the user, wherein the personality characteristic set includes M1 personality characteristics as shown in FIG. 2; vectorizing the current dialogue text and M1 individual features to obtain a current dialogue vector and M1 feature vectors; calculating the similarity between the feature vector and the current dialogue vector for each of the M1 feature vectors to obtain M1 similarities respectively corresponding to the M1 feature vectors; and selecting M2 personal characteristics with the similarity larger than a characteristic similarity threshold and the maximum similarity from M1 personal characteristics as a plurality of personal characteristics based on the M1 similarity. M1 and M2 are positive integers, and M1 is greater than or equal to M2.
For example, in step S110, a personality characteristic associated with the user may be acquired in advance to form a personality characteristic set, which may be stored in a device implementing the dialog generating method or may also be stored in the cloud. For example, the M1 personal features included in the personal feature set may include at least one user portrait feature US of the user and/or at least one historical dialog text UO sent by the user, as shown in fig. 2, the personal feature 1 may be a user portrait feature, and the personal feature 2 and the personal feature M1 may be historical dialog texts. The user portrayal feature US may comprise information about the user, such as age, gender, address, occupation, type of car in possession, etc., the historical dialog text UO representing dialog text that the user has already issued. For example, as shown in Table 1 below, for two different users, user u001 and user u002 (e.g., u001 and u002 may represent user identification information, such as an identification code, etc.), the two different users have different user portrayal features and different historical dialog text.
Table 1
Figure BDA0004087988370000081
It should be noted that, the historical dialog text in the personality characteristic set and the user portrait characteristic may be increased as the user uses the dialog system. Based on the enumerated user portrayal features and the historical dialogue text, the method is not limited to the enumerated user portrayal features, other information which can characterize user preference and behavior features can be used as user portrayal features for generating reference for personalized dialogue, and a dialogue system selects which features to use and can flexibly select aiming at user information which can be collected in actual application.
For example, in some examples, a plurality of personality traits may be selected by the feature selection module including at least one user portrait trait of the user and/or at least one historical dialog text uttered by the user. As shown in fig. 2, the plurality of personality characteristics includes personality characteristics i and personality characteristics j, where i and j are positive integers and less than or equal to M1, and in one example, personality characteristics i may be user portrait characteristics and personality characteristics j may be historical dialog text.
Fig. 3 is a schematic flow chart of selecting personality traits provided by at least one embodiment of the present disclosure.
For example, the feature selection module may include a feature encoder, in one embodiment, the personality characteristic set may include p user portrait features USi (i=1, 2, …, p) and q historical dialog text UOi (i= 1+p, 2+p, …, q+p), i.e., m1=q+p, at which point, after the current dialog text of the user is acquired, as shown in fig. 3, first, a personality characteristic set corresponding to the user (including user portrait features and/or personality features such as historical dialog text corresponding to the user) is determined based on information (e.g., a user identity code (i.e., a user ID)) of the user, and in the example shown in fig. 3, the personality characteristic set includes M1 personality features; then, the feature encoder uses word vector addition and other techniques to make a conversation Carrying out vectorization processing on the text and the M1 individual features to obtain a current dialogue vector corresponding to the current dialogue text and M1 feature vectors (namely feature vector 1-feature vector M1) corresponding to the M1 individual features respectively; then, performing similarity calculation on the current dialogue vector and the M1 feature vectors to obtain M1 similarities corresponding to the M1 feature vectors respectively, for example, calculating the similarity between the feature vector and the current dialogue vector for each feature vector to serve as the similarity corresponding to the feature vector, where the similarity corresponding to the feature vector is the similarity corresponding to the personality feature corresponding to the feature vector; then, based on the M1 similarities, determining a plurality of personality characteristics with the strongest binding property (the largest similarity) with the current dialogue text in the personality characteristic set, for example, selecting M2 feature vectors with the similarity larger than a feature similarity threshold and the largest similarity from the M1 feature vectors, where M2 personality characteristics corresponding to the M2 feature vectors are the personality characteristics. The number of the plurality of personality traits may be M2, and the plurality of personality traits may be represented as U M2 ,U M2 ∈[USi∪UOj]The logic selected by M2 is such that the similarity exceeds a specified feature similarity threshold P (0 < P < 1) and the number of individual features does not exceed a first number threshold, e.g., the first number threshold may be 3, such that M2 is less than or equal to 3. M2 is less than or equal to 3, so that the processing speed of the dialogue system is high, the real-time dialogue requirement is met, and meanwhile, the generated reply can meet the requirement of personalized reply; p is a hyper-parameter of the dialog system, e.g., in one example, p=0.9. It should be noted that, specific values of P and M2 may be set according to practical situations, which is not specifically limited in the present disclosure.
For example, in step S110, the similarity corresponding to each feature vector may be characterized by a vector inner product value between the feature vector and the current dialogue vector, e.g., the similarity between the feature vector and the current dialogue vector is calculated for each of the M1 feature vectors, including: for each feature vector: and calculating the vector inner product value between the feature vector and the current dialogue vector as the corresponding similarity of the feature vector.
For example, the similarity corresponding to the personality trait may be calculated using equation 1 as follows:
sa= (Emb (Ua) ×emb (Q1)) formula 1
Wherein Ua represents a personality in the personality set, ua e [ USi ] UOj, a=1, 2, …, M1, sa represents a similarity corresponding to the personality Ua, Q1 represents a current dialog text, emb (Ua) represents a feature vector of the personality Ua, and Emb (Q1) represents a current dialog vector.
In step S110, the problem of selecting the association strength between the current dialogue text and the user portrait features and between the current dialogue text and the historical dialogue text can be solved by selecting the personality features based on the similarity, and in the practical product application, the personality features having key influence on the current dialogue text can be effectively selected based on the similarity, so that the user portrait features and the historical dialogue text are fully utilized to generate the personalized reply text conforming to the personality of the user.
For example, in some embodiments, step S120 may include: for each of a plurality of personality traits: determining a prompt template corresponding to the personalized features based on the feature types of the personalized features; and processing the personalized features by using the prompt template to obtain template feature texts corresponding to the personalized features.
For example, in step S120, the plurality of alert templates are alert sentence pattern (promt) templates, that is, in the embodiment of the present disclosure, the plurality of template feature texts are implemented based on a prompt technique, where the promt technique indicates that the downstream machine learning task is directly completed by means of constructing the alert sentence pattern on the basis of the pre-training model. The personalized generation mode based on the prompt can meet more diversified and complex personalized scenes.
For example, in step S120, a template for splicing is selected based on the feature type of each individual feature, and the individual features are processed through the corresponding template to obtain a plurality of template feature texts.
For example, examples of multiple template templates may be shown in table 2.
Table 2
Figure BDA0004087988370000101
Figure BDA0004087988370000111
In the above table 2, the content in { } represents a content that can be filled in at the time of actual application.
For example, in some embodiments, step S130 may include: and sequentially connecting the plurality of template feature texts and the current dialogue text by using a predetermined separator to splice to obtain a first spliced text.
For example, in step S130, a plurality of template feature texts may be first sequentially connected using a predetermined separator to obtain a template feature spliced text, and then the template feature spliced text and the current dialog text are connected using the predetermined separator to generate a first spliced text. For example, the predetermined separator may be a comma, a pause, a space, a bracket, or the like. In the example shown in fig. 2, the first spliced text may be represented as [ template feature text i ] [ template feature text j ] … … [ current dialog text ], the template feature text i represents the template feature text corresponding to the personality feature i, and the template feature text j represents the template feature text corresponding to the personality feature j. In this example, the predetermined separator is [ ].
The process of obtaining the first spliced text will be described below taking the example of "navigate to 4S store" one actual current dialogue text of the user u001 in the above table 1. Based on table 1, the user portrait characteristics of the user u001 recorded in the dialogue system include: us= { age: 40-50 years old, style preference: elegant knowledge, area: DD1, occupation: doctor, motorcycle type: CX1}, the historical dialog text of user u001 recorded in the dialog system includes: uo= { ' navigate to XX1 region XX2 way XX3 No. XX4 4S store ', ' put the song of XX5 singer ', ' current dialog text Q1 of user u001 is: q1=navigate to 4S store.
For the current dialog text Q1 (to navigate to the 4S store), based on the above-mentioned processing of step S110, two personality characteristics with the highest similarity with the current dialog text Q1 and greater than the characteristic similarity threshold, namely, us= { vehicle model: CX1}, UO = { 'navigates to XX1 region XX2 way XX3 No. XX4 4S store' }, except for the two personality characteristics, the similarity between the rest of user portrait characteristics in the personality characteristic set corresponding to the user u001 and the historical dialog text and the current dialog text Q1 is less than the characteristic similarity threshold, and does not participate in the personalized dialog generation.
Based on the processing in steps S120 to S130, after the two personalized features and the current dialogue text are spliced in a prompt mode, a first spliced text Sc may be obtained: sc= { vehicle model CX1} user, { once asked 'navigate to XX1 region XX2 way XX3 CX1 4S store' }, say: navigating to a 4S store, answer: .
For example, in some embodiments, step S140 may include: processing the first spliced text for N1 times through a language model to generate N1 first scores corresponding to N1 pieces of to-be-selected reply text and N1 pieces of to-be-selected reply text respectively; based on the N1 first scores, selecting N2 to-be-selected reply texts with the highest first score from the N1 to-be-selected reply texts as N2 candidate reply texts; based on the current dialogue text, the plurality of personality characteristics and the N2 candidate reply texts, N2 second scores corresponding to the N2 candidate reply texts are calculated respectively; and selecting the candidate reply text with the highest second score from the N2 candidate reply texts as the reply text based on the N2 second scores.
For example, N1 and N2 are both positive integers, and N1 is greater than or equal to N2, in some examples N1 may be 20 and N2 may be 5. N1 and N2 may be set according to actual conditions (e.g., factors such as calculation force, time cost, etc.), which is not particularly limited by the present disclosure.
For example, as shown in fig. 2, the first spliced text (i.e., [ template feature text i ] [ template feature text j ] … … [ current dialog text ]) may be input into a language model for processing, so as to obtain N2 candidate reply texts, i.e., candidate reply texts 1-N2.
For example, in step S140, the language model may be a unified pre-training language model (Unified Language Model, UNILM), and the unified pre-training language model may implement the generation of the language model and the unified training phase model by adjusting attention (attention) matrix values of the generation phase.
In the dialogue generation method provided by the embodiment of the disclosure, the simplet method is combined to generate rich and changeable reply texts based on UNILM, personalized dialogue generation under low-resource and small-sample scenes is realized, zero-sample generation capacity and small-sample learning capacity of a large-scale pre-training language model are fully utilized, and compared with the prior art, the generalization is stronger, and training sample resources required by a training model are greatly saved.
However, embodiments of the present disclosure are not limited thereto, and the language model may be other pre-training language models (for example, GPT3 and the like) having a natural language generating capability, and in view of differences in the scale and generalization of the current various pre-training language models, different language models may be flexibly selected as the language model according to actual application scenarios.
For example, in step S140, the first spliced text Sc may be input to the UNILM for processing, for example, N1 (e.g., 20) repeated processing may be performed on the first spliced text Sc to generate N1 first scores corresponding to the N1 pieces of reply text to be selected and the N1 pieces of reply text to be selected respectively. For example, the first score corresponding to each reply text to be selected may be calculated based on the following equation 2:
Figure BDA0004087988370000121
in equation 2, A represents the text to be selected for reply, P (A-U M2 Q1) represents the score of A, t is the subscript, n represents the number of characters in A, A t Represents the t-th character in A, A <t Representing the first (t-1) characters in a.
For example, in one embodiment, in the processing of the UNILM, N1 pieces of reply text to be selected may be generated using a bundle search (beam search) method.
For example, N2 (e.g., 5) pieces of reply text to be selected may be selected based on the following equation 3:
AtopN=topN2(P(A│U M2 Q1)) equation 3
The AtopN represents the first scores corresponding to the selected N2 reply texts to be selected, and topN2 represents the N2 first scores selected highest.
For example, for the first spliced text Sc described above, 5 candidate reply texts may be generated by a language model based on a bundle search generation method, which may be: a1 Is? 'a2=' please is which 4S store to navigate to? Is a navigation to XX1, XX2, XX3, CX1 4S shop? Is the CX1 4S store where the'a4=' question navigated? ' a5= ' please select a specific location of the 4S store '.
For the generated candidate reply text, verification is needed through a personalized verification module, and each personalized feature Uj (Uj E U) in personalized features participating in generating the candidate reply text is verified M2 ) And the current dialogue text Q1 carries out matching prediction scoring on the candidate reply text, the personalized features and the current dialogue text according to an inverse transformation campt splicing method, namely N2 second scores corresponding to N2 candidate reply texts are calculated based on the current dialogue text, a plurality of personalized features and N2 candidate reply texts, and then a final reply text can be obtained according to a scoring result, namely the candidate reply text with the highest second score is selected from the N2 candidate reply texts to serve as the reply text.
The embodiment of the disclosure provides a personalized evaluation method based on reverse conversion, which utilizes a promtt mode to realize automatic evaluation of the matching degree of candidate reply texts generated based on a language model to personalized features, namely utilizes the prompt mode to measure the matching degree of the generated candidate reply texts and the personalized features by generating probability scores, realizes real-time evaluation of the personalized reply texts, and solves the problem that the personalized degree of the reply texts is difficult to evaluate.
For example, in some embodiments, calculating N2 second scores for each of the N2 candidate reply texts based on the current dialog text, the plurality of personality traits, and the N2 candidate reply texts includes: for each candidate reply text: generating a plurality of feature scores and dialogue scores for the candidate reply text based on the current dialogue text, the plurality of personality features, and the candidate reply text; based on the plurality of feature scores and the dialogue score, a second score corresponding to the candidate reply text is calculated. For example, the plurality of feature scores represent scores of the candidate reply text for a plurality of personality features, respectively, and the dialog score represents a score of the candidate reply text for the current dialog text.
For example, in some embodiments, for each candidate reply text: generating a plurality of feature scores and dialogue scores for the candidate reply text based on the current dialogue text, the plurality of personality traits, and the candidate reply text, comprising: for each candidate reply text: splicing the current dialogue text and the candidate reply text to obtain dialogue spliced text; splicing the plurality of individual features with the candidate reply texts respectively to splice texts with a plurality of features; processing the dialogue splicing text through a personalized verification model to obtain dialogue scores; and processing the characteristic spliced texts through the personalized verification model to obtain a plurality of characteristic scores.
For example, the feature score may be calculated based on the following equation 4:
Figure BDA0004087988370000141
in equation 4, a represents a candidate reply text, uj represents a jth personality trait among the personality traits, P (U) j -A) represents the feature score of A for the jth individual feature, t is the subscript, and n represents U j The number of characters in Uj t Representing U j The t-th character, uj in (b) <t Representing U j The first (t-1) character of (b).
For example, the dialogue score may be calculated based on the following equation 5:
Figure BDA0004087988370000142
in equation 5, A represents a candidate reply text, Q1 represents a current dialog text, P (Q1_A) represents a dialog score of A for the current dialog text, t is a subscript, n represents the number of characters in Q1, Q1 t Represents the t-th character in Q1, Q1 <t Representing the first (t-1) characters in Q1.
For example, in some embodiments, an example of an inverse transformed template of campt is shown in table 3 below. In table 3, a represents candidate reply text.
TABLE 3
Figure BDA0004087988370000143
For example, as shown in fig. 2, when personalized verification is performed, for candidate reply text 1, feature spliced text may be obtained: the [ candidate reply text 1] accords with the characteristic [ personality characteristic i ] and the [ candidate reply text 1] accords with the characteristic [ personality characteristic j ], and the dialogue splicing text can be obtained: the candidate reply text 1 is suitable for answering the current dialogue text, and then the dialogue spliced text is processed through a personalized verification model to obtain a dialogue score 1; processing the characteristic spliced texts through the personalized verification model to obtain characteristic scores, namely a characteristic score 1i and a characteristic score 1j; then, fusion scoring is performed based on the dialogue score 1, the feature score 1i, the feature score 1j, and the like, to obtain a second score of the candidate reply text 1. Similarly, a second score for candidate reply text 2, … for candidate reply text N2, may also be obtained.
Still taking the current dialogue text Q1 (navigating to a 4S store) as an example, after obtaining 5 candidate reply texts A1 to A5, it can be calculated that A1 to A5 correspond to us= { vehicle types: CX1 and uo= { 'navigating to personalized matching verification score for XX1 region XX2 way XX3 No. XX4 4S store' }, table 4 below shows the feature score for each candidate reply text.
Table 4
Figure BDA0004087988370000151
For example, after obtaining a plurality of feature scores and dialogue scores of each of the N2 candidate reply texts, a second score corresponding to the candidate reply text may be calculated, and the second score corresponding to each candidate reply text may be calculated by the following equation 6:
Figure BDA0004087988370000161
in formula 6, A i Represents the i candidate reply text, log represents a base 10 log function, score i (A i │U M2 Q1) represents the ith candidate reply text A i Corresponding second score, U j ∈U M2 ,U j The j-th individual feature of the plurality of individual features is represented, pi represents a product operation, i is a positive integer and is equal to or less than N2, and j is a positive integer and is equal to or less than M2.
It should be noted that the disclosure is not limited to the above formula for calculating the second score, and in some embodiments, the second score may also be calculated using the following formula 7:
Figure BDA0004087988370000162
the second score in table 4 is calculated based on equation 6. If the calculation is based on equation 7, score 1 (A 1 |U M2 ,Q1)=0.66,Score 2 (A 2 |U M2 ,Q1)=0.536,Score 3 (A 3 |U M2 ,Q1)=0.7679,Score 4 (A 4 |U M2 ,Q1)=0.3185,Score 5 (A 5 |U M2 ,Q1)=0.2332。
From the N2 second scores corresponding to the N2 candidate reply texts, respectively, the candidate reply text with the highest second score is selected as the final reply text, for example, may be selected by the following formula 8.
A best =Max(Score i (A i | U M2 Q1)) equation 8
In formula 8, max () represents maximum value, A best And representing the maximum value in N2 second scores corresponding to the N2 candidate reply texts respectively.
Still taking the current dialogue text Q1 (navigating to the 4S store) as an example, after obtaining 5 second scores corresponding to the 5 candidate reply texts A1 to A5, respectively, the highest second Score may be determined, e.g., score 3 (A 3 |U M2 Q1) = -0.1146 (0.7679 if based on equation 7), then the candidate reply text with the highest second score, i.e. candidate reply text A3, may be determined, and finally the candidate reply text A3 is output to the user as the personalized reply text that best fits the current dialog text Q1.
In some embodiments, the language model and the personality verification model may be the same model, and thus may share the same parameters. In the embodiment of the disclosure, personalized text generation and personalized text verification are fused into one model through inverse transformation of promtt in the process of dialogue generation and personalized verification, so that parameter sharing is realized, model parameters are reduced, practicability and expandability are enhanced, and the method has a very wide application prospect.
It should be noted that the language model and the personalized verification model may not be the same model, and do not share the same parameters, as long as the language model and the personalized verification model are both pre-training language models capable of realizing the functions thereof.
For example, in some embodiments, the dialog generation method further comprises: obtaining a second score of the reply text; generating a history record based on the first spliced text, the plurality of personality traits, the reply text, and the second score of the reply text; the history is stored to a history database (QADB, query answer data base). For example, the history database includes all histories generated since the user used the dialog system, each history including a history splice text and a corresponding history reply text.
Taking the current dialogue text Q1 (to navigate to 4S store) as an example, after obtaining the reply text, a history (s= { { { vehicle type CX1} user, { once asked 'navigate to XX1 region XX2 XX3 CX1 4S store' }, say, navigate to 4S store, reply }, U M2 = { vehicle type: CX1}, { 'navigate to XX1 region XX2 way XX3 No. XX4 4S store' }, q=navigate to 4S store, a=ask to navigate to XX1 region XX2 way XX3 way CX1 4S store, score= 0.7679) and store to the history database, thereby expanding the history data of the history database.
It should be noted that, in order to meet the storage requirement, the history database is prevented from occupying too large storage space, and the history data in the history database may be deleted at regular time.
In the above embodiment, in step S140, when generating the candidate reply text, N1 times of processing are required to be repeated on the first spliced text to obtain enough candidate reply texts, and each item of the candidate reply text and the plurality of personality characteristics obtained in step S110 needs to be personalized matching verified, and N1+ N1 x M2 times of generating calculation process are required in total. In order to solve the time-consuming requirement of online real-time prediction and fully utilize the calculated personalized generation example, in some embodiments of the present disclosure, a reply text generation mode of a small sample combined offline-online is provided, for a current dialogue text, if a history record with similarity to the current dialogue text being greater than a record similarity threshold exists, small sample imitation writing can be performed by referring to the history record, so that a personalized reply with better effect can be obtained by performing calculation for 1 time only. The generation speed of the on-line reply text can be further improved by referring to similar histories in the history database and performing small sample imitation writing through a language model.
For example, in some embodiments, before N1 times of processing is performed on the first spliced text by using one language model to generate N1 first scores corresponding to N1 pieces of reply text to be selected and N1 pieces of reply text to be selected respectively, step S140 further includes: querying a history record database based on the first spliced text, wherein the history record database comprises R history records, each history record in the R history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer; it is determined that the history database does not include a history having a similarity to the first spliced text greater than a record similarity threshold. That is, before the first spliced text is processed N1 times by one language model, it is necessary to first confirm whether the history database includes a history having a similarity with the first spliced text greater than a recording similarity threshold value, and after it is determined that the history database does not include a history having a similarity with the first spliced text greater than the recording similarity threshold value, personalized dialog generation, that is, reply text generation based on the language model, may be performed.
Fig. 4 is a flowchart of another dialog generating method according to at least one embodiment of the present disclosure, where the embodiment shown in fig. 4 is an embodiment of generating reply text in an offline manner.
For example, in other embodiments, step S140 may include: querying a history record database based on the first spliced text, wherein the history record database comprises R history records, each history record in the R history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer; determining that the history database comprises at least one history record with a similarity to the first spliced text greater than a record similarity threshold; acquiring at least one history record; splicing the first spliced text, the history spliced text in at least one history record and the history reply text to obtain a second spliced text; and performing imitation writing processing on the second spliced text through a small sample imitation writing model to generate a reply text. This embodiment is applicable to current dialog text where similar histories already exist in the history database, and is faster because only a small sample copy-back model is required to be processed once to generate the reply text.
For example, as shown in fig. 4, in an offline mode, a plurality of personality characteristics may be selected by the characteristic selection module, including personality characteristics i, j, and so on. Then, the plurality of individual features are respectively processed by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts, for example, the plurality of template feature texts may include a template feature text i corresponding to the individual feature i and a template feature text j corresponding to the individual feature j. The plurality of template feature texts and the current dialog text are then stitched to obtain a first stitched text, which is represented as [ template feature text i ] [ template feature text j ] … … [ current dialog text ], as shown in fig. 4. Then, based on the first spliced text, a history database is searched, and at least one history with the similarity with the first spliced text larger than a recording similarity threshold value is searched. And then, performing primary processing on a second spliced text spliced based on at least one history record and the first spliced text through a small sample imitation writing model to generate a reply text.
For example, histories in a historian database may be stored in a manner that retrieves libraries (e.g., faiss, facebook AI Similarity Search) of similarity vectors.
In some embodiments, the similarity between the first stitched text and the history may be calculated based on using Euclidean distance or vector inner product, etc. In one example, the similarity between the first spliced text and the history may be a similarity (euclidean distance or vector inner product, etc.) between a current dialog text in the first spliced text and a history dialog text in the history.
In some embodiments, the number of at least one history record may be less than or equal to a second number threshold. For example, the second number threshold may be 3. It should be noted that the second number threshold may be set according to practical situations, which is not limited in this disclosure.
For example, in some embodiments, the history database includes two histories having similarities to the first spliced text greater than a recording similarity threshold, historian 1 (Sh 1, U M2 h1, qh1, ah1, scoeh 1) and historyRecord 2 (Sh 2, U) M2 h2, qh2, ah2, score 2), then the history 1 (Sh 1, U) M2 h1, qh1, ah1, score 1) and history 2 (Sh 2, U M2 h2, qh2, ah2, score 2) and the historical splice text Sh1 and Sh2 and the historical reply text Ah1 and Ah2 and the first splice text Sc to obtain second splice text (Sh 1, ah1, sh2, ah2, sc).
In this example, the small sample imitation writing model is a language model obtained by using large-scale generation type pre-training, a small amount of history records are provided as references, and reply sentences with similar individuality can be imitated written through the model, because the history records in the history record database are subjected to inverse individuality verification based on the prompt when being generated, and therefore, aiming at the current dialogue text, the text subjected to imitation writing by directly using the history records can be used as a reply text, and the reply text can reach individuality degree meeting requirements.
For example, the small sample imitation writing model and the language model can be the same model, so that the number of models is saved, and the cost is saved. It should be noted that the small sample imitation writing model and the language model can be different models respectively, so that different application scenes are satisfied, and the implementation mode is more flexible and changeable.
For example, in some embodiments, the dialog generation method further comprises: processing the second spliced text through a small sample imitation writing model to generate a score corresponding to the reply text; generating a history record based on the scores of the first spliced text, the plurality of personality traits, the reply text and the reply text; the history is stored to a history database.
The small sample imitation writing by using the history database can fully utilize the generated personalized reply data to provide directly-referenced reply cases for similar dialogue requests of similar users, and save calculation resources required by online real-time prediction, so that an offline-online combined small sample imitation writing model is also constructed by online implementation. The flow chart of the generation process of the offline-online combined reply text is shown in fig. 5, and the flow chart is described as follows: the current dialogue text of the user is acquired, and the step S110 is executed, for example, a plurality of personality characteristics are selected by the characteristic selecting module, for example, personality characteristics i, personality characteristics j and the like can be selected; then, based on a plurality of template feature texts and current dialogue texts respectively corresponding to the plurality of individual features, a first spliced text is obtained, and the first spliced text shown in fig. 5 is expressed as: template feature text i ] [ template feature text j ] … … [ current dialog text ]; and searching a history record database, searching whether a history record with the similarity larger than a record similarity threshold exists in the history record database, if the history record with the similarity larger than the record similarity threshold exists in the history record database, namely, branching Y, performing personalized dialogue imitation writing, namely, taking a history reply text in the searched history record as an imitation writing case, quickly generating a personalized reply text 1 (a mode shown in fig. 4) corresponding to the current dialogue text and a score1 corresponding to the personalized reply text through a small sample imitation writing model, and then generating a history record by the reply text 1 and the score1 corresponding to the reply text, the first spliced text and a plurality of personalized features, and storing the history record into the history record database. As the history records in the history record database are subjected to personalized verification, the effective personalized reply text can be obtained only through one-time imitation writing generation, and the time consumption of online prediction is saved. If there is no history record with similarity greater than the record similarity threshold, namely branch N, in the history record database, personalized dialogue generation may be performed, that is, personalized reply text 2 corresponding to the current dialogue text and score2 corresponding thereto may be generated online in real time (in the manner shown in fig. 2), and then, the reply text 2 and score2 corresponding thereto, the first spliced text, and the plurality of personalized features may be generated into a history record, and the history record may be stored in the history record database.
The personalized imitation writing model is further described below in connection with a personalized imitation writing example, but the disclosure is not limited to this embodiment. For example, for user u003, the user portrait features corresponding to user u003 include us= { age: 30-40 years old, style preference: elegant knowledge, area: DD1, occupation: lawyer, motorcycle type: CX3}, the history dialog text comprises: once asked "navigate to the nearest XX64S store", the current dialog text q2= "navigate to 4S store".
By searching the history database, it is found that there is a history (Sh, U) having a similarity with the current dialog text Q2 greater than the recording similarity threshold value M2 h, qh, ah, score), the history is thus directly selected (sh= { { model CX1} user, { once asked 'navigate to XX1 region XX2 way XX3 No. XX4 4S store' }, say: navigating to a 4S store, answer: u (U) M2 h= { vehicle type: CX1}, { 'navigate to XX1 region XX2 XX3 No. XX4 4S store' }, qh = navigate to 4S store, ah = ask is to navigate to XX1 region XX2 XX3 No. CX1 4S store, score = 0.7679
Then, based on the history (Sh, U M2 h, qh, ah, score) and the current dialog text Q2, to obtain a personalized reply text of the current dialog text Q2 of the user u 003: is a = ask to navigate to the nearest XX64S store?
For example, in some embodiments, examples of the first spliced text corresponding to the current dialog text and the reply text to the current dialog text may include:
s: { first sign-on } { user name unknown } say: { hello o }, a: { is your good, i are dream, do you tell me your name? }
S: { old user } { user name is an axi } say: { hello o }, a: { you are good, A. West, good, recently busy what is? }
S: { child } user { happy } say: { tell me story }, a: { good, just have very interesting stories and you share-! }
S: { child } user { boring } say: { tell me story }, a: { good, give you a story that is not so boring-! }
S: { middle-aged } user { tired place }, say: { put the song bar }, a: { good, is not that today's work is too hard to be tired, the song is relaxed down the mood bar. }
In the above example, S represents the first spliced text corresponding to the current dialog text, and a represents the reply text corresponding to the current dialog text.
For example, in some embodiments, examples of dialog splice text and/or feature splice text at the time of personalized verification may include:
{ good, just have very interesting stories and you share-! -fit { happy } users;
{ good, give you a story that is not so boring-! -fit { boring } users;
{ why do younger get out of mind, can say with me? -fit { child } user;
{ why do younger get out of mind, can say with me? When the user is difficult.
For example, in some embodiments, in step S150, the reply text may be output to the user by way of a display screen, speaker, or the like.
The dialogue generating method provided by the embodiment of the disclosure can automatically generate the reply text of the personalized dialogue, fully utilizes the generating capability of the language model, and has the following advantages compared with the prior art:
1. the resource requirement is low, the generalization is stronger, and the training sample resources required for training the specific personalized dialogue model are greatly saved. The personalized answer operation library does not need to be constructed manually in advance, so that the labor cost is saved, training samples of a certain style do not need to be collected, and the requirement on sample data is reduced.
2. Through feature selection and a personalized generation mode based on the prompt, rich and varied reply texts can be generated so as to meet more diversified and complex personalized scenes. Because the integral model is not bound with any fixed personality characteristics, the enhanced personality characteristics are selected in real time from various portrait characteristics and historical dialogue information of the user through the characteristic selection module every time the personalized reply text is generated, the combination modes are more various, and the method is more in line with the context of the current dialogue scene.
3. In the dialogue generation method provided by the disclosure, the probability score is generated by using a prompt mode to measure the matching degree of the generated candidate reply text and the personalized features, so that the real-time evaluation of the personalized reply text is realized, and the problem that the personalized degree of the reply text is difficult to evaluate is solved.
4. The offline-online combined mode solves the problem of relatively high time consumption of online real-time prediction. The off-line-on-line combined mode can be based on similar histories of a history database, small sample imitation writing is performed through a language model, the small sample learning capacity of a pre-training language model is utilized, the on-line prediction speed is further improved, on-line prediction resources are saved, and meanwhile, the manual operation strategy can be quickly adapted in practical application. In the dialog generation method, the personalized dialog imitation writing and the personalized dialog generation can be combined, the personalized dialog imitation writing and the personalized dialog generation can be flexibly disassembled, the practicability and the expandability are strong, new personality characteristics can be quickly adapted in practical application, the dialog generation method is more suitable for manually operated dialog personality data, and the newly-added manual configuration dialog operation and the personalized reply strategy can be quickly responded.
It will be appreciated that prior to using the technical solutions disclosed in the embodiments of the present disclosure, the user should be informed and authorized of the type, usage range, usage scenario, etc. of the personal information (e.g., user portrait features, historical dialog text, etc.) related to the present disclosure in an appropriate manner according to relevant legal regulations. For example, in response to receiving an active request from a user, a prompt is sent to the user to explicitly prompt the user that the operation it is requesting to perform will require personal information to be obtained and used with the user. Therefore, a user can autonomously select whether to provide personal information to software or hardware such as electronic equipment, application programs, servers or storage media for executing the technical scheme of the present disclosure according to the prompt information.
As an alternative but non-limiting implementation, in response to receiving an active request from a user, the manner in which the prompt information is sent to the user may be, for example, a popup, in which the prompt information may be presented in a text manner. In addition, a selection control for the user to select to provide personal information to the electronic device in a 'consent' or 'disagreement' manner can be carried in the popup window.
It will be appreciated that the above-described notification and user authorization process is merely illustrative and not limiting of the implementations of the present disclosure, and that other ways of satisfying relevant legal regulations may be applied to the implementations of the present disclosure.
It will be appreciated that the data (including, but not limited to, the data itself, the acquisition or use of the data) involved in the technical solutions of the present disclosure should comply with the requirements of the corresponding laws and regulations and related regulations.
At least one embodiment of the present disclosure also provides a dialog generating apparatus. Fig. 6 is a schematic block diagram of a dialog generating apparatus provided in at least one embodiment of the present disclosure.
As shown in fig. 6, the dialog generating apparatus 600 includes an acquisition module 601, a feature selection module 602, a dialog generating module 603, and an output module 604. The components and structures of the dialog generating device 600 shown in fig. 6 are merely exemplary and not limiting, and the dialog generating device 600 may also include other components and structures as desired.
The acquisition module 601 is configured to acquire a current dialog text issued by a user. The obtaining module 601 is configured to perform step S100 shown in fig. 1.
The feature selection module 602 is configured to: based on the user and the current dialogue text, a plurality of personality characteristics corresponding to the current dialogue text are acquired. The feature selection module 602 is configured to perform step S110 shown in fig. 1.
The dialog generation module 603 is configured to: processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the plurality of template feature texts and the current dialogue text to obtain a first spliced text; a reply text is generated based on the first stitched text. The dialogue generation module 603 is configured to execute steps S120 to S140 shown in fig. 1.
The output module 604 is configured to: and outputting the reply text. The dialogue generation module 603 is configured to execute step S150 shown in fig. 1.
The specific description of the function implemented by the acquisition module 601 may refer to the related description of step S100 shown in fig. 1 in the embodiment of the above-described dialog generation method, the specific description of the function implemented by the feature selection module 602 may refer to the related description of step S110 shown in fig. 1 in the embodiment of the above-described dialog generation method, the specific description of the function implemented by the dialog generation module 603 may refer to the related descriptions of steps S120 to S140 shown in fig. 1 in the embodiment of the above-described dialog generation method, and the specific description of the function implemented by the output module 604 may refer to the related description of step S150 shown in fig. 1 in the embodiment of the above-described dialog generation method. The dialog generating apparatus 600 may achieve similar or identical technical effects as the dialog generating method described above, and will not be described again here.
For example, the acquisition module 601, feature selection module 602, dialog generation module 603, and/or output module 604 may be hardware, software, firmware, and any feasible combination thereof. For example, the acquisition module 601, the feature selection module 602, the dialogue generation module 603, and/or the output module 604 may be dedicated or general-purpose circuits, chips, or devices, or the like, or may be a combination of a processor and a memory, for example, the acquisition module 601 may include an audio acquisition device, or the like; the feature selection module 602 may include a feature encoder or the like; the dialogue generation module 603 may include the language model, the personalized verification model, the small sample imitation writing model, and the like; the output module 604 may include a display screen, speakers, etc. Embodiments of the present disclosure are not limited to the specific implementation of the various modules, sub-modules, and units described above.
At least one embodiment of the present disclosure further provides a dialog generating apparatus, and fig. 7 is a schematic block diagram of another dialog generating apparatus provided by at least one embodiment of the present disclosure.
For example, as shown in fig. 7, the dialog generation device 700 includes one or more memories 701 and one or more processors 702. The one or more memories 701 are configured to non-transitory store computer executable instructions; the one or more processors 702 are configured to execute computer-executable instructions. Computer-executable instructions, when executed by the one or more processors 702, implement the dialog generation method in accordance with any of the embodiments described above. For a specific implementation of each step of the session generation method and related explanation content, reference may be made to the description of the embodiments of the session generation method, which is not described herein.
For example, in some embodiments, the dialog generation device 700 may also include a communication interface and a communication bus. The memory 701, the processor 702 and the communication interface may communicate with each other through a communication bus, and the components of the memory 701, the processor 702 and the communication interface may also communicate with each other through network connection. The present disclosure is not limited herein with respect to the type and functionality of the network.
For example, the communication bus may be a peripheral component interconnect standard (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be classified as an address bus, a data bus, a control bus, or the like.
For example, the communication interface is used to enable communication between the dialog generating apparatus 700 and other devices. The communication interface may be a universal serial bus (Universal Serial Bus, USB) interface, or the like.
For example, the memory 701 and the processor 702 may be disposed at a server side (or cloud).
For example, the processor 702 may control other components in the dialog generation device 700 to perform the desired functions. The processor 702 may be a Central Processing Unit (CPU), a Network Processor (NP), or the like; but also Digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The Central Processing Unit (CPU) can be an X86 or ARM architecture, etc.
For example, memory 701 may comprise any combination of one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and/or non-volatile memory. Volatile memory can include, for example, random Access Memory (RAM) and/or cache memory (cache) and the like. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, erasable programmable read-only memory (EPROM), portable compact disc read-only memory (CD-ROM), USB memory, flash memory, and the like. One or more computer-executable instructions may be stored on the computer-readable storage medium and the processor 702 may execute the computer-executable instructions to implement the various functions of the dialog generation device 700. Various applications and various data, etc. may also be stored in the memory 701.
For example, a detailed description of the process of performing the dialog generation by the dialog generating apparatus 700 may refer to a related description in an embodiment of the dialog generating method, and the repetition is not repeated.
Fig. 8 is a schematic diagram of a non-transitory computer-readable storage medium provided by at least one embodiment of the present disclosure. For example, as shown in FIG. 8, one or more computer-executable instructions 1001 may be stored non-transitory on a non-transitory computer-readable storage medium 1000. For example, the computer-executable instructions 1001, when executed by a processor, may perform one or more steps in accordance with the dialog generation method described above.
For example, the non-transitory computer-readable storage medium 1000 may be applied to the above-described dialog generating apparatus 700, and may include, for example, the memory 701 in the dialog generating apparatus 700.
The description of the non-transitory computer readable storage medium 1000 may refer to the description of the memory 701 in the embodiment of the dialog generating device 700 shown in fig. 7, and the repetition is omitted.
For the purposes of this disclosure, the following points are also noted:
(1) The drawings of the embodiments of the present disclosure relate only to the structures related to the embodiments of the present disclosure, and other structures may refer to the general design.
(2) The embodiments of the present disclosure and features in the embodiments may be combined with each other to arrive at a new embodiment without conflict.
The foregoing is merely a specific embodiment of the disclosure, but the scope of the disclosure is not limited thereto and should be determined by the scope of the claims.

Claims (13)

1. A dialog generation method, comprising:
acquiring a current dialogue text sent by a user;
based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text;
processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts;
Splicing the template feature texts and the current dialogue text to obtain a first spliced text;
generating a reply text based on the first spliced text;
and outputting the reply text.
2. The dialog generation method of claim 1, wherein generating a reply text based on the first stitched text comprises:
processing the first spliced text for N1 times through a language model to generate N1 pieces of first scores corresponding to N1 pieces of to-be-selected reply text and N1 pieces of to-be-selected reply text respectively;
based on the N1 first scores, selecting N2 to-be-selected reply texts with the highest first score from the N1 to-be-selected reply texts as N2 candidate reply texts, wherein N1 and N2 are positive integers and N1 is greater than or equal to N2;
calculating N2 second scores corresponding to the N2 candidate reply texts respectively based on the current dialogue text, the plurality of personality characteristics and the N2 candidate reply texts;
and selecting a candidate reply text with the highest second score from the N2 candidate reply texts as the reply text based on the N2 second scores.
3. The dialog generation method of claim 2, wherein calculating N2 second scores for the N2 candidate reply texts based on the current dialog text, the plurality of personality traits, and the N2 candidate reply texts, respectively, includes:
For each candidate reply text:
generating a plurality of feature scores and dialogue scores of the candidate reply text based on the current dialogue text, the plurality of personality features and the candidate reply text, wherein the plurality of feature scores represent scores of the candidate reply text for the plurality of personality features respectively, and the dialogue scores represent scores of the candidate reply text for the current dialogue text;
and calculating a second score corresponding to the candidate reply text based on the feature scores and the dialogue scores.
4. A dialog generation method as claimed in claim 3, wherein, for each candidate reply text: generating a plurality of feature scores and dialogue scores for the candidate reply text based on the current dialogue text, the plurality of personality features, and the candidate reply text, including:
for each candidate reply text:
splicing the current dialogue text and the candidate reply text to obtain dialogue spliced text;
splicing the plurality of individual features with the candidate reply text respectively to obtain a plurality of feature spliced texts;
processing the dialogue splicing text through a personalized verification model to obtain the dialogue score;
And respectively processing the plurality of feature spliced texts through the personalized verification model to obtain the plurality of feature scores.
5. The dialog generation method of claim 2, wherein the language model is a unified pre-trained language model.
6. The dialog generation method of claim 2, wherein generating a reply text based on the first stitched text before processing the first stitched text N1 times by a language model to generate N1 pieces of reply text to be selected and N1 first scores corresponding to the N1 pieces of reply text to be selected, respectively, further comprises:
querying a history record database based on the first spliced text, wherein the history record database comprises R pieces of history records, each history record in the R pieces of history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer;
determining that the history database does not include a history having a similarity with the first spliced text greater than a recording similarity threshold.
7. The dialog generation method of claim 1, wherein generating a reply text based on the first stitched text comprises:
Querying a history record database based on the first spliced text, wherein the history record database comprises R pieces of history records, each history record in the R pieces of history records comprises a history spliced text and a corresponding history reply text, and R is a positive integer;
determining that the history database comprises at least one history record with similarity with the first spliced text being greater than a record similarity threshold;
acquiring the at least one history record;
splicing the first spliced text, the history spliced text in the at least one history record and the history reply text to obtain a second spliced text;
and performing imitation writing processing on the second spliced text through a small sample imitation writing model to generate the reply text.
8. The dialog generation method of any of claims 1-7, wherein obtaining, based on the user and the current dialog text, a plurality of personality characteristics corresponding to the current dialog text includes:
determining a personality characteristic set corresponding to the user based on the user, wherein the personality characteristic set comprises M1 personality characteristics;
vectorizing the current dialogue text and the M1 personal characteristics to obtain a current dialogue vector and M1 characteristic vectors;
Calculating the similarity between the feature vector and the current dialogue vector for each feature vector in the M1 feature vectors to obtain M1 similarities respectively corresponding to the M1 feature vectors;
selecting M2 personal features with the similarity larger than a feature similarity threshold and the maximum similarity from the M1 personal features as the plurality of personal features based on the M1 similarity,
wherein M1 and M2 are positive integers, and M1 is greater than or equal to M2.
9. The dialog generation method of any one of claims 1 to 7, wherein processing the plurality of personality characteristics with a plurality of alert templates corresponding to the plurality of personality characteristics, respectively, to obtain a plurality of template feature texts includes:
for each of the plurality of personality traits:
determining a prompt template corresponding to the personalized features based on the feature types of the personalized features;
processing the personalized features by using the prompt template to obtain template feature texts corresponding to the personalized features,
the personalized features comprise at least one user portrait feature of the user and/or at least one historical dialogue text sent by the user, and the prompting templates are prompting sentence pattern (prompt) templates.
10. The dialog generation method of any of claims 1 to 7, further comprising:
obtaining a second score of the reply text;
generating a history record based on the first spliced text, the plurality of personality traits, the reply text, and the second score of the reply text;
and storing the history record to a history record database.
11. A dialog generation device comprising:
an acquisition module configured to: acquiring a current dialogue text sent by a user;
a feature selection module configured to: based on the user and the current dialogue text, acquiring a plurality of personality characteristics corresponding to the current dialogue text;
a dialog generation module configured to: processing the plurality of individual features by using a plurality of prompt templates respectively corresponding to the plurality of individual features to obtain a plurality of template feature texts; splicing the template feature texts and the current dialogue text to obtain a first spliced text; generating a reply text based on the first spliced text;
and the output module is configured to output the reply text.
12. A dialog generation device comprising:
one or more memories non-transitory storing computer-executable instructions;
One or more processors configured to execute the computer-executable instructions,
wherein the computer-executable instructions, when executed by the one or more processors, implement the dialog generation method of any of claims 1-10.
13. A non-transitory computer-readable storage medium storing computer-executable instructions which, when executed by a processor, implement a dialog generation method according to any of claims 1 to 10.
CN202310140951.8A 2023-02-20 2023-02-20 Dialogue generation method, dialogue generation device, and storage medium Pending CN116226344A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310140951.8A CN116226344A (en) 2023-02-20 2023-02-20 Dialogue generation method, dialogue generation device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310140951.8A CN116226344A (en) 2023-02-20 2023-02-20 Dialogue generation method, dialogue generation device, and storage medium

Publications (1)

Publication Number Publication Date
CN116226344A true CN116226344A (en) 2023-06-06

Family

ID=86570946

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310140951.8A Pending CN116226344A (en) 2023-02-20 2023-02-20 Dialogue generation method, dialogue generation device, and storage medium

Country Status (1)

Country Link
CN (1) CN116226344A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116932726A (en) * 2023-08-04 2023-10-24 重庆邮电大学 Open domain dialogue generation method based on controllable multi-space feature decoupling
CN117216229A (en) * 2023-11-08 2023-12-12 支付宝(杭州)信息技术有限公司 Method and device for generating customer service answers

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116932726A (en) * 2023-08-04 2023-10-24 重庆邮电大学 Open domain dialogue generation method based on controllable multi-space feature decoupling
CN116932726B (en) * 2023-08-04 2024-05-10 重庆邮电大学 Open domain dialogue generation method based on controllable multi-space feature decoupling
CN117216229A (en) * 2023-11-08 2023-12-12 支付宝(杭州)信息技术有限公司 Method and device for generating customer service answers

Similar Documents

Publication Publication Date Title
CN107943998B (en) Man-machine conversation control system and method based on knowledge graph
US10950234B2 (en) Method and apparatus for determining speech interaction satisfaction
US11302337B2 (en) Voiceprint recognition method and apparatus
CN110288985B (en) Voice data processing method and device, electronic equipment and storage medium
CN107481720B (en) Explicit voiceprint recognition method and device
CN116226344A (en) Dialogue generation method, dialogue generation device, and storage medium
US9154629B2 (en) System and method for generating personalized tag recommendations for tagging audio content
CN111191016A (en) Multi-turn conversation processing method and device and computing equipment
CN109243468B (en) Voice recognition method and device, electronic equipment and storage medium
US20240153489A1 (en) Data driven dialog management
US11113335B2 (en) Dialogue system and computer program therefor
Chi et al. Speaker role contextual modeling for language understanding and dialogue policy learning
CN113421561B (en) Voice control method, voice control device, server, and storage medium
US20220130389A1 (en) Contextual content for voice user interfaces
US20240087562A1 (en) Interactive content output
US20230419957A1 (en) User profile linking
CN113761268A (en) Playing control method, device, equipment and storage medium of audio program content
CN116821290A (en) Multitasking dialogue-oriented large language model training method and interaction method
CN115640398A (en) Comment generation model training method, comment generation device and storage medium
Mariani et al. Natural interaction with robots, knowbots and smartphones
CN112446219A (en) Chinese request text intention analysis method
CN111427444B (en) Control method and device of intelligent device
JP2019056791A (en) Voice recognition device, voice recognition method and program
CN115168558A (en) Method for realizing multi-round man-machine conversation
CN113066473A (en) Voice synthesis method and device, storage medium and electronic equipment

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
CB02 Change of applicant information

Address after: 430050 No. b1337, chuanggu startup area, taizihu cultural Digital Creative Industry Park, No. 18, Shenlong Avenue, Wuhan Economic and Technological Development Zone, Hubei Province

Applicant after: Hubei Xingji Meizu Technology Co.,Ltd.

Address before: 430050 No. b1337, chuanggu startup area, taizihu cultural Digital Creative Industry Park, No. 18, Shenlong Avenue, Wuhan Economic and Technological Development Zone, Hubei Province

Applicant before: Hubei Xingji times Technology Co.,Ltd.

CB02 Change of applicant information