Context-based big language model dialogue processing method and apparatus, and electronic device

By encoding and semantic similarity filtering of user input and historical dialogue information, concise and relevant input text are formed, which solves the shortcomings of large language models in dialogue context management and improves the speed and accuracy of response.

CN119831045APending Publication Date: 2025-04-15北京中科闻歌科技股份有限公司
View PDF 0 Cites 15 Cited by

Patent Information

Application Number
CN202411915111.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The existing large language models have problems such as insufficient context coherence, limited input length, waste of computing resources and lack of critical information in dialogue context management.

Method used

By obtaining the current text information input by the user and multiple pre-stored historical dialogue information for encoding, the semantic similarity between each historical dialogue vector and the current text vector is calculated, the historical dialogue content that is highly related to the current input is selected, and it is spliced ​​with the current text information to form a concise and highly related target input text, and input it into the large language model to generate a response.

Benefits of technology

Effectively avoid redundant information, improve the speed and accuracy of response generation, enhance the model's context understanding ability, and ensure that the input text is concise and highly relevant.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119831045A_ABST
    Figure CN119831045A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a context-based big language model dialogue processing method and device and electronic equipment, and can solve the problem of how to provide a dynamic management method based on context similarity analysis and intelligent screening to optimize big language model interaction. The method comprises the steps of obtaining current text information input by a user; coding the current text information and a plurality of pieces of pre-stored historical dialogue information to obtain a current text vector and a plurality of historical dialogue vectors; according to the semantic similarity between each historical dialogue vector and the current text vector, screening the plurality of historical dialogue vectors to obtain screened target historical dialogue information; splicing the current text information and the screened target historical dialogue information to obtain a target input text; the target input text is input into a target language model, target output response information is obtained, and the target language model comprises a large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of natural language processing technology, and in particular to a context-based large language model dialogue processing method, device and electronic device. Background Art

[0002] In recent years, Large Language Models (LLMs) have been widely used in intelligent customer service, dialogue systems, education, and medical fields due to their powerful natural language understanding and generation capabilities. Through pre-training and fine-tuning, large language models can learn the semantics and grammatical rules of language from massive data, thereby generating fluent text responses. Existing large language model interaction technologies may have problems in dialogue context management: insufficient context coherence, limited input length, waste of computing resources, missing key information, etc. Therefore, how to provide a dynamic management method based on context similarity analysis and intelligent screening to optimize large language model interactions has become a problem that needs to be solved urgently. Summary of the invention

[0003] Based on this, it is necessary to provide a context-based large language model dialogue processing method, device and electronic device to address the above technical problems.

[0004] In a first aspect, an embodiment of the present application provides a context-based large language model dialogue processing method, the context-based large language model dialogue processing method comprising: obtaining current text information input by a user;

[0005] Encoding the current text information and the pre-stored multiple historical conversation information respectively to obtain a current text vector and multiple historical conversation vectors;

[0006] Filtering the multiple historical conversation vectors according to the semantic similarity between each historical conversation vector and the current text vector to obtain filtered target historical conversation information;

[0007] The current text information and the filtered target historical conversation information are concatenated to obtain a target input text;

[0008] The target input text is input into a target language model to obtain target output response information, wherein the target language model includes the large language model.

[0009] As an optional implementation manner, in the first aspect of the embodiment of the present application, the current text information and the pre-stored multiple historical dialogue information are respectively encoded to obtain a current text vector and multiple historical dialogue vectors, including:

[0010] The current text information and the multiple historical conversation information are encoded respectively through a preset text encoding model to obtain the current text vector and the multiple historical conversation vectors.

[0011] As an optional implementation manner, in the first aspect of the embodiment of the present application, the filtering of the multiple historical dialogue vectors according to the semantic similarity between each historical dialogue vector and the current text vector to obtain the filtered target historical dialogue information includes:

[0012] Compare the semantic similarity between each historical conversation vector and the current text vector with a preset threshold to obtain a comparison result;

[0013] According to the comparison result, the multiple historical dialogue vectors are screened to obtain the screened target historical dialogue information.

[0014] As an optional implementation manner, in the first aspect of the embodiment of the present application, the filtering of the multiple historical conversation vectors according to the comparison result to obtain the filtered target historical conversation information includes:

[0015] Determine the vector whose semantic similarity is greater than or equal to the preset threshold value as a first historical conversation vector;

[0016] Determine the vector whose semantic similarity is less than the preset threshold value as a second historical conversation vector;

[0017] The filtered target historical dialogue information is obtained according to the first historical dialogue vector and the second historical dialogue vector.

[0018] As an optional implementation manner, in the first aspect of the embodiment of the present application, obtaining the filtered target historical conversation information according to the first historical conversation vector and the second historical conversation vector includes:

[0019] Processing the second historical conversation vector by a preset text summary generation algorithm to obtain summary content corresponding to the second historical conversation vector;

[0020] The first historical conversation vector and the summary content are concatenated to obtain the filtered target historical conversation information.

[0021] As an optional implementation manner, in the first aspect of the embodiment of the present application, after inputting the target input text into the target language model and obtaining the target output response information, the method further includes:

[0022] The target input text and the target output response information are stored correspondingly.

[0023] As an optional implementation manner, in the first aspect of the embodiment of the present application, after inputting the target input text into the target language model and obtaining the target output response information, the method further includes:

[0024] The target output response information is output to the user.

[0025] In a second aspect, an embodiment of the present application provides a context-based large language model dialogue processing device, the context-based large language model dialogue processing device comprising: an acquisition module, configured to acquire current text information input by a user;

[0026] A processing module, encoding the current text information and the pre-stored multiple historical dialogue information respectively to obtain a current text vector and multiple historical dialogue vectors;

[0027] The processing module is further used to filter the multiple historical dialogue vectors according to the semantic similarity between each historical dialogue vector and the current text vector to obtain filtered target historical dialogue information;

[0028] The processing module is further used to splice the current text information with the filtered target historical dialogue information to obtain the target input text;

[0029] The processing module is further used to input the target input text into a target language model to obtain target output response information, and the target language model includes the large language model.

[0030] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:

[0031] A memory storing executable program code;

[0032] a processor coupled to the memory;

[0033] The processor calls the executable program code stored in the memory to execute the context-based large language model dialogue processing method in the first aspect of the embodiment of the present application.

[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the context-based large language model dialogue processing method in the first aspect of the embodiment of the present application. The computer-readable storage medium includes a ROM / RAM, a disk or an optical disk, etc.

[0035] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute part or all of the steps of any one of the methods of the first aspect.

[0036] In a sixth aspect, an embodiment of the present application provides an application publishing platform, which is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes part or all of the steps of any one method of the first aspect.

[0037] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0038] The embodiment of the present application provides a context-based large language model dialogue processing method, device and electronic device, which obtains the current text information input by the user; encodes the current text information and multiple pre-stored historical dialogue information respectively to obtain the current text vector and multiple historical dialogue vectors; according to the semantic similarity between each historical dialogue vector and the current text vector, multiple historical dialogue vectors are screened to obtain the screened target historical dialogue information; the current text information and the screened target historical dialogue information are spliced ​​to obtain the target input text; the target input text is input into the target language model to obtain the target output response information, and the target language model includes a large language model. In this scheme, through context semantic similarity analysis, the historical dialogue content related to the current input text is dynamically screened, and the related dialogue information is intelligently spliced ​​to ensure that the input text is concise and highly relevant, thereby providing a more accurate input for the model, effectively avoiding redundant information, improving the speed and accuracy of response generation, and enhancing the context understanding ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 This is a flow chart of a context-based large language model dialogue processing method provided in an embodiment of the present application. Figure 1 ;

[0042] Figure 2This is a flow chart of a context-based large language model dialogue processing method provided in an embodiment of the present application. Figure 2 ;

[0043] Figure 3 It is a structural diagram of a context-based large language model dialogue processing device provided in an embodiment of the present application;

[0044] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0046] The terms “first”, “second” and the like in the description and claims of the present application are used to distinguish different objects rather than to describe a specific order of the objects.

[0047] The terms "including" and "having" and any variations thereof in the embodiments of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.

[0048] It should be noted that, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0049] In recent years, large language models have been widely used in intelligent customer service, dialogue systems, education, medical care and other fields due to their powerful natural language understanding and generation capabilities. Through pre-training and fine-tuning, large language models can learn the semantics and grammatical rules of language from massive data, thereby generating fluent text responses. However, different application scenarios place higher demands on the dialogue coherence and semantic understanding of the model.

[0050] The current large language model mainly relies on the following three methods to interact with users:

[0051] Independent interaction method: This method treats each user input as an isolated event. The model does not consider the previous conversation history when generating a response, which makes it difficult to maintain contextual coherence in complex conversation scenarios and easily leads to misunderstanding of user input.

[0052] Full context interaction method: All historical conversation records are spliced ​​as input content, so that the model can refer to the complete context to generate responses. Although this method can enhance coherence to a certain extent, when the conversation content is long, the input will exceed the maximum length limit of the model, thereby losing key information, and as the input length increases, the computational complexity and resource consumption also increase significantly.

[0053] Windowed context interaction method: This method sets a fixed-length "window" and uses only the most recent rounds of dialogue as input to generate responses. This method reduces the input length to a certain extent and alleviates the resource consumption problem. However, a fixed window size may ignore key early dialogue content, especially when it comes to complex, multi-round dialogues, which can easily lead to information loss or insufficient context understanding.

[0054] In summary, existing large model technologies still have significant deficiencies in the management and utilization of conversation context, which can be specifically described as follows:

[0055] (1) Insufficient contextual coherence: In independent interactions, each input is treated as an isolated event, ignoring the contextual relevance of historical conversation information, making it difficult for large language models to fully understand user intent. In particular, when complex reasoning requires comprehensive integration of multiple rounds of input, the responses generated by the model often lack coherence and accuracy.

[0056] (2) Limited input length: The full-context interaction method concatenates all historical conversations as input. When the conversation length is long, it is easy to exceed the maximum processing length of the large language model. In this case, key information may be truncated, affecting the quality of the generated results. In addition, a large amount of irrelevant historical content is retained, further increasing the burden on the model.

[0057] (3) Waste of computing resources: The full-context interaction method indiscriminately inputs all historical conversations into the model, regardless of their relevance to the current input. This redundant calculation not only wastes computing power and storage resources, but may also cause response delays, making it difficult to meet the requirements of real-time interaction.

[0058] (4) Key information missing problem: The window context interaction method controls the input size by intercepting the most recent conversation content of a fixed length. Although it optimizes computational efficiency, it may ignore early important information that is closely related to the current input. In scenarios that require long-term conversation memory or complex context association, this method is prone to cause key semantic loss, reducing the accuracy of the response and user satisfaction.

[0059] In order to solve some or all of the above technical problems, the embodiment of the present application provides a context-based large language model dialogue processing method, device and electronic device, which obtains the current text information input by the user; encodes the current text information and multiple pre-stored historical dialogue information respectively to obtain the current text vector and multiple historical dialogue vectors; according to the semantic similarity between each historical dialogue vector and the current text vector, multiple historical dialogue vectors are screened to obtain the screened target historical dialogue information; the current text information and the screened target historical dialogue information are spliced ​​to obtain the target input text; the target input text is input into the target language model to obtain the target output response information, and the target language model includes a large language model. In this scheme, through context semantic similarity analysis, the historical dialogue content related to the current input text is dynamically screened, and the related dialogue information is intelligently spliced ​​to ensure that the input text is concise and highly relevant, thereby providing a more accurate input for the large language model, effectively avoiding redundant information, improving the speed and accuracy of response generation, and enhancing the context understanding ability of the model.

[0060] like Figure 1 As shown, Figure 1 A flowchart of a context-based large language model dialogue processing method provided in an embodiment of the present application, the method may include the following steps:

[0061] 101. Get the current text information entered by the user.

[0062] In an embodiment of the present application, the current text information may be information such as questions or requests input by the user through a dialogue interface. The current text information may be information input by the user in real time, or may be information selected by the user from multiple alternative information, or may be information input by the user through other means, and the embodiment of the present application does not make any specific limitation.

[0063] 102. Encode the current text information and the pre-stored multiple historical dialogue information respectively to obtain a current text vector and multiple historical dialogue vectors.

[0064] In an embodiment of the present application, the historical conversation information is the pre-stored text information and corresponding answer information input by the user at historical moments. That is to say, the user's previous various questions and answers are stored accordingly. These historical information can be used for model training and optimization so that the model can be more in line with the actual scenario and the output answers are more intelligent.

[0065] It should be noted that in the processor, all information is stored in binary form, and text information is no exception. Therefore, the text information needs to be converted into binary data through encoding before it can be stored and processed by the processor. The encoding process is to convert each text character in the text into a corresponding binary vector.

[0066] In an embodiment of the present application, both the current text information currently input and the multiple historical conversation information pre-stored need to be encoded and converted into vectors to facilitate subsequent calculations, that is, the current text vector corresponding to the current text information and the multiple historical conversation vectors corresponding to the multiple historical conversation information can be obtained.

[0067] It should be noted that the multiple historical conversation information can be stored in the format of text information, and retrieved and encoded into vectors when needed; of course, they can also be encoded and converted into vectors directly when stored, and stored directly in the vector format, so that multiple historical conversation information in vector format can be directly obtained when retrieved, and the embodiments of the present application do not make specific limitations.

[0068] 103. According to the semantic similarity between each historical conversation vector and the current text vector, multiple historical conversation vectors are screened to obtain screened target historical conversation information.

[0069] In an embodiment of the present application, among multiple historical conversation information, there may be information that is relatively similar to the current text information, that is, the user has asked or input similar questions before and received corresponding answers. Of course, there may also be some information that has nothing to do with the current text information. Therefore, the semantic similarity between the historical conversation vector corresponding to each historical conversation information and the current text vector corresponding to the current text information can be calculated, and then the historical conversation vectors can be screened according to the semantic similarity to obtain the screened target historical conversation information.

[0070] In some embodiments, the semantic similarity between each historical conversation vector and the current text vector can be represented by cosine similarity or other similarity measurement methods. In the embodiments of the present application, cosine similarity is used as an example for explanation.

[0071] In some embodiments, multiple historical conversation vectors can be represented by D, where D = {d1, d2, ..., dn}, the current text vector currently entered by the user can be used with Input t Logo, semantic similarity can be expressed as:

[0072]

[0073] Among them, Similarity(d i ,Input i ) represents each historical dialogue vector d i and the current text vector Input t ∥·∥ represents the semantic similarity between , and ∥·∥ represents the L2 norm of the vector.

[0074] It should be noted that the L2 norm is also called the Euclidean norm, which is the square root of the sum of the squares of the vector elements. The value of semantic similarity is between -1 and 1. The closer it is to 1, the more similar the historical conversation vector is to the current text vector. The closer it is to -1, the greater the difference between the historical conversation vector and the current text vector.

[0075] 104. The current text information and the filtered target historical dialogue information are concatenated to obtain the target input text.

[0076] In an embodiment of the present application, after filtering the historical conversations, the target historical conversation information obtained can be considered as a conversation that is closer to the current text information or can reflect key information. Therefore, the current text information and the filtered target historical conversation information can be spliced ​​to obtain the target input text.

[0077] It should be noted that splicing can be understood literally, that is, splicing two parts of text information together to form a group of text.

[0078] 105. Input the target input text into the target language model to obtain target output response information.

[0079] In an embodiment of the present application, the target input text obtained after splicing is determined as the input item of the model, and the target input text is input into the target language model to obtain target output response information. The target output response information can be considered as the target language model's answer to the target input text, and can also be understood as the target language model's answer to the current text information in combination with historical dialogue information.

[0080] The target language model may include a large language model, and of course other language models, which are not specifically limited here.

[0081] The embodiment of the present application provides a context-based large language model dialogue processing method, which obtains the current text information input by the user; encodes the current text information and multiple pre-stored historical dialogue information respectively to obtain the current text vector and multiple historical dialogue vectors; according to the semantic similarity between each historical dialogue vector and the current text vector, multiple historical dialogue vectors are screened to obtain the screened target historical dialogue information; the current text information and the screened target historical dialogue information are spliced ​​to obtain the target input text; the target input text is input into the target language model to obtain the target output response information, and the target language model includes a large language model. In this scheme, through context semantic similarity analysis, the historical dialogue content related to the current input text is dynamically screened, and the related dialogue information is intelligently spliced ​​to ensure that the input text is concise and highly relevant, thereby providing a more accurate input for the model, effectively avoiding redundant information, improving the speed and accuracy of response generation, and enhancing the context understanding ability of the model.

[0082] like Figure 2 As shown, Figure 2 A flowchart of a context-based large language model dialogue processing method provided in an embodiment of the present application, the method may also include the following steps:

[0083] 201. Obtain current text information input by the user.

[0084] In the embodiment of the present application, for the description of step 201, please refer to the detailed description of step 101 in the above embodiment, and the embodiment of the present application will not be repeated.

[0085] 202. Encode the current text information and the multiple historical conversation information respectively through a preset text encoding model to obtain a current text vector and multiple historical conversation vectors.

[0086] In an embodiment of the present application, when encoding the current text information and multiple historical conversation information respectively, a preset text encoding model can be used to implement it. The preset text encoding model can include a small-scale pre-trained model such as BERT and RoBERTa.

[0087] In some embodiments, BERT (Bidirectional Encoder Representations from Transformers) and RoBERTa (Robustly Optimized BERT Approach) are both important models in the field of Natural Language Processing (NLP). They are based on the Transformer architecture and perform well in various NLP tasks.

[0088] Among them, BERT is a deep learning model based on Transformer, specifically the encoder part in Transformer. Functionally, BERT is a feature extractor for text, similar to CNN in the field of computer vision. The model structure of BERT is the same as the encoder in the original Transformer, which is composed of multiple Transformer blocks stacked together. In terms of input processing, BERT adds segment encoding (Segment Embedding) and uses trainable positional encoding (Trainable Positional Embedding). BERT uses the WordPiece algorithm for lemma, which can automatically learn and generate sub-word-level lemma divisions suitable for a specific corpus. BERT has a wide range of applications in the field of natural language processing, such as text classification, named entity recognition, relationship extraction, question-answering systems, semantic similarity calculation, etc.

[0089] Among them, RoBERTa is a natural language processing model proposed by Facebook AI Research after a series of improvements and optimizations based on the BERT model. It uses a larger training data set, including 160GB of training text, covering more news, community questions and answers, encyclopedias, etc., and uses a larger model parameter amount. By using more GPU resources and training time, higher model performance is achieved. A larger batch size is used during training to improve training efficiency and model performance. A dynamic masking strategy is used, and a new masking pattern is generated each time a sequence is input, so that the model can adapt to different masking strategies and learn richer language representations. A larger byte-level BPE vocabulary is used, containing 50K words, to support the processing of many common words in the natural language corpus. In other words, RoBERTa has been improved and optimized on the basis of BERT, further improving model performance.

[0090] 203. Compare the semantic similarity between each historical dialogue vector and the current text vector with a preset threshold to obtain a comparison result.

[0091] In an embodiment of the present application, after calculating the semantic similarity between each historical conversation vector and the current text vector, it is necessary to screen the historical conversation vectors and the current text vector with different semantic similarities. Therefore, in order to distinguish the historical conversation vectors with different semantic similarities, a preset threshold can be set in advance for distinction. That is to say, the semantic similarity between each historical conversation vector and the current text vector is compared with the preset threshold to obtain a comparison result. The comparison result can indicate the size relationship between the semantic similarity between each historical conversation vector and the current text vector and the preset threshold.

[0092] 204. According to the comparison result, multiple historical dialogue vectors are screened to obtain screened target historical dialogue information.

[0093] In the embodiment of the present application, the comparison result may specifically include two situations: the feature similarity is greater than or equal to a preset threshold, or the feature similarity is less than the preset threshold, which may indicate the similarity between each historical conversation vector and the current text vector. Screening for different similarities may specifically include the following steps:

[0094] In some embodiments, a vector whose comparison result indicates that the semantic similarity is greater than or equal to a preset threshold is determined as a first historical conversation vector; a vector whose comparison result indicates that the semantic similarity is less than a preset threshold is determined as a second historical conversation vector; and based on the first historical conversation vector and the second historical conversation vector, the filtered target historical conversation information is obtained.

[0095] It should be noted that the first historical conversation vector is a vector whose comparison result indicates that the semantic similarity is greater than or equal to a preset threshold; and the second historical conversation vector is a vector whose comparison result indicates that the semantic similarity is less than the preset threshold.

[0096] It should be noted that, according to the result of the semantic similarity comparison, the historical conversation content that is highly relevant to the current input is screened out. Specifically, according to the semantic similarity, several historical conversation contents that are most relevant to the current input are selected, which can be expressed by the following formula:

[0097] D selected ={d i ∈D|Similarity(d i ,Input i )≥θ}

[0098] Among them, θ is the preset threshold, which controls the similarity of the selected historical conversations.

[0099] In some embodiments, for historical conversation content with low semantic similarity, a summary or key sentences can be generated to retain key information. Specifically, obtaining the filtered target historical conversation information based on the first historical conversation vector and the second historical conversation vector can include: processing the second historical conversation vector through a preset text summary generation algorithm to obtain summary content corresponding to the second historical conversation vector; filtering the first historical conversation vector and the summary content to obtain the filtered target historical conversation information.

[0100] It should be noted that all historical conversation vectors with a high similarity to the current text vector of the current input can pass the screening, and the historical conversation vectors with a low similarity to the current text vector of the current input can be compressed, and only the key information is extracted for splicing, which can be expressed by the following formula:

[0101] Summary(d j )=TextSummarizer(d i )

[0102] Among them, TextSummarizer represents the text summary generation algorithm used.

[0103] In some embodiments, the text summary generation algorithm can be a BART model, namely Bidirectional and Auto-Regressive Transformers, which is a deep learning model based on the Transformer architecture, designed for generating high-quality text summaries. Its core architecture consists of two main parts: an encoder and a decoder. The encoder is mainly responsible for contextual analysis of the input long text to capture key information and semantic relationships in the text. It uses a bidirectional Transformer encoder, which can process the input text from both the front and back directions at the same time to ensure that the representation of each word contains rich contextual information; the decoder can mainly generate concise and accurate summaries based on the representation generated by the encoder. It uses an autoregressive method to generate summaries word by word to ensure that the generated text is logically clear, coherent and natural.

[0104] The working mechanism of the BART model mainly includes context analysis, key information extraction and summary generation. Among them, in the BART model, context analysis is one of the key steps to generate high-quality summaries. The encoder can perform in-depth analysis of the input text through a multi-layer Transformer network to capture key information and semantic relationships. In addition, when processing the input text, the encoder will automatically identify those information that have little impact on the core content and remove them when generating the summary, while retaining key information, such as key concepts and terms. Finally, the decoder gradually generates a concise and accurate summary based on the representation generated by the encoder. When generating the summary, the decoder will ensure that the generated text is logically clear, coherent and natural, and try to maintain the structure and meaning of the original text.

[0105] From this, it can be seen that when the second historical conversation vector is processed by the preset text summary generation algorithm, the content with low similarity will be automatically eliminated, and only the key information will be retained, so as to obtain the summary content corresponding to the second historical conversation vector, and the first historical conversation vector and the summary content will be filtered to obtain the filtered target historical conversation information.

[0106] 205. The current text information and the filtered target historical dialogue information are concatenated to obtain the target input text.

[0107] In the embodiment of the present application, since the filtered target historical conversation information is obtained by combining the first historical conversation vector and the summary content, the target input text can be understood as the concatenation of the current text information, the first historical conversation vector and the summary content, which can be specifically expressed by the following formula:

[0108] Input final =Concat(Input t , D selected ,Summary(d j ))

[0109] Concat means concatenating the historical conversation and summary content with the current input. final Enter the text for the target.

[0110] 206. Input the target input text into the target language model to obtain target output response information.

[0111] In the embodiment of the present application, for the description of step 206, please refer to the detailed description of step 104 in the above embodiment, which will not be repeated in the embodiment of the present application.

[0112] 207. Store the target input text and the target output response information in correspondence with each other.

[0113] In an embodiment of the present application, historical conversation information is the inquiries and corresponding answers made by users at historical moments. That is to say, after obtaining the answers, the questions and answers will be stored and defined as historical conversation information, and integrated into the questions of subsequent users. In order to enable the questions input by subsequent users to obtain more appropriate answers, the historical conversation information also needs to be updated. Therefore, after obtaining the target output response information corresponding to the target input text, the target input text and the target output response information can be stored accordingly. In this way, after the subsequent user enters the text information, the historical conversation information retrieved will include the target input text and the target output response information for screening and splicing.

[0114] 208. Output the target output response information to the user.

[0115] In the embodiment of the present application, after the target output response information is obtained, the target output response information can be output to the user, and the target output response information can be considered as a corresponding answer given to the current text information input by the user.

[0116] In some embodiments, after the target output response information is output to the user, user feedback information can also be received. The feedback information can be feedback information input by the user regarding the target output response information. The feedback information can be used to indicate the user's satisfaction with the target output response information. The user can input feedback information through various forms such as display screen input, touch, voice, etc.

[0117] The embodiment of the present application provides a context-based large language model dialogue processing method. Through context semantic similarity analysis, historical dialogue content that is highly relevant to the current input is dynamically screened to effectively avoid redundant information. The method improves the relevance and coherence of the context in the dialogue system and enhances the response quality of the large language model. In addition, when processing lengthy historical dialogues, intelligent summary technology is used to extract key information to avoid information loss. By retaining important content, the model's understanding ability and response accuracy in multiple rounds of dialogues are improved. In addition, the construction method of context input is optimized, and relevant dialogue information is intelligently screened and spliced ​​to ensure that the input text is concise and highly relevant. This strategy effectively improves computing efficiency and enhances the model's context understanding ability. In addition, through a refined context management strategy, a more accurate input is provided to the model, which improves the speed and accuracy of response generation. The optimized input processing improves the overall performance of the model, ensures that the generation results are more in line with the user's intentions, and provides a more natural and personalized interactive experience.

[0118] like Figure 3 As shown, the embodiment of the present application provides a context-based large language model dialogue processing device, and the context-based large language model dialogue processing device may include:

[0119] The acquisition module 301 is used to acquire the current text information input by the user;

[0120] Processing module 302, respectively encodes the current text information and the pre-stored multiple historical dialogue information to obtain a current text vector and multiple historical dialogue vectors;

[0121] The processing module 302 is further used to filter the multiple historical dialogue vectors according to the semantic similarity between each historical dialogue vector and the current text vector to obtain filtered target historical dialogue information;

[0122] The processing module 302 is also used to combine the current text information with the filtered target historical conversation information to obtain the target input text;

[0123] The processing module 302 is further used to input the target input text into the target language model to obtain target output response information, and the target language model includes a large language model.

[0124] In some embodiments, the processing module 302 is specifically configured to encode the current text information and the multiple historical conversation information respectively through a preset text encoding model to obtain a current text vector and multiple historical conversation vectors.

[0125] In some embodiments, the processing module 302 is specifically used to compare the semantic similarity between each historical conversation vector and the current text vector with a preset threshold to obtain a comparison result;

[0126] The processing module 302 is specifically configured to filter the multiple historical dialogue vectors according to the comparison result to obtain filtered target historical dialogue information.

[0127] In some embodiments, the processing module 302 is specifically configured to determine a vector whose semantic similarity indicated by the comparison result is greater than or equal to a preset threshold as a first historical conversation vector;

[0128] The processing module 302 is specifically configured to determine a vector whose semantic similarity indicated by the comparison result is less than a preset threshold as a second historical conversation vector;

[0129] The processing module 302 is specifically configured to obtain filtered target historical dialogue information according to the first historical dialogue vector and the second historical dialogue vector.

[0130] In some embodiments, the processing module 302 is specifically configured to process the second historical conversation vector by using a preset text summary generation algorithm to obtain summary content corresponding to the second historical conversation vector;

[0131] The processing module 302 is specifically configured to concatenate the first historical conversation vector and the summary content to obtain filtered target historical conversation information.

[0132] In some embodiments, the processing module 302 is further used to store the target input text and the target output response information in correspondence.

[0133] In some embodiments, the processing module 302 is further configured to output target output response information to the user.

[0134] In the embodiment of the present application, each module can implement the context-based large language model dialogue processing method provided in the above method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0135] like Figure 4 As shown, an embodiment of the present application further provides an electronic device, which may include:

[0136] A memory 401 storing executable program codes;

[0137] a processor 402 coupled to the memory 401;

[0138] The processor 402 calls the executable program code stored in the memory 401 to execute the context-based large language model dialogue processing method executed by the electronic device in the above-mentioned method embodiments.

[0139] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the context-based large language model dialogue processing method in the above method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0140] An embodiment of the present application also provides a computer program product, which stores a computer program. When the computer program is executed by a processor, the various processes of the context-based large language model dialogue processing method in the above method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0141] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media that include computer-usable program code.

[0142] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0143] In the present application, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0144] In this application, memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0145] In this application, a person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, and the computer-readable medium includes permanent and non-permanent, removable and non-removable storage media. The storage medium can implement information storage by any method or technology, and the information can be a computer-readable instruction, a data structure, a module of a program, or other data. Examples of computer storage media include, but are not limited to, Parallel Random Access Memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Programmable Read-only Memory (PROM), Erasable Programmable Read Only Memory (EPROM), other types of Random Access Memory (RAM), Read-Only Memory (ROM), One-time Programmable Read-Only Memory (OTPROM), Electrically-Erasable Programmable Read-Only Memory (EEPROM), flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0146] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0147] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application. The above-mentioned multiple embodiments are not necessarily multiple independent embodiments. Dividing into multiple embodiments is only used to highlight the different technical features in different embodiments. Those skilled in the art should be aware that the above-mentioned multiple embodiments can also be combined in any way.

[0148] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0149] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0150] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0151] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-accessible memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for a computer device (which can be a personal computer, a server or a network device, etc., specifically a processor in a computer device) to perform some or all of the steps of the above-mentioned methods of various embodiments of the present application.

[0152] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A context-based large language model dialogue processing method, characterized in that: The method comprises: Get the current text information entered by the user; Encoding the current text information and the pre-stored multiple historical conversation information respectively to obtain a current text vector and multiple historical conversation vectors; Filtering the multiple historical conversation vectors according to the semantic similarity between each historical conversation vector and the current text vector to obtain filtered target historical conversation information; The current text information and the filtered target historical conversation information are concatenated to obtain a target input text; The target input text is input into a target language model to obtain target output response information, wherein the target language model includes the large language model.

2. The method according to claim 1, characterized in that The current text information and the pre-stored multiple historical dialogue information are respectively encoded to obtain a current text vector and multiple historical dialogue vectors, including: The current text information and the multiple historical conversation information are encoded respectively through a preset text encoding model to obtain the current text vector and the multiple historical conversation vectors.

3. The method according to claim 1, characterized in that The filtering of the plurality of historical dialogue vectors according to the semantic similarity between each historical dialogue vector and the current text vector to obtain filtered target historical dialogue information includes: Compare the semantic similarity between each historical conversation vector and the current text vector with a preset threshold to obtain a comparison result; According to the comparison result, the multiple historical dialogue vectors are screened to obtain the screened target historical dialogue information.

4. The method according to claim 3, characterized in that The step of screening the plurality of historical conversation vectors according to the comparison result to obtain the screened target historical conversation information includes: Determine the vector whose semantic similarity is greater than or equal to the preset threshold value as a first historical conversation vector; Determine the vector whose semantic similarity is less than the preset threshold value as a second historical conversation vector; The filtered target historical dialogue information is obtained according to the first historical dialogue vector and the second historical dialogue vector.

5. The method according to claim 4, characterized in that The obtaining the filtered target historical conversation information according to the first historical conversation vector and the second historical conversation vector includes: Processing the second historical conversation vector by a preset text summary generation algorithm to obtain summary content corresponding to the second historical conversation vector; The first historical conversation vector and the summary content are concatenated to obtain the filtered target historical conversation information.

6. The method according to claim 1, characterized in that After inputting the target input text into the target language model to obtain target output response information, the method further includes: The target input text and the target output response information are stored correspondingly.

7. The method according to claim 1, characterized in that After inputting the target input text into the target language model to obtain target output response information, the method further includes: The target output response information is output to the user.

8. A context-based large language model dialogue processing device, characterized in that: The context-based large language model dialogue processing device comprises: The acquisition module is used to obtain the current text information input by the user; A processing module, encoding the current text information and the pre-stored multiple historical dialogue information respectively to obtain a current text vector and multiple historical dialogue vectors; The processing module is further used to filter the multiple historical dialogue vectors according to the semantic similarity between each historical dialogue vector and the current text vector to obtain filtered target historical dialogue information; The processing module is further used to splice the current text information with the filtered target historical dialogue information to obtain the target input text; The processing module is further used to input the target input text into a target language model to obtain target output response information, and the target language model includes the large language model.

9. An electronic device, characterized in that: The electronic device comprises: A memory storing executable program code; and a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the context-based large language model dialogue processing method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by the processor, the context-based large language model dialogue processing method as described in any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Enterprise group chat message reply method and system

    CN120104764A

  • A method and system for replying to enterprise group chat messages

    CN120104764B

  • Question query processing method and electronic equipment

    CN120256587A

  • Problem query processing method and electronic equipment

    CN120256587B

  • Context learning ability guiding method based on historical dialogue editing

    CN120317229A