Method for extracting and optimizing large model memory based on historical dialogue entities
By performing entity extraction and information combination of historical dialogue records, the memory of the large language model is optimized, and the problem of memory decay in large language models in multiple rounds of dialogue is solved, improving the quality of answers and context integrity.
Patent Information
- Application Number
- CN202411785626.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-28
AI Technical Summary
Large language models are prone to memory decay problems in multiple rounds of conversations, forgetting key information and losing relevant contexts, resulting in a decline in the quality of answers.
By extracting the historical dialogue records physically, extracting user-related attributes and other information, combining this information with user's statements, summarizing and outputting new statements with context information through a large language model, and then inputting the statement as user dialogue content to the large language model to optimize the memory of the large model.
It effectively reduces the cost of use, avoids memory loss due to excessive rounds, and improves the context integrity and answer quality of the big model during the question and answer process.
Smart Images

Figure CN119719290A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of large language models, and more specifically, particularly relates to a method for optimizing large model memory based on historical dialogue entity extraction. Background Art
[0002] A large language model refers to a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. Large language models can handle a variety of natural language tasks, such as text classification, question answering, and dialogue, and are an important path to artificial intelligence. Currently, large language models use a Transformer architecture and pre-training objectives (such as Language Modeling) similar to small models. The difference from small models is the increase in model size, training data, and computing resources.
[0003] The principle of the large language model is based on deep learning, which uses a large amount of data and computing resources to train a neural network model with a large number of parameters. By continuously adjusting the model parameters, the model can achieve the best performance in various tasks. The "big" characteristics of the large model are usually reflected in: a large number of parameters, a large amount of training data, and high computing resource requirements. Many advanced models have more and more model parameters, better generalization performance, and more and more accurate output results in various specialized fields due to their "big" characteristics.
[0004] In multi-round conversations, large language models may face the problem of memory decay. During long conversations, large language models need to remember previous context information to ensure the coherence and accuracy of answers. However, as the number of conversation rounds increases, the model may forget key information, lose relevant context, and confuse information in different conversation rounds, resulting in a decrease in the quality of answers.
[0005] However, there are some problems with the existing technology: the existing technology uses a large language model to streamline historical conversations, which consumes extra time and computing power; the large language model cannot grasp the key points when summarizing historical conversation records and may miss content; when the retrieved content is used as the conversation context between the user and the large language model, the new context is still too long and the memory decay problem still occurs. Therefore, we propose a method to optimize the memory of the large model based on historical conversation entity extraction. Summary of the invention
[0006] In view of the problems existing in the prior art, the purpose of the present invention is to provide a method for optimizing the memory of a large model based on historical conversation entity extraction. By performing entity extraction on historical conversation records, the extracted user-related attributes and other information are saved, and then the user's sentences are combined with this information through a large language model to summarize and output a new sentence with context information. The sentence is then input into the large language model as the user conversation content, thereby solving the problem of memory attenuation of the large language model.
[0007] To achieve the above object, the present invention provides the following technical solution: a method for optimizing large model memory based on historical dialogue entity extraction, comprising the following steps:
[0008] S1. Obtain historical conversation records: collect historical conversation records between the user and the large language model from the database, and pre-process the collected historical conversation records;
[0009] S2. Extract information from historical conversation records: Use the entity extraction model in the field of machine learning to extract the required information and convert the extracted information into a vector set;
[0010] S3, vector set storage: convert the vector set into a knowledge graph, and then input the knowledge graph into the database for storage;
[0011] S4. Obtain user input: When the user inputs a question, the entity extraction model in the field of machine learning is used to extract useful information from the input question;
[0012] S5. Determine the consistency of information: Determine whether the useful information in the input question is consistent with the historical conversation record extracted information stored in the database. If not, update the useful information in the input question and store it in the database;
[0013] S6. Input data information combination: Combine the useful information in the input question with the information extracted from the historical dialogue records, and combine them into a new input sentence to input into the large language model;
[0014] S7. Obtaining the output result of the large language model: the large language model analyzes and recognizes the input new sentence, and the large language model answers according to the input new sentence to obtain the output of the large language model;
[0015] S8, continuous question and answer: conduct multiple rounds of question and answer according to the user's needs, and repeat steps S4-S7 until the question and answer is completed.
[0016] Specifically, the steps of preprocessing the collected historical conversation records in S1 are as follows:
[0017] Text cleaning: Clean historical conversation records, remove useless information, reduce interference with subsequent processing, convert all texts to uniform uppercase and lowercase, reduce vocabulary diversity; delete stop words in the text; remove duplicate content; process emoticons and special symbols;
[0018] Word segmentation and part-of-speech tagging: perform word segmentation and part-of-speech tagging on historical conversation records;
[0019] Spelling correction and synonym processing: Correct misspelled words in historical conversation records; replace synonyms with unified vocabulary to reduce vocabulary diversity during model learning;
[0020] Remove low-frequency words: For historical conversation records that contain some very rare or extremely specific words, remove low-frequency words through word frequency statistics;
[0021] Text normalization: Normalization is used to standardize vocabulary;
[0022] Dialogue context management: Perform appropriate context management for multi-round dialogues to ensure context consistency.
[0023] Specifically, the algorithm for text cleaning is as follows:
[0024]
[0025] Among them, x is the value of the data point, μ is the mean of the data set, σ is the standard deviation of the data set, and points with a value of Z greater than 3 or less than -3 are considered outliers and are removed;
[0026] For the removed outliers or missing values, the mean is filled; and the mean calculation formula is as follows:
[0027]
[0028] Among them, x′ i is the value of non-missing data, and n is the number of non-missing data.
[0029] Specifically, the removal of duplicate content uses the Jaccard similarity algorithm to check for word duplication, which is defined as the ratio of the size of the intersection of two sets to the size of the union; its Jaccard similarity is expressed by the following formula:
[0030] A is a vocabulary set, and B is another vocabulary set. Then, the intersection |A∩B| and the union |A∪B| of any two vocabulary sets are calculated. If the Jaccard similarity J exceeds the preset threshold of 0.8, they are considered as duplicate words, and one of the words is deleted.
[0031] The calculation formula for the normalization process is as follows:
[0032]
[0033] Among them, x i is the historical conversation record of input, x min is the minimum value in the data set, x max is the maximum value in the dataset, scaling the historical conversation records to the range of [0, 1].
[0034] Specifically, the entity extraction model in S2 extracts the required information by extracting features from historical conversation records:
[0035]
[0036] Among them, TFIDF(x i ,d) reflects the importance of a word in the historical conversation record. The more frequently it appears, the higher the TF value, x i represents the word for calculation, and d represents the word x i The number of times it appears in the historical conversation records, It is used to measure the prevalence of a word in the entire corpus. The higher the value, the less common the word is in the corpus. It is expressed as the total number of texts in the corpus. DF(x i ) means that it contains word x i The number of texts;
[0037] If a word appears frequently in the historical conversation records that need to be detected, but appears less frequently in other texts, TF(x i ,The value of d) will be very high, indicating the importance of the word to the data information that needs to be detected and calculated;
[0038] On the contrary, if the word frequency is low or the word appears in many texts, then TF(x i ,The value of d) will be low, indicating that the word is not important to the data information that needs to be detected and calculated.
[0039] Specifically, the transformation of the vector set in S2 is as follows:
[0040] Classify the feature information extracted from the entity extraction model, divide the feature information into nodes and relationships, and establish feature information for nodes and relationships:
[0041] V=[T j1 , T g1 ,T j1 , T g1 ,…,T jn , T gn], and store the vector set, where T j , T g They are nodes and relationships respectively;
[0042] The knowledge graph in S3 is constructed based on the nodes and relationships in the vector set, and a suitable graph database is selected for storage.
[0043] Specifically, the consistency of the judgment information in S5 is calculated by cosine similarity, useful information in the user input question is extracted, and compared with the node or vector set stored in the knowledge graph;
[0044] By calculating the cosine similarity, we can identify nodes related to the user’s question.
[0045] For the nodes identified in the user input question, extract their vector representation and compare them with the nodes or vector sets stored in the knowledge graph. By calculating the cosine similarity, identify the nodes related to the user input question. The calculation formula of cosine similarity is:
[0046]
[0047] Where: V A and V B are two vectors, representing the node of the user input question and the node in the knowledge graph or vector set, · represents the vector dot product, ||V A || and ||V B || represents the Euclidean length of a vector;
[0048] The calculation method is:
[0049] Among them, V i is the i-th node in the vector, and n is the dimension of the vector;
[0050] Relevant entity identification: Based on the calculation results of cosine similarity, the entities most relevant to the user’s question are selected, which constitute the basic information for answer generation.
[0051] Specifically, the updating and storing of useful information in the input question into the database in S5 is to update the nodes in the input question into the knowledge graph when the cosine similarity cannot match the similar nodes, and optimize the memory update strategy through the RL model so that the knowledge graph can be updated, and establish connections with the existing nodes in the knowledge graph through relationships to form a new knowledge graph, which is used to connect the questions input by the user and output comprehensive answers to the questions.
[0052] Specifically, the algorithm adopted by the RL model is the Q-learning reinforcement learning algorithm;
[0053] And the calculation formula is as follows:
[0054]
[0055] Among them, Q(s t ,a t ) is the current knowledge graph state s t Next update node adds action a t Q value; r t+1 It is the RL model that performs action a t After that, the immediate reward is given; t+1 is the RL model executing action a t After that, the next state reached; is in state s t+1 In the following example, α is the maximum Q value of all possible actions, which indicates the expected return of the RL model selecting the optimal action; α is the learning rate, which indicates the step size of the Q value update; γ is the discount factor, which indicates the importance of future rewards and is between 0 and 1.
[0056] Specifically, the concatenation combination in S6 adopts array concatenation to combine and concatenate the vector set;
[0057] Suppose the vector array of historical conversation records is A, and the vector array of useful information in the input question is B; the vector array A is in the form of (m,n), and the vector array B is in the form of (p,n), indicating that there are m and m rows, and each row has n columns of data;
[0058] Vector set array A and vector set array B are concatenated along rows, and the calculation formula is as follows:
[0059] ResultingShape=(m+p,n),
[0060] The vector set array A and the vector set array B are spliced vertically.
[0061] Technical effects and advantages of the present invention:
[0062] The present invention uses a machine learning model entity extraction method to extract historical conversation records. The machine learning model has a low dependence on hardware and can effectively reduce the cost of use. Secondly, since each conversation is reconstructed, the memory information can always be linked to the context of the question and answer, and will not cause new memory loss problems due to long rounds.
[0063] Collect historical conversation records between users and large language models, from the beginning of asking questions to the end of asking questions as a complete conversation, in which one question and one answer is a round of conversation; use the entity extraction model in the field of machine learning to extract entities from the collected historical conversation records to obtain specified data information; perform entity extraction on the user's input content to determine whether the new extraction needs to be updated to the original data information, and if it needs to be updated, update the extracted information; output a new sentence with entity information through the large language model using the updated or unupdated extracted information and the sentence input by the user; the generated new sentence is input into the large language model as the user conversation content, and the large language model outputs the question and answer result to the user, completing the memory update of the large model and improving the integrity of the context in the question and answer process of the large model.
[0064] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 It is a schematic diagram of the step flow provided by the present invention. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0067] like Figure 1 As shown, the method for optimizing large model memory based on historical dialogue entity extraction provided by an embodiment of the present invention includes the following steps:
[0068] S1. Obtain historical conversation records: collect historical conversation records between the user and the large language model from the database, and pre-process the collected historical conversation records;
[0069] S2. Extract information from historical conversation records: Use the entity extraction model in the field of machine learning to extract the required information and convert the extracted information into a vector set;
[0070] S3, vector set storage: convert the vector set into a knowledge graph, and then input the knowledge graph into the database for storage;
[0071] S4. Obtain user input: When the user inputs a question, the entity extraction model in the field of machine learning is used to extract useful information from the input question;
[0072] S5. Determine the consistency of information: Determine whether the useful information in the input question is consistent with the historical conversation record extracted information stored in the database. If not, update the useful information in the input question and store it in the database;
[0073] S6. Input data information combination: Combine the useful information in the input question with the information extracted from the historical dialogue records, and combine them into a new input sentence to input into the large language model;
[0074] S7. Obtaining the output result of the large language model: the large language model analyzes and recognizes the input new sentence, and the large language model answers according to the input new sentence to obtain the output of the large language model;
[0075] S8, continuous question and answer: conduct multiple rounds of question and answer according to the user's needs, and repeat steps S4-S7 until the question and answer is completed.
[0076] In this embodiment, preferably, the step of preprocessing the collected historical conversation records in S1 is as follows:
[0077] Text cleaning: Clean historical conversation records, remove useless information, reduce interference with subsequent processing, convert all texts to uniform uppercase and lowercase, reduce vocabulary diversity; delete stop words in the text; remove duplicate content; process emoticons and special symbols;
[0078] Word segmentation and part-of-speech tagging: perform word segmentation and part-of-speech tagging on historical conversation records;
[0079] Spelling correction and synonym processing: Correct misspelled words in historical conversation records; replace synonyms with unified vocabulary to reduce vocabulary diversity during model learning;
[0080] Remove low-frequency words: For historical conversation records that contain some very rare or extremely specific words, remove low-frequency words through word frequency statistics;
[0081] Text normalization: Normalization is used to standardize vocabulary;
[0082] Dialogue context management: Proper context management for multi-round dialogues to ensure context consistency;
[0083] It should be noted that by preprocessing the collected historical conversation records, it is convenient to perform effective computational processing on the content of the historical conversations, thereby improving the efficiency of computational processing and reducing the pressure of processing.
[0084] In this embodiment, preferably, the algorithm for text cleaning is as follows:
[0085]
[0086] Among them, x is the value of the data point, μ is the mean of the data set, σ is the standard deviation of the data set, and points with a value of Z greater than 3 or less than -3 are considered outliers and are removed;
[0087] For the removed outliers or missing values, the mean is filled; and the mean calculation formula is as follows:
[0088]
[0089] Among them, x′ i is the value of non-missing data, n is the number of non-missing data;
[0090] It should be noted that the computational processing of text cleaning can reduce anomalies in historical conversation records and compensate for missing values, thereby improving the integrity of historical conversation records.
[0091] In this embodiment, preferably, the removal of duplicate content uses a Jaccard similarity algorithm to check for vocabulary duplication, which is defined as the ratio of the size of the intersection of two sets to the size of the union; its Jaccard similarity is expressed by the following formula:
[0092] A is a vocabulary set, and B is another vocabulary set. Then, the intersection |A∩B| and the union |A∪B| of any two vocabulary sets are calculated. If the Jaccard similarity J exceeds the preset threshold of 0.8, they are considered as duplicate words, and one of the words is deleted.
[0093] The calculation formula for the normalization process is as follows:
[0094]
[0095] Among them, x i is the historical conversation record of input, x min is the minimum value in the data set, x max is the maximum value in the data set, scaling the historical conversation records to the range of [0, 1];
[0096] It should be noted that the Jaccard similarity algorithm is used to compare and determine words, remove duplicate words in historical conversation records, reduce the capacity of historical conversation records, and facilitate analysis and processing of historical conversation records.
[0097] In this embodiment, preferably, the entity extraction model in S2 extracts the required information by extracting features from the historical conversation records:
[0098]
[0099] Among them, TFIDF(x i ,d) reflects the importance of a word in the historical conversation record. The more frequently it appears, the higher the TF value, x i represents the word for calculation, and d represents the word x i The number of times it appears in the historical conversation records, It is used to measure the prevalence of a word in the entire corpus. The higher the value, the less common the word is in the corpus. It is expressed as the total number of texts in the corpus. DF(x i ) means that it contains word x i The number of texts;
[0100] If a word appears frequently in the historical conversation records that need to be detected, but appears less frequently in other texts, TF(x i ,The value of d) will be very high, indicating the importance of the word to the data information that needs to be detected and calculated;
[0101] On the contrary, if the word frequency is low or the word appears in many texts, then TF(x i ,The value of d) will be low, indicating that the word is not important to the data information that needs to be detected and calculated;
[0102] It should be noted that extracting features from historical conversation records through an entity extraction model facilitates the extraction of features from historical conversation records, facilitates the extraction of nodes and relationships in historical conversation records, and facilitates subsequent analysis and processing.
[0103] In this embodiment, preferably, the conversion of the vector set in S2 is as follows:
[0104] Classify the feature information extracted from the entity extraction model, divide the feature information into nodes and relationships, and establish feature information for nodes and relationships:
[0105] V=[T j1 , T g1 ,T j1 , T g1 ,…,T jn , T gn ], and store the vector set, where T j , T g They are nodes and relationships respectively;
[0106] The knowledge graph in S3 is constructed based on the nodes and relationships in the vector set, and a suitable graph database is selected for storage;
[0107] It should be noted that the extracted nodes and relationships are grouped into a vector set to facilitate the subsequent combination and splicing of the nodes, and the vector set is generated into a knowledge graph to facilitate storage and to facilitate the connection with the context during the knowledge question and answer process to provide complete and contextual question and answer results.
[0108] In this embodiment, preferably, the consistency of the judgment information in S5 is calculated by cosine similarity, useful information in the user input question is extracted, and compared with the node or vector set stored in the knowledge graph;
[0109] By calculating the cosine similarity, we can identify nodes related to the user’s question.
[0110] For the nodes identified in the user input question, extract their vector representation and compare them with the nodes or vector sets stored in the knowledge graph. By calculating the cosine similarity, identify the nodes related to the user input question. The calculation formula of cosine similarity is:
[0111]
[0112] Where: V A and V B are two vectors, representing the node of the user input question and the node in the knowledge graph or vector set, · represents the vector dot product, ||V A || and ||V B || represents the Euclidean length of a vector;
[0113] The calculation method is:
[0114] Among them, V i is the i-th node in the vector, and n is the dimension of the vector;
[0115] Relevant entity identification: Based on the calculation results of cosine similarity, the entities most relevant to the user's question are selected, which constitute the basic information for answer generation;
[0116] It should be noted that cosine similarity is used to match useful information in the knowledge graph and question and answer. The matching results are used to determine whether the information exists in the knowledge graph. For nodes that already exist in the knowledge graph, they are combined and spliced to form new question and answer inputs. For unmatched useful information, the knowledge graph is updated so that questions and answers can be answered according to the context.
[0117] In this embodiment, preferably, the updating and storing of useful information in the input question into the database in S5 is to update the node in the input question into the knowledge graph when the cosine similarity cannot match the similar node, optimize the memory update strategy through the RL model, so that the knowledge graph can be updated, and establish a connection with the existing nodes in the knowledge graph through the relationship to form a new knowledge graph, which is used to connect the user input question and output a comprehensive answer to the question;
[0118] It should be noted that the RL model is used to update the nodes and input them into the knowledge graph, making the knowledge graph more complete, and used to connect the questions input by users and output comprehensive answers to the questions.
[0119] In this embodiment, preferably, the algorithm adopted by the RL model is the Q-learning reinforcement learning algorithm;
[0120] And the calculation formula is as follows:
[0121]
[0122] Among them, Q(s t ,a t ) is the current knowledge graph state s t Next update node adds action a t Q value; r t+1 It is the RL model that performs action a t After that, the immediate reward is given; t+1 is the RL model executing action a t After that, the next state reached; is in state s t+1 The maximum Q value of all possible actions represents the expected return of the RL model selecting the optimal action; α is the learning rate, which represents the step size of the Q value update; γ is the discount factor, which represents the importance of future rewards and is between 0 and 1;
[0123] It should be noted that the Q-learning reinforcement learning algorithm is used to update new nodes to the knowledge graph, which facilitates the updating of the knowledge graph.
[0124] In this embodiment, preferably, the splicing combination in S6 adopts array splicing to combine and splice the vector set;
[0125] Suppose the vector array of historical conversation records is A, and the vector array of useful information in the input question is B; the vector array A is in the form of (m,n), and the vector array B is in the form of (p,n), indicating that there are m and m rows, and each row has n columns of data;
[0126] Vector set array A and vector set array B are concatenated along rows, and the calculation formula is as follows:
[0127] ResultingShape=(m+p,n),
[0128] The vector set array A and the vector set array B are vertically spliced;
[0129] It should be noted that by splicing the knowledge graph and the input question, it is convenient to combine and connect the vector set array A and the vector set array B to form a new question input, so that the question and answer can be connected in context and a complete and rich answer can be formed.
[0130] The specific operation process of this application:
[0131] Step 1: Obtain historical conversation records: Collect historical conversation records between users and the large language model from the database, and pre-process the collected historical conversation records;
[0132] Step 2: Extract information from historical conversation records: Use the entity extraction model in the field of machine learning to extract the required information and convert the extracted information into a vector set;
[0133] Step 3: Store the vector set: Convert the vector set into a knowledge graph, and then input the knowledge graph into the database for storage;
[0134] Step 4: Get user input: When the user inputs a question, use the entity extraction model in the field of machine learning to extract useful information from the input question;
[0135] Step 5: Check the consistency of information: Check whether the useful information in the input question is consistent with the historical conversation record extracted information stored in the database. If not, update the useful information in the input question and store it in the database.
[0136] Step 6: Input data information combination: Combine the useful information in the input question with the information extracted from the historical conversation record, and combine the combined information into a new input sentence to input into the large language model;
[0137] Step 7: Obtain the output result of the large language model: the large language model analyzes and recognizes the new sentence input, and the large language model answers according to the new sentence input, thereby obtaining the output of the large language model;
[0138] Step 8. Continuous Q&A: Conduct multiple rounds of Q&A based on user needs, and repeat steps S4-S7 until the Q&A is completed.
[0139] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for optimizing large model memory based on historical dialogue entity extraction, characterized in that: The steps include: S1. Obtain historical conversation records: collect historical conversation records between the user and the large language model from the database, and pre-process the collected historical conversation records; S2. Extract information from historical conversation records: Use the entity extraction model in the field of machine learning to extract the required information and convert the extracted information into a vector set; S3, vector set storage: convert the vector set into a knowledge graph, and then input the knowledge graph into the database for storage; S4. Obtain user input: When the user inputs a question, the entity extraction model in the field of machine learning is used to extract useful information from the input question; S5. Determine the consistency of information: Determine whether the useful information in the input question is consistent with the historical conversation record extracted information stored in the database. If not, update the useful information in the input question and store it in the database; S6. Input data information combination: Combine the useful information in the input question with the information extracted from the historical dialogue records, and combine them into a new input sentence to input into the large language model; S7. Obtaining the output result of the large language model: the large language model analyzes and recognizes the input new sentence, and the large language model answers according to the input new sentence to obtain the output of the large language model; S8, continuous question and answer: conduct multiple rounds of question and answer according to the user's needs, and repeat steps S4-S7 until the question and answer is completed.
2. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 1 is characterized in that: The steps of preprocessing the collected historical conversation records in S1 are as follows: Text cleaning: Clean historical conversation records, remove useless information, reduce interference with subsequent processing, convert all texts to uniform uppercase and lowercase, reduce vocabulary diversity; delete stop words in the text; remove duplicate content; process emoticons and special symbols; Word segmentation and part-of-speech tagging: perform word segmentation and part-of-speech tagging on historical conversation records; Spelling correction and synonym processing: Correct misspelled words in historical conversation records; replace synonyms with unified vocabulary to reduce vocabulary diversity during model learning; Remove low-frequency words: For historical conversation records that contain some very rare or extremely specific words, remove low-frequency words through word frequency statistics; Text normalization: Normalization is used to standardize vocabulary; Dialogue context management: Perform appropriate context management for multi-round dialogues to ensure context consistency.
3. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 2 is characterized in that: The algorithm for text cleaning is as follows: Among them, x is the value of the data point, μ is the mean of the data set, σ is the standard deviation of the data set, and points with a value of Z greater than 3 or less than -3 are considered outliers and are removed; For the removed outliers or missing values, the mean is filled; and the mean calculation formula is as follows: Among them, x′ i is the value of non-missing data, and n is the number of non-missing data.
4. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 2 is characterized in that: The removal of duplicate content uses the Jaccard similarity algorithm to check for word duplication, which is defined as the ratio of the size of the intersection of two sets to the size of the union; its Jaccard similarity is expressed by the following formula: A is a vocabulary set, and B is another vocabulary set. Then, the intersection |A∩B| and the union |A∪B| of any two vocabulary sets are calculated. If the Jaccard similarity J exceeds the preset threshold of 0.8, they are considered as duplicate words, and one of the words is deleted. The calculation formula for the normalization process is as follows: Among them, x i is the historical conversation record of input, x min is the minimum value in the data set, x max is the maximum value in the dataset, scaling the historical conversation records to the range of [0, 1].
5. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 1 is characterized in that: The entity extraction model in S2 extracts the required information by extracting features from historical conversation records: Among them, TFIDF(x i ,d) reflects the importance of a word in the historical conversation record. The more frequently it appears, the higher the TF value, x i represents the word for calculation, and d represents the word x i The number of times it appears in the historical conversation records, It is used to measure the prevalence of a word in the entire corpus. The higher the value, the less common the word is in the corpus. It is expressed as the total number of texts in the corpus. DF(x i ) means that it contains word x i The number of texts; If a word appears frequently in the historical conversation records that need to be detected, but appears less frequently in other texts, TF(x i ,The value of d) will be very high, indicating the importance of the word to the data information that needs to be detected and calculated; On the contrary, if the word frequency is low or the word appears in many texts, then TF(x i ,The value of d) will be low, indicating that the word is not important to the data information that needs to be detected and calculated.
6. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 1 is characterized in that: The transformation of the vector set in S2 is as follows: Classify the feature information extracted from the entity extraction model, divide the feature information into nodes and relationships, and establish feature information for nodes and relationships: V=[T j1 、T g1 ,T j1 、T g1 ,…,T jn 、T gn ], and store the vector set, where T j 、T g They are nodes and relationships respectively; The knowledge graph in S3 is constructed based on the nodes and relationships in the vector set, and a suitable graph database is selected for storage.
7. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 1 is characterized in that: The consistency of the judgment information in S5 is calculated by cosine similarity, and useful information in the user input question is extracted and compared with the node or vector set stored in the knowledge graph; By calculating the cosine similarity, we can identify nodes related to the user’s question. For the nodes identified in the user input question, extract their vector representation and compare them with the nodes or vector sets stored in the knowledge graph. By calculating the cosine similarity, identify the nodes related to the user input question. The calculation formula of cosine similarity is: Where: V A and V B are two vectors, representing the node of the user input question and the node in the knowledge graph or vector set, · represents the vector dot product, ||V A || and ||V B || represents the Euclidean length of a vector; The calculation method is: Among them, V i is the i-th node in the vector, and n is the dimension of the vector; Relevant entity identification: Based on the calculation results of cosine similarity, the entities most relevant to the user’s question are selected, which constitute the basic information for answer generation.
8. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 7 is characterized in that: The updating and storing of useful information in the input question into the database in S5 is to update the nodes in the input question into the knowledge graph when the cosine similarity cannot match the similar nodes, and optimize the memory updating strategy through the RL model so that the knowledge graph can be updated, and establish connections with the existing nodes in the knowledge graph through relationships to form a new knowledge graph, which is used to connect the questions input by the user and output comprehensive answers to the questions.
9. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 8 is characterized in that: The algorithm adopted by the RL model is the Q-learning reinforcement learning algorithm; And the calculation formula is as follows: Among them, Q(s t ,a t ) is the current knowledge graph state s t Next update node adds action a t Q value; r t+1 It is the RL model that performs action a t After that, the immediate reward is given; t+1 is the RL model executing action a t After that, the next state reached; is in state s t+1 In the following example, α is the maximum Q value of all possible actions, which indicates the expected return of the RL model selecting the optimal action; α is the learning rate, which indicates the step size of the Q value update; γ is the discount factor, which indicates the importance of future rewards and is between 0 and 1.
10. The method for optimizing large model memory based on historical dialogue entity extraction according to claim 1 is characterized in that: The concatenation combination in S6 adopts array concatenation to combine and concatenate the vector sets; Suppose the vector array of historical conversation records is A, and the vector array of useful information in the input question is B; the vector array A is in the form of (m,n), and the vector array B is in the form of (p,n), indicating that there are m and m rows, and each row has n columns of data; Vector set array A and vector set array B are concatenated along rows, and the calculation formula is as follows: ResultingShape=(m+p,n), The vector set array A and the vector set array B are spliced vertically.
Citation Information
Cited By
Context learning ability guiding method based on historical dialogue editing
CN120317229A
Memory information updating method, dialogue reply method and device
CN120780803A
Retrieval task processing method, computing equipment and electronic equipment
CN121071068A
Automatic memory management method based on context awareness and hierarchical routing
CN121092650A
Memory perception thinking enhancement type large model recommendation method and system
CN121327125A