A knowledge processing method and device combining user feedback and contextual learning
By combining user feedback with contextual learning methods, the knowledge base update mechanism of the large language model is optimized, which solves the problems of insufficient timeliness and generalization of the knowledge base, realizes the timely update and expansion of the knowledge base, and improves the accuracy and coverage of knowledge processing.
Patent Information
- Application Number
- CN202411502361.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The knowledge base update mechanism of large language models in existing technologies leads to weakened knowledge timeliness and insufficient generalization, and the conventional maximum similarity retrieval mechanism cannot meet the needs of knowledge scope expansion.
Combining user feedback with contextual learning methods, we build a knowledge collection by continuously collecting knowledge information, regularly update the knowledge base, and extract, update or add knowledge after user feedback satisfaction is confirmed, and optimize the knowledge sequence using multiple weight calculations.
It improves the timeliness and generalization of the knowledge base, ensures that the knowledge base is more closely aligned with user needs, and enhances the accuracy and coverage of knowledge processing.
Smart Images

Figure CN119443248B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a knowledge processing method and device combining user feedback and context learning. Background Art
[0002] Large Language Models (LLMs) are widely used in a variety of Natural Language Processing (NLP) tasks, such as translation and question-answering. To improve the predictive accuracy of large language models, they are often configured with a knowledge base capable of knowledge querying. Currently, knowledge editing (additions, modifications, etc.) for such knowledge bases is mostly implemented using a periodic batch update processing mechanism, and knowledge retrieval from such knowledge bases is mostly based on the maximum similarity between knowledge and query text. Through practical applications, we have found that: 1) conventional batch update mechanisms reduce the timeliness of knowledge; 2) conventional maximum similarity retrieval mechanisms result in insufficient knowledge coverage and generalization. Summary of the Invention
[0003] The purpose of the present invention is to address the shortcomings of the existing technology and provide a knowledge processing method, device, electronic device and computer-readable storage medium that combines user feedback and context learning. The present invention records any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and directional domain fine-tuning as a first model; and constructs a corresponding collection knowledge set based on the continuously collected knowledge information, and regularly performs batch knowledge addition and update processing on the knowledge base based on the collected knowledge set; and after receiving the first instruction text (translation or question-answering instruction text) input by the user, first performs context knowledge learning based on the first instruction text and the knowledge base to obtain a knowledge sequence, and then inputs the knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing to obtain the corresponding first generated text and feedback to the current user, and then identifies the first generated text when receiving user satisfaction feedback on the first generated text. If the user is satisfied, the first instruction text and the first generated text are input into the knowledge extraction instruction template to perform knowledge extraction instruction assembly to obtain a second instruction text, and then the second instruction text is input into the first model for knowledge extraction processing to obtain extracted knowledge, and then the old knowledge records in the knowledge base that match the extracted knowledge are queried. If the old knowledge records that match it exist, the old knowledge records are updated based on the extracted knowledge. If the old knowledge records that match it do not exist, knowledge is added to the knowledge base based on the extracted knowledge. The present invention can improve the timeliness of knowledge, expand the scope of knowledge, and improve the generalization of knowledge.
[0004] To achieve the above objectives, a first aspect of an embodiment of the present invention provides a knowledge processing method combining user feedback and context learning, the method comprising:
[0005] Any large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning is recorded as the corresponding first model; and the knowledge base used by the first model is recorded as the corresponding first knowledge base;
[0006] Receive a translation or question-answering instruction text input by a user as a corresponding first instruction text; perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence; input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing; and feedback the translation or answer text generated by the model as the corresponding first generated text to the current user;
[0007] receiving satisfaction feedback from the current user on the first generated text as a corresponding first satisfaction level; and when the first satisfaction level is satisfactory, inputting the first instruction text and the first generated text into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text; and inputting the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge; the first satisfaction level includes satisfaction and dissatisfaction;
[0008] Based on the first extracted knowledge, the first knowledge base is queried for old knowledge records to obtain a corresponding first query record; and whether the first query record is empty is identified; if so, the first knowledge base is added with knowledge based on the first extracted knowledge; if not, the first query record is updated with knowledge based on the first extracted knowledge.
[0009] Preferably, the first knowledge base is composed of a plurality of first knowledge records; each of the first knowledge records includes a first knowledge purpose, a first knowledge topic, a first knowledge content, a first encoding vector, a second encoding vector, and a first update time; the first knowledge purpose includes at least translation and question-answering; the first and second encoding vectors are respectively embedded encoding vectors of the corresponding first knowledge topic and the first knowledge content, and the embedding encoding rules corresponding to the first and second encoding vectors are both preset first embedding encoding rules; the first embedding encoding rules include at least N-gram encoding rules and Word2vec encoding rules;
[0010] The knowledge extraction instruction template is a formatting template; the knowledge extraction instruction template is used to record the input instruction text and the generated text as the corresponding current instruction text and the current generated text, and sequentially splice the current instruction text and the current generated text to obtain the corresponding current spliced text, and inform the first model through a narrative natural language text to perform knowledge extraction processing on the current spliced text according to the formatted extraction method of knowledge subject-knowledge content, and to form the corresponding current extracted knowledge from the extracted subject text and content text, and output the current extracted knowledge as the corresponding model generated text;
[0011] The first extracted knowledge includes a first subject text and a first content text.
[0012] Preferably, performing contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain the corresponding first knowledge sequence specifically includes:
[0013] Step 31: taking the translation or question-answering task type corresponding to the first instruction text as the corresponding current knowledge usage;
[0014] Wherein, the current knowledge usage includes translation and question answering;
[0015] Step 32: Based on the first embedded coding rule, the first instruction text is embedded and coded to obtain the corresponding current coding vector; and the first knowledge records in the first knowledge base whose vector similarity with the first or second coding vector and the current coding vector exceeds a preset first similarity threshold are extracted to form a corresponding first record set; and the total number of records in the first record set is counted to obtain a corresponding first total number N; and the vector similarity corresponding to each of the first knowledge records in the first record set is recorded as the corresponding first similarity d i , 1≤i≤N;
[0016] Step 33: calculate the first task weight wa corresponding to each first knowledge record in the first record set that matches the first knowledge usage with the current knowledge usage. i Set as the preset related task weight coefficient wa high ; and the first task weight wa corresponding to each first knowledge record in the first record set whose first knowledge usage does not match the current knowledge usage i Set to the preset irrelevant task weight coefficient wa low ;
[0017] Among them, the irrelevant task weight coefficient wa low <Related task weight coefficient wa high ;
[0018] Step 34: extract the earliest and latest first update times in the first record set to form a corresponding first time period; identify the time period length of the first time period to obtain the corresponding first time period length L; and calculate the time difference between the first update time of each first knowledge record and the start time of the first time period to obtain the corresponding first time difference Δt i , and based on each of the first time differences Δt i The first time weight wb corresponding to the first time period length L is calculated i =△t i / L;
[0019] Step 35, the first similarity d corresponding to each of the first knowledge records in the first record set is calculated. i , the first task weight wa i and the first time weight wb i Calculate the corresponding first knowledge weight
[0020] Step 36: extract the first knowledge subject and the first knowledge content of each of the first knowledge records in the first record set to form a corresponding first learning knowledge c i ; and according to the first knowledge weight kw i The first learning knowledge c is sorted from low to high. i Sorting is performed to obtain the corresponding first knowledge sequence.
[0021] Preferably, performing an old knowledge record query on the first knowledge base based on the first extracted knowledge to obtain a corresponding first query record specifically includes:
[0022] Step 41: taking the translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge as the corresponding current knowledge usage;
[0023] Step 42: performing embedding coding on the first knowledge subject of the first extracted knowledge based on the first embedding coding rule to obtain a corresponding current coding vector;
[0024] Step 43: extract the first knowledge records in the first knowledge base whose first knowledge usage matches the current knowledge usage and whose first encoding vector has a vector similarity with the current encoding vector exceeding a preset second similarity threshold, and form a corresponding second record set;
[0025] Wherein, the first similarity threshold < the second similarity threshold;
[0026] Step 44, identifying whether the second record set is empty; if so, setting the corresponding first query record to empty; if not, extracting the first knowledge record with the greatest similarity in the second record set as the corresponding first query record.
[0027] Preferably, the step of adding knowledge to the first knowledge base based on the first extracted knowledge specifically includes:
[0028] The translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge is used as the corresponding first knowledge purpose; and the first subject text and the first content text of the first extracted knowledge are used as the corresponding first knowledge subject and the first knowledge content; and based on the first embedded coding rule, the first knowledge subject and the first knowledge content obtained this time are respectively embedded coded to obtain the corresponding first coding vector and the second coding vector; and the current time is used as the corresponding first update time; and the first knowledge purpose, the first knowledge subject, the first knowledge content, the first coding vector, the second coding vector and the first update time obtained this time form a corresponding first knowledge record and add it to the first knowledge base.
[0029] Preferably, the performing knowledge updating processing on the first query record based on the first extracted knowledge specifically includes:
[0030] The first content text of the first extracted knowledge is used as the corresponding updated content; and the updated content is embedded and encoded based on the first embedded coding rule to obtain the corresponding updated vector; and the current time is used as the corresponding updated time; and the first knowledge content, the second coding vector and the first update time of the first query record are updated to the corresponding updated content, the updated vector and the updated time.
[0031] Preferably, the method further comprises:
[0032] Continuously collect knowledge information and construct a corresponding first collected knowledge set based on the collected information; and regularly perform batch knowledge addition and update processing on the first knowledge base based on the first collected knowledge set.
[0033] A second aspect of an embodiment of the present invention provides a device for implementing the knowledge processing method combining user feedback and context learning as described in the first aspect, the device comprising: a knowledge base selection module, a knowledge retrieval module, a knowledge extraction module, and a knowledge base update module;
[0034] The knowledge base selection module is used to record any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning as the corresponding first model; and record the knowledge base used by the first model as the corresponding first knowledge base;
[0035] The knowledge retrieval module is used to receive a translation or question-answering instruction text input by a user as a corresponding first instruction text; and perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence; and input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing, and feed back the translation or answer text generated by the model as the corresponding first generated text to the current user;
[0036] The knowledge extraction module is configured to receive satisfaction feedback from the current user on the first generated text as a corresponding first satisfaction level; and when the first satisfaction level is satisfied, input the first instruction text and the first generated text into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text; and input the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge; the first satisfaction level includes satisfied and dissatisfied.
[0037] The knowledge base update module is used to perform old knowledge record query on the first knowledge base based on the first extracted knowledge to obtain the corresponding first query record; and to identify whether the first query record is empty; if so, perform knowledge addition processing on the first knowledge base based on the first extracted knowledge; if not, perform knowledge update processing on the first query record based on the first extracted knowledge.
[0038] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0039] The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0040] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0041] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0042] The embodiments of the present invention provide a knowledge processing method, device, electronic device and computer-readable storage medium that combine user feedback and contextual learning. As can be seen from the above content, the embodiments of the present invention record any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and directional field fine-tuning as the first model; and construct a corresponding collection knowledge set based on the continuously collected knowledge information, and regularly perform batch knowledge addition and update processing on the knowledge base based on the collected knowledge set; and after receiving the first instruction text (translation or question-and-answer instruction text) input by the user, first perform contextual knowledge learning based on the first instruction text and the knowledge base to obtain a knowledge sequence, and then input the knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform the corresponding translation or question-and-answer task. The service processing obtains the corresponding first generated text and feeds it back to the current user. Then, when receiving the user's satisfaction feedback on the first generated text, it is identified. If the user is satisfied, the first instruction text and the first generated text are input into the knowledge extraction instruction template to assemble the knowledge extraction instruction to obtain the second instruction text. The second instruction text is then input into the first model for knowledge extraction processing to obtain extracted knowledge. Then, the old knowledge records matching the extracted knowledge in the knowledge base are queried. If the old knowledge records matching it exist, the old knowledge records are updated based on the extracted knowledge. If the old knowledge records matching it do not exist, the knowledge base is added based on the extracted knowledge. The embodiment of the present invention not only improves the timeliness of knowledge, but also expands the scope of knowledge and improves the generalization of knowledge. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of a knowledge processing method combining user feedback and contextual learning provided in the first embodiment of the present invention;
[0044] Figure 2 This is a module structure diagram of a knowledge processing device that combines user feedback and context learning, provided in the second embodiment of the present invention;
[0045] Figure 3 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0046] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described herein are merely some, rather than all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0047] The first embodiment of the present invention provides a knowledge processing method that combines user feedback and context learning, such as Figure 1A schematic diagram of a knowledge processing method combining user feedback and context learning provided in the first embodiment of the present invention is shown. The method mainly includes the following steps:
[0048] Step 1: Any large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning is recorded as the corresponding first model; and the knowledge base used by the first model is recorded as the corresponding first knowledge base.
[0049] Here, the first model of the embodiment of the present invention is any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning. It should at least include common BERT series models, BART series models, GPT series models, T5 series models, Wenxin series models, etc., and may also include large language models that meet other specific application requirements.
[0050] The first knowledge base of an embodiment of the present invention is composed of multiple first knowledge records; each first knowledge record includes a first knowledge purpose, a first knowledge topic, a first knowledge content, a first coding vector, a second coding vector and a first update time; the first knowledge purpose includes at least translation and question and answer; the first and second coding vectors are respectively embedded coding vectors of the corresponding first knowledge topic and first knowledge content, and the embedded coding rules corresponding to the first and second coding vectors are both preset first embedded coding rules; the first embedded coding rules include at least N-gram coding rules and Word2vec coding rules.
[0051] Step 2: Receive the translation or question-answering instruction text input by the user as the corresponding first instruction text; perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence; input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform the corresponding translation or question-answering task processing; and feedback the translation or answer text generated by the model as the corresponding first generated text to the current user;
[0052] Specifically comprising: step 21, receiving a translation or question-and-answer instruction text input by a user as a corresponding first instruction text;
[0053] Step 22: performing contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence;
[0054] Specifically, it includes: step 221, taking the translation or question-answering task type corresponding to the first instruction text as the corresponding current knowledge usage;
[0055] Among them, current knowledge uses include translation and question answering;
[0056] Step 222: Based on the first embedding coding rule, the first instruction text is embedded and coded to obtain the corresponding current coding vector; and the first knowledge records in the first knowledge base whose vector similarity with the first or second coding vector exceeds a preset first similarity threshold are extracted to form a corresponding first record set; and the total number of records in the first record set is counted to obtain a corresponding first total number N; and the vector similarity corresponding to each first knowledge record in the first record set is recorded as the corresponding first similarity d i , 1≤i≤N;
[0057] Wherein, the first similarity threshold is a preset threshold parameter;
[0058] Step 223: calculate the first task weight wa corresponding to each first knowledge record in the first record set that matches the first knowledge usage with the current knowledge usage. i Set as the preset related task weight coefficient wa high ; and the first task weight wa corresponding to the first knowledge record of each first knowledge usage in the first record set that does not match the current knowledge usage i Set to the preset irrelevant task weight coefficient wa low ;
[0059] Among them, the irrelevant task weight coefficient wa low , related task weight coefficient wa high are two pre-set weight coefficients, and 0 < irrelevant task weight coefficient wa low <Related task weight coefficient wa high ≤1;
[0060] Step 224: extract the earliest and latest first update times in the first record set to form a corresponding first time period; identify the time period length of the first time period to obtain the corresponding first time period length L; and calculate the time difference between the first update time of each first knowledge record and the start time of the first time period to obtain the corresponding first time difference Δt i , and based on each first time difference △t i The first time weight wb corresponding to the first time period length L is calculated i =△t i / L;
[0061] Here, each first time weight is actually a normalized time weight;
[0062] Step 225, the first similarity d corresponding to each first knowledge record in the first record set is calculated. i , the first task weight wa i and first time weight wb i Calculate the corresponding first knowledge weight
[0063] Here, the first knowledge weight is actually a normalized knowledge weight. The greater the relevance to the instruction text content (the higher the similarity), the greater the first knowledge weight; the better the task relevance (the greater the task weight), the greater the first knowledge weight; the better the timeliness (the greater the time weight), the greater the first knowledge weight;
[0064] Step 226: extract the first knowledge subject and the first knowledge content of each first knowledge record in the first record set to form the corresponding first learning knowledge c i ; and according to the first knowledge weight kw i The N first learning knowledge c is sorted from low to high i Sorting to obtain the corresponding first knowledge sequence;
[0065] Here, from the above steps 221-226, it can be seen that the embodiment of the present invention expands the knowledge scope and improves the generalization of knowledge by increasing the number of knowledge items when performing knowledge retrieval, and refines the degree of correlation between sequence knowledge items and instruction texts through multiple weight types (similarity, task weight, time weight);
[0066] In step 23, the first knowledge sequence is input as instruction prompt text information together with the first instruction text into the first model for corresponding translation or question-answering task processing, and the translation or answer text generated by the model is fed back to the current user as the corresponding first generated text.
[0067] Step 3: receiving the satisfaction feedback of the current user on the first generated text as the corresponding first satisfaction; and when the first satisfaction is satisfactory, inputting the first instruction text and the first generated text into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text; and inputting the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge;
[0068] Specifically comprising: step 31, receiving satisfaction feedback of the current user on the first generated text as the corresponding first satisfaction;
[0069] Among them, the first satisfaction level includes satisfaction and dissatisfaction;
[0070] Step 32: When the first satisfaction level is satisfactory, the first instruction text and the first generated text are input into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text;
[0071] Here, the knowledge extraction instruction template of the embodiment of the present invention is a formatting template; the knowledge extraction instruction template is used to record the input instruction text and the generated text as the corresponding current instruction text and the current generated text, and sequentially splice the current instruction text and the current generated text to obtain the corresponding current spliced text, and inform the first model through a narrative natural language text to perform knowledge extraction processing on the current spliced text according to the formatted extraction method of knowledge subject-knowledge content, and to form the corresponding current extracted knowledge from the extracted subject text and content text, and output the current extracted knowledge as the corresponding model generated text;
[0072] Step 33: Input the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge;
[0073] The first extracted knowledge includes a first subject text and a first content text.
[0074] Step 4: Based on the first extracted knowledge, the first knowledge base is queried for old knowledge records to obtain a corresponding first query record; and whether the first query record is empty is identified; if so, knowledge is added to the first knowledge base based on the first extracted knowledge; if not, knowledge is updated on the first query record based on the first extracted knowledge;
[0075] Specifically comprising: step 41, performing an old knowledge record query on the first knowledge base based on the first extracted knowledge to obtain a corresponding first query record;
[0076] Specifically, it includes: step 411, taking the translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge as the corresponding current knowledge usage;
[0077] Step 412: performing embedding coding on the first knowledge subject of the first extracted knowledge based on the first embedding coding rule to obtain a corresponding current coding vector;
[0078] Step 413: extract first knowledge records in the first knowledge base whose first knowledge usage matches the current knowledge usage and whose first encoding vector has a vector similarity with the current encoding vector exceeding a preset second similarity threshold, and form a corresponding second record set;
[0079] Here, the second similarity threshold is a preset threshold parameter, and the first similarity threshold is less than the second similarity threshold;
[0080] Step 414: Identify whether the second record set is empty; if so, set the corresponding first query record to empty; if not, extract the first knowledge record with the greatest similarity in the second record set as the corresponding first query record;
[0081] Step 42: Identify whether the first query record is empty;
[0082] Step 43: If the first query record is empty, then perform knowledge addition processing on the first knowledge base based on the first extracted knowledge;
[0083] Specifically, it includes: taking the translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge as the corresponding first knowledge purpose; taking the first subject text and the first content text of the first extracted knowledge as the corresponding first knowledge subject and the first knowledge content; and performing embedding coding processing on the first knowledge subject and the first knowledge content obtained this time based on the first embedding coding rule to obtain the corresponding first coding vector and second coding vector; and taking the current time as the corresponding first update time; and forming a corresponding first knowledge record with the first knowledge purpose, the first knowledge subject, the first knowledge content, the first coding vector, the second coding vector and the first update time obtained this time and adding it to the first knowledge base;
[0084] Step 44: If the first query record is not empty, then perform knowledge update processing on the first query record based on the first extracted knowledge;
[0085] Specifically, it includes: taking the first content text of the first extracted knowledge as the corresponding updated content; and performing embedded coding processing on the updated content based on the first embedded coding rule to obtain the corresponding updated vector; and taking the current time as the corresponding updated time; and updating the first knowledge content, the second coding vector and the first update time of the first query record to the corresponding updated content, the updated vector and the updated time.
[0086] Here, from the above steps 41-44, it can be seen that the embodiment of the present invention can perform a corresponding knowledge extraction after each text generation process that satisfies the user feedback in the large language model, i.e., the first model, and can perform a knowledge update when the extracted knowledge does not match the old knowledge in the knowledge base, or perform a knowledge addition when the extracted knowledge does not exist in the knowledge base; thereby, the timeliness of the knowledge base can be timely and effectively improved under the premise of combining user feedback.
[0087] It should also be noted that the embodiment of the present invention is also compatible with the conventional batch update mechanism, that is: the embodiment of the present invention will continuously collect knowledge information and construct a corresponding first collected knowledge set based on the collected information, and regularly perform batch knowledge addition and update processing on the first knowledge base based on the first collected knowledge set.
[0088] Figure 2This is a module structure diagram of a knowledge processing device that combines user feedback and context learning provided in the second embodiment of the present invention. The device is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: a knowledge base selection module 201, a knowledge retrieval module 202, a knowledge extraction module 203 and a knowledge base update module 204.
[0089] The knowledge base selection module 201 is used to record any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning as the corresponding first model; and record the knowledge base used by the first model as the corresponding first knowledge base.
[0090] The knowledge retrieval module 202 is used to receive the translation or question-answering instruction text input by the user as the corresponding first instruction text; and perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain the corresponding first knowledge sequence; and input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing and feed back the translation or answer text generated by the model as the corresponding first generated text to the current user.
[0091] The knowledge extraction module 203 is used to receive the current user's satisfaction feedback on the first generated text as the corresponding first satisfaction; and when the first satisfaction is satisfied, the first instruction text and the first generated text are input into the preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain the corresponding second instruction text; and the second instruction text is input into the first model to perform corresponding knowledge extraction processing to obtain the corresponding first extracted knowledge; the first satisfaction includes satisfaction and dissatisfaction.
[0092] The knowledge base update module 204 is used to query the old knowledge records of the first knowledge base based on the first extracted knowledge to obtain the corresponding first query record; and to identify whether the first query record is empty; if so, knowledge addition processing is performed on the first knowledge base based on the first extracted knowledge; if not, knowledge update processing is performed on the first query record based on the first extracted knowledge.
[0093] An embodiment of the present invention provides a knowledge processing device that combines user feedback and context learning, which can execute the method steps in the above method embodiment. Its implementation principles and technical effects are similar and will not be repeated here.
[0094] It should be noted that it should be understood that the division of the various modules of the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into a physical entity, or they can be physically separated. Moreover, these modules can all be implemented in the form of software called by a processing element; or they can all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the knowledge base selection module can be a separately established processing element, or it can be integrated into a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called by a processing element of the above device to perform the functions of the above determination module. The implementation of other modules is similar. In addition, these modules can all or partly be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed by hardware integrated logic circuits in the processor element or instructions in the form of software.
[0095] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0096] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the above method embodiments are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) means. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, hard disk, tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0097] Figure 3 This is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present invention. The electronic device can be a terminal device or server that implements the method of the aforementioned embodiment, or it can be a terminal device or server that implements the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 3 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303's transceiver actions. Various instructions may be stored in the memory 302 for completing various processing functions and implementing the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.
[0098] exist Figure 3The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0099] The above-mentioned processors can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0100] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the methods and processing procedures provided in the above embodiments.
[0101] The embodiments of the present invention provide a knowledge processing method, device, electronic device and computer-readable storage medium that combine user feedback and contextual learning. As can be seen from the above content, the embodiments of the present invention record any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and directional field fine-tuning as the first model; and construct a corresponding collection knowledge set based on the continuously collected knowledge information, and regularly perform batch knowledge addition and update processing on the knowledge base based on the collected knowledge set; and after receiving the first instruction text (translation or question-and-answer instruction text) input by the user, first perform contextual knowledge learning based on the first instruction text and the knowledge base to obtain a knowledge sequence, and then input the knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform the corresponding translation or question-and-answer task. The service processing obtains the corresponding first generated text and feeds it back to the current user. Then, when receiving the user's satisfaction feedback on the first generated text, it is identified. If the user is satisfied, the first instruction text and the first generated text are input into the knowledge extraction instruction template to assemble the knowledge extraction instruction to obtain the second instruction text. The second instruction text is then input into the first model for knowledge extraction processing to obtain extracted knowledge. Then, the old knowledge records matching the extracted knowledge in the knowledge base are queried. If the old knowledge records matching it exist, the old knowledge records are updated based on the extracted knowledge. If the old knowledge records matching it do not exist, the knowledge base is added based on the extracted knowledge. The embodiment of the present invention not only improves the timeliness of knowledge, but also expands the scope of knowledge and improves the generalization of knowledge.
[0102] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0103] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A knowledge processing method combining user feedback and contextual learning, characterized in that: The method comprises: Any large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning is recorded as the corresponding first model; and the knowledge base used by the first model is recorded as the corresponding first knowledge base; Receive a translation or question-answering instruction text input by a user as a corresponding first instruction text; perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence; input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing; and feedback the translation or answer text generated by the model as the corresponding first generated text to the current user; receiving satisfaction feedback from the current user on the first generated text as a corresponding first satisfaction level; and when the first satisfaction level is satisfactory, inputting the first instruction text and the first generated text into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text; and inputting the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge; the first satisfaction level includes satisfaction and dissatisfaction; Based on the first extracted knowledge, the first knowledge base is queried for old knowledge records to obtain a corresponding first query record; and whether the first query record is empty is identified; if so, the first knowledge base is added with knowledge based on the first extracted knowledge; if not, the first query record is updated with knowledge based on the first extracted knowledge.
2. The knowledge processing method combining user feedback and contextual learning according to claim 1, characterized in that: The first knowledge base is composed of a plurality of first knowledge records; each of the first knowledge records includes a first knowledge purpose, a first knowledge subject, a first knowledge content, a first encoding vector, a second encoding vector and a first update time; The first knowledge use includes at least translation and question-answering; the first and second coding vectors are respectively the embedding coding vectors of the corresponding first knowledge subject and the first knowledge content, and the embedding coding rules corresponding to the first and second coding vectors are both preset first embedding coding rules; the first embedding coding rules include at least N-gram encoding rules and Word2vec encoding rules; The knowledge extraction instruction template is a formatting template; The knowledge extraction instruction template is used to record the input instruction text and the generated text as the corresponding current instruction text and the current generated text, and sequentially splice the current instruction text and the current generated text to obtain the corresponding current spliced text, and inform the first model through a narrative natural language text to perform knowledge extraction processing on the current spliced text according to the formatted extraction method of knowledge subject-knowledge content, and to form the corresponding current extracted knowledge from the extracted subject text and content text, and output the current extracted knowledge as the corresponding model generated text; The first extracted knowledge includes a first subject text and a first content text.
3. The knowledge processing method combining user feedback and contextual learning according to claim 2, characterized in that: The performing contextual knowledge learning processing according to the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence specifically includes: Step 31: taking the translation or question-answering task type corresponding to the first instruction text as the corresponding current knowledge usage; Wherein, the current knowledge usage includes translation and question answering; Step 32: Based on the first embedded coding rule, the first instruction text is embedded and coded to obtain the corresponding current coding vector; and the first knowledge records in the first knowledge base whose vector similarity with the first or second coding vector and the current coding vector exceeds a preset first similarity threshold are extracted to form a corresponding first record set; and the total number of records in the first record set is counted to obtain a corresponding first total number N; and the vector similarity corresponding to each of the first knowledge records in the first record set is recorded as the corresponding first similarity d i , 1≤i≤N; Step 33: calculate the first task weight wa corresponding to each first knowledge record in the first record set that matches the first knowledge usage with the current knowledge usage. i Set as the preset related task weight coefficient wa high ; and the first task weight wa corresponding to each first knowledge record in the first record set whose first knowledge usage does not match the current knowledge usage i Set to the preset irrelevant task weight coefficient wa low ; Among them, the irrelevant task weight coefficient wa low <Related task weight coefficient wa high ; Step 34: extract the earliest and latest first update times in the first record set to form a corresponding first time period; identify the time period length of the first time period to obtain the corresponding first time period length L; and calculate the time difference between the first update time of each first knowledge record and the start time of the first time period to obtain the corresponding first time difference Δt i , and based on each of the first time differences Δt i The first time weight wb corresponding to the first time period length L is calculated i =△t i / L; Step 35, the first similarity d corresponding to each of the first knowledge records in the first record set is calculated. i , the first task weight wa i and the first time weight wb i Calculate the corresponding first knowledge weight Step 36: extract the first knowledge subject and the first knowledge content of each of the first knowledge records in the first record set to form a corresponding first learning knowledge c i ; and according to the first knowledge weight kw i The first learning knowledge c is sorted from low to high. i Sorting is performed to obtain the corresponding first knowledge sequence.
4. The knowledge processing method combining user feedback and contextual learning according to claim 2, characterized in that: The step of querying the first knowledge base for old knowledge records based on the first extracted knowledge to obtain a corresponding first query record specifically includes: Step 41: taking the translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge as the corresponding current knowledge usage; Step 42: performing embedding coding on the first knowledge subject of the first extracted knowledge based on the first embedding coding rule to obtain a corresponding current coding vector; Step 43: extract the first knowledge records in the first knowledge base whose first knowledge usage matches the current knowledge usage and whose first encoding vector has a vector similarity with the current encoding vector exceeding a preset second similarity threshold, and form a corresponding second record set; Wherein, the first similarity threshold < the second similarity threshold; Step 44, identifying whether the second record set is empty; if so, setting the corresponding first query record to empty; if not, extracting the first knowledge record with the greatest similarity in the second record set as the corresponding first query record.
5. The knowledge processing method combining user feedback and contextual learning according to claim 2, characterized in that: The performing knowledge addition processing on the first knowledge base based on the first extracted knowledge specifically includes: The translation or question-answering task type corresponding to the first instruction text corresponding to the first extracted knowledge is used as the corresponding first knowledge purpose; and the first subject text and the first content text of the first extracted knowledge are used as the corresponding first knowledge subject and the first knowledge content; and based on the first embedded coding rule, the first knowledge subject and the first knowledge content obtained this time are respectively embedded coded to obtain the corresponding first coding vector and the second coding vector; and the current time is used as the corresponding first update time; and the first knowledge purpose, the first knowledge subject, the first knowledge content, the first coding vector, the second coding vector and the first update time obtained this time form a corresponding first knowledge record and add it to the first knowledge base.
6. The knowledge processing method combining user feedback and contextual learning according to claim 2, characterized in that: The performing knowledge updating processing on the first query record based on the first extracted knowledge specifically includes: The first content text of the first extracted knowledge is used as the corresponding updated content; and the updated content is embedded and encoded based on the first embedded coding rule to obtain the corresponding updated vector; and the current time is used as the corresponding updated time; and the first knowledge content, the second coding vector and the first update time of the first query record are updated to the corresponding updated content, the updated vector and the updated time.
7. The knowledge processing method combining user feedback and contextual learning according to claim 1, characterized in that: The method further comprises: Continuously collect knowledge information and construct a corresponding first collected knowledge set based on the collected information; and regularly perform batch knowledge addition and update processing on the first knowledge base based on the first collected knowledge set.
8. A device for executing the knowledge processing method combining user feedback and context learning according to any one of claims 1 to 7, characterized in that: The device includes: a knowledge base selection module, a knowledge retrieval module, a knowledge extraction module and a knowledge base update module; The knowledge base selection module is used to record any type of large language model that uses a knowledge base in the knowledge reasoning process and has completed model pre-training and targeted domain fine-tuning as the corresponding first model; and record the knowledge base used by the first model as the corresponding first knowledge base; The knowledge retrieval module is used to receive a translation or question-answering instruction text input by a user as a corresponding first instruction text; and perform contextual knowledge learning processing based on the first instruction text and the first knowledge base to obtain a corresponding first knowledge sequence; and input the first knowledge sequence as instruction prompt text information together with the first instruction text into the first model to perform corresponding translation or question-answering task processing, and feed back the translation or answer text generated by the model as the corresponding first generated text to the current user; The knowledge extraction module is configured to receive satisfaction feedback from the current user on the first generated text as a corresponding first satisfaction level; and when the first satisfaction level is satisfied, input the first instruction text and the first generated text into a preset knowledge extraction instruction template to perform corresponding knowledge extraction instruction assembly to obtain a corresponding second instruction text; and input the second instruction text into the first model to perform corresponding knowledge extraction processing to obtain corresponding first extracted knowledge; the first satisfaction level includes satisfied and dissatisfied. The knowledge base update module is used to perform old knowledge record query on the first knowledge base based on the first extracted knowledge to obtain the corresponding first query record; and to identify whether the first query record is empty; if so, perform knowledge addition processing on the first knowledge base based on the first extracted knowledge; if not, perform knowledge update processing on the first query record based on the first extracted knowledge.
9. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 7; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Local knowledge base updating method and system based on large language model and BERT model
CN117194602A
Knowledge retrieval method based on large language model and knowledge base management platform
CN118210875A