CN117251552B - Dialogue processing method and device based on large language model and electronic equipment - Google Patents

Dialogue processing method and device based on large language model and electronic equipment Download PDF

Info

Publication number
CN117251552B
CN117251552B CN202311501026.XA CN202311501026A CN117251552B CN 117251552 B CN117251552 B CN 117251552B CN 202311501026 A CN202311501026 A CN 202311501026A CN 117251552 B CN117251552 B CN 117251552B
Authority
CN
China
Prior art keywords
reply
information
dialogue
question
corpus
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311501026.XA
Other languages
Chinese (zh)
Other versions
CN117251552A (en
Inventor
刘刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202311501026.XA priority Critical patent/CN117251552B/en
Publication of CN117251552A publication Critical patent/CN117251552A/en
Application granted granted Critical
Publication of CN117251552B publication Critical patent/CN117251552B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/34Browsing; Visualisation therefor
    • 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/34Browsing; Visualisation therefor
    • G06F16/345Summarisation for human users
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Human Computer Interaction (AREA)
  • Machine Translation (AREA)

Abstract

The application relates to a dialogue processing method and device based on a large language model and electronic equipment. The method comprises the following steps: responding to the current question information of the target object in the dialogue process, and acquiring role information corresponding to the virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; searching a plurality of question-answer vector pairs in a dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair; generating type reply processing is carried out on the current question information based on the dialogue generating type model, and second reply information is obtained; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on a plurality of dialogue corpora in a dialogue corpus; and determining target reply information of the current question information based on the first reply information and the second reply information. The method and the device can promote consistency of replies based on role setting.

Description

Dialogue processing method and device based on large language model and electronic equipment
Technical Field
The present disclosure relates to the field of natural language processing technologies, and in particular, to a method and an apparatus for processing a dialogue based on a large language model, and an electronic device.
Background
A dialog System (dialog System) is a computer System that simulates a human being and is intended to form a coherent dialog with the human being. Dialog systems generally fall into three categories: task type, question-answer type, open field. The task type and the question-answer type generally have clear task and knowledge ranges, and some question-answer pairs are generally selected to be preset for answer queries in the dialogue in the related art, which results in inflexibility of the dialogue. Open domain conversations may be more flexible, but for the same or similar problems, the response results may vary greatly from time to time, the response may not be consistent, and the conversational experience is poor.
Disclosure of Invention
The application provides a dialogue processing method and device based on a large language model and electronic equipment, so that response consistency based on role setting in a dialogue process is realized. The technical scheme of the application is as follows:
according to a first aspect of an embodiment of the present application, there is provided a dialogue processing method based on a large language model, including:
Responding to the current question information of a target object in a dialogue process, and acquiring role information corresponding to a virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; the question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information;
searching the question-answer vector pairs in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair;
generating type reply processing is carried out on the current questioning information based on a dialogue generating type model, and second reply information is obtained; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus;
and determining target reply information of the current question information based on the first reply information and the second reply information.
According to a second aspect of embodiments of the present application, there is provided a dialogue processing apparatus based on a large language model, including:
The system comprises an acquisition module, a dialogue vector library and a dialogue vector library, wherein the acquisition module is used for responding to the current question information of a target object in the dialogue process and acquiring role information corresponding to a virtual object of the target object dialogue and the dialogue vector library corresponding to the role information; the question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information;
the reply retrieval module is used for searching the question-answer vector pairs in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to the reply vector in the target question-answer vector pair;
the reply generation module is used for carrying out generation type reply processing on the current question information based on the dialogue generation type model to obtain second reply information; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus;
and the reply determining module is used for determining target reply information of the current question information based on the first reply information and the second reply information.
According to a third aspect of embodiments of the present application, there is provided an electronic device, including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any of the first aspects above.
According to a fourth aspect of embodiments of the present application, there is provided a computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the method of any of the first aspects of embodiments of the present application.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions which, when executed by a processor, cause the computer to perform the method of any of the first aspects of embodiments of the present application.
The technical scheme provided by the embodiment of the application at least brings the following beneficial effects:
responding to the current question information of the target object in the dialogue process, and acquiring role information corresponding to the virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; searching a plurality of question-answer vector pairs in a dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair; generating type reply processing is carried out on the current questioning information based on the dialogue generating type model, and second reply information is obtained; and determining target reply information of the current question information based on the first reply information and the second reply information. The combination of the search type reply and the generated type reply is realized, a plurality of question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information, and the dialogue generation type model is obtained by fine tuning a pre-trained large language model based on a plurality of dialogue corpora in the dialogue corpus, so that flexibility of the dialogue can be realized based on the generated type reply, rich questions can be covered based on the dialogue corpus corresponding to the role information to realize reply consistency based on the role information, and the consistency of the reply can be maintained based on the role setting after a plurality of rounds of dialogues by the dialogue generation type model which is finely tuned based on the dialogue corpus related to the role information; and converting the dialogue corpus in the dialogue corpus into vectors for retrieving the reply information, so that the accuracy and the efficiency of retrieval can be improved, the dialogue processing can be more efficient and accurate, and the dialogue experience is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application and do not constitute an undue limitation on the application.
FIG. 1 is a schematic diagram of an application environment, shown in accordance with an exemplary embodiment.
FIG. 2 is a flow chart illustrating a method of dialog processing based on a large language model, according to an exemplary embodiment.
Fig. 3 is a flow diagram illustrating a method of dialog processing based on a large language model, according to an example embodiment.
FIG. 4 is a flow diagram illustrating another method of dialog processing based on a large language model, according to an example embodiment.
FIG. 5 is a schematic diagram illustrating a process for building a dialog corpus, according to an example embodiment.
FIG. 6 is a flowchart illustrating a method of large language model based dialog processing, according to an exemplary embodiment.
FIG. 7 is a block diagram of a large language model based dialog processing device, according to an example embodiment.
FIG. 8 is a block diagram of an electronic device for large language model based dialog processing, as illustrated in accordance with an exemplary embodiment.
FIG. 9 is a block diagram of an electronic device for large language model based dialog processing, according to an example embodiment.
Detailed Description
Various exemplary embodiments, features and aspects of the present application will be described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
In addition, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present application. It will be understood by those skilled in the art that the present application may be practiced without some of these specific details. In some instances, methods, means, elements, and circuits have not been described in detail as not to unnecessarily obscure the present application.
Artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use the knowledge to obtain optimal results. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
In recent years, with research and progress of artificial intelligence technology, the artificial intelligence technology is widely applied in a plurality of fields, and the scheme provided by the embodiment of the application relates to technology such as natural language processing technology, and is specifically described by the following embodiments.
Referring to fig. 1, fig. 1 is a schematic diagram of an application system according to an embodiment of the present application. The application system can be used for the dialogue processing method based on the large language model. As shown in fig. 1, the application system may include at least a server 01 and a terminal 02.
In this embodiment of the present application, the server 01 may be used for session processing based on a large language model, where the server 01 may include an independent physical server, or may be a server cluster or a distributed system formed by multiple physical servers, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network), and basic cloud computing services such as big data and an artificial intelligence platform.
In this embodiment of the present application, the terminal 02 may be configured to provide a dialogue interface for the above dialogue process, where the dialogue interface may be used for inputting the question information by the target object, and displaying the question information of the target object and the reply information of the virtual object. The terminal 02 may include a smart phone, a desktop computer, a tablet computer, a notebook computer, a smart speaker, a digital assistant, an augmented reality (augmented reality, AR)/Virtual Reality (VR) device, a smart wearable device, or other type of physical device. The physical device may also include software, such as an application, running in the physical device. The operating system running on the terminal 02 in the embodiment of the present application may include, but is not limited to, an android system, an IOS system, linux, windows, and the like.
In addition, it should be noted that fig. 1 is only one application environment of the dialog processing method based on a large language model provided in the present application.
In the embodiment of the present disclosure, the terminal 02 and the server 01 may be directly or indirectly connected through a wired or wireless communication method, which is not limited in this application.
It should be noted that, in the specific embodiments of the present application, related data of a user is referred to, and when the following embodiments of the present application are applied to specific products or technologies, permission or consent of the user needs to be obtained, and collection, use and processing of related data need to comply with related laws and regulations and standards of related countries and regions.
Before describing the method embodiments provided in the present application, application scenarios, related terms or nouns that may be involved in the method embodiments of the present application are briefly described, so as to be understood by those skilled in the art of the present application.
Machine learning: the Machine Learning, ML for short, is a multi-domain interdisciplinary, and relates to multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and the like. It is specially studied how a computer simulates or implements learning behavior of a human to acquire new knowledge or skills, and reorganizes existing knowledge structures to continuously improve own performance.
Large language model: large Language Model, LLM for short, refers to a computer model capable of processing and generating natural language. LLM can predict the next word or sentence through learning the statistical rule and semantic information of language data, and with the continuous expansion of input data set and parameter space, LLM's ability also can expand correspondingly. It is used in a variety of application fields such as machine learning, machine translation, speech recognition, image processing, etc., and so is called a multi-modal large language model.
Dialog system: the conversation agent is a computer system simulating human-to-human conversation, namely an intelligent agent, and aims to form a consistent conversation with human, wherein the communication mode mainly comprises voice/text/picture, and other modes such as gesture/touch and the like.
RLHF: human feedback reinforcement learning (Reinforcement Learning with Human Feedback) is an extension of reinforcement learning, which incorporates human feedback into the training process, providing a natural, humanized interactive learning process for the machine. In addition to the reward signal, RLHF agents get feedback from humans, learn with a wider view and higher efficiency, similar to how humans learn from another person's expertise. By setting up a bridge between the agent and the human, RLHF allows the human to direct the machine and allow the machine to master decision elements that are obviously embedded in the human experience.
FIG. 2 is a flow chart illustrating a method of dialog processing based on a large language model, according to an exemplary embodiment. As shown in fig. 2, the following steps may be included.
In step S201, in response to the current question information of the target object in the session, role information corresponding to the virtual object of the target object session and a session vector library corresponding to the role information are acquired.
In the embodiment of the present specification, the target object may refer to any user performing an intelligent dialogue, and the target object may input question information in a dialogue interface provided by the intelligent dialogue to obtain a corresponding answer. The virtual object may refer to a virtual person, such as a conversation robot, that is intelligently placed to converse with the target object.
In one embodiment, the virtual object may be configured with character information, which may be considered a persona, such as may include, but not limited to, personality, language style, interest preferences, and the like, as not limited in this application. Based on this, it is desirable in the embodiments of the present specification to promote flexibility of conversations and consistency of character-based replies by assigning character information to virtual objects.
The dialogue vector library may include a plurality of question-answer vector pairs, and the plurality of question-answer vector pairs may be obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the character information. For example, the dialogue corpus may include a question corpus and a reply corpus, and accordingly, the question-answer vector pair may include a question vector corresponding to the question corpus and a reply vector corresponding to the reply corpus. For example, for any dialogue corpus, the pre-trained BERT model may be used to perform vector conversion processing on the question corpus and the answer corpus, so that a question vector corresponding to the question corpus and an answer vector corresponding to the answer corpus may be obtained, so that the question vector and the answer vector corresponding to the dialogue corpus may be used as question and answer vectors corresponding to the dialogue corpus, that is, the question and answer vectors include the question vector and the answer vector. Therefore, question-answer vectors corresponding to the dialog corpora can be obtained, and the question-answer vectors can be formed into a dialog corpus corresponding to the role information. Here, the dialogue corpus corresponding to the character information may refer to a corpus storing dialogue corpora related to the character information.
For example, the dialog corpus may be summarized from character information or simulated multiple rounds of dialog based on character information. For example, character information may include my name XXX, my favorite sports XXX, i good at … …. Based on this, the question corpus and the answer corpus can be summarized from the character information as follows:
what name you call? My name XXX;
what do you like? I like sports XXX;
what do you have good at doing? I are good at … ….
It should be noted that this is merely an example, and the number and arrangement of the plurality of dialogue corpora in the present application are not limited.
In practical application, the target object may input current question information in the dialogue interface, and correspondingly, in response to the current question information of the target object in the dialogue process, the role information corresponding to the virtual object of the target object dialogue and the dialogue vector library corresponding to the role information may be obtained. For example, the character information corresponding to the virtual object may be obtained by searching the stored object character configuration information, where the object character configuration information may store the character information configured by the virtual object, or the object character information may store the correspondence between a plurality of virtual objects and the corresponding character information. Further, from the correspondence between the stored character information and the dialogue vector library, the dialogue vector library corresponding to the character information can be obtained for the retrieval of the subsequent answer.
In step S203, a plurality of question-answer vector pairs are searched in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and the first reply information is obtained based on the reply corpus corresponding to the reply vector in the target question-answer vector pair.
Referring to fig. 3, the current question information may be respectively replied in two ways to obtain a first reply information and a second reply information, so that the target reply information may be obtained based on the first reply information and the second reply information, and a specific process may be described below.
In the embodiment of the present disclosure, the current question information may be subjected to vector characterization processing, for example, a pre-trained BERT model may be used to perform vector conversion on the current question information, so as to obtain a current question vector corresponding to the current question information. Therefore, the question vector in a plurality of question-answer vector pairs can be searched in the dialogue vector library by using the current question vector, and the question-answer vector pair in which the question vector matched with the current question vector is positioned is determined to be used as the target question-answer vector pair. Further, the first reply information may be obtained based on a reply corpus corresponding to a reply vector in the target question-answer vector pair. For example, a reply vector may be extracted from the target question-answer vector, so that a reply corpus corresponding to the reply vector may be obtained as the first reply information, where the reply corpus corresponding to the reply vector may belong to a reply corpus included in a dialogue corpus in the dialogue corpus. As an example, when converting the dialogue corpus into the dialogue vector pair, the correspondence between the dialogue corpus and the dialogue vector pair may be recorded and saved, and based on this, the reply corpus corresponding to the reply vector may be obtained according to the correspondence.
In an optional implementation manner, the obtaining the first reply message based on the reply corpus corresponding to the reply vector in the target question-answer vector pair may include:
searching from a plurality of dialogue corpora in a dialogue corpus to obtain a target dialogue corpus matched with the target question-answer vector pair, for example, searching based on the corresponding relation to obtain a target dialogue corpus matched with the target question-answer vector pair; so that the reply corpus can be extracted from the target dialogue corpus.
Further, the character style language adjustment model may be used to perform character style language adjustment on the reply corpus, so as to obtain the first reply information. As an example, the character style language adjustment model may be obtained by fine tuning a pre-trained large language model based on the reply corpus in the dialog corpus, the character information, and the constructed reply text (corresponding to the reply corpus). For example, a convolution layer may be added after each decoding module of the large language model, parameters of the large language model may be fixed, the reply text and the character information may be input into the large language model added to the convolution layer, and the predicted reply text may be output, so that the predicted reply text may be compared with the reply corpus corresponding to the reply text to obtain the loss information, a gradient may be calculated based on the loss information, and parameters of the convolution layer may be adjusted based on the gradient until the loss information satisfies a loss threshold, so that the large language model added to the convolution layer corresponding to the loss threshold may be used as the character style language adjustment model.
In practical application, the text length of the question corpus or the text length of the answer corpus in the dialogue corpus may be greater than the preset length, in which case, the text of the question corpus or the answer corpus may be segmented, and then the segmented question corpus or the segmented answer corpus is subjected to vector conversion to obtain a question sub-vector corresponding to the question sub-corpus or a answer sub-vector corresponding to the answer sub-corpus. Based on this, referring to fig. 4, searching a plurality of question-answer vector pairs in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information may include:
under the condition that the text length of the current question information is larger than the preset length, text segmentation is carried out on the current question information to obtain a plurality of question sub-information;
searching a plurality of question-answer vector pairs in a dialogue vector library to obtain question-answer vector pairs corresponding to each of a plurality of question sub-information; the question-answer vector pair corresponding to the question sub-information may refer to a question-answer vector pair to which a question word vector matched with the question sub-information belongs. For example, the embedded vector Embedding representation may be performed on the multiple question sub-information to obtain multiple corresponding embedded vector features, so as to find multiple question-answer vector pairs in the dialogue vector library, and obtain question-answer vector pairs corresponding to the multiple embedded vector features, which are used as question-answer vector pairs corresponding to the multiple question sub-information. And then a plurality of question-answer vector pairs can be used as target question-answer vector pairs.
It should be noted that, the matching may refer to that the same or similar degree is greater than a preset similarity threshold.
In step S205, a generated reply process is performed on the current question information based on the dialogue generated model, so as to obtain second reply information.
In the embodiment of the present disclosure, the dialogue generating model may be obtained by fine tuning a pre-trained large language model based on a plurality of dialogue corpora in a dialogue corpus. For example, the pre-trained large language model may be fine-tuned in the manner of LoRA (LoRA, full Low-Rank Adaptation of Large Language Models, low-order adaptation of large language models). Based on this, in one example, parameters of the pre-trained large language model may be frozen and dropout+linear+conv1d (decay, linear transform, and convolution) additional parameters are added in each layer Decoder (decoding layer). Therefore, the questioning corpus in the dialogue corpus can be input into the large language model with the additional parameters for answer prediction to obtain the predicted answer corpus, loss information between the predicted answer corpus and the answer corpus in the dialogue corpus can be determined, and the gradient is calculated based on the loss information to adjust the parameters of attenuation, linear transformation and convolution until the loss information meets a loss threshold value. Thus, a large language model corresponding to the added additional parameter when the loss threshold is satisfied can be used as the dialogue generating model. The whole training process can be light, can also accord with the people setting style of the role information, the reply information output is more accurate, the stability and consistency of people setting are maintained, and meanwhile, the dialogue generating model has memory capacity and is not influenced by the number of dialogue rounds.
Accordingly, the dialogue generating model obtained by fine tuning can be used for answer prediction of the questioning information, for example, generating type answer processing can be performed on the current questioning information based on the dialogue generating model, and second answer information is obtained. For example, the current question information may be input into a dialogue generating model to perform generating type reply prediction, so as to obtain second reply information.
The large language model in the embodiment of the present specification may refer to a model using the generated transformation architecture, and the present application is not limited thereto.
In one possible implementation manner, the generating type reply processing for the current question information based on the dialogue generating type model to obtain the second reply information may include:
inputting the current questioning information into a dialogue generating model to perform generating type reply processing to obtain a plurality of initial reply information; the plurality of initial reply messages may be output by inputting the current question information once or may be output by inputting the current question information a plurality of times, which is not limited in this application.
Further, the reply evaluation model may be used to evaluate the plurality of initial reply messages respectively, so as to obtain respective evaluation information, such as scoring, of the plurality of initial reply messages. The evaluation information may be used to characterize the matching degree of the initial reply information and the character information, for example, the higher the matching degree is, the higher the score is;
Therefore, based on the evaluation information, the initial reply information with the highest matching degree with the role information can be screened out from the plurality of initial reply information to serve as the second reply information. Through the use of the reply evaluation model, second reply information with higher matching degree with the role information can be obtained.
The recovery evaluation model may be obtained by performing reinforcement learning on a preset machine learning model based on a sample corpus, where the reinforcement learning may be RLHF. For example, the sample corpus may include a plurality of sample question corpora and at least one sample reply corpus corresponding to each sample question corpus, and the corresponding at least one sample reply corpus may include a sample reply corpus matching the character information and a sample reply corpus not matching the character information. For example, the sample reply corpus may be reply corpus output by inputting the sample question corpus into a pre-trained large language model for reply prediction, and these output reply corpora may be scored using a manual scoring manner, so that the scoring may be used as a reward signal to train a preset machine learning model to learn to score sample reply corpora in the sample corpus until the scoring of sample reply corpus matching the role information is above a first threshold and the scoring of sample reply corpus not matching the role information is below a second threshold, which is lower than the first threshold. Therefore, the corresponding preset machine learning model can be used as the reply evaluation model when the scoring of the sample reply corpus matched with the character information is higher than a first threshold value and the scoring of the sample reply corpus not matched with the character information is lower than a second threshold value.
By way of example, the operator of the virtual object, the product manager, etc., who is manually scored in reinforcement learning, is not limited in this application.
In an alternative embodiment, the method may further include:
and determining the answer matching degree of the first reply information and the current question information and the style matching degree of the first reply information and the role information. The answer matching degree and the style matching degree herein may be predicted based on the corresponding models, which is not limited in this application. Alternatively, the first reply information, the current question information, and the character information may be respectively converted into corresponding vector features using a pre-trained language model, so that the reply matching degree and the style matching degree may be determined based on the similarity between the vector features. For example, determining the answer matching degree may be a similarity between the vector feature of the first answer information and the vector feature of the current question information, i.e., a vector distance; the style matching degree may be a similarity between the vector features of the first reply information and the vector features of the character information.
Further, the target matching degree corresponding to the first reply information can be determined according to the reply matching degree or the style matching degree, namely, the target matching degree can be positively correlated with the reply matching degree or the style matching degree;
Accordingly, the generating reply processing for the current question information based on the dialogue generating model to obtain the second reply information may include: and under the condition that the target matching degree does not reach the preset matching degree, generating type reply processing is carried out on the current question information based on the dialogue generating type model, and second reply information is obtained. Alternatively, in the case where the target matching degree reaches the preset matching degree, the first reply information may be directly used as the target reply information.
In step S207, the target reply information of the current question information is determined based on the first reply information and the second reply information.
In the embodiment of the present disclosure, the first reply information and the second reply information may be combined to obtain the target reply information of the current question information. The merging may include, but is not limited to, merging the content of the first reply message with the content of the second reply message, adjusting the language style of the first reply message and the second reply message, and the like, which is not limited in this application.
Responding to the current question information of the target object in the dialogue process, and acquiring role information corresponding to the virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; searching a plurality of question-answer vector pairs in a dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair; generating type reply processing is carried out on the current questioning information based on the dialogue generating type model, and second reply information is obtained; and determining target reply information of the current question information based on the first reply information and the second reply information. The combination of the search type reply and the generated type reply is realized, a plurality of question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information, the dialogue generated model is obtained by fine tuning a pre-trained large language model based on a plurality of dialogue corpora in the dialogue corpus, the flexibility of the dialogue can be realized based on the generated type reply, rich questions can be covered based on the dialogue corpus corresponding to the role information to realize the consistency of the reply based on the role information, and the consistency of the reply can be maintained based on the role setting after a plurality of rounds of dialogues by the dialogue generated model which is finely tuned based on the dialogue corpus related to the role information; and converting the dialogue corpus in the dialogue corpus into vectors for retrieving the reply information, so that the accuracy and the efficiency of retrieval can be improved, the dialogue processing can be more efficient and accurate, and the dialogue experience is improved.
In an optional embodiment, the determining the target reply information of the current question information based on the first reply information and the second reply information may include:
and extracting the first reply content, the first reply language style, the second reply content and the second reply language style from the first reply information and the second reply information respectively. For example, the first reply content and the first reply language style may be extracted from the first reply information; and may extract the second reply content and the second reply language style from the second reply message. The first and second reply language styles may belong to a plurality of preset language styles. The plurality of predetermined language styles may include, but are not limited to, humor, naught, etc., as the present application is not limited thereto.
Content fusion is carried out on the first reply content and the second reply content, and fusion reply content is obtained; content fusion herein may include content deduplication, content endian adjustment, and the like, which is not limited in this application.
And screening a target reply language style from the first reply language style and the second reply language style, wherein the matching degree of the target reply language style and the role information meets a matching degree condition, and the matching degree condition can be the highest matching degree by way of example. For example, a first matching degree of the first reply language style and the character information and a second matching degree of the second reply language style and the character information may be determined, so that a highest of the first matching degree and the second matching degree may be regarded as a target matching degree, and accordingly, a reply language style (the first reply language style or the second reply language style) corresponding to the target matching degree may be regarded as a target reply language style.
Therefore, the target reply language style can be used for adjusting and fusing reply contents to obtain target reply information, so that the target reply information can be highly matched with the current question information in the content, and can be highly matched with role information in the language style, and reply consistency is realized. For example, if the target reply language style is humour and the fused reply content is "i good at drinking water", the fused reply content may be adjusted using the target reply language style to obtain the target reply information, for example, "i good at drinking water because swimming is old as drinking water woolen". Alternatively, humor expression and the like may be added on the basis of the fusion reply content, which is not limited in this application.
As an example, the language style recognition model may be used to recognize the first reply language style of the first reply message and the second reply language style of the second reply message. The language style recognition model may be obtained by supervised training of a preset machine learning model based on a plurality of training samples. The training sample may include sample text information and corresponding language style tag information, so when the sample text information is input into a preset machine learning model to perform language style recognition to obtain recognized language style information, loss information corresponding to the recognized language style information and the language style tag information may be calculated based on a preset loss function, and further, parameters of the preset machine learning model may be adjusted based on the loss information until the loss information is smaller than a loss threshold value, so that the preset machine learning model learns the language style of the text, and thus the corresponding preset machine learning model may be used as the language style recognition model when the loss information is smaller than the loss threshold value.
In an alternative embodiment, referring to fig. 5, the dialog corpus described above may be pre-constructed, for example, the dialog corpus may be constructed using the underlying corpus information. Based on this, the method may further comprise: acquiring basic corpus information corresponding to the role information; the basic corpus information can be subjected to corpus data processing to obtain a dialogue corpus, for example, single-round or multi-round dialogue processing can be performed on the basis of the basic corpus information, for example, single-round or multi-round inquiry is performed to obtain an initial dialogue corpus, namely, the dialogue corpus with a preset order of magnitude is obtained; and adjusting the initial dialogue corpus based on the role information to obtain a dialogue corpus comprising a plurality of dialogue corpora. The dialogue corpus may include a plurality of dialogue corpora of the question corpus and the corresponding answer corpus.
In one example, the basic corpus information corresponding to the role information may be obtained by the following steps:
acquiring historical dialogue information of a virtual object and role-related dialogue information (human-set QA) configured for the virtual object; for example, a dialogue record of a virtual object in a history period may be acquired, and a question-answer information pair may be extracted from the dialogue record as history dialogue information. And, character-related dialogue information configured for the virtual object may be acquired, which may refer to question information and answer information corresponding to character basic attribute information configured for the character information of the virtual object, and the character basic attribute information may include, but is not limited to, question sums of information such as character names, interest preferences, and proficiency skills, which are not limited in this application. For example, the character-related dialogue information may be classified and mined from the character information, for example, the character information may be classified into a plurality of basic attribute information, so that question information and answer information may be set for each basic attribute information, and thus the character-related dialogue information of the virtual object may be obtained.
And, can be based on the intelligent dialogue tool and automatically make multiple questions on the basis of the historical dialogue information, get the automatic dialogue information (automatic QA). The intelligent dialog tool herein may refer to an artificial intelligence technology driven natural language processing tool.
Further, the basic corpus information can be obtained according to the historical dialogue information, the role related dialogue information and the automatic dialogue information. For example, historical dialog information, role related dialog information, and automated dialog information may be organized into base corpus information. For example, according to the structures of the question corpus and the answer corpus, the historical dialogue information, the role related dialogue information and the automatic dialogue information can be respectively constructed into formats of the question corpus and the answer corpus to form structured basic corpus information.
In one example application, the large language model based dialog processing function (or dialog system) may be configured in the architecture of existing business services, messaging services, access services, and the like. For example, based on the architecture, the dialogue system can perform management of dialogue corpus, fine tuning of large language model, dialogue processing based on role information, dialogue service, and the like. In particular, the dialog process may refer to fig. 6, for example, the target object may select to dialog with the virtual object, so that a dialog interface with the virtual object may be entered, so that question information may be entered in the dialog interface, which may be regarded as current question information. Accordingly, S601 may be performed: and responding to the current question information of the target object in the dialogue process, and acquiring the role information corresponding to the virtual object of the target object dialogue and a dialogue vector library corresponding to the role information. For example, the character information corresponding to the virtual object may be obtained by searching the stored object character configuration information, where the object character configuration information may store the character information configured by the virtual object, or the object character information may store the correspondence between a plurality of virtual objects and the corresponding character information. Further, a dialogue vector library corresponding to the character information can be obtained from the corresponding relation between the stored character information and the dialogue vector library.
So that S603 and S605 can be performed: searching and obtaining target dialogue corpora matched with the target question-answer vector pairs from a plurality of dialogue corpora in a dialogue corpus; and then, the reply corpus can be extracted from the target dialogue corpus, and the character style language adjustment is carried out on the reply corpus by utilizing the character style language adjustment model, so that the first reply information is obtained. For example, the current question information may be subjected to vector characterization processing, for example, a pre-trained BERT model may be used to perform vector conversion on the current question information, so as to obtain a current question vector corresponding to the current question information. Therefore, the question vector in a plurality of question-answer vector pairs can be searched in the dialogue vector library by using the current question vector, and the question-answer vector pair in which the question vector matched with the current question vector is positioned is determined to be used as the target question-answer vector pair. Thus, the target dialogue corpus matched by the target question-answer vector pair can be obtained by searching and the answer corpus can be extracted from the target dialogue corpus based on the corresponding relation, wherein the corresponding relation can be the corresponding relation between the dialogue corpus and the dialogue vector pair recorded when the dialogue corpus is converted into the dialogue vector pair. And then, character style language adjustment can be carried out on the reply corpus by utilizing a character style language adjustment model, so as to obtain first reply information.
Alternatively, when searching for the target question-answer vector pair, if the text length of the current question information is greater than the preset length, text segmentation may be performed first. For example, when the text length of the current question information is greater than the preset length, the current question information may be text-segmented to obtain a plurality of question sub-information; searching a plurality of question-answer vector pairs in a dialogue vector library to obtain question-answer vector pairs corresponding to the question sub-information; the question-answer vector pair corresponding to the question sub-information may refer to a question-answer vector pair to which a question word vector matched with the question sub-information belongs. And then a plurality of question-answer vector pairs can be used as target question-answer vector pairs.
Further, it may be determined whether the target matching degree of the first reply information and the current question information reaches a preset matching degree. For example, the target matching degree of the first reply information and the current question information may be obtained based on the following steps: and determining the answer matching degree of the first reply information and the current question information and the style matching degree of the first reply information and the role information. The answer matching degree and the style matching degree herein may be predicted based on the corresponding models, which is not limited in this application. Alternatively, the first reply information, the current question information, and the character information may be respectively converted into corresponding vector features using a pre-trained language model, so that the reply matching degree and the style matching degree may be determined based on the similarity between the vector features. For example, determining the reply match may be a similarity between the vector features of the first reply message and the vector features of the current question message; the style matching degree may be a similarity between the vector feature of the first reply information and the vector feature of the character information, and the similarity may be a pointing distance. And then, according to the answer matching degree or the style matching degree, determining the target matching degree corresponding to the first answer information, i.e. the target matching degree can be positively correlated with the answer matching degree or the style matching degree.
If so, S607 may be performed: taking the first reply information as target reply information of the current question information; if not, a generative reply process may be performed, e.g., S609-S615 may be performed. Specifically, the current question information can be input into a dialogue generating model to perform generating type reply processing, so as to obtain a plurality of initial reply information; therefore, the reply evaluation model can be used for evaluating the plurality of initial reply messages respectively to obtain respective evaluation information, such as scoring, of the plurality of initial reply messages, and the evaluation information can be used for representing the matching degree of the initial reply messages and the role information. Based on the above, the initial reply information with the highest matching degree with the character information can be selected from the plurality of initial reply information based on the evaluation information as the second reply information.
Under the condition that the first reply information and the second reply information are obtained, the first reply information and the second reply information can be combined to obtain target question information corresponding to the current question information. For example, the first reply content, the first reply language style, the second reply content, and the second reply language style are extracted from the first reply information and the second reply information, respectively. For example, the first reply content and the first reply language style may be extracted from the first reply information; and may extract the second reply content and the second reply language style from the second reply message. The first and second reply language styles may belong to a plurality of preset language styles. The plurality of predetermined language styles may include, but are not limited to, humor, naught, etc., as the present application is not limited thereto. And the first reply content and the second reply content can be subjected to content fusion to obtain fusion reply content; content fusion herein may include content deduplication, content endian adjustment, and the like, which is not limited in this application. And determining a first matching degree of the first reply language style and the character information and a second matching degree of the second reply language style and the character information, so that the highest matching degree of the first matching degree and the second matching degree can be used as a target matching degree, and accordingly, the reply language style (the first reply language style or the second reply language style) corresponding to the target matching degree can be used as a target reply language style. Therefore, the target reply language style can be used for adjusting and fusing reply contents to obtain target reply information of the current question information, so that the target reply information can be highly matched with the current question information in the contents, and can also be highly matched with role information in the language style, and reply consistency is realized. Further, the target reply information may be presented in a dialog interface to enable dialog with the target object, thereby continuing the dialog process.
Through effectively activating the core capability of the pre-trained large language model, the powerful natural language processing capability of the large language model is fully utilized, the context information and the semantic relation are understood, different virtual objects are personalized through role setting, and the virtual objects can be put in a plurality of business scenes, such as live broadcasting and group/channel robots, so that communication with different users in different scenes is realized, the activity of the corresponding scenes is increased, and the users can actively communicate with robots of different roles and add friends; the virtual robot can be used as a brain of a virtual robot, for example, can be used for virtual social and accompanying scenes of digital people, can be used for carrying out two-creation, digital body separation and the like on the existing virtual anchor image through different setting of roles, helps the virtual anchor image to expand story backgrounds and people setting of the virtual world, continues expansion value, and can also provide more capability assistance conforming to role positioning.
FIG. 7 is a block diagram of a large language model based dialog processing device, according to an example embodiment. Referring to fig. 7, the dialog processing device may include:
an obtaining module 701, configured to obtain, in response to current question information of a target object in a session, role information corresponding to a virtual object of the target object session and a session vector library corresponding to the role information; the question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information;
A reply retrieval module 703, configured to find the multiple question-answer vector pairs in the dialogue vector library, obtain a target question-answer vector pair that is matched with the current question information, and obtain first reply information based on a reply corpus corresponding to a reply vector in the target question-answer vector pair;
the reply generation module 705 is configured to perform a generated reply process on the current question information based on a dialogue generation model, so as to obtain second reply information; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus;
and a reply determining module 707, configured to determine target reply information of the current question information based on the first reply information and the second reply information.
Responding to the current question information of the target object in the dialogue process, and acquiring role information corresponding to the virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; searching a plurality of question-answer vector pairs in a dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair; generating type reply processing is carried out on the current questioning information based on the dialogue generating type model, and second reply information is obtained; and determining target reply information of the current question information based on the first reply information and the second reply information. According to the dialogue processing device of the embodiment of the specification, the combination of the search type reply and the generated type reply can be realized, a plurality of question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in the dialogue corpus corresponding to the role information, the dialogue generated type model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus, the flexibility of the dialogue can be realized based on the generated type reply, rich questions can be covered based on the dialogue corpus corresponding to the role information to realize the consistency of the reply based on the role information, and the consistency of the reply can be maintained after a plurality of rounds of dialogues based on the dialogue generation type model which is finely tuned by the role information; and converting the dialogue corpus in the dialogue corpus into vectors for retrieving the reply information, so that the accuracy and the efficiency of retrieval can be improved, the dialogue processing can be more efficient and accurate, and the dialogue experience is improved.
In one possible implementation, the reply generation module 705 may include:
the generating type reply processing unit is used for inputting the current questioning information into the dialogue generating type model to perform generating type reply processing to obtain a plurality of initial reply information;
the evaluation unit is used for evaluating the plurality of initial reply messages by using a reply evaluation model to obtain respective evaluation information of the plurality of initial reply messages, wherein the evaluation information is used for representing the matching degree of the initial reply messages and the role information; the reply evaluation model is obtained by performing reinforcement learning on a preset machine learning model based on a sample corpus;
and the reply screening unit is used for screening the initial reply information with the highest matching degree with the role information from the plurality of initial reply information based on the evaluation information to serve as the second reply information.
In one possible implementation, the reply retrieval module 703 may include:
the target dialogue corpus searching unit is used for searching and obtaining target dialogue corpus matched with the target question-answer vector pair from the plurality of dialogue corpuses in the dialogue corpus;
A reply corpus extraction unit, configured to extract the reply corpus from the target dialogue corpus;
and the character style language adjustment unit is used for carrying out character style language adjustment on the reply corpus by utilizing a character style language adjustment model to obtain the first reply information.
In one possible implementation manner, the reply retrieval module 703 may further include:
the text segmentation unit is used for carrying out text segmentation on the current question information to obtain a plurality of question sub-information under the condition that the text length of the current question information is larger than the preset length;
the question-answer vector pair searching unit is used for searching the question-answer vector pairs in the dialogue vector library to obtain question-answer vector pairs corresponding to the question sub-information;
and a reply retrieval unit, configured to take a plurality of question-answer vector pairs as the target question-answer vector pairs.
In one possible implementation, the reply determination module 707 may include:
the content and style extraction unit is used for extracting a first reply content, a first reply language style, a second reply content and a second reply language style from the first reply information and the second reply information respectively;
The content fusion unit is used for carrying out content fusion on the first reply content and the second reply content to obtain fusion reply content;
the target reply language style screening unit is used for screening a target reply language style from the first reply language style and the second reply language style, and the matching degree of the target reply language style and the character information meets a matching degree condition;
and the reply determining unit is used for adjusting the fusion reply content by using the target reply language style to obtain the target reply information.
In one possible implementation manner, the session processing apparatus may further include:
the first reply matching determining module is used for determining the reply matching degree of the first reply information and the current question information and the style matching degree of the first reply information and the role information;
the second reply matching determining module is used for determining the target matching degree corresponding to the first reply information according to the reply matching degree or the style matching degree;
correspondingly, the reply generation module 705 is further configured to perform a generated reply process on the current question information based on the dialogue generation model to obtain the second reply information when the target matching degree does not reach the preset matching degree.
In one possible implementation manner, the session processing apparatus may further include:
the basic corpus information acquisition unit is used for acquiring basic corpus information corresponding to the role information;
the dialogue processing unit is used for carrying out single-round or multi-round dialogue processing on the basis of the basic corpus information to obtain initial dialogue corpus;
and the dialogue corpus obtaining unit is used for adjusting the initial dialogue corpus based on the role information to obtain the dialogue corpus comprising the plurality of dialogue corpora.
In one possible implementation manner, the basic corpus information acquiring unit may include:
a first dialogue information acquisition subunit, configured to acquire historical dialogue information of the virtual object and role-related dialogue information configured for the virtual object;
the multi-round questioning subunit is used for automatically carrying out multi-round questioning on the basis of the historical dialogue information based on the intelligent dialogue tool to obtain automatic dialogue information;
and the basic corpus information acquisition subunit is used for acquiring the basic corpus information according to the historical dialogue information, the role-related dialogue information and the automatic dialogue information.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Fig. 8 is a block diagram of an electronic device, which may be a terminal, for a large language model-based dialog process, which may be an internal structure diagram as shown in fig. 8, according to an exemplary embodiment. The electronic device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of dialogue processing based on a large language model. The display screen of the electronic equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the electronic equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in fig. 8 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the electronic device to which the present application is applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
Fig. 9 is a block diagram of an electronic device, which may be a server, for a large language model-based dialog process, the internal structure of which may be as shown in fig. 9, according to an exemplary embodiment. The electronic device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of dialogue processing based on a large language model.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the electronic device to which the present application is applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an exemplary embodiment, there is also provided an electronic device including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement a large language model based dialog processing method as in an embodiment of the present application.
In an exemplary embodiment, a computer readable storage medium is also provided, which when executed by a processor of an electronic device, enables the electronic device to perform the large language model based dialog processing method in the embodiments of the present application. The computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
In an exemplary embodiment, a computer program product containing instructions that, when run on a computer, cause the computer to perform the method of large language model based dialog processing in embodiments of the present application is also provided.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (14)

1. A large language model-based dialog processing method, comprising:
responding to the current question information of a target object in a dialogue process, and acquiring role information corresponding to a virtual object of the target object dialogue and a dialogue vector library corresponding to the role information; the question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information;
Searching the question-answer vector pairs in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to reply vectors in the target question-answer vector pair;
generating type reply processing is carried out on the current questioning information based on a dialogue generating type model, and second reply information is obtained; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus;
determining target reply information of the current question information based on the first reply information and the second reply information;
the determining, based on the first reply information and the second reply information, the target reply information of the current question information includes:
extracting a first reply content, a first reply language style, a second reply content and a second reply language style from the first reply information and the second reply information respectively;
performing content fusion on the first reply content and the second reply content to obtain fusion reply content;
screening a target reply language style from the first reply language style and the second reply language style, wherein the matching degree of the target reply language style and the role information meets a matching degree condition;
Adjusting the fusion reply content by using the target reply language style to obtain the target reply information;
wherein the method further comprises:
determining the answer matching degree of the first reply information and the current question information and the style matching degree of the first reply information and the role information;
determining a target matching degree corresponding to the first reply information according to the reply matching degree or the style matching degree;
correspondingly, the generating type reply processing is performed on the current question information based on the dialogue generating type model to obtain second reply information, which comprises the following steps:
and under the condition that the target matching degree does not reach the preset matching degree, carrying out generating type reply processing on the current question information based on the dialogue generating type model to obtain the second reply information.
2. The method for processing a dialogue according to claim 1, wherein the performing a generated reply process on the current question information based on a dialogue generating model to obtain second reply information includes:
inputting the current question information into the dialogue generation type model to perform generation type reply processing to obtain a plurality of initial reply information;
Evaluating the plurality of initial reply messages by using a reply evaluation model to obtain respective evaluation information of the plurality of initial reply messages, wherein the evaluation information is used for representing the matching degree of the initial reply messages and the role information; the reply evaluation model is obtained by performing reinforcement learning on a preset machine learning model based on a sample corpus;
and based on the evaluation information, selecting initial reply information with highest matching degree with the role information from the plurality of initial reply information as the second reply information.
3. The method of claim 1, wherein the obtaining the first reply message based on the reply corpus corresponding to the reply vector in the target question-answer vector pair includes:
searching and obtaining target dialogue corpora matched with the target question-answer vector pairs from the dialogue corpora;
extracting the reply corpus from the target dialogue corpus;
and performing role style language adjustment on the reply corpus by using a role style language adjustment model to obtain the first reply information.
4. A dialogue processing method according to claim 1 or 3, wherein searching the dialogue vector library for the question-answer vector pairs to obtain the target question-answer vector pair matched with the current question information comprises:
Under the condition that the text length of the current question information is larger than the preset length, text segmentation is carried out on the current question information to obtain a plurality of question sub-information;
searching the question-answer vector pairs in the dialogue vector library to obtain question-answer vector pairs corresponding to the question sub-information;
and taking a plurality of question-answer vector pairs as the target question-answer vector pairs.
5. The dialog processing method of claim 1, characterized in that the method further comprises:
acquiring basic corpus information corresponding to the role information;
carrying out single-round or multi-round dialogue processing on the basis of the basic corpus information to obtain initial dialogue corpus;
and adjusting the initial dialogue corpus based on the role information to obtain the dialogue corpus comprising the dialogue corpora.
6. The method for processing a dialogue according to claim 5, wherein the obtaining basic corpus information corresponding to the character information includes:
acquiring historical dialogue information of the virtual object and role-related dialogue information configured for the virtual object;
automatically carrying out multiple rounds of questioning on the basis of the historical dialogue information based on the intelligent dialogue tool to obtain automatic dialogue information;
And obtaining the basic corpus information according to the historical dialogue information, the role-related dialogue information and the automatic dialogue information.
7. A large language model based dialog processing device comprising:
the system comprises an acquisition module, a dialogue vector library and a dialogue vector library, wherein the acquisition module is used for responding to the current question information of a target object in the dialogue process and acquiring role information corresponding to a virtual object of the target object dialogue and the dialogue vector library corresponding to the role information; the question-answer vector pairs included in the dialogue vector library are obtained based on a plurality of dialogue corpora in a dialogue corpus corresponding to the role information;
the reply retrieval module is used for searching the question-answer vector pairs in the dialogue vector library to obtain a target question-answer vector pair matched with the current question information, and obtaining first reply information based on reply corpus corresponding to the reply vector in the target question-answer vector pair;
the reply generation module is used for carrying out generation type reply processing on the current question information based on the dialogue generation type model to obtain second reply information; the dialogue generating model is obtained by fine tuning a pre-trained large language model based on the plurality of dialogue corpora in the dialogue corpus;
The reply determining module is used for determining target reply information of the current question information based on the first reply information and the second reply information;
wherein the reply determination module comprises:
the content and style extraction unit is used for extracting a first reply content, a first reply language style, a second reply content and a second reply language style from the first reply information and the second reply information respectively;
the content fusion unit is used for carrying out content fusion on the first reply content and the second reply content to obtain fusion reply content;
the target reply language style screening unit is used for screening a target reply language style from the first reply language style and the second reply language style, and the matching degree of the target reply language style and the character information meets a matching degree condition;
the reply determining unit is used for adjusting the fusion reply content by using the target reply language style to obtain the target reply information;
wherein, the dialogue processing device further includes:
the first reply matching determining module is used for determining the reply matching degree of the first reply information and the current question information and the style matching degree of the first reply information and the role information;
The second reply matching determining module is used for determining the target matching degree corresponding to the first reply information according to the reply matching degree or the style matching degree;
correspondingly, the reply generation module is further configured to perform a generated reply process on the current question information based on the dialogue generation model to obtain the second reply information when the target matching degree does not reach the preset matching degree.
8. The dialog processing device of claim 7, wherein the reply generation module comprises:
the generating type reply processing unit is used for inputting the current questioning information into the dialogue generating type model to perform generating type reply processing to obtain a plurality of initial reply information;
the evaluation unit is used for evaluating the plurality of initial reply messages by using a reply evaluation model to obtain respective evaluation information of the plurality of initial reply messages, wherein the evaluation information is used for representing the matching degree of the initial reply messages and the role information; the reply evaluation model is obtained by performing reinforcement learning on a preset machine learning model based on a sample corpus;
and the reply screening unit is used for screening the initial reply information with the highest matching degree with the role information from the plurality of initial reply information based on the evaluation information to serve as the second reply information.
9. The dialog processing device of claim 7, wherein the reply retrieval module comprises:
the target dialogue corpus searching unit is used for searching and obtaining target dialogue corpus matched with the target question-answer vector pair from the plurality of dialogue corpuses in the dialogue corpus;
a reply corpus extraction unit, configured to extract the reply corpus from the target dialogue corpus;
and the character style language adjustment unit is used for carrying out character style language adjustment on the reply corpus by utilizing a character style language adjustment model to obtain the first reply information.
10. The dialog processing device of claim 7 or 9, wherein the reply retrieval module further comprises:
the text segmentation unit is used for carrying out text segmentation on the current question information to obtain a plurality of question sub-information under the condition that the text length of the current question information is larger than the preset length;
the question-answer vector pair searching unit is used for searching the question-answer vector pairs in the dialogue vector library to obtain question-answer vector pairs corresponding to the question sub-information;
and a reply retrieval unit, configured to take a plurality of question-answer vector pairs as the target question-answer vector pairs.
11. The conversation processing apparatus of claim 7, wherein the conversation processing apparatus further comprises:
the basic corpus information acquisition unit is used for acquiring basic corpus information corresponding to the role information;
the dialogue processing unit is used for carrying out single-round or multi-round dialogue processing on the basis of the basic corpus information to obtain initial dialogue corpus;
and the dialogue corpus obtaining unit is used for adjusting the initial dialogue corpus based on the role information to obtain the dialogue corpus comprising the plurality of dialogue corpora.
12. The apparatus according to claim 11, wherein the basic corpus information acquiring unit includes:
a first dialogue information acquisition subunit, configured to acquire historical dialogue information of the virtual object and role-related dialogue information configured for the virtual object;
the multi-round questioning subunit is used for automatically carrying out multi-round questioning on the basis of the historical dialogue information based on the intelligent dialogue tool to obtain automatic dialogue information;
and the basic corpus information acquisition subunit is used for acquiring the basic corpus information according to the historical dialogue information, the role-related dialogue information and the automatic dialogue information.
13. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the large language model based dialog processing method of any of claims 1 to 6.
14. A computer readable storage medium, characterized in that instructions in the computer readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the large language model based dialog processing method of any of claims 1 to 6.
CN202311501026.XA 2023-11-13 2023-11-13 Dialogue processing method and device based on large language model and electronic equipment Active CN117251552B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311501026.XA CN117251552B (en) 2023-11-13 2023-11-13 Dialogue processing method and device based on large language model and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311501026.XA CN117251552B (en) 2023-11-13 2023-11-13 Dialogue processing method and device based on large language model and electronic equipment

Publications (2)

Publication Number Publication Date
CN117251552A CN117251552A (en) 2023-12-19
CN117251552B true CN117251552B (en) 2024-02-27

Family

ID=89137110

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311501026.XA Active CN117251552B (en) 2023-11-13 2023-11-13 Dialogue processing method and device based on large language model and electronic equipment

Country Status (1)

Country Link
CN (1) CN117251552B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117808946A (en) * 2024-03-01 2024-04-02 厦门深度赋智科技有限公司 Method and system for constructing secondary roles based on large language model
CN118093854A (en) * 2024-04-28 2024-05-28 浙江大学 Data processing method, device, equipment and medium based on language model

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013012099A (en) * 2011-06-30 2013-01-17 Fujitsu Social Science Laboratory Ltd Email reply confirmation device, method and program
CN111858854A (en) * 2020-07-20 2020-10-30 上海汽车集团股份有限公司 Question-answer matching method based on historical dialogue information and related device
CN114238595A (en) * 2021-12-01 2022-03-25 中冶赛迪重庆信息技术有限公司 Metallurgical knowledge question-answering method and system based on knowledge graph
CN115221271A (en) * 2022-06-10 2022-10-21 网易(杭州)网络有限公司 Dialog reply method and device, and language model training method and device
CN115309877A (en) * 2022-08-03 2022-11-08 北京百度网讯科技有限公司 Dialog generation method, dialog model training method and device
CN116431780A (en) * 2023-03-22 2023-07-14 中国传媒大学 Man-machine conversation method, system, electronic equipment and storage medium
CN116821308A (en) * 2023-08-22 2023-09-29 浙江口碑网络技术有限公司 Generation method, training method and device of model and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013012099A (en) * 2011-06-30 2013-01-17 Fujitsu Social Science Laboratory Ltd Email reply confirmation device, method and program
CN111858854A (en) * 2020-07-20 2020-10-30 上海汽车集团股份有限公司 Question-answer matching method based on historical dialogue information and related device
CN114238595A (en) * 2021-12-01 2022-03-25 中冶赛迪重庆信息技术有限公司 Metallurgical knowledge question-answering method and system based on knowledge graph
CN115221271A (en) * 2022-06-10 2022-10-21 网易(杭州)网络有限公司 Dialog reply method and device, and language model training method and device
CN115309877A (en) * 2022-08-03 2022-11-08 北京百度网讯科技有限公司 Dialog generation method, dialog model training method and device
CN116431780A (en) * 2023-03-22 2023-07-14 中国传媒大学 Man-machine conversation method, system, electronic equipment and storage medium
CN116821308A (en) * 2023-08-22 2023-09-29 浙江口碑网络技术有限公司 Generation method, training method and device of model and storage medium

Also Published As

Publication number Publication date
CN117251552A (en) 2023-12-19

Similar Documents

Publication Publication Date Title
CN107943998B (en) Man-machine conversation control system and method based on knowledge graph
CN108829822B (en) Media content recommendation method and device, storage medium and electronic device
CN109829039B (en) Intelligent chat method, intelligent chat device, computer equipment and storage medium
CN117251552B (en) Dialogue processing method and device based on large language model and electronic equipment
CN110263150B (en) Text generation method, device, computer equipment and storage medium
WO2021159632A1 (en) Intelligent questioning and answering method and apparatus, computer device, and computer storage medium
CN110990543A (en) Intelligent conversation generation method and device, computer equipment and computer storage medium
CN112487139A (en) Text-based automatic question setting method and device and computer equipment
CN110895656B (en) Text similarity calculation method and device, electronic equipment and storage medium
US11036996B2 (en) Method and apparatus for determining (raw) video materials for news
CN111767394A (en) Abstract extraction method and device based on artificial intelligence expert system
CN108595609A (en) Generation method, system, medium and equipment are replied by robot based on personage IP
CN110597968A (en) Reply selection method and device
CN113342948A (en) Intelligent question and answer method and device
CN116541493A (en) Interactive response method, device, equipment and storage medium based on intention recognition
CN112231554A (en) Search recommendation word generation method and device, storage medium and computer equipment
CN117708428A (en) Recommendation information prediction method and device and electronic equipment
CN117370190A (en) Test case generation method and device, electronic equipment and storage medium
CN112100355A (en) Intelligent interaction method, device and equipment
CN117132923A (en) Video classification method, device, electronic equipment and storage medium
CN116956183A (en) Multimedia resource recommendation method, model training method, device and storage medium
CN115393849A (en) Data processing method and device, electronic equipment and storage medium
CN114416941A (en) Generation method and device of dialogue knowledge point determination model fusing knowledge graph
CN114065785B (en) Real-time online communication translation method and system
JP2019194759A (en) Dialogue system reinforcement device and computer program

Legal Events

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