Content intervention method and device, equipment and storage medium
By querying the preset question and answer library in the digital human system or using the preset language model to generate reply information and performing harmless processing, the problem of poor intervention effect on replying harmful information in the existing technology is solved, and intervention ability and reply are improved quality, reducing resource costs.
Patent Information
- Application Number
- CN202310988796.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art has poor intervention on question-response to harmful information, and it is difficult to effectively deal with missed harmful information and user dissatisfied reply content.
In response to the received question information, query the preset question and answer library based on the question information; when there is question information in the preset question and answer library, the corresponding reply information is obtained from the library; when there is no question information in the preset question and answer library, Use the preset language model to generate reply information, and perform harmless processing when harmful information is detected, and finally update the preset question and answer library based on the processed reply information.
It improves the ability to intervene in reply information, enhances the ability to process harmful information, reduces the cost of calling language model resources, and improves the effect of reply intervention.
Smart Images

Figure CN119474288A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a content intervention method, device, equipment and storage medium. Background Art
[0002] With the rise of large language models, the applications of digital humans are endless. In digital human conversations, there may be harmful information such as pornography, which needs to be intervened. In addition, there are some harmful information that is not hit, but the user is not satisfied with the reply content of the large model, which needs intervention. Summary of the invention
[0003] The main purpose of the present invention is to provide a content intervention method, device, equipment and storage medium, aiming to solve the technical problem that the prior art has poor intervention effect on question responses to harmful information.
[0004] To achieve the above object, the present invention provides a content intervention method, which comprises the following steps:
[0005] In response to the received question information, query a preset question and answer library based on the question information;
[0006] When the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user;
[0007] When the question information does not exist in the preset question-answer library, generating answer information based on the question information through a preset language model;
[0008] When it is detected that the reply information contains harmful information, the reply information is rendered harmless to obtain harmless reply information and returned to the user;
[0009] The preset question and answer library is updated according to the harmless reply information.
[0010] Optionally, when the question information does not exist in the preset question-answer library, after generating the answer information based on the question information by using a preset language model, the method further includes:
[0011] Detecting whether the reply information contains harmful information;
[0012] When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0013] Optionally, the detecting whether the reply information contains harmful information includes:
[0014] Segmenting the reply information to obtain reply information segmentation;
[0015] Perform keyword matching according to the word segmentation of the reply information to obtain a keyword matching degree;
[0016] Determine whether the reply information contains harmful information according to the keyword matching degree.
[0017] Optionally, the detecting whether the reply information contains harmful information further includes:
[0018] Vectorizing the reply information to obtain the reply information vector;
[0019] Performing semantic matching according to the reply information vector to obtain a semantic matching degree;
[0020] Determine whether the reply information contains harmful information according to the semantic matching degree.
[0021] Optionally, updating the preset question and answer library according to the harmless reply information includes:
[0022] Pairing the question information with the harmless answer information to obtain a question information-answer information pair;
[0023] The question information-answer information pair is updated to the preset question and answer library.
[0024] Optionally, updating the question information-answer information pair to the preset question and answer library includes:
[0025] Segmenting and vectorizing the question information in the question information-answer information pair to obtain question information segmentation and question information vectors;
[0026] The question information segmentation and question information vector are stored in the preset question and answer library.
[0027] Optionally, after updating the question information-answer information pair to the preset question and answer library, the method further includes:
[0028] Classifying the harmless answer information in the preset question and answer library to obtain multiple categories of harmless answer information;
[0029] Set different timeliness thresholds for each category of harmless response information;
[0030] The preset question and answer library is updated according to the timeliness threshold corresponding to the harmless reply information.
[0031] Optionally, updating the preset question and answer library according to the timeliness threshold corresponding to the harmless reply information includes:
[0032] Obtain the existence time of harmless answer information in the preset question and answer database;
[0033] Comparing the existence time of the harmless reply information in the preset question and answer database with the corresponding time threshold;
[0034] If the existence time of the harmless reply information in the preset question and answer library reaches the corresponding time limit threshold, the harmless reply information is regarded as expired data and the expired data is deleted from the preset question and answer library.
[0035] Optionally, obtaining answer information corresponding to the question information from the preset question and answer library includes:
[0036] Calculating keyword similarity and semantic similarity between the question information and questions in a preset question-answer library, and obtaining a candidate question set according to the keyword similarity and the semantic similarity;
[0037] Determine matching questions for the question information in the preset question-answer library according to the question information and the candidate question set;
[0038] The answer information corresponding to the question information is determined based on the answer information corresponding to the matching question.
[0039] Optionally, the performing harmless processing on the reply information to obtain harmless reply information includes:
[0040] Obtain the category to which the problem information belongs;
[0041] Determine a corresponding harmless treatment method according to the category to which the problem information belongs;
[0042] The reply information is rendered harmless according to the corresponding harmless processing method to obtain harmless reply information, wherein the harmless processing method at least includes deleting keywords, replacing keywords with preset character strings, and using preset sentences as reply information.
[0043] Optionally, before querying a preset question and answer database based on the question information in response to the received question information, the method further includes:
[0044] Obtain a question information set and a response information set;
[0045] Calculate the keyword similarity between any question information in the question information set and any answer information in the answer information set;
[0046] Pairing the question information in the question information set with the answer information in the answer information set based on the keyword similarity to obtain a plurality of question information-answer information pairs;
[0047] A preset question and answer database is established based on the multiple question information-answer information pairs.
[0048] Optionally, before querying a preset question and answer database based on the question information in response to the received question information, the method further includes:
[0049] Create an initial language model;
[0050] Obtaining a data set, and dividing the data set into a training set and a validation set, wherein the data set includes a plurality of question samples and corresponding answer samples;
[0051] Training the initial language model based on the training set to obtain a trained language model;
[0052] Verifying the trained language model based on the verification set to obtain accuracy information;
[0053] When the accuracy information reaches the accuracy threshold, the training is stopped and the trained language model is used as the preset language model.
[0054] In addition, to achieve the above-mentioned purpose, the present invention further proposes a content intervention device, the content intervention device comprising:
[0055] A query module, configured to query a preset question-answer database based on the received question information in response to the received question information;
[0056] An acquisition module, configured to, when the question information exists in a preset question-and-answer library, acquire answer information corresponding to the question information from the preset question-and-answer library and return the answer information to the user;
[0057] A generation module, configured to generate answer information based on the question information by using a preset language model when the question information does not exist in the preset question-answer library;
[0058] A processing module, configured to, when detecting that the reply information contains harmful information, perform harmless processing on the reply information, obtain harmless reply information and return it to the user;
[0059] An updating module updates the preset question and answer library according to the harmless reply information.
[0060] Optionally, the content intervention device further includes: a detection module;
[0061] The detection module is used to detect whether the reply information contains harmful information;
[0062] When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0063] Optionally, the detection module is further used to segment the reply information to obtain reply information segmentation;
[0064] Perform keyword matching according to the word segmentation of the reply information to obtain a keyword matching degree;
[0065] Determine whether the reply information contains harmful information according to the keyword matching degree.
[0066] Optionally, the detection module is further used to vectorize the reply information to obtain the reply information vector;
[0067] Performing semantic matching according to the reply information vector to obtain a semantic matching degree;
[0068] Determine whether the reply information contains harmful information according to the semantic matching degree.
[0069] Optionally, the updating module is further used to pair the question information with the harmless reply information to obtain a question information-reply information pair;
[0070] The question information-answer information pair is updated to the preset question and answer library.
[0071] Optionally, the updating module is further used to segment and vectorize the question information in the question information-answer information pair to obtain question information segmentation and question information vector;
[0072] The question information segmentation and question information vector are stored in the preset question and answer library.
[0073] In addition, to achieve the above-mentioned purpose, the present invention also proposes a content intervention device, which includes: a memory, a processor, and a content intervention program stored in the memory and executable on the processor, and the content intervention program is configured to implement the steps of the content intervention method described above.
[0074] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a content intervention program is stored, and when the content intervention program is executed by a processor, the steps of the content intervention method described above are implemented.
[0075] The present invention queries a preset question and answer library based on the question information in response to the received question information; when the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user; when the question information does not exist in the preset question and answer library, the answer information is generated based on the question information through a preset language model; when it is detected that the answer information contains harmful information, the answer information is harmlessly processed to obtain harmless answer information and returned to the user; the preset question and answer library is updated according to the harmless answer information. Through the above method, when the preset question and answer library exists, the corresponding answer information is obtained from the preset question and answer library and returned to the user; when the preset question and answer library does not exist, the answer information is generated through a preset language model and harmlessly processed to obtain harmless answer information and returned to the user, which solves the technical problem of poor intervention effect on the answer to harmful information, improves the intervention capability on the answer information, and reduces the cost of calling language model resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 It is a structural diagram of a content intervention device in a hardware operating environment involved in an embodiment of the present invention;
[0077] Figure 2 It is a flowchart of the first embodiment of the content intervention method of the present invention;
[0078] Figure 3 It is a flowchart of the second embodiment of the content intervention method of the present invention;
[0079] Figure 4 It is a flowchart of the third embodiment of the content intervention method of the present invention;
[0080] Figure 5 It is an overall flow chart of an embodiment of the content intervention method of the present invention;
[0081] Figure 6 It is a structural block diagram of the first embodiment of the content intervention device of the present invention.
[0082] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0083] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0084] Reference Figure 1 , Figure 1 It is a schematic diagram of the structure of a content intervention device in a hardware operating environment involved in an embodiment of the present invention.
[0085] like Figure 1As shown, the content intervention device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0086] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the content intervention device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0087] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a content intervention program.
[0088] exist Figure 1 In the content intervention device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the content intervention device of the present invention can be set in the content intervention device, and the content intervention device calls the content intervention program stored in the memory 1005 through the processor 1001, and executes the content intervention method provided by the embodiment of the present invention.
[0089] The embodiment of the present invention provides a content intervention method, referring to Figure 2 , Figure 2 It is a flowchart of the first embodiment of the content intervention method of the present invention.
[0090] In this embodiment, the content intervention method includes the following steps:
[0091] Step S10: In response to the received question information, query a preset question and answer database based on the question information.
[0092] It should be noted that the executor of this embodiment is a content intervention device, and may also be other devices that can achieve the same or similar functions. This embodiment is not limited to this, and this embodiment is described by taking the content intervention device as an example.
[0093] In a specific implementation, when a user inputs a question, the prepared script library will be accessed, and in response to the received question information, a search will be performed in the prepared script library based on the question information to determine whether a corresponding matching question is found.
[0094] It can be understood that the preset question and answer library is the prepared speech library, which is a pre-prepared material library for quickly replying to user questions. The prepared speech library contains harmless reply information corresponding to different question information. The harmless reply information is generated by a preset language model and stored in the preset question and answer library after being harmlessly processed.
[0095] It is worth noting that the questions and answers in the prepared script library can also be manually prepared by the digital human administrator to obtain multiple question information-answer information pairs. The digital human administrator can also modify, delete, and perform other operations on the scripts in the prepared script library. This embodiment does not impose specific restrictions on this.
[0096] Step S20: When the question information does not exist in the preset question and answer database, generate answer information based on the question information through a preset language model.
[0097] In a specific implementation, if the prepared speech library matches the question information, the reply speech corresponding to the question information is obtained from the prepared speech library.
[0098] Furthermore, in order to improve the hit rate of the query, the obtaining of answer information corresponding to the question information from the preset question and answer library includes: calculating the keyword similarity and semantic similarity between the question information and the questions in the preset question and answer library, and obtaining a set of candidate questions based on the keyword similarity and the semantic similarity; determining matching questions for the question information in the preset question and answer library based on the question information and the candidate question set; and determining harmless answer information corresponding to the question information based on the harmless answer information corresponding to the matching questions.
[0099] In a specific implementation, retrieval is performed by means of text retrieval and vector retrieval respectively to obtain retrieval results; the keyword similarity and semantic similarity between the question information and the questions in the preset question and answer library are calculated according to the retrieval results to obtain a similarity set; the similarity data in the similarity set are sorted from high to low, and the first several similarity data are taken; the questions corresponding to the first several similarity data are taken as a candidate question set; the question most relevant to the question input by the user is determined from the candidate question set, that is, the matching question of the question information, and the answer configured for the matching question is returned.
[0100] It is understandable that for retrieval scenarios, in order to cover the hits of the script library, at the keyword retrieval level, the degree of generalization of the question can be selected to adapt to more questions.
[0101] Step S30: When the question information does not exist in the preset question and answer database, generate answer information based on the question information through a preset language model.
[0102] It should be noted that the preset language model is a large language model. A large language model (LLM) 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. The large language model can handle a variety of natural language tasks, such as text classification, question answering, dialogue, etc., and this embodiment does not specifically limit this.
[0103] In a specific implementation, if the prepared script library is a hit question information, the question information is input into the large language model, the reply information is generated by the large language model, and a risk assessment is performed on the reply information generated by the large language model.
[0104] It is worth noting that for topics with a high degree of harmfulness, similar questions are generated through a large model and the same answers are set to increase similarity hits.
[0105] Step S40: When it is detected that the reply information contains harmful information, the reply information is rendered harmless to obtain harmless reply information and return it to the user.
[0106] In a specific implementation, if the reply information contains harmful information, it indicates that the reply information has a high risk of being replied to, and the reply information needs to be rendered harmless before being returned to the user.
[0107] Furthermore, in order to improve the efficiency of harmless processing, the reply information is harmlessly processed to obtain harmless reply information, including: obtaining the category to which the question information belongs; determining a corresponding harmless processing method according to the category to which the question information belongs; and harmlessly processing the reply information according to the corresponding harmless processing method to obtain harmless reply information, wherein the harmless processing method at least includes deleting keywords, replacing keywords with preset character strings, and using preset sentences as reply information.
[0108] It can be understood that the type of harmful information involved in the question information is determined according to the category to which the question information belongs, and different types of harmful information are processed through different harmless processing methods. The harmless processing methods may include deleting keywords, replacing keywords with preset strings, and using preset sentences as reply information, etc. This embodiment does not impose specific restrictions on this.
[0109] In a specific implementation, different types of harmful information are processed through different harmless processing methods. For example, for harmful information involving pornography, a preset sentence can be used as the reply information. The preset sentence can be "This question is beyond the scope of the answer" or "This question cannot be answered", etc., or a preset string can be used to replace the keywords in the reply information. The preset string can be "***" or "×××", etc., and the pornographic keywords in the reply information can also be deleted. This embodiment does not impose specific restrictions on this.
[0110] Step S50: updating the preset question and answer database according to the harmless reply information.
[0111] It is understandable that the harmless reply information of the user information is stored in the preset question and answer library, so that the user can directly obtain the corresponding reply when querying again, improve the reply efficiency and reduce the call of language model resources, saving costs.
[0112] This embodiment queries a preset question and answer library based on the question information in response to the received question information; when the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user; when the question information does not exist in the preset question and answer library, the answer information is generated based on the question information through a preset language model; when it is detected that the answer information contains harmful information, the answer information is harmlessly processed to obtain harmless answer information and returned to the user; the preset question and answer library is updated according to the harmless answer information. Through the above method, when the preset question and answer library exists, the corresponding answer information is obtained from the preset question and answer library and returned to the user; when the preset question and answer library does not exist, the answer information is generated through a preset language model and harmlessly processed to obtain harmless answer information and returned to the user, which solves the technical problem of poor intervention effect on the answer to harmful information, improves the intervention capability on the answer information, and reduces the cost of calling language model resources.
[0113] refer to Figure 3 , Figure 3 It is a flowchart of the second embodiment of the content intervention method of the present invention.
[0114] Based on the first embodiment, the content intervention method of this embodiment further includes, after step S10:
[0115] Step S31: Detect whether the reply information contains harmful information.
[0116] It is understandable that whether the reply information contains harmful information can be determined by keyword detection or semantic detection.
[0117] Furthermore, in order to improve the accuracy of detection, the detection of whether the reply information contains harmful information includes: segmenting the reply information to obtain reply information segmentation; performing keyword matching based on the reply information segmentation to obtain a keyword matching degree; and determining whether the reply information contains harmful information based on the keyword matching degree.
[0118] In a specific implementation, if the keyword matching degree reaches a preset keyword matching degree threshold, it is determined that the reply information contains harmful information. If the keyword matching degree does not reach the preset keyword matching degree threshold, it is determined that the reply information does not contain harmful information. The preset keyword matching degree threshold can be 70%, 80%, 90%, etc., and this embodiment does not impose specific restrictions on this.
[0119] Furthermore, in order to improve the accuracy of detection, the detection of whether the reply information contains harmful information also includes: vectorizing the reply information to obtain the reply information vector; performing semantic matching based on the reply information vector to obtain a semantic matching degree; and determining whether the reply information contains harmful information based on the semantic matching degree.
[0120] In a specific implementation, if the semantic matching degree reaches a preset semantic matching degree threshold, it is determined that the reply information contains harmful information. If the semantic matching degree does not reach the preset semantic matching degree threshold, it is determined that the reply information does not contain harmful information. The preset semantic matching degree threshold can be 70%, 80%, 90%, etc., and this embodiment does not impose any specific restrictions on this.
[0121] It is understandable that the harmful information may be pornographic information, and this embodiment does not impose any specific limitation on this.
[0122] Step S32: When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0123] It is understandable that if the reply information does not contain harmful information, it indicates that the reply information has a low risk of replying, and the reply information can be directly returned to the user, and the question information and the reply information generated by the large language model can be stored in the prepared speech library.
[0124] Further, updating the preset question and answer library according to the harmless reply information includes: pairing the question information and the harmless reply information to obtain a question information-reply information pair; and updating the question information-reply information pair to the preset question and answer library.
[0125] It should be noted that after the question information and the harmless reply information are paired, the reply information paired with the question information can be obtained when the question information is queried, thereby improving the efficiency of information reply.
[0126] It can be understood that by storing the question information-answer information pair in the prepared speech library, when the CIA inputs the same question information for the second time, the corresponding answer information can be obtained through the prepared speech library and returned to the user without using the large language model again, thereby reducing the calling cost of the large language model.
[0127] Furthermore, in order to improve the accuracy of querying a preset question and answer library, the updating of the question information-answer information pair to the preset question and answer library includes: separately segmenting and vectorizing the question information in the question information-answer information pair to obtain question information segmentation and question information vector; and storing the question information segmentation and question information vector to the preset question and answer library.
[0128] It should be noted that for the data in the prepared script library, the questions need to be stored through vectorization and word segmentation to facilitate retrieval through a combination of text retrieval and vector retrieval, thereby improving the accuracy of the retrieval.
[0129] Furthermore, in order to improve the effectiveness of the reply information, after updating the question information-reply information pair to the preset question and answer library, it also includes: classifying the harmless reply information in the preset question and answer library to obtain multiple categories of harmless reply information; setting different timeliness thresholds for each category of harmless reply information; and updating the preset question and answer library according to the timeliness threshold corresponding to the harmless reply information.
[0130] It is understandable that the update of the prepared script library can be based on the type of script, that is, the type of harmless reply information, and set a time limit, such as permanent validity, 1 week, 1 year, etc. This embodiment does not impose specific restrictions on this.
[0131] In a specific implementation, the speech in the prepared question and answer library is classified, different timeliness thresholds are set according to the types of speech, and the content of the prepared speech library is updated according to the timeliness threshold corresponding to the speech.
[0132] Furthermore, updating the preset question and answer library according to the time limit threshold corresponding to the harmless reply information includes: obtaining the existence time of the harmless reply information in the preset question and answer library; comparing the existence time of the harmless reply information in the preset question and answer library with the corresponding time limit threshold; if the existence time of the harmless reply information in the preset question and answer library reaches the corresponding time limit threshold, treating the harmless reply information as expired data and deleting the expired data from the preset question and answer library.
[0133] In the specific implementation, it is periodically determined whether the data in the prepared speech library has reached the corresponding timeliness threshold, and the data that has reached the timeliness threshold is regarded as expired data and deleted, thereby updating the prepared speech library to ensure the validity of the reply information.
[0134] This embodiment detects whether the reply information contains harmful information; when the reply information does not contain harmful information, the reply information is regarded as harmless reply information. In the above manner, by detecting whether the reply information contains harmful information, it is determined whether harmless processing is required, thereby improving information processing efficiency.
[0135] refer to Figure 4 , Figure 4 It is a flowchart of the third embodiment of the content intervention method of the present invention.
[0136] Based on the first embodiment, the content intervention method of this embodiment further includes, before step S10:
[0137] Step S01: Obtain a question information set and an answer information set.
[0138] It should be noted that the question information and answer information in the question information set and answer information set are all low-risk information, that is, harmless information.
[0139] Step S02: Calculate the keyword similarity between any question information in the question information set and any answer information in the answer information set.
[0140] It can be understood that the keywords of each question information in the question information set and the keywords of each reply information in the reply information set are extracted respectively, and the keyword similarity calculation is performed on the question information and the reply information in pairs.
[0141] Step S03: Pairing the question information in the question information set with the answer information in the answer information set based on the keyword similarity to obtain a plurality of question information-answer information pairs.
[0142] It is understandable that the question information in the question information set and the answer information in the answer information set can be paired according to the keyword similarity, and multiple question information-answer information pairs can be obtained through manual preparation by the digital human administrator, and this embodiment does not impose specific restrictions on this. The digital human administrator can also modify, delete, and other operations on the speech in the prepared speech library.
[0143] like Figure 5 As shown, Figure 5This is an overall flow chart of the content intervention method in this embodiment. The overall process of the content intervention method includes: the digital human administrator manually prepares questions and corresponding answers, and stores the questions and corresponding answers in the prepared speech library; when the user inputs a question, the prepared speech library is accessed; when the speech library hits, the corresponding answer to the input question is obtained from the prepared speech library and returned to the user; when the speech library does not hit, the large model (i.e., large language model) service is requested to obtain a reply, and the risk assessment is performed on the content returned by the large model. When the response risk is low, the answer generated by the large model is returned to the user, and the question and the answer generated by the large model are stored in the prepared speech library.
[0144] Step S04: establishing a preset question and answer database based on the plurality of question information-answer information pairs.
[0145] It can be understood that an initial prepared speech library is established based on multiple question information-answer information pairs, and the prepared speech library is continuously updated during use.
[0146] Furthermore, the response to the received question information, before querying the preset question and answer library based on the question information, also includes: creating an initial language model; obtaining a data set, and dividing the data set into a training set and a verification set, wherein the data set includes multiple question samples and corresponding answer samples; training the initial language model based on the training set to obtain a trained language model; verifying the trained language model based on the verification set to obtain accuracy information; when the accuracy information reaches an accuracy threshold, stopping the training and using the trained language model as the preset language model.
[0147] It should be noted that the preset language model, namely the large language model, is obtained by training with a large number of data samples.
[0148] This embodiment obtains a question information set and an answer information set; calculates the keyword similarity of any question information in the question information set and any answer information in the answer information set; pairs the question information in the question information set and the answer information in the answer information set based on the keyword similarity to obtain multiple question information-answer information pairs; and establishes a preset question and answer library based on the multiple question information-answer information pairs. In the above manner, the question information in the question information set and the answer information in the answer information set are paired according to the keyword similarity, thereby establishing a preset question and answer library, reducing the call to a large language model and saving costs.
[0149] Reference Figure 5 , Figure 5 It is a structural block diagram of the first embodiment of the content intervention device of the present invention.
[0150] like Figure 5As shown, the content intervention device proposed in the embodiment of the present invention includes:
[0151] A query module 10, configured to query a preset question-answer database based on the received question information in response to the received question information;
[0152] The acquisition module 20 is used to acquire the answer information corresponding to the question information from the preset question and answer library and return it to the user when the question information exists in the preset question and answer library;
[0153] A generating module 30, configured to generate answer information based on the question information by using a preset language model when the question information does not exist in the preset question-answer library;
[0154] The processing module 40 is used to, when detecting that the reply information contains harmful information, perform harmless processing on the reply information, obtain harmless reply information and return it to the user;
[0155] The updating module 50 updates the preset question and answer library according to the harmless reply information.
[0156] This embodiment queries a preset question and answer library based on the question information in response to the received question information; when the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user; when the question information does not exist in the preset question and answer library, the answer information is generated based on the question information through a preset language model; when it is detected that the answer information contains harmful information, the answer information is harmlessly processed to obtain harmless answer information and returned to the user; the preset question and answer library is updated according to the harmless answer information. Through the above method, when the preset question and answer library exists, the corresponding answer information is obtained from the preset question and answer library and returned to the user; when the preset question and answer library does not exist, the answer information is generated through a preset language model and harmlessly processed to obtain harmless answer information and returned to the user, which solves the technical problem of poor intervention effect on the answer to harmful information, improves the intervention capability on the answer information, and reduces the cost of calling language model resources.
[0157] In one embodiment, the content intervention device further includes: a detection module 60; the detection module 60 is used to detect whether the reply information contains harmful information; when the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0158] In one embodiment, the detection module 60 is further used to segment the reply information to obtain reply information segmentations; perform keyword matching based on the reply information segmentations to obtain keyword matching degrees; and determine whether the reply information contains harmful information based on the keyword matching degrees.
[0159] In one embodiment, the detection module 60 is further used to vectorize the reply information to obtain the reply information vector; perform semantic matching based on the reply information vector to obtain a semantic matching degree; and determine whether the reply information contains harmful information based on the semantic matching degree.
[0160] In one embodiment, the updating module 50 is further used to pair the question information with the harmless answer information to obtain a question information-answer information pair; and update the question information-answer information pair to the preset question and answer library.
[0161] In one embodiment, the update module 50 is further used to segment and vectorize the question information in the question information-answer information pair to obtain question information segmentation and question information vector; and store the question information segmentation and question information vector in the preset question and answer library.
[0162] In one embodiment, the update module 50 is further used to classify the harmless response information in the preset question and answer library to obtain multiple categories of harmless response information; set different timeliness thresholds for each category of harmless response information; and update the preset question and answer library according to the timeliness threshold corresponding to the harmless response information.
[0163] In one embodiment, the update module 50 is further used to obtain the existence time of the harmless reply information in the preset question and answer library; compare the existence time of the harmless reply information in the preset question and answer library with the corresponding time threshold; if the existence time of the harmless reply information in the preset question and answer library reaches the corresponding time threshold, the harmless reply information is treated as expired data and the expired data is deleted from the preset question and answer library.
[0164] In one embodiment, the acquisition module 20 is also used to calculate the keyword similarity and semantic similarity between the question information and the questions in the preset question and answer library, and obtain a candidate question set based on the keyword similarity and the semantic similarity; determine the matching questions of the question information in the preset question and answer library based on the question information and the candidate question set; and determine the answer information corresponding to the question information based on the answer information corresponding to the matching questions.
[0165] In one embodiment, the processing module 40 is further used to obtain the category to which the question information belongs;
[0166] Determine a corresponding harmless processing method according to the category to which the question information belongs; perform harmless processing on the reply information according to the corresponding harmless processing method to obtain harmless reply information, wherein the harmless processing method at least includes deleting keywords, replacing keywords with preset character strings, and using preset sentences as reply information.
[0167] In one embodiment, the content intervention device also includes: an establishment module 70; the establishment module 70 is also used to obtain a question information set and a reply information set; calculate the keyword similarity of any question information in the question information set and any reply information in the reply information set; pair the question information in the question information set and the reply information in the reply information set based on the keyword similarity to obtain multiple question information-reply information pairs; and establish a preset question and answer library based on the multiple question information-reply information pairs.
[0168] In one embodiment, the content intervention device also includes: a training module 80, which is also used to create an initial language model; obtain a data set, and divide the data set into a training set and a verification set, wherein the data set includes multiple question samples and corresponding answer samples; train the initial language model based on the training set to obtain a trained language model; verify the trained language model based on the verification set to obtain accuracy information; when the accuracy information reaches an accuracy threshold, stop training and use the trained language model as a preset language model.
[0169] In addition, to achieve the above-mentioned purpose, the present invention also proposes a content intervention device, which includes: a memory, a processor, and a content intervention program stored in the memory and executable on the processor, and the content intervention program is configured to implement the steps of the content intervention method described above.
[0170] Since the content intervention device adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0171] In addition, an embodiment of the present invention further provides a storage medium, on which a content intervention program is stored. When the content intervention program is executed by a processor, the steps of the content intervention method described above are implemented.
[0172] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0173] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0174] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0175] In addition, for technical details that are not described in detail in this embodiment, reference can be made to the content intervention method provided in any embodiment of the present invention, and will not be repeated here.
[0176] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0177] It should be understood that, although the various steps in the flowchart in the embodiment of the present application are displayed in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and it can be performed in other orders. Moreover, at least a portion of the steps in the figure may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and their execution order is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0178] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0180] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
[0181] The present invention discloses A1, a content intervention method, the method comprising:
[0182] In response to the received question information, query a preset question and answer library based on the question information;
[0183] When the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user;
[0184] When the question information does not exist in the preset question-answer library, generating answer information based on the question information through a preset language model;
[0185] When it is detected that the reply information contains harmful information, the reply information is rendered harmless to obtain harmless reply information and returned to the user;
[0186] The preset question and answer library is updated according to the harmless reply information.
[0187] A2. The method according to claim A1, wherein when the question information does not exist in the preset question-answer library, after generating the answer information based on the question information by using a preset language model, the method further comprises:
[0188] Detecting whether the reply information contains harmful information;
[0189] When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0190] A3. The method as claimed in claim A2, wherein the detecting whether the reply information contains harmful information comprises:
[0191] Segmenting the reply information to obtain reply information segmentation;
[0192] Perform keyword matching according to the word segmentation of the reply information to obtain a keyword matching degree;
[0193] Determine whether the reply information contains harmful information according to the keyword matching degree.
[0194] A4. The method of claim A2, wherein the detecting whether the reply information contains harmful information further comprises:
[0195] Vectorizing the reply information to obtain the reply information vector;
[0196] Performing semantic matching according to the reply information vector to obtain a semantic matching degree;
[0197] Determine whether the reply information contains harmful information according to the semantic matching degree.
[0198] A5. The method as claimed in claim A1, wherein updating the preset question and answer library according to the harmless reply information comprises:
[0199] Pairing the question information with the harmless answer information to obtain a question information-answer information pair;
[0200] The question information-answer information pair is updated to the preset question and answer library.
[0201] A6. The method according to claim A5, wherein updating the question information-answer information pair to the preset question and answer library comprises:
[0202] Segmenting and vectorizing the question information in the question information-answer information pair to obtain question information segmentation and question information vectors;
[0203] The question information segmentation and question information vector are stored in the preset question and answer library.
[0204] A7. The method according to claim A5, after updating the question information-answer information pair to the preset question and answer library, further comprising:
[0205] Classifying the harmless answer information in the preset question and answer library to obtain multiple categories of harmless answer information;
[0206] Set different timeliness thresholds for each category of harmless response information;
[0207] The preset question and answer library is updated according to the timeliness threshold corresponding to the harmless reply information.
[0208] A8. The method of claim A7, wherein updating the preset question-and-answer database according to the timeliness threshold corresponding to the harmless reply information comprises:
[0209] Obtain the existence time of harmless answer information in the preset question and answer database;
[0210] Comparing the existence time of the harmless reply information in the preset question and answer database with the corresponding time threshold;
[0211] If the existence time of the harmless reply information in the preset question and answer library reaches the corresponding time limit threshold, the harmless reply information is regarded as expired data and the expired data is deleted from the preset question and answer library.
[0212] A9. The method according to claim A1, wherein obtaining answer information corresponding to the question information from the preset question and answer library comprises:
[0213] Calculating keyword similarity and semantic similarity between the question information and questions in a preset question-answer library, and obtaining a candidate question set according to the keyword similarity and the semantic similarity;
[0214] Determine matching questions for the question information in the preset question-answer library according to the question information and the candidate question set;
[0215] The answer information corresponding to the question information is determined based on the answer information corresponding to the matching question.
[0216] A10. The method according to claim A1, wherein the harmless processing of the reply information to obtain the harmless reply information comprises:
[0217] Obtain the category to which the problem information belongs;
[0218] Determine a corresponding harmless treatment method according to the category to which the problem information belongs;
[0219] The reply information is rendered harmless according to the corresponding harmless processing method to obtain harmless reply information, wherein the harmless processing method at least includes deleting keywords, replacing keywords with preset character strings, and using preset sentences as reply information.
[0220] A11. The method according to claim A1, wherein before querying a preset question-answer database based on the question information in response to the received question information, the method further comprises:
[0221] Obtain a question information set and a response information set;
[0222] Calculate the keyword similarity between any question information in the question information set and any answer information in the answer information set;
[0223] Pairing the question information in the question information set with the answer information in the answer information set based on the keyword similarity to obtain a plurality of question information-answer information pairs;
[0224] A preset question and answer database is established based on the multiple question information-answer information pairs.
[0225] A12. The method according to claim A1, wherein before querying a preset question-answer database based on the question information in response to the received question information, the method further comprises:
[0226] Create an initial language model;
[0227] Obtaining a data set, and dividing the data set into a training set and a validation set, wherein the data set includes a plurality of question samples and corresponding answer samples;
[0228] Training the initial language model based on the training set to obtain a trained language model;
[0229] Verifying the trained language model based on the verification set to obtain accuracy information;
[0230] When the accuracy information reaches the accuracy threshold, the training is stopped and the trained language model is used as the preset language model.
[0231] The present invention also discloses B13, a content intervention device, the content intervention device comprising:
[0232] A query module, configured to query a preset question-answer database based on the received question information in response to the received question information;
[0233] An acquisition module, configured to, when the question information exists in a preset question-and-answer library, acquire answer information corresponding to the question information from the preset question-and-answer library and return the answer information to the user;
[0234] A generation module, configured to generate answer information based on the question information by using a preset language model when the question information does not exist in the preset question-answer library;
[0235] A processing module, configured to, when detecting that the reply information contains harmful information, perform harmless processing on the reply information, obtain harmless reply information and return it to the user;
[0236] An updating module updates the preset question and answer library according to the harmless reply information.
[0237] B14. The device as claimed in claim B13, wherein the content intervention device further comprises: a detection module;
[0238] The detection module is used to detect whether the reply information contains harmful information;
[0239] When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
[0240] B15. The device as claimed in claim B14, wherein the detection module is further used to segment the reply information to obtain the reply information segmentation;
[0241] Perform keyword matching according to the word segmentation of the reply information to obtain a keyword matching degree;
[0242] Determine whether the reply information contains harmful information according to the keyword matching degree.
[0243] B16. The apparatus as claimed in claim B14, wherein the detection module is further used to vectorize the reply information to obtain the reply information vector;
[0244] Performing semantic matching according to the reply information vector to obtain a semantic matching degree;
[0245] Determine whether the reply information contains harmful information according to the semantic matching degree.
[0246] B17. The apparatus as claimed in claim B13, wherein the updating module is further used to pair the question information with the harmless reply information to obtain a question information-reply information pair;
[0247] The question information-answer information pair is updated to the preset question and answer library.
[0248] B18. The device as claimed in claim B17, wherein the updating module is further used to segment and vectorize the question information in the question information-answer information pair to obtain question information segmentation and question information vector;
[0249] The question information segmentation and question information vector are stored in the preset question and answer library.
[0250] The present invention also discloses C19, a content intervention device, which includes: a memory, a processor, and a content intervention program stored in the memory and executable on the processor, wherein the content intervention program is configured to implement the content intervention method as described above.
[0251] The present invention also discloses D20, a storage medium, on which a content intervention program is stored, and when the content intervention program is executed by a processor, the content intervention method as described above is implemented.
Claims
1. A content intervention method, characterized in that: The method comprises: In response to the received question information, query a preset question and answer library based on the question information; When the question information exists in the preset question and answer library, the answer information corresponding to the question information is obtained from the preset question and answer library and returned to the user; When the question information does not exist in the preset question-answer library, generating answer information based on the question information through a preset language model; When it is detected that the reply information contains harmful information, the reply information is rendered harmless to obtain harmless reply information and returned to the user; The preset question and answer library is updated according to the harmless reply information.
2. The method according to claim 1, characterized in that When the question information does not exist in the preset question-answer library, after generating the answer information based on the question information by using the preset language model, the method further includes: Detecting whether the reply information contains harmful information; When the reply information does not contain harmful information, the reply information is regarded as harmless reply information.
3. The method according to claim 2, characterized in that The detecting whether the reply information contains harmful information includes: Segmenting the reply information to obtain reply information segmentation; Perform keyword matching according to the word segmentation of the reply information to obtain a keyword matching degree; Determine whether the reply information contains harmful information according to the keyword matching degree.
4. The method according to claim 2, characterized in that The detecting whether the reply information contains harmful information further includes: Vectorizing the reply information to obtain the reply information vector; Performing semantic matching according to the reply information vector to obtain a semantic matching degree; Determine whether the reply information contains harmful information according to the semantic matching degree.
5. The method according to claim 1, characterized in that The updating of the preset question and answer library according to the harmless reply information comprises: Pairing the question information with the harmless answer information to obtain a question information-answer information pair; The question information-answer information pair is updated to the preset question and answer library.
6. The method according to claim 5, characterized in that The updating of the question information-answer information pair to the preset question and answer library includes: Segmenting and vectorizing the question information in the question information-answer information pair to obtain question information segmentation and question information vectors; The question information segmentation and question information vector are stored in the preset question and answer library.
7. The method according to claim 5, characterized in that After the question information-answer information pair is updated to the preset question and answer library, the method further includes: Classifying the harmless answer information in the preset question and answer library to obtain multiple categories of harmless answer information; Set different timeliness thresholds for each category of harmless response information; The preset question and answer library is updated according to the timeliness threshold corresponding to the harmless reply information.
8. A content intervention device, characterized in that: The content intervention device comprises: A query module, configured to query a preset question-answer database based on the received question information in response to the received question information; An acquisition module, configured to, when the question information exists in a preset question-and-answer library, acquire answer information corresponding to the question information from the preset question-and-answer library and return the answer information to the user; A generation module, configured to generate answer information based on the question information by using a preset language model when the question information does not exist in the preset question-answer library; A processing module, configured to, when detecting that the reply information contains harmful information, perform harmless processing on the reply information, obtain harmless reply information and return it to the user; An updating module updates the preset question and answer library according to the harmless reply information.
9. A content intervention device, characterized in that: The content intervention device comprises: a memory, a processor, and a content intervention program stored in the memory and executable on the processor, wherein the content intervention program is configured to implement the content intervention method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium stores a content intervention program, and when the content intervention program is executed by the processor, the content intervention method according to any one of claims 1 to 7 is implemented.