Conversation interaction method and electronic equipment
By inputting the first dialogue information into multiple dialogue models and performing information fusion processing, the problem of a single large language model responding to information in human-computer dialogue interaction is solved, and a more comprehensive and accurate reply is achieved.
Patent Information
- Application Number
- CN202411271744.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-06
AI Technical Summary
In the prior art, a single large language model is difficult to provide comprehensive and accurate responses when human-computer dialogue interaction, especially when the dialogue information is not in the field of expertise of the model, it may lead to one-sided or incomplete reply information.
By inputting the first dialogue information into a plurality of different dialogue models, a plurality of second dialogue information is obtained, and the information fusion process is performed using the second dialogue model to generate the third dialogue information as the final reply.
It improves the comprehensiveness and accuracy of dialogue interaction, improves the user experience, ensures that the reply content is more comprehensive and accurate, and overcomes the limitations of a single model when answering.
Smart Images

Figure CN119088940A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of human-computer dialogue interaction, and in particular to a dialogue interaction method and electronic equipment. Background Art
[0002] At present, with the rapid development of artificial intelligence technology, large language models have been widely used in human-computer dialogue question and answering. Large language models can give corresponding reply information based on dialogue information such as user voice or user input text.
[0003] In the prior art, the conversation interaction method based on the large language model uses a single large language model to output corresponding reply information according to the conversation information such as user voice or user input text. Due to the differences in training data, algorithm architecture, parameter setting, optimization goals, etc., different large language models have different advantages and limitations when generating answers using different large language models. For example, some large language models have strong answering capabilities for general basic knowledge, while answers for specific fields usually require fine-tuning training with professional data in specific fields to achieve better answering results; some large language models have old training data and can only reply based on knowledge up to a certain point in time; some large language models have Internet search capabilities and can obtain the latest knowledge information, and are strong in the real-time nature of knowledge answers. Therefore, for the same question, the answer ideas, perspectives, completeness, professionalism, timeliness, etc. given by different large language models are different, and it is difficult for a single large model to achieve a relatively perfect universal question-answering capability. That is, when a single large language model is used for conversation interaction, if the conversation information is not the field that the large language model is good at, there are problems of one-sided, incomplete or misunderstood reply information. Summary of the invention
[0004] The present application provides a conversation interaction method and electronic device, which are used to solve the problem in the prior art that when a single large language model is used to answer conversation information, the reply information may be one-sided, incomplete or misunderstood.
[0005] The first dialogue information is input into a plurality of first dialogue models so that each first dialogue model obtains the second dialogue information according to the first dialogue information, and then each second dialogue information is input into the second dialogue model so that the second dialogue model fuses the second dialogue information to obtain the third dialogue information, and the third dialogue information is used as the reply information to the first dialogue information. In this way, user dialogue interaction is performed based on a plurality of different dialogue models, and the fused dialogue information is obtained based on the second dialogue model as the reply information, so that the obtained reply content is more comprehensive and accurate.
[0006] To solve the above technical problems, in a first aspect, an implementation method of the present application discloses a dialogue interaction method, which includes: inputting first dialogue information into multiple different first dialogue models, so that each first dialogue model obtains second dialogue information according to the first dialogue information; inputting second dialogue information into a second dialogue model, so that the second dialogue model performs information fusion processing on the second dialogue information to obtain third dialogue information; and using the third dialogue information as reply information to the first dialogue information.
[0007] The dialogue interaction method provided by the implementation of the present application inputs the first dialogue information into multiple first dialogue models so that each first dialogue model obtains the second dialogue information according to the first dialogue information, and then inputs each second dialogue information into the second dialogue model so that the second dialogue model performs information fusion processing on the second dialogue information to obtain the third dialogue information, and uses the third dialogue information as the reply information for the first dialogue information. In this way, multiple second dialogue information is obtained according to the first dialogue information based on multiple first dialogue models, and multiple second dialogue information is subjected to information fusion processing based on the second dialogue model to obtain accurate and unique third dialogue information as the reply information. This dialogue interaction method based on multiple dialogue models for dialogue information generation and fusion processing in different dimensions makes the content of the reply information obtained more comprehensive and accurate, and improves the dialogue interaction experience.
[0008] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method, the method further comprising: the second dialogue model performs information fusion processing on the second dialogue information to obtain third dialogue information in the following manner: if the second dialogue information is consistent, any second dialogue information is used as the third dialogue information; if the second dialogue information is inconsistent, the reference weights of the first dialogue models are determined, and the second dialogue information is subjected to information fusion processing based on the first dialogue information and the reference weights of the first dialogue models to obtain the third dialogue information; or if the second dialogue information is inconsistent, the target dialogue information is determined from the second dialogue information, and the target dialogue information is input into the first dialogue models, so that the first dialogue models obtain fourth dialogue information according to the target dialogue information, until it is determined that a preset proportion of the fourth dialogue information obtained is consistent, and any consistent fourth dialogue information is used as the third dialogue information.
[0009] By adopting the above technical solution, the second dialogue information generated by multiple first dialogue models is subjected to information fusion processing based on the second dialogue model to obtain the third dialogue information as the reply information. This method of user dialogue interaction based on multiple dialogue models makes the obtained reply content more comprehensive and accurate. Furthermore, when multiple second dialogue information are inconsistent, the second dialogue information is subjected to information fusion processing based on the first dialogue information and the reference weights of each first dialogue model to obtain the third dialogue information, or the target dialogue information is determined from the second dialogue information, and the target dialogue information is input into each first dialogue model, so that each first dialogue model obtains the fourth dialogue information according to the target dialogue information, until it is determined that the fourth dialogue information of the preset proportion in the obtained fourth dialogue information is consistent, and any consistent fourth dialogue information is used as the third dialogue information. In this way, the second dialogue model can obtain unique and accurate reply content, which improves the user's human-computer interaction experience.
[0010] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method, which also includes determining multiple different first dialogue models in the following manner: performing feature extraction processing on the first dialogue information to obtain a dialogue feature vector; and determining multiple different first dialogue models from the multiple dialogue models based on the dialogue feature vector and preset classification rules.
[0011] By adopting the above technical solution, multiple different first dialogue models are determined from multiple dialogue models according to the dialogue feature vector and the preset classification rules. In this way, a matching first dialogue model can be determined according to the dialogue feature vector of the first dialogue information, so that the second dialogue information obtained by the first dialogue model according to the first dialogue information is dialogue information that better meets the requirements.
[0012] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method, which performs feature extraction processing on first dialogue information to obtain a dialogue feature vector, including: performing feature extraction processing on the first dialogue information based on a preset feature extraction rule to obtain a text length feature vector and a language feature vector; performing feature extraction processing on the first dialogue information based on a text classification algorithm to obtain a dialogue type feature vector; performing feature extraction processing on the first dialogue information based on a third dialogue model to obtain a target feature vector; and obtaining a dialogue feature vector based on the text length feature vector, the language feature vector, the dialogue type feature vector, and the target feature vector.
[0013] By adopting the above technical solution, a dialogue feature vector is obtained according to the text length feature vector, the language feature vector, the dialogue type feature vector and the target feature vector, so that a first dialogue model is determined based on multiple feature vectors of the first dialogue information, so that the obtained first dialogue model is a model that is more suitable for processing the first dialogue information, and the final reply information is more accurate.
[0014] According to another specific implementation of the present application, the implementation of the present application discloses a conversation interaction method, which performs feature extraction processing on first conversation information based on a text classification algorithm to obtain a conversation type feature vector, including: determining multiple training set samples of the text classification algorithm, and determining a first text feature vector of each training set sample; obtaining a conversation type feature vector based on the first text feature vector and a second text feature vector corresponding to the first conversation information based on the text classification algorithm, and the second text feature vector is obtained by performing feature extraction processing on the first conversation information based on a feature extraction algorithm.
[0015] By adopting the above technical solution, a conversation type feature vector is obtained based on the first text feature vector and each second text feature vector based on a text classification algorithm. In this way, the conversation type of the first conversation information can be determined, and then a matching first conversation model is determined based on the conversation type feature vector, so that the obtained first conversation model is a model that is more suitable for processing the first conversation information, and the final reply information is more accurate.
[0016] According to another specific implementation of the present application, the implementation of the present application discloses a conversation interaction method, wherein the feature extraction algorithm is one of the TF-IDF algorithm, the Word2Vector algorithm, and the GloVe algorithm.
[0017] By adopting the above technical solution and using different algorithms for feature extraction, feature extraction is made more efficient.
[0018] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method. If the feature extraction algorithm is a TF-IDF algorithm, the method further includes performing feature extraction processing on the first dialogue information based on the feature extraction algorithm in the following manner to obtain a second text feature vector: determining the number of occurrences of a segmented word in the first dialogue information and the total number of segmented words in the first dialogue information; determining the word frequency value of the segmented word in the first dialogue information according to the number of occurrences and the total number of segmented words; determining the number of occurrence samples of the segmented word in the training set samples and the total number of samples of the training set samples; determining the reverse file frequency value of the segmented word according to the number of occurrence samples and the total number of samples; obtaining a frequency feature vector of the segmented word according to the word frequency value and the reverse file frequency value; and using the frequency feature vectors of all segmented words as the second text feature vector of the first dialogue information.
[0019] By adopting the above technical solution, the first text feature vector of the first dialogue information is determined based on the TF-IDF algorithm, so that the determination of the first text feature vector is more accurate and efficient.
[0020] According to another specific implementation of the present application, the implementation of the present application discloses a method for dialogue interaction, the method further comprising obtaining a frequency feature vector of a word segmentation by the following method:
[0021]
[0022] Among them, TF_IDF X is the frequency feature vector of the word segment X in the first dialogue information, TF X is the frequency value of word segment X, freq(X,H) is the number of occurrences of word segment X in the first dialogue information H, size(H) is the total number of words in the first dialogue information H, and IDF X is the inverse document frequency value of word segmentation X, df(X) is the number of occurrences of word segmentation X in all training set samples, and N is the total number of samples.
[0023] By adopting the above technical solution, the frequency feature vector is calculated using a calculation formula to obtain an accurate frequency feature vector, and then a more accurate first text feature vector is obtained, so that the dialogue type of the first dialogue information is determined more accurately.
[0024] According to another specific implementation of the present application, the implementation of the present application discloses a conversation interaction method, which obtains a conversation type feature vector based on a text classification algorithm according to a first text feature vector and a second text feature vector corresponding to a first conversation information, including: calculating the similarity between each first text feature vector and the second text feature vector; determining a preset number of training set samples from multiple training set samples as target training set samples according to the similarity; determining the conversation type feature vector of the target training set samples, and using the conversation type feature vector with the largest number of repetitions in the conversation type feature vectors of the target training set samples as the conversation type feature vector of the first conversation information.
[0025] By adopting the above technical scheme, a similarity calculation method is used to obtain target training set samples, and the dialogue type feature vector of the target training set samples is determined. The dialogue type feature vector with the most repetitions in the dialogue type of the target training set samples is used as the dialogue type feature vector of the first dialogue information. In this way, an accurate dialogue type feature vector of the first dialogue information is obtained.
[0026] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method, which also includes obtaining a reference weight of the dialogue model in the following manner: determining a first score of the dialogue model corresponding to a dialogue feature vector, and determining a total score of all dialogue models corresponding to the dialogue feature vector; determining a reference weight of the dialogue model corresponding to the dialogue feature vector based on the first score and the total score; and taking the sum of the reference weights of the dialogue model corresponding to all dialogue feature vectors as the reference weight of the dialogue model.
[0027] By adopting the above technical solution, by calculating the reference weight of the first dialogue model, when performing information fusion processing on the second dialogue model, the reference weights of each first dialogue model in the dialogue model are considered, and then the reference weight of the first dialogue model and the second dialogue information are fused to obtain more accurate and more demand-compliant third dialogue information.
[0028] According to another specific implementation of the present application, the implementation of the present application discloses a dialogue interaction method, the method further comprising obtaining a reference weight of the dialogue model by the following method:
[0029]
[0030] Among them, V i is the reference weight of dialogue model i, V m,i is the reference weight of dialogue model i corresponding to dialogue feature vector m, n is the number of dialogue feature vectors, m≤n, S m,i is the first score of dialogue model i corresponding to dialogue feature vector m, is the total score of the dialogue model corresponding to the dialogue feature vector m, k is the number of dialogue models, i≤k.
[0031] By adopting the above technical solution, the reference weight of each dialogue model is calculated based on the above calculation formula, and then the reference weight of each first dialogue model can be obtained, so that the reference weight of the first dialogue model is more accurate.
[0032] According to another specific implementation of the present application, the implementation of the present application discloses a conversation interaction method, in which each first conversation model is integrated in a multi-model integration framework, and the first conversation information is input into multiple different first conversation models, including: based on the API interface of the multi-model integration framework, the first conversation information is respectively input into each first conversation model.
[0033] By adopting the above technical solution, the first dialogue information is input into each first dialogue model respectively based on the API interface of the multi-model integration framework, so that the new dialogue model can be directly accessed based on the API interface, making the dialogue interaction processing based on multiple models more efficient.
[0034] In a second aspect, the implementation method of the present application also discloses an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores a computer program, and the processor executes the computer program stored in the memory, so that the electronic device implements the conversation interaction method provided in any one of the implementation methods of the first aspect mentioned above.
[0035] In a third aspect, an implementation method of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the dialogue interaction method provided in any one of the implementation methods of the first aspect above.
[0036] In a fourth aspect, an implementation of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the conversational interaction method provided in any one of the implementations of the first aspect above.
[0037] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can also be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flowchart of a conversation interaction method provided in an embodiment of the present application;
[0039] Figure 2 is a schematic diagram of a process for obtaining a conversation feature vector provided by an embodiment of the present application;
[0040] Figure 3 is a schematic diagram of a process for obtaining a conversation type feature vector provided by an embodiment of the present application;
[0041] Figure 4 is a schematic diagram of a process for obtaining a first text feature vector provided in an embodiment of the present application;
[0042] Figure 5 is a schematic diagram of a process for obtaining a second text feature vector provided in an embodiment of the present application;
[0043] Figure 6 is another flowchart of obtaining a conversation type feature vector provided by an embodiment of the present application;
[0044] Figure 7 is a schematic diagram of a flow chart of obtaining a reference weight of a first dialogue model provided in an embodiment of the present application;
[0045] Figure 8 is a flowchart of another dialog interaction method provided in an embodiment of the present application;
[0046] Fig. 9It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0047] Specific implementation method
[0048] At present, with the rapid development of artificial intelligence technology, large language models have been widely used in human-computer dialogue question and answer. Large language models can give corresponding reply information based on dialogue information such as user voice or user input text. However, when existing large language models are used for human-computer dialogue interactions such as answering user questions, they often have problems such as one-sided, incomplete answers or misunderstandings.
[0049] In the prior art, the conversation interaction method based on the large language model uses a single large language model to output corresponding reply information based on conversation information such as user voice or user input text. Due to differences in training data, algorithm architecture, parameter settings, optimization goals, etc., different large language models have different advantages and limitations when using different large language models to generate answers. For example, some large language models have strong answer capabilities for general basic knowledge, while answers to specific fields usually require fine-tuning training using professional data in specific fields to achieve better answer results; some large language models have outdated training data and can only respond based on knowledge up to a certain point in time; some large language models have Internet search capabilities, can obtain the latest knowledge information, and are more real-time in knowledge answers. Different large language models have different limitations on the length of text they process. For example, they can understand and process thousands or tens of thousands of words (tokens) very well, but only a very small number of large language models can support text analysis in the long text field of hundreds of thousands, millions or even more tokens. Some large language models have strong English processing capabilities, but some large language models are better at Chinese text processing. Some large language models are prone to hallucinations for certain issues, but some large language models can avoid hallucinations to a large extent.
[0050] Therefore, for the same question, different large language models give different answers in terms of ideas, perspectives, completeness, professionalism, timeliness, etc. It is difficult for a single large model to achieve a perfect universal question-answering capability. In other words, when a single large language model is used for dialogue interaction, if the dialogue information is not the domain that the large language model is good at, there will be problems with one-sided, incomplete or misunderstood responses.
[0051] Based on this, the implementation of the present application provides a method for dialogue interaction, inputting first dialogue information into multiple first dialogue models, so that each first dialogue model obtains second dialogue information according to the first dialogue information, and then inputting the second dialogue information into the second dialogue model, so that the second dialogue model fuses the second dialogue information to obtain third dialogue information, and uses the third dialogue information as reply information for the first dialogue information. In this way, by integrating multiple large language models (as an example of a dialogue model), user dialogue interaction is performed based on multiple dialogue models, and information fusion processing is performed on the answers of multiple large language models based on the second dialogue model, taking their respective advantages, or verifying and optimizing the content of each other's answers (that is, the second dialogue information), and obtaining the fused third dialogue information as reply information, the quality of dialogue question and answer is comprehensively improved, so that the obtained reply content is more comprehensive and accurate.
[0052] Next, the dialogue interaction method provided by the implementation of this application is described in detail.
[0053] See also Figure 1 The dialogue interaction method provided by the implementation of this application specifically includes the following steps.
[0054] S100, inputting first dialogue information into a plurality of different first dialogue models, so that each first dialogue model obtains second dialogue information according to the first dialogue information.
[0055] S200: input the second dialogue information into the second dialogue model, so that the second dialogue model performs information fusion processing on the second dialogue information to obtain third dialogue information.
[0056] S300: Use the third dialogue information as reply information to the first dialogue information.
[0057] The dialogue interaction method provided by the implementation of the present application inputs the first dialogue information into multiple first dialogue models so that each first dialogue model obtains the second dialogue information according to the first dialogue information, and then inputs the second dialogue information into the second dialogue model so that the second dialogue model performs information fusion processing on the second dialogue information to obtain the third dialogue information, and uses the third dialogue information as the reply information for the first dialogue information. In this way, multiple second dialogue information is obtained according to the first dialogue information based on multiple first dialogue models, and accurate and unique third dialogue information is obtained as the reply information based on the second dialogue model. This dialogue interaction method based on multiple dialogue models for dialogue information generation and fusion processing in different dimensions makes the content of the reply information obtained more comprehensive and accurate, and improves the dialogue interaction experience.
[0058] In one implementation of the present application, each first dialogue model is integrated into a multi-model integration framework.
[0059] Exemplarily, a multi-model integration framework is constructed. The multi-model integration framework is a highly modular system that can flexibly connect to multiple different large language models (as an example of the first dialogue model) bases, and each large language model can be connected as an independent module service, so that the multi-model integration framework can call multiple different large language models at the same time, ensuring that each large language model can independently receive input user questions (as an example of the first dialogue information) and return corresponding answers (as an example of the second dialogue information), and each large language model service can be independently updated and maintained.
[0060] In the implementation of the present application, the large language model may be, for example, ChatGPT, ChatGLM, Kimi or other models, and of course, may also be any other human-computer interaction model.
[0061] Furthermore, in the implementation of the present application, the standardized application programming interface (API) of the multi-model integration framework is adapted. When the first dialogue information is input into a plurality of different first dialogue models, the first dialogue information is input into each first dialogue model based on the API interface of the multi-model integration framework.
[0062] Exemplarily, each large language model has a standard API interface for receiving user questions (i.e., receiving the first dialogue information) and returning answers (i.e., outputting the second dialogue information). That is, by encapsulating a unified input and output API layer, each large language model can access the API interface, receive the first dialogue information, and output the second dialogue information, abstracting the specific implementation details of the API of each large language model, so that the upper-layer service (such as an electronic device) does not need to care about the specific API differences of the underlying large language model when calling the multi-model integration framework. It only needs to send the first dialogue information to the API interface corresponding to the corresponding large language model, so that the corresponding large language model can obtain the first dialogue information, and the large language model outputs the second dialogue information to the API interface, so that the multi-model integration framework collects the reply results (i.e., the second dialogue information) of each large language model. Therefore, when accessing a new large language model, it is only necessary to configure and access the corresponding API interface of the multi-model integration framework, and there is no need to configure the API interface of the large language model.
[0063] Furthermore, in step S100, the first dialogue information may be dialogue information such as questions input by the user in text, voice, etc. through human-computer interaction. Of course, it may also be dialogue information such as normal chatting.
[0064] For example, the first conversation message can be a simple chat question and answer such as "How is the weather today?" or "It's so hot today", or it can be a solution to a math problem or an analysis requirement for housing prices or the stock market.
[0065] Furthermore, in an implementation of the present application, after obtaining the first dialogue information, the first dialogue information can be forwarded to the multi-model integration framework to be input into all large language models integrated in the multi-model integration framework, or the corresponding first dialogue model can be determined from the large language model based on the first dialogue information. Therefore, in the present application, multiple different first dialogue models are determined in the following manner: feature extraction processing is performed on the first dialogue information to obtain a dialogue feature vector, and multiple different first dialogue models are determined from multiple dialogue models according to the dialogue feature vector and a preset classification rule.
[0066] For example, see Figure 2 In one implementation of the present application, feature extraction processing is performed on the first dialogue information to obtain a dialogue feature vector, including the following steps.
[0067] S110: Perform feature extraction processing on the first dialogue information based on a preset feature extraction rule to obtain a text length feature vector and a language feature vector.
[0068] Exemplarily, simple feature extraction processing is performed based on a simple rule-based feature extraction rule, such as identifying the length of the first dialogue information to obtain a text length feature vector, and identifying the language type of the first dialogue information to obtain a language feature vector.
[0069] S120: Perform feature extraction processing on the first dialogue information based on a text classification algorithm to obtain a dialogue type feature vector.
[0070] Exemplarily, feature vectors that cannot be judged by some feature extraction rules (ie, cannot be subjected to feature extraction processing) are subjected to feature extraction processing using an AI field text classification algorithm (ie, a text classification algorithm) to obtain a dialogue type feature vector.
[0071] In one implementation of the present application, the text classification algorithm is, for example, a KNN algorithm (a neighboring algorithm, or a K-nearest neighbor (KNN) classification algorithm), an SVM algorithm (a classification algorithm based on a support vector machine (SVM)), a naive Bayes algorithm, or the like. Of course, other classification algorithms may also be used.
[0072] Further, see Figure 3 In one implementation of the present application, feature extraction processing is performed on the first dialogue information based on a text classification algorithm to obtain a dialogue type feature vector, including the following steps.
[0073] S121, determining a plurality of training set samples of a text classification algorithm, and determining a first text feature vector of each training set sample.
[0074] Exemplarily, the first text feature vector is obtained by performing feature extraction processing on each training set sample based on a feature extraction algorithm.
[0075] In one implementation of the present application, the feature extraction algorithm is one of the TF-IDF algorithm, the Word2Vec algorithm, and the GloVe algorithm. Of course, other feature extraction algorithms may also be used.
[0076] Among them, the TF-IDF algorithm is a frequency feature extraction algorithm, which is mainly used to determine the frequency feature vector of the first dialogue information (as an example of the first text feature vector). The Word2Vec algorithm is a related model for generating word vectors (as another example of the first text feature vector). The GloVe algorithm is also a related model for generating word vectors (as another example of the first text feature vector).
[0077] For example, see Figure 4 In one implementation of the present application, if the feature extraction algorithm is the TF-IDF algorithm, then performing feature extraction processing on the training set samples based on the feature extraction algorithm to obtain the first text feature vector includes the following steps.
[0078] S1211, determining the number of occurrences of the segmented words of each training set sample and the total number of segmented words of each training set sample.
[0079] Exemplarily, the training set samples are segmented to obtain at least one segmented word, and the number of occurrences of each segmented word in the corresponding training set sample and the total number of segmented words in the training set sample are determined.
[0080] For example, the total number of samples in the training set is 100, and the number of occurrences of segmentation 1 of training set sample 1 in the training set sample 1 and the total number of segmentations of training set sample 1 are determined. In this way, the number of occurrences of all segmentations of training set sample 1 is determined.
[0081] S1212, determining the frequency value of the segmented words in the training set sample according to the number of occurrences and the total number of segmented words.
[0082] For example, the frequency value of each word in the training set sample can be obtained by dividing the number of occurrences by the total number of words.
[0083]
[0084] Among them, TF wis the frequency value of the word segmentation W in the training set sample, freq(W,D) is the number of occurrences of the word segmentation W in the training set sample D, and size(D) is the total number of word segments in the training set sample D.
[0085] For example, the word frequency value of segmentation 1 is determined according to the number of occurrences of segmentation 1 (as an example of segmentation W) of training set sample 1 and the total number of segmentations of training set sample 1. In this way, the number of occurrences of all segmentations of training set sample 1 is determined.
[0086] S1213, determining the number of occurrence samples of the word segments in the training set samples and the total number of samples in the training set samples.
[0087] Exemplarily, in the implementation of the present application, the text classification algorithm is pre-trained based on the training set samples, so that the text classification algorithm obtains the dialogue type feature vector of the training set samples based on the training set samples.
[0088] Exemplarily, the number of occurrence samples of each word in all training set samples and the total number of samples in the training set samples are determined.
[0089] For example, determine the number of occurrence samples of word 1 of training set sample 1 in the training set sample. In this way, the number of occurrence samples of all word segments of training set sample 1 is obtained.
[0090] S1214, determining the reverse document frequency value of the word segmentation according to the number of occurrence samples and the total number of samples.
[0091] Exemplarily, the reverse document frequency value of each word is determined based on the number of occurrence samples of each word in the training set samples and the total number of samples in the training set samples.
[0092]
[0093] Among them, IDF W is the reverse document frequency value of word segmentation W, df(W) is the number of occurrences of word segmentation W in all training set samples, and N is the total number of samples.
[0094] For example, the reverse document frequency value of word segment 1 in training set sample 1 is obtained according to the number of occurrence samples and the total number of samples of word segment 1 in training set sample 1. In this way, the reverse document frequency values of all word segmentations in training set sample 1 can be obtained.
[0095] S1215, obtaining a frequency feature vector of the word segmentation according to the word frequency value and the inverse document frequency value.
[0096] Exemplarily, the frequency feature vector (ie, the first frequency feature vector) of the corresponding word segment can be obtained according to the word frequency value of each word segment in the training set sample and the reverse document frequency value of each word segment.
[0097] TF_IDFW =TF w *IDF W
[0098] Among them, TF_IDF W is the frequency feature vector of word segmentation W, TF w is the word frequency value of word segmentation W, IDF W is the inverse document frequency value of word segment W.
[0099] For example, the frequency feature vector (ie, TF_IDF1 value) of word segment 1 of training set sample 1 is obtained according to the word frequency value of word segment 1 of training set sample 1 and the reverse document frequency value of word segment 1. In this way, the frequency feature vectors of all word segmentations of training set sample 1 can be obtained.
[0100] S1216, taking the frequency feature vectors of all word segments as the first text feature vector of the training set samples.
[0101] Exemplarily, in one implementation, a frequency feature vector of each word segment is obtained, and the frequency feature vectors of all word segmentations (i.e., the first frequency feature vector) are set as the first text feature vector. Therefore, the first text feature vector is also the frequency feature vector of each training set sample (i.e., the second frequency feature vector).
[0102] For example, get the frequency feature vectors TF_IDF1, TF_IDF2, ..., TF_IDF of all word segments n , and then the first text feature vector is obtained as [TF_IDF1, TF_IDF2, ..., TF_IDF n ]'s collection.
[0103] For example, the frequency feature vectors TF_IDF1, TF_IDF2, ..., TF_IDF of all word segments in training set sample 1 are obtained. n , and then the frequency feature vector of training set sample 1 is [TF_IDF1, TF_IDF2, ..., TF_IDF n ]'s collection.
[0104] Exemplarily, in another implementation, the frequency feature vectors TF_IDF1, TF_IDF2, ..., TF_IDF n Accumulate and get the frequency feature vector of training set sample 1
[0105] Among them, TF_IDF 总 is the frequency feature vector of the training set samples, TF_IDF i is the frequency feature vector of word segmentation i, n≤the total number of word segments.
[0106] In this way, the first text feature vectors corresponding to all training set samples can be obtained by adopting the above method.
[0107] In another implementation of the present application, the frequency feature vector of the word segmentation is obtained in the following manner:
[0108]
[0109] Among them, TF_IDF W is the frequency feature vector of the word segmentation W of the training set sample, TF w is the frequency value of word segmentation W, freq(W,D) is the number of occurrences of word segmentation W in training set sample D, size(D) is the total number of word segments in training set sample D, and IDF W is the reverse document frequency value of word segmentation W, df(W) is the number of occurrences of word segmentation W in all training set samples, and N is the total number of samples.
[0110] Exemplarily, the word frequency value and the reverse document frequency value of each word segment of the training set sample are determined to obtain the frequency feature vector of each word segment of the training set sample.
[0111] Next, step S122 is executed to calculate the question classification (ie, the dialogue type) of the first dialogue information input by the user using a classification algorithm.
[0112] S122: Obtain a dialogue type feature vector based on a text classification algorithm according to the first text feature vector and the second text feature vector corresponding to the first dialogue information.
[0113] The second text feature vector is obtained by performing feature extraction processing on the first dialogue information based on a feature extraction algorithm.
[0114] For example, see Figure 5 In one implementation of the present application, if the feature extraction algorithm is the TF-IDF algorithm, performing feature extraction processing on the first conversation information based on the feature extraction algorithm to obtain a second text feature vector includes the following steps.
[0115] S1221, determining the number of occurrences of the segmented words in the first dialogue information and the total number of segmented words in the first dialogue information.
[0116] Exemplarily, the first dialogue information is segmented to obtain at least one segmented word, and the number of occurrences of each segmented word in the first dialogue information and the total number of segmented words in the first dialogue information are determined.
[0117] For example, the first dialog information includes participle 1, participle 2, ..., participle 13, which is a total of 13 participles, and participle 1 appears 3 times.
[0118] S1222: Determine the frequency value of the segmented words in the first dialogue information according to the number of occurrences and the total number of segmented words.
[0119] Exemplarily, the frequency value of each word in the first dialogue information can be obtained by dividing the number of occurrences by the total number of words.
[0120]
[0121] Among them, TF X is the frequency value of the segmentation X in the first dialogue information, freq(X,H) is the number of occurrences of the segmentation X in the first dialogue information H, and size(H) is the total number of segmentations in the first dialogue information.
[0122] For example, taking word segmentation 1 (as an example of word segmentation X) as an example, based on the above formula, according to the number of occurrences of word segmentation 1 and the total number of word segments in the first dialogue information, the word frequency value of word segmentation 1 is 3 / 13. In this way, the word frequency values of all word segments in the first dialogue information can be calculated.
[0123] S1223, determining the number of occurrence samples of the word segments in the training set samples and the total number of samples in the training set samples.
[0124] Exemplarily, in the present application, the number of occurrence samples of each word segment of the first dialogue information in the training set samples and the total number of samples of the training set samples are also determined.
[0125] For example, the total number of samples in the training set is 100, and the number of samples in which word 1 appears in the training set is determined to be 25. In this way, the number of samples in which all words in the first dialogue information appear is determined.
[0126] S1224, determining the reverse document frequency value of the word segmentation according to the number of occurrence samples and the total number of samples.
[0127] Exemplarily, the inverse document frequency value of the corresponding word segment can be obtained according to the number of occurrence samples of each word segment and the total number of samples.
[0128] That is to say
[0129]
[0130] Among them, IDF X is the inverse document frequency value of word segmentation X, df(X) is the number of occurrences of word segmentation X in all training set samples, and N is the total number of samples.
[0131] For example, based on the above formula, the reverse document frequency value of segmentation 1 is obtained according to the number of occurrence samples and the total number of samples of segmentation 1. In this way, the reverse document frequency values of all segmentations of the first dialogue information can be obtained.
[0132] S1225, obtaining a frequency feature vector of the word segmentation according to the word frequency value and the inverse document frequency value.
[0133] Exemplarily, the frequency feature vector (ie, the third frequency feature vector) of the corresponding word segment can be obtained according to the word frequency value of each word segment and the reverse document frequency value of each word segment.
[0134] TF_IDF X =TF X *IDF X
[0135] Among them, TF_IDF X is the frequency feature vector of word segment X, TF X is the frequency value of word segment X, IDF X is the inverse document frequency value of word segment X.
[0136] For example, based on the above formula, the frequency feature vector of word segment 1 (ie, TF_IDF1 value) is obtained according to the word frequency value of word segment 1 and the inverse document frequency value of word segment 1. In this way, the frequency feature vectors of all word segments of the first dialogue information can be obtained.
[0137] S1226: Use the frequency feature vectors of all the word segments as the second text feature vector of the first dialogue information.
[0138] Exemplarily, in one implementation, a frequency feature vector of each word segment is obtained (ie, the third frequency feature vector), and the frequency feature vectors of all word segmentations are set as the second text feature vector. Therefore, the second text feature vector is also the frequency feature vector of the first dialogue information (ie, the fourth frequency feature vector).
[0139] For example, we can obtain the frequency feature vectors TF_IDF′1, TF_IDF′2, ..., TF_IDF′ of all word segments. n , and then the second text feature vector is obtained as [TF_IDF′1, TF_IDF′2, …, TF_IDF′ n ]'s collection.
[0140] Exemplarily, in another implementation, the frequency feature vectors of all word segments TF_IDF′1, TF_IDF′2, ..., TF_IDF′ n Accumulate and get the second text feature vector
[0141] Among them, TF_IDF′ 总 is the frequency feature vector of the first dialogue information, TF_IDF′ i is the frequency feature vector of word segmentation i, n≤the total number of word segments.
[0142] In another implementation of the present application, the frequency feature vector of the word segmentation is obtained in the following manner:
[0143]
[0144] Among them, TF_IDF X is the frequency feature vector of the word segment X in the first dialogue information, TF X is the frequency value of word segment X, freq(X,H) is the number of occurrences of word segment X in the first dialogue information H, size(H) is the total number of words in the first dialogue information H, and IDF X is the inverse document frequency value of word segmentation X, df(X) is the number of occurrences of word segmentation X in all training set samples, and N is the total number of samples.
[0145] Exemplarily, the word frequency value and the reverse document frequency value of each word segment of the first dialogue information are determined to obtain the frequency feature vector of each word segment of the first dialogue information.
[0146] Furthermore, using methods such as Word2Vec and GloVe, each training set sample can be converted into a feature vector (that is, the first text feature vector), and the first dialogue information can be converted into a corresponding feature vector (that is, the second text feature vector).
[0147] Furthermore, in another implementation of the present application, if the feature extraction algorithm is the Word2Vec algorithm, all word segments of the first conversation information are converted into feature vectors based on the Word2Vec algorithm to obtain a word feature vector set (as another example of the second text feature vector).
[0148] For example, the second text feature vector of the first dialogue information is a vector set formed by [segmentation 1, segmentation 2, ..., segmentation n].
[0149] Furthermore, all word segments of each training set sample are converted into feature vectors based on the Word2Vec algorithm to obtain a word feature vector set of the training set sample (as another example of the first text feature vector).
[0150] For example, the first text feature vector of training set sample 1 is a vector set formed by [segment word 1, segment word 2, ..., segment word n]. In this way, the first text feature vectors of all training set samples can be obtained.
[0151] Exemplarily, in another implementation of the present application, if the feature extraction algorithm is the GloVe algorithm, all word segments of the first conversation information are converted into feature vectors based on the GloVe algorithm to obtain a word feature vector set (as another example of the second text feature vector).
[0152] For example, the second text feature vector of the first dialogue information is a vector set formed by [segmentation 1, segmentation 2, ..., segmentation n].
[0153] Furthermore, all word segments of each training set sample are converted into feature vectors based on the GloVe algorithm to obtain a word feature vector set of the training set sample (as another example of the first text feature vector).
[0154] For example, the first text feature vector of training set sample 1 is a vector set formed by [segment word 1, segment word 2, ..., segment word n]. In this way, the first text feature vectors of all training set samples can be obtained.
[0155] It should be noted that in the implementation of the present application, the first text feature vector of each training set sample can be pre-generated based on the above feature extraction algorithm and stored in the multi-model integration framework. In this way, the first text feature vector is obtained by pre-generating and storing. When performing dialogue interaction processing, the first text feature vector can be directly obtained to determine the dialogue type feature vector, thereby accelerating the dialogue interaction response efficiency and improving the user experience. Of course, it can also be generated based on the above feature extraction algorithm when performing dialogue interaction processing.
[0156] For example, in one implementation of the present application, see Figure 6 Taking the use of the KNN machine learning algorithm to obtain a dialogue type feature vector as an example, the dialogue type feature vector is obtained based on the first text feature vector and the second text feature vector corresponding to the first dialogue information based on the text classification algorithm, including the following steps.
[0157] S1231, calculating the similarity between each first text feature vector and the second text feature vector.
[0158] For example, taking the first text feature vector and the second text feature vector obtained based on the TF-IDF algorithm as an example, for the first dialogue information input by the user, the similarity between the second frequency feature vector of each training set sample (as an example of the first text feature vector) and the fourth frequency feature vector of the first dialogue information (as an example of the second text feature vector) is calculated. The similarity calculation can be performed using the Euclidean distance or cosine similarity calculation method.
[0159] Further, taking the first text feature vector and the second text feature vector obtained based on the Word2Vec algorithm or the GloVe algorithm as an example, for the first dialogue information input by the user, the similarity between each word feature vector of the second text feature vector and each word feature vector of the first text feature vector of the training set sample 1 is calculated, and the average value of the similarity between each word feature vector of the second text feature vector and each word feature vector of the first text feature vector of the training set sample 1 is screened out to obtain the similarity between the first dialogue information and the corresponding training set sample 1. Among them, the similarity calculation method can be used to calculate the Euclidean distance and the cosine similarity. In this way, the similarity between the second text feature vector and the first text feature vector of all training set samples can be calculated.
[0160] For example, the similarity between the word 1 included in the second text feature vector and each word in the first text feature vector is calculated, and the average value of the similarity is calculated as the similarity of the word 1 relative to the first text feature vector. In this way, the similarity of each word included in the second text feature vector relative to the first text feature vector is calculated. Further, the average value of the similarity of each word relative to the first text feature vector is calculated to obtain the similarity between the second text feature vector and the first text feature vector.
[0161] In the implementation of the present application, the similarity can be calculated based on all word feature vectors of the word segmentation relative to the first text feature vector, and then the average value is calculated based on all similarities, or some similarities can be screened out and the average value is calculated. For example, similarities greater than a preset threshold are screened, or similarities before a preset number after the similarities are sorted from large to small, and the average value is calculated. Among them, the preset threshold and the preset number can be set according to actual needs.
[0162] S1232, determining a preset number of training set samples from the plurality of training set samples according to the similarity as target training set samples.
[0163] Exemplarily, find the K (as an example of a preset number) training set samples (as an example of a target training set sample) that are closest to the second text feature vector of the first dialogue information input by the user. For example, sort the similarities between the second text feature vector and all the first text feature vectors from large to small, and use the training set samples corresponding to the first K similarities as the target training set samples.
[0164] Among them, K can be 8, 10, 12, 15 and other values, and of course can also be other values. Those skilled in the art can set it according to actual needs.
[0165] S1233, determining the dialogue type feature vectors of the target training set samples, and using the dialogue type feature vector with the largest number of repetitions among the dialogue type feature vectors of the target training set samples as the dialogue type feature vector of the first dialogue information.
[0166] Exemplarily, the conversation types (ie, text categories) to which the K target training set samples belong are counted, and the conversation type with the most occurrences is used as the conversation type of the first conversation information.
[0167] It should be noted that in the implementation of the present application, the conversation type is represented in the form of a feature vector, so the conversation type feature vector is also a vectorized conversation type, and its essence is still a conversation type.
[0168] For example, the dialogue types of the 10 target training set samples are dialogue type 1, dialogue type 2, dialogue type 2, dialogue type 2, dialogue type 5, dialogue type 4, dialogue type 4, dialogue type 2, dialogue type 7, and dialogue type 2. The dialogue type with the most repetitions is determined to be dialogue type 2, the dialogue type of the first dialogue information is determined to be dialogue type 2, and the dialogue type feature vector of the first dialogue type is vectorized dialogue type 2.
[0169] In the implementation of the present application, dialogue types (e.g., question categories) include but are not limited to mathematics, common sense, objective logical reasoning, open logical reasoning, science, chemistry, automobile, music, whether high real-time knowledge is required, image generation, etc.
[0170] It should be noted that the method of using SVM, Naive Bayes and other algorithms to classify text to obtain the dialogue type feature vector is similar to the method of using the KNN algorithm to obtain the dialogue type feature vector.
[0171] S130: Perform feature extraction processing on the first dialogue information based on the third dialogue model to obtain a target feature vector.
[0172] Exemplarily, some complex rules can also be judged using a large language model to extract features. For example, based on a multi-model integration framework, the first dialogue information and the corresponding classification requirements are input as prompt words into a large language model (as an example of a third dialogue model) that is good at text understanding and feature extraction of a certain feature, and the prompt words stipulate that the third dialogue model needs to output feature vector results in a specific structured manner (such as Json format). In this way, the large language model outputs feature extraction results (i.e., target feature vectors) based on given prompt words.
[0173] In the implementation of the present application, the target feature vector may include the aforementioned text length feature vector, language feature vector, text feature vector, conversation type feature vector, etc., and may also include a conversation attribute feature vector for representing conversation attributes (such as a question-and-answer feature vector, a small talk feature vector, etc.), and of course may also include a conversation domain feature vector for representing the conversation domain (such as a vehicle development domain feature vector, a vehicle control domain feature vector, etc.).
[0174] It should be noted that dialogue attributes and dialogue fields can be subcategories of dialogue classifications. Of course, dialogue classifications can also be subcategories of dialogue fields. Or dialogue attributes can be subcategories of dialogue classifications, and dialogue classifications can be subcategories of dialogue fields.
[0175] It should also be noted that the third dialogue model can be a model in the first dialogue model that is good at classifying dialogue information and extracting dialogue information features, or it can be a model different from the first dialogue model and the second dialogue model that is good at classifying dialogue information and extracting dialogue information features.
[0176] S140, obtaining a dialogue feature vector according to the text length feature vector, the language feature vector, the dialogue type feature vector and the target feature vector.
[0177] Exemplarily, a dialogue feature vector of the first dialogue information is formed according to a text length feature vector, a language feature vector, a dialogue type feature vector, and a target feature vector.
[0178] In the implementation of the present application, step S110, step S120, and step S130 can be executed simultaneously or in different orders. In addition, step S130 can be directly executed to directly perform feature extraction processing based on the large language model to obtain a dialogue feature vector. Of course, only step S110 and step S120 can also be executed to obtain a dialogue feature vector. The specific implementation method can be obtained based on the setting of the multi-model integration framework.
[0179] Furthermore, in an implementation of the present application, after the dialogue feature vector is obtained, a plurality of different first dialogue models are determined from a plurality of dialogue models according to the dialogue feature vector and a preset classification rule.
[0180] Exemplarily, a large language model answer task distribution rule is defined (as an example of a classification rule). When it is determined that the corresponding specific feature condition is met based on the dialogue feature vector of the first dialogue information, it is distributed only to a specific sub-large language model or not distributed to a specific sub-large language model.
[0181] For example, the preset classification rules include but are not limited to the following examples:
[0182] If the text length of the first dialogue information is determined by the text length feature vector to be greater than the preset length threshold 1, it is not distributed to the large language model A; if the text length of the first dialogue information is determined by the text length feature vector to be greater than the preset length threshold 2, it is not distributed to the large language models A and B.
[0183] If it is determined based on the language feature vector that the language of the first dialogue information is the specific language 1, it is not distributed to the large language model C.
[0184] If it is determined according to the dialogue type feature vector that the dialogue type of the first dialogue information is an image generation task, it is only distributed to the multimodal large language model D.
[0185] In this way, when a user inputs a dialogue message, it is determined based on the distribution rule (ie, the classification rule) to distribute the first dialogue message to one or more designated large language models.
[0186] Among them, the classification rules can be formulated based on the needs of the user, and the multi-model integration framework can be called to distribute the user's first dialogue information input to one or more specified large language models based on the determined classification results.
[0187] For step S200, the second dialogue model performs information fusion processing on the second dialogue information in the following manner to obtain the third dialogue information.
[0188] If the second conversation information is consistent, any second conversation information is used as the third conversation information.
[0189] Exemplarily, the multi-model integration framework inputs the second dialogue information output by each first dialogue model into the second dialogue model. If the second dialogue model determines that each second dialogue information is consistent (for example, the same or similar in meaning), any second dialogue information is output as the third dialogue information.
[0190] Among them, if it is objective dialogue information with only a unique answer such as mathematics, objective logical reasoning, etc., any second dialogue information can be output as the third dialogue information only after it is determined that all second dialogue information are exactly the same.
[0191] If it is a subjective dialogue information with different answers such as open-ended logical reasoning, if it is determined that the second dialogue information is completely the same or has similar meanings (that is, there are no obviously contradictory answers), any second dialogue information can be output as the third dialogue information. Of course, a fused third dialogue information can also be output based on the second dialogue information.
[0192] Furthermore, if the second dialogue information is inconsistent, the reference weights of the first dialogue models are determined, and the second dialogue information is fused according to the first dialogue information and the reference weights of the first dialogue models to obtain the third dialogue information.
[0193] For example, for relatively open questions, the second dialogue information output by different large language models may be different (that is, the second dialogue information is inconsistent), and weight fusion is required, that is, the reference weight distribution information of each major language model and the actual answer content output by each major language model (that is, the second dialogue information) are used as prompt words and input into the second dialogue model, and the second dialogue model comprehensively generates the final answer (that is, the three dialogue information).
[0194] For example, in one implementation of the present application, see Figure 7 , a reference weight of a dialogue model (eg, the first dialogue model) is obtained in the following manner.
[0195] S210, determining a first score of a dialogue model corresponding to a dialogue feature vector, and determining a total score of all dialogue models corresponding to the dialogue feature vector.
[0196] Exemplarily, according to the performance of each large language model in different fields, each large language model is assigned a corresponding weight based on different dialogue fields (as an example of the first score). For example, for question-answering in a specific dialogue field, a large language model specialized in the corresponding field will receive a higher weight, and for long text dialogues, a large language model that is good at long text dialogues will receive a higher weight.
[0197] That is, the performance of each language model on each question feature dimension (that is, the dialogue feature vector) is experimented and manually scored in advance. For example, the performance of each language model on each feature dimension is scored from 0 to 100 in long text (as an example of text length feature vector), language A, language B (as an example of language feature vector), mathematics, common sense, objective logical reasoning, open logical reasoning, science, automotive professional field, medical professional field, chemical professional field, etc. (as an example of dialogue type feature vector). After multiple experiments, the average score is finally calculated to obtain the score of the large language model on the dimension corresponding to different dialogue feature vectors (that is, the first score). Assume that the i-th large language model LLM on the m-th dimension (that is, corresponding to the dialogue feature vector m) i The score is S m,i .
[0198] Further, all large language models LLM are obtained i Corresponding to the total score of the dialogue feature vector m.
[0199] For example, there are dialogue models 1, 2, 3, and 4, and the first score S corresponding to the dialogue feature vector m of dialogue model 1 is determined. m,1 , further, determining the first score S of the dialogue model 2 corresponding to the dialogue feature vector m m,2 , determine the first score S of dialogue model 3 corresponding to dialogue feature vector m m,3 , determine the first score S of the dialogue model 4 corresponding to the dialogue feature vector m m,4 The total score of all dialogue models corresponding to the dialogue feature vector m is
[0200] S220: Determine a reference weight of the dialogue model corresponding to the dialogue feature vector according to the first score and the total score.
[0201] Exemplarily, the first score is divided by the total score to obtain the reference weight of the dialogue model corresponding to the dialogue feature vector m. That is,
[0202]
[0203] Among them, V m,i is the reference weight of dialogue model i corresponding to dialogue feature vector m, S m,i is the first score of dialogue model i corresponding to dialogue feature vector m is the total score of all dialogue models corresponding to the dialogue feature vector m, k is the number of dialogue models, i≤k.
[0204] For example, the Large Language Model LLM i The first score of the long text feature vector in the text length feature vector is 70 points, and the total score of all large language models corresponding to the long text feature vector is 470 points. Then the large language model LLM is obtained. i The reference weight corresponding to the long text feature vector in the text length feature vector is 15%. In this way, a large language model LLM can be obtained. i The reference weights correspond to language feature vectors (e.g., language A, language B) and dialogue type feature vectors (e.g., mathematics, common sense, objective logical reasoning, open logical reasoning, science, automotive professional fields, medical professional fields, chemical professional fields, etc.).
[0205] In this way, based on the above method, the reference weights of all large language models corresponding to each dialogue feature vector can be obtained.
[0206] S230: taking the sum of the reference weights of the dialogue model corresponding to all dialogue feature vectors as the reference weight of the dialogue model.
[0207] Exemplarily, the reference weights of the large language model are accumulated and summed to obtain the reference weight of the large language model.
[0208]
[0209] Among them, V i is the reference weight of dialogue model i, V m,i is the reference weight of dialogue model i corresponding to each dialogue feature vector m, n is the number of dialogue feature vectors, m≤n.
[0210] For example, the Large Language Model LLM i The reference weight corresponding to the long text feature vector in the text length feature vector is 15%, the reference weight corresponding to language A is 10%, ..., the reference weight corresponding to the field of chemistry is 20%, and the large language model LLM i The reference weights corresponding to all dialogue feature vectors are added together to obtain the large language model LLM i The reference weight of .
[0211] In this way, the comprehensive weight V of each language model corresponding to all dialogue feature vectors can be obtained i After the first dialogue model is determined, the reference weight V of each first dialogue model is obtained by querying i .
[0212] In another implementation of the present application, the reference weight of the dialogue model is obtained in the following manner:
[0213]
[0214] Among them, V i is the reference weight of dialogue model i, V m,i is the reference weight of dialogue model i corresponding to dialogue feature vector m, n is the number of dialogue feature vectors, m≤n, S m,i is the first score of dialogue model i corresponding to dialogue feature vector m, is the total score of the dialogue model corresponding to the dialogue feature vector m, k is the number of dialogue models, i≤k.
[0215] That is, in the implementation of the present application, the reference weights V0, V1, V2, ..., V n The second dialogue information generated by each first dialogue model is input into a large language model LLM through prompt engineering to generate a fusion answer. i (As an example of the second dialogue model), a large language model LLM is required in the prompt word iA final answer (ie, third dialogue information) is generated based on the second dialogue information of each first dialogue model and the reference weight of each first dialogue model.
[0216] Furthermore, if there is inconsistency in the second dialogue information, target dialogue information is determined from the second dialogue information, and the target dialogue information is input into each first dialogue model so that each first dialogue model obtains fourth dialogue information according to the target dialogue information, until a preset proportion of fourth dialogue information in the obtained fourth dialogue information is determined to be consistent, and any consistent fourth dialogue information is used as the third dialogue information.
[0217] Exemplarily, a multi-model game is conducted. For example, for certain relatively objective problems (such as math problems with only a unique solution, and objective logical reasoning problems with only a unique answer), if the second dialogue model finds that the second dialogue information output by each first dialogue model is significantly different (that is, the second dialogue information is inconsistent), the target dialogue information is determined, and the target dialogue information is input into part or all of the first dialogue models so that the first dialogue model can be verified again and generate new answer content (as an example of the fourth dialogue information). This is repeated multiple times until most (for example, 80% (as an example of a preset ratio)) of the fourth dialogue information are consistent, and any consistent fourth dialogue information is used as the third dialogue information.
[0218] For example, if the second dialogue model finds that the second dialogue information output by each first dialogue model is significantly different (that is, the second dialogue information is inconsistent), the second dialogue information with the largest number of identical ones is determined as the target dialogue information, and the target dialogue information is input into the first dialogue model that outputs different second dialogue information, so that the first dialogue model that outputs different second dialogue information is verified again and generates new answer content (as an example of the fourth dialogue information), and this is repeated multiple times until most of the fourth dialogue information are consistent, and any consistent fourth dialogue information is used as the third dialogue information.
[0219] In the implementation of the present application, the second dialogue information includes the generated answer and answer ideas. For example, there are first dialogue models 1, 2, and 3. If the second dialogue information output by the first dialogue models 1 and 2 is the same, and the second dialogue information output by the first dialogue model 3 is different, then the answer and answer ideas output by the first dialogue models 1 and 2 are input into the first dialogue model 3, so that the first dialogue model 3 regenerates new dialogue information (that is, the fourth dialogue information) according to the second dialogue information and the first dialogue information. If the second dialogue model determines that the fourth dialogue information is the same as the second dialogue information output by the first dialogue models 1 and 2, then the fourth dialogue information (that is, the second dialogue information) is output as the third dialogue information. If it is determined that the fourth dialogue information is not the same as the second dialogue information output by the first dialogue models 1 and 2, it can be repeated again until the fourth dialogue information output by each first dialogue model is an answer with relative commonality, and any fourth dialogue information is used as the third dialogue information. Of course, the second dialogue information output by the first dialogue model 3 can also be input into the first dialogue models 1 and 2, so that the first dialogue models 1 and 2 can regenerate the fourth dialogue information, until most of the fourth dialogue information are relatively consistent, and the relatively consistent fourth dialogue information are summarized and adopted to generate the final high-quality answer.
[0220] In the implementation of the present application, if the second dialogue information output by the first dialogue models 1 and 2 is the same, and the second dialogue information output by the first dialogue model 3 is different, the answers and answer ideas output by the first dialogue models 1 and 2 are input to the first dialogue model 3, so that the first dialogue model 3 regenerates new dialogue information (that is, the fourth dialogue information) according to the second dialogue information and the first dialogue information, and the second dialogue information output by the first dialogue model 3 is input to the first dialogue models 1 and 2, so that the first dialogue models 1 and 2 regenerate the fourth dialogue information, and if the second dialogue model determines that the fourth dialogue information output by the first dialogue model 3 is the same as the fourth dialogue information output by the first dialogue models 1 and 2, the fourth dialogue information is output as the third dialogue information. If it is determined that they are not the same, it can be repeated again until most of the fourth dialogue information output by the first dialogue models is a relatively common answer (that is, the fourth dialogue information of the preset proportion is consistent), and any consistent fourth dialogue information is used as the third dialogue information.
[0221] Of course, the third dialogue information can also be obtained based on the first dialogue information and the fourth dialogue information.
[0222] Of course, the second dialogue model may also perform information fusion processing based on the second dialogue information of each first dialogue model in other specific ways. Those skilled in the art may set the processing procedure of the second dialogue model as required so that when responding to dialogue information with a unique answer, a unique reply information can be output.
[0223] Among them, the preset ratio can be set according to actual needs.
[0224] It should be noted that the second dialogue model and the third dialogue model are also integrated into the multi-model integration framework.
[0225] For step S300, using the third dialogue information as reply information to the first dialogue information includes: using the third dialogue information generated after information fusion processing by the second dialogue model as reply information, and outputting it to the user through a human-computer interaction method such as a UI interface or voice broadcast.
[0226] The conversation interaction method provided by the implementation of the present application is actually a method for obtaining high-quality conversation questions and answers based on the fusion of multiple large language models. It introduces multiple large language models (that is, the first conversation model) for fusion and uses an arbitration large model (that is, the second conversation model) for summarization. Compared with a single large language model, it can show stronger capabilities when conducting user-computer interaction.
[0227] Specifically, due to the integration of the unique advantages of multiple large language models, it can provide more accurate and professional answers when answering complex, multi-dimensional or specific professional questions, and reduce hallucination problems, significantly improving the quality of question and answer. Furthermore, it can integrate the unique perspectives and novel ideas of different models, so that the generated answers are not only correct, but also more complete, inspiring and creative, enhancing the diversity and innovation of the reply information. In addition, by integrating large language models with real-time information retrieval capabilities, the timeliness of the answer content is ensured. Furthermore, the disadvantage of a single large model not having long text dialogue is avoided, and the advantages of long text dialogue of some large models are brought into play to achieve long text dialogue capabilities. In addition, the dialogue advantages of some large language models in specific languages are brought into play to achieve the highest possible answer quality in various languages to improve the multilingual dialogue effect.
[0228] The implementation of this application also discloses a dialogue interaction method, see Figure 8 , specifically including the following steps.
[0229] S1, build a multi-model integration framework to integrate multiple large language models.
[0230] S2, accepting user questions (as an example of first dialogue information) input.
[0231] S3, problem feature extraction.
[0232] That is, feature extraction processing is performed on the first dialogue information to obtain a dialogue feature vector.
[0233] S4, based on question features and predefined rules (i.e. preset classification rules), multi-submodel (i.e. large language model) question and answer task distribution is performed.
[0234] That is, a plurality of different first dialogue models are determined from a plurality of dialogue models according to the dialogue feature vector and the preset classification rule.
[0235] S5: Each sub-language model generates a response.
[0236] That is, each first dialogue model obtains the second dialogue information according to the first dialogue information.
[0237] S6, each sub-language model’s answer content reference weight definition and matching.
[0238] That is, the reference weight of the first dialogue model is obtained.
[0239] S7, based on the answer content and reference weight of each sub-language model, the final answer is generated by fusion.
[0240] That is, according to the first dialogue information and the reference weights of the first dialogue models, the second dialogue information is subjected to information fusion processing to obtain the third dialogue information.
[0241] S8: Output the final answer to the user.
[0242] That is, the third dialogue information is output to the user as reply information to the first dialogue information of the user.
[0243] In the implementation of the present application, multiple large language models are used to reply to the same question (that is, the same first dialogue information) (that is, to generate the second dialogue information), and an arbitration fusion large model (that is, the second dialogue model) is introduced to optimize and summarize the answers of multiple sub-large language models, make full use of the advantages of different models, overcome the limitations of a single model in answering questions, or allow multiple large language models to correct their own answers with reference to each other's answers, so as to obtain more complete and high-quality response information.
[0244] The dialog interaction method provided by the implementation of the present application is applied to electronic devices.
[0245] See also Fig. 9 , Fig. 9 The figure shows a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, the electronic device may include: a transceiver 121 , a processor 122 , and a memory 123 .
[0246] The processor 122 executes the computer execution instructions stored in the memory, so that the processor 122 executes part of the technical solutions of the dialogue interaction method in the above embodiment. The processor 122 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital data processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0247] The memory 123 is connected to the processor 122 via a system bus and completes communication between them. The memory 123 is used to store computer program instructions.
[0248] By way of example and not limitation, the memory 123 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 123 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 123 may be inside or outside the integrated gateway device. In a particular embodiment, the memory 123 is a non-volatile solid-state memory. In a particular embodiment, the memory 123 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or a flash memory, or a combination of two or more of these.
[0249] The transceiver 121 may be used to obtain tasks to be executed and configuration information of the tasks to be executed.
[0250] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0251] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the dialogue interaction method in the above embodiment.
[0252] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a processor of an electronic device, the processor of the electronic device executes the technical solution of the conversation interaction method of the above embodiment.
[0253] In some possible implementations, various aspects of the method provided in the present application may also be implemented in the form of a program product, which includes program code. When the program product runs on a processor of an electronic device, the program code is used to enable the processor of the electronic device to execute the steps of the method according to various exemplary implementations of the present application described above in this specification. For example, the electronic device may execute the conversational interaction method recorded in the embodiments of the present application.
[0254] The program product may employ any combination of one or more readable media. The readable medium may be a readable data medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0255] The implementation method of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, the technical solution of the conversation interaction method in the above embodiment can be implemented.
[0256] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable information processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable information processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0257] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable information processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0258] These computer program instructions can also be loaded onto a computer or other programmable information processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0259] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.
[0260] It should be noted that, in addition to the implementation of the present application described in the above-mentioned specific embodiments, those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Although the description of the present application is introduced in conjunction with the preferred embodiment, this does not mean that the features of this invention are limited to the implementation. On the contrary, the purpose of introducing the invention in conjunction with the implementation is to cover other options or modifications that may extend based on the claims of the present application. In order to provide an in-depth understanding of the present application, the above description contains many specific details, and the present application may also be implemented without using these details. In addition, in order to avoid confusion or blurring the focus of the present application, some specific details will be omitted in the description. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0261] It should be noted that in this specification, similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0262] Although the present application has been illustrated and described by referring to certain preferred implementations of the present application, it should be understood by those skilled in the art that the above contents are further detailed descriptions of the present application in combination with specific implementations, and it cannot be determined that the specific implementation of the present application is limited to these descriptions. Those skilled in the art may make various changes in form and details, including making several simple deductions or substitutions, without departing from the spirit and scope of the present application.
Claims
1. A conversation interaction method, characterized in that: The method comprises: inputting the first dialogue information into a plurality of different first dialogue models so that each of the first dialogue models obtains the second dialogue information according to the first dialogue information; inputting the second dialogue information into a second dialogue model, so that the second dialogue model performs information fusion processing on the second dialogue information to obtain third dialogue information; The third dialogue message is used as reply message to the first dialogue message.
2. The method for dialog interaction according to claim 1, characterized in that: The method further includes, the second dialogue model performing information fusion processing on the second dialogue information in the following manner to obtain the third dialogue information: If the second dialogue information is consistent, any one of the second dialogue information is used as the third dialogue information; If the second dialogue information is inconsistent, determining reference weights of the first dialogue models, and performing information fusion processing on the second dialogue information according to the first dialogue information and the reference weights of the first dialogue models to obtain the third dialogue information; or If the second dialogue information is inconsistent, target dialogue information is determined from the second dialogue information, and the target dialogue information is input into each of the first dialogue models, so that each of the first dialogue models obtains fourth dialogue information according to the target dialogue information, until it is determined that a preset proportion of the fourth dialogue information obtained is consistent, and any consistent fourth dialogue information is used as the third dialogue information.
3. The method for dialog interaction according to claim 2, characterized in that: The method further includes determining the plurality of different first dialogue models by: Performing feature extraction processing on the first conversation information to obtain a conversation feature vector; The multiple different first dialogue models are determined from the multiple dialogue models according to the dialogue feature vector and a preset classification rule.
4. The method for dialog interaction according to claim 3, characterized in that: Performing feature extraction processing on the first dialogue information to obtain a dialogue feature vector includes: Performing feature extraction processing on the first dialogue information based on a preset feature extraction rule to obtain a text length feature vector and a language feature vector; Performing feature extraction processing on the first conversation information based on a text classification algorithm to obtain a conversation type feature vector; Performing feature extraction processing on the first dialogue information based on a third dialogue model to obtain a target feature vector; The dialogue feature vector is obtained according to the text length feature vector, the language feature vector, the dialogue type feature vector and the target feature vector.
5. The method for dialog interaction according to claim 4, characterized in that: Performing feature extraction processing on the first dialogue information based on a text classification algorithm to obtain a dialogue type feature vector includes: Determine a plurality of training set samples of the text classification algorithm, and determine a first text feature vector of each of the training set samples; The dialogue type feature vector is obtained based on the text classification algorithm according to the first text feature vector and the second text feature vector corresponding to the first dialogue information. The second text feature vector is obtained by performing feature extraction processing on the first dialogue information based on a feature extraction algorithm.
6. The method for dialog interaction according to claim 5, characterized in that: The feature extraction algorithm is one of the TF-IDF algorithm, the Word2Vector algorithm, and the GloVe algorithm.
7. The method for dialog interaction according to claim 6, characterized in that: If the feature extraction algorithm is a TF-IDF algorithm, the method further includes performing feature extraction processing on the first dialogue information based on the feature extraction algorithm to obtain the second text feature vector in the following manner: Determining the number of occurrences of the segmented words in the first dialogue information and the total number of segmented words in the first dialogue information; Determine a frequency value of the segmented word in the first dialogue information according to the number of occurrences and the total number of segmented words; Determine the number of occurrence samples of the word segment in the training set samples and the total number of samples of the training set samples; Determine the reverse document frequency value of the word segmentation according to the number of occurrence samples and the total number of samples; Obtaining a frequency feature vector of the word segmentation according to the word frequency value and the inverse document frequency value; The frequency feature vectors of all the word segments are used as the second text feature vector of the first dialogue information.
8. The method for dialog interaction according to claim 7, characterized in that: The method further includes obtaining the frequency feature vector of the word segmentation by: Among them, TF_IDF X is the frequency feature vector of the word segment X of the first dialogue information, TF X is the frequency value of word segment X, freq(X,H) is the number of occurrences of word segment X in the first dialogue information H, size(H) is the total number of word segments in the first dialogue information H, and IDF x is the reverse document frequency value of word segment X, df(X) is the number of occurrence samples of word segment X in all the training set samples, and N is the total number of samples.
9. The dialog interaction method according to any one of claims 5 to 8, characterized in that: Obtaining the dialogue type feature vector based on the text classification algorithm according to the first text feature vector and the second text feature vector corresponding to the first dialogue information includes: Calculating the similarity between each of the first text feature vectors and the second text feature vectors; Determine a preset number of training set samples from the plurality of training set samples according to the similarity as target training set samples; Determine the dialogue type feature vectors of the target training set samples, and use the dialogue type feature vector with the largest number of repetitions among the dialogue type feature vectors of the target training set samples as the dialogue type feature vector of the first dialogue information.
10. The dialog interaction method according to any one of claims 4 to 9, characterized in that: The method further includes obtaining the reference weight of the dialogue model by: Determining a first score of the dialogue model corresponding to the dialogue feature vector, and determining a total score of all the dialogue models corresponding to the dialogue feature vector; Determining a reference weight of the dialogue model corresponding to the dialogue feature vector according to the first score and the total score; The sum of the reference weights of the dialogue model corresponding to all the dialogue feature vectors is used as the reference weight of the dialogue model.
11. The method for dialog interaction according to claim 10, characterized in that: The method further includes obtaining the reference weight of the dialogue model by: Among them, V i is the reference weight of the dialogue model i, V m,i is the reference weight of the dialogue model i corresponding to the dialogue feature vector m, n is the number of the dialogue feature vectors, m≤n, S m,i is the first score of the dialogue model i corresponding to the dialogue feature vector m, is the total score of the dialogue model corresponding to the dialogue feature vector m, k is the number of the dialogue models, i≤k.
12. The dialog interaction method according to any one of claims 1 to 11, characterized in that: The first dialogue models are integrated into a multi-model integration framework, and the first dialogue information is input into a plurality of different first dialogue models, including: The first dialogue information is respectively input into each of the first dialogue models based on the API interface of the multi-model integration framework.
13. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores a computer program, and the processor executes the computer program stored in the memory so that the electronic device implements the conversation interaction method as described in any one of claims 1-12.
Citation Information
Cited By
Urinary interrogation method and device based on LLM context embedding assistance
CN119811647A
A urology consultation method and device based on LLM context embedding assistance
CN119811647B
