CN118312605A - User input filtering method and device based on large language model - Google Patents

User input filtering method and device based on large language model Download PDF

Info

Publication number
CN118312605A
CN118312605A CN202410411258.4A CN202410411258A CN118312605A CN 118312605 A CN118312605 A CN 118312605A CN 202410411258 A CN202410411258 A CN 202410411258A CN 118312605 A CN118312605 A CN 118312605A
Authority
CN
China
Prior art keywords
user input
vector
large language
language models
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410411258.4A
Other languages
Chinese (zh)
Inventor
冯凯
黄蕾蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Regular Quantum Beijing Technology Co ltd
Original Assignee
Regular Quantum Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Regular Quantum Beijing Technology Co ltd filed Critical Regular Quantum Beijing Technology Co ltd
Priority to CN202410411258.4A priority Critical patent/CN118312605A/en
Publication of CN118312605A publication Critical patent/CN118312605A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a user input filtering method and device based on a large language model, comprising the following steps: performing similarity matching on the received first user input and a vector database to obtain a target vector matched with the first user input; the vector database is used for storing vector representations of allowed and/or disallowed user input items; filling a text corresponding to the first user input and the target vector into a preset template to obtain second user input, and providing the second user input for a plurality of large language models to obtain judging results corresponding to the large language models respectively; and carrying out weighted voting on the plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input. Thus, by introducing the search enhancement generation technique, the parallel decision mechanism, and the weighted majority voting mechanism into the filtering process of the user input, the efficiency and accuracy of the user input filtering can be improved.

Description

User input filtering method and device based on large language model
Technical Field
The application relates to the technical field of data security and artificial intelligence, in particular to a user input filtering method and device based on a large language model.
Background
With the rapid development of Internet and large language models (large language model, LLM), both user generated content (user generated content, UGC) and large numbers of applications based on generated artificial intelligence, there is a need for efficient filtering and management of user inputs (e.g., questions) or answers to large models. For a question-answering system based on a large language model in the vertical domain, a developer also wants to be able to filter the questions of the user, and wants to limit the questions of the user to a specific domain.
Traditionally, content filtering of user input is typically performed using rule-based or keyword-based methods. However, these methods often face challenges such as difficulty in writing rules, poor pattern matching, and inadequate coverage.
If a single large language model is adopted for judgment, problems such as view limitation, lack of robustness, data bias transfer, model vulnerability exposure and the like exist.
Currently, large language models and retrieval enhancement generation (RETRIEVAL AUGMENTED GENERATION, RAG) techniques are widely used in natural language processing tasks.
Accordingly, there is a need to provide an efficient and accurate content security filtering system based on the above-described techniques that effectively controls and filters user input.
Disclosure of Invention
In order to solve the above problems, the present application provides a large language model-based user input filtering method, apparatus, electronic device, computer readable storage medium, and computer program product, which can improve the efficiency and accuracy of user input filtering.
In a first aspect, the present application provides a method for filtering user input based on a large language model, the method comprising: performing similarity matching on the received first user input and a vector database to obtain a target vector matched with the first user input; the vector database is used for storing vector representations of allowed and/or disallowed user input items; filling a text corresponding to the first user input and the target vector into a preset template to obtain second user input, and providing the second user input for a plurality of large language models to obtain judging results corresponding to the large language models respectively; the plurality of large language models have the same architecture, but different model parameters or pre-training data; the preset template comprises preset prompt words for prompting a plurality of large language models to judge; and carrying out weighted voting on the plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
The method comprises the steps of carrying out similarity matching on received first user input and a vector database to obtain a target vector matched with the first user input, filling texts corresponding to the first user input and the target vector into a preset template to obtain second user input, and providing the second user input for a plurality of large language models, so that RAG technology is externally connected to the large language models; and then, carrying out weighted voting on the judgment results corresponding to the large language models to obtain a decision result whether to filter the user input, thereby introducing a parallel decision mechanism and a weighted majority voting mechanism based on the large language models, and improving the efficiency and the accuracy of filtering the user input.
In one possible implementation, the method further includes: obtaining the accuracy of each large language model in the large language models based on a decision result of a preset round; and adjusting the weight occupied by each large model in the plurality of large language models when weighted voting is carried out according to the accuracy.
In one possible implementation, an adjustment formula for adjusting the weight occupied by each large model in the plurality of large language models when performing weighted voting is: w i=1/(1-ai), wherein w i represents the weight of the i-th large language model, and a i represents the accuracy of the i-th large language model.
In one possible implementation, the formula for weighted voting is: w sum=∑(Xi*wi)/∑(wi), wherein w sum represents a weighted judgment result obtained by performing weighted voting on a plurality of corresponding judgment results, w i represents the weight of the ith large language model, and X i represents the judgment result corresponding to the ith large language model.
In one possible implementation, performing similarity matching on the received first user input and the vector database to obtain a target vector matched with the first user input includes: vector conversion is carried out on the first user input to obtain a first vector; carrying out vector operation on each vector in the first vector and the vector database respectively to obtain the similarity corresponding to each vector; the target vector is determined from a vector database based on the similarity corresponding to each vector.
In one possible implementation, weighting the plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input includes: carrying out weighted voting on a plurality of corresponding judgment results to obtain weighted judgment results; and comparing the weighted judgment result with a preset threshold value to obtain a result serving as a decision result of whether filtering is performed on the user input.
In one possible implementation, the vectors in the vector database are encoded with allowed and/or disallowed user input entries using the Sentence Transformer model.
In a second aspect, the present application provides a large language model based user input filtering apparatus, the apparatus comprising: the matching module is used for matching the received first user input with the similarity of the vector database to obtain a target vector matched with the first user input; the vector database is used for storing vector representations of allowed and/or disallowed user input items; the processing module is used for filling texts corresponding to the first user input and the target vector into a preset template to obtain second user input, and providing the second user input for a plurality of large language models to obtain judging results corresponding to the large language models respectively; the plurality of large language models have the same architecture, but different model parameters or pre-training data; the preset template comprises preset prompt words for prompting a plurality of large language models to judge; and the voting module is used for carrying out weighted voting on a plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
In a third aspect, the present application provides an electronic device comprising: at least one memory for storing a program; at least one processor for executing programs stored in the memory; wherein the processor is adapted to perform the method described in the first aspect or any one of the possible implementations of the first aspect, when the memory-stored program is executed.
In a fourth aspect, a computer readable storage medium storing a computer program which, when run on an electronic device, causes the electronic device to perform the method described in the first aspect or any one of the possible implementations of the first aspect.
In a fifth aspect, the application provides a computer program product for, when run on an electronic device, causing the electronic device to perform the method as described in the first aspect or any one of the possible implementations of the first aspect.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a diagram of a user input filtering system framework based on a large language model provided by an embodiment of the present application;
FIG. 2 is a flow chart of a user input filtering method based on a large language model provided by an embodiment of the present application;
FIG. 3 is a schematic diagram of generating user input using search enhancement techniques provided by an embodiment of the present application;
FIG. 4 is a diagram of a user input filtering apparatus based on a large language model according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be described below with reference to the accompanying drawings.
In describing embodiments of the present application, words such as "exemplary," "such as" or "for example" are used to mean serving as examples, illustrations or explanations. Any embodiment or design described herein as "exemplary," "such as" or "for example" is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "such as" or "for example," etc., is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, the term "and/or" is merely an association relationship describing an association object, and indicates that three relationships may exist, for example, a and/or B may indicate: a alone, B alone, and both A and B. In addition, unless otherwise indicated, the term "plurality" means two or more. For example, a plurality of systems means two or more systems, and a plurality of screen terminals means two or more screen terminals.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating an indicated technical feature. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The meaning of RAG expands with the development of technology, and in the age of large language models, the specific definition of RAG means that when a model answers a question or generates text, related information is first retrieved from a large corpus of documents. A response or text is then generated using this retrieved information, thereby improving the quality of the prediction. The RAG method allows developers to avoid having to retrain the entire large language model for each particular task. Instead, they can attach a knowledge base to provide additional information input to the model and to improve its accuracy of response. The RAG method is particularly suitable for knowledge intensive tasks. In summary, the RAG system consists of two key phases: 1. and (2) searching relevant documents based on the problems by using the coding model, and generating a text by using the searched context as a condition.
In view of this, the application obtains a target vector matched with the first user input by matching the received first user input with the vector database in similarity, fills a text corresponding to the target vector in the first user input into a preset template to obtain a second user input, and provides the second user input to a plurality of large language models, thereby externally connecting the RAG technology to the plurality of large language models; and then, carrying out weighted voting on the judgment results corresponding to the large language models to obtain a decision result whether to filter the user input, thereby introducing a parallel decision mechanism and a weighted majority voting mechanism based on the large language models, and improving the efficiency and the accuracy of filtering the user input.
Illustratively, a user input filtering system framework diagram based on a large language model provided by an embodiment of the present application is shown in fig. 1. As shown in fig. 1, the user input filtration system generally comprises the following components or techniques:
A plurality of large language models: a number of different large models (e.g., N) are used as base models for understanding user inputs and making security filtering decisions for them.
Vector database: data structures for storing vector representations of whitelists (allowed user input entries) and/or blacklists (disallowed user input entries), semantic similarity matching may be performed by calculating the similarity between the embedded vector of user input and an entry in a vector database. The results of the similarity match may be used to determine whether the user input is associated with semantic content in the white list and/or the black list for content security filtering.
Search enhancement generation technology: and (3) adopting RAG technology, taking user input as query, and searching a white list and/or a black list in the vector database to obtain a query answer.
Parallel decision technique: the user input is provided to a plurality of large language models, and the large language models simultaneously make parallel decisions to obtain a judgment result of each model on the user input, wherein the judgment result can be binary, such as { yes, no } or {1,0}.
Decision summarizing technology: summarizing the judgment results of the large language models, and carrying out weighted voting by adopting a weighted majority voting algorithm to obtain a final decision result.
Dynamic weight updating technology: and according to the result of the decision summarization and user feedback, a dynamic weight updating algorithm is adopted to adjust the weight of each large language model so as to improve the accuracy of the content security filtering mechanism in the next round of decision.
Specifically, first, the user input is similarity matched with the vector representations in the RAG (white list and/or black list), and RAG entries similar to the user input are determined.
Next, text from the user input and similar RAG entries filled into the pre-set templates is provided to a plurality of large language models. Wherein the selected plurality of large language models should ensure independence and diversity of each large language model. Typically, each large language model is assigned an initial weight with a weight value of 1, and the sum of the weights of all large language models should be equal to the number of large language models. The preset template comprises preset prompt words for prompting the large language models to judge, so that the judging efficiency and accuracy of the large language models can be further improved.
Further, the plurality of large language models take parallelization and independent decision judgment. And according to the decision result and the weight of each large language model, adopting a weighted majority voting algorithm to obtain a final decision result. If the decision result shows that the user input passes the detection, a business processing link of the next stage is entered, and the result of business processing by the business system is fed back to the user. If the decision result indicates that the user input does not pass the detection, the decision result is fed back to the user to prompt the user to improve the user input.
Furthermore, the statistics system can adopt the judgment results and decision results of a plurality of large language models with a certain turn to carry out statistics so as to obtain the accuracy of each large language model, and dynamically update the weight of each large language model according to the accuracy.
Next, based on the content shown in fig. 1, a detailed description is given of a user input filtering method based on a large language model according to an embodiment of the present application.
FIG. 2 shows a flowchart of a user input filtering method based on a large language model according to an embodiment of the present application. It is understood that the method may be performed by any apparatus, device, platform, cluster of devices having computing, processing capabilities.
As shown in fig. 2, the user input filtering method includes the steps of:
In step 201, similarity matching is performed between the received first user input and the vector database, so as to obtain a target vector matched with the first user input. The vector database is used to store vector representations of allowed and/or disallowed user input entries.
In this embodiment, the first user input is text based on a question of the user, and filtering of the user's questions is required in order to limit the user's questions to a specific domain. The vector database is a data structure for storing vector representations of whitelists (allowed user input entries) and/or blacklists (disallowed user input entries). Thus, the vector database is used to store vector representations of allowed and/or disallowed user input entries. The user input entries may be keywords or key sentence patterns related to some particular domain.
Accordingly, a suitable set of user input entries may be obtained to construct a white list and/or a black list based on the breadth of the particular domain scope supported by the method. For example, when the scope of the specific field supported by the method is small, a corresponding white list can be constructed by acquiring enough allowed user input items, and each user input item in the white list is converted into a vector representation through a pre-trained language model to obtain a vector database. On the contrary, when the specific field supported by the method is large, a corresponding blacklist can be constructed by acquiring sufficient impermissible user input items, and each user input item in the blacklist is converted into a vector representation through a pre-trained language model to obtain a vector database. It will be appreciated that the above operations may speed up the matching of the received first user input to the vector database.
The first user input is subjected to vector conversion to obtain a first vector, and each vector in the first vector and the vector database is subjected to vector operation respectively, so that the similarity corresponding to each vector can be obtained. And matching the similarity between the received first user input and the vector database to obtain a target vector matched with the first user input.
In one possible implementation, the similarity matching task may be performed using Sentence Transformer natural language processing techniques. Sentence Transformer is a transform-based model that can convert text into fixed-length sentence vectors. Sentence vectors are a data structure used to represent sentences or text, and are commonly used in natural language processing. It is a method of converting sentences into numerical vectors of fixed length to facilitate machine learning and data analysis.
When vector conversion is carried out, a pre-trained Sentence Transformer model is required to be loaded, user input items in a white list and/or a black list are respectively input into the Sentence Transformer model, sentence vectors with fixed lengths are converted into a vector database, and semantic information of the user input items can be captured by the sentence vectors.
Optionally, the Sentence Transformer model may also be used to encode the first user input to obtain a sentence vector corresponding to the first user input, so as to perform the similarity matching operation.
When matching is performed, similarity between the sentence vector corresponding to the first user input and each sentence vector in the vector database may be calculated using a similarity measure based on the sentence vectors, such as cosine similarity, euclidean distance, etc. Then, selecting the user input item corresponding to the sentence vector with the highest similarity in the vector database as a matching result.
It will be appreciated that by performing the matching process described above, it may be selected to return only the one user input entry that is the best match in the white list and/or the black list, or to return the first three or n user input entries that are the best match in the white list and/or the black list.
Step 202, filling the text corresponding to the target vector into a preset template to obtain a second user input, and providing the second user input to a plurality of large language models to obtain the judgment results corresponding to the large language models. The architecture of the large language models is the same, but model parameters or pre-training data are different.
The preset template can be flexibly written according to the needs, and comprises three parts, namely input, instruction/question and output. The instruction/question part comprises preset prompt words for prompting a plurality of large language models to judge. The preset template constructs matched output items according to the input content and the requirement of the instruction/question.
In this embodiment, the plurality of large language models are models with the same pre-training architecture, but different model parameters or pre-training data.
In order to ensure the independence and diversity of each large language model, the large language models with different types can be obtained by pre-training based on the same architecture but different types of model parameters, different numbers of model parameters, different types of pre-training data or different numbers of pre-training data. For example, a large language model is obtained by pre-training the parameter quantity of 7Billion based on a Transform architecture.
The second user input is text obtained by filling the text corresponding to the target vector in the preset template. Since the second user input includes text information corresponding to the target vector retrieved from the vector database according to the retrieval enhancement technique, the quality of large language model prediction can be improved.
And because the preset template comprises preset prompt words for prompting a plurality of large language models to judge, the preset prompt words are used for indicating the large language models to judge the first user input more accurately, so that the prediction quality of the large language models can be further improved.
For example, when constructing a new second user input, a pre-set template may be written first, e.g., the written instruction/question is "user's question is { user original input }. If the user's question is related to { matching rule entry }, answer no, otherwise answer yes ", then in each round of judgment, the real user input is filled in { user original input } and { matching rule entry } sections to output matching rule entries.
Exemplary, a schematic diagram of generating user input using search enhancement techniques provided by an embodiment of the present application is shown in fig. 3. As shown in fig. 3, first, a suitable user input entry in a specific field range, such as "internet of things", "vehicle network", "artificial intelligence", and the like, is acquired to construct a corresponding blacklist, and then the following operations are performed after the user proposes the first user input "what is the internet of things":
At ①, a first user input is provided to a vector database storing a blacklist.
And ②, carrying out RAG retrieval by adopting the method in the step 201 based on the first user input and the vector database to obtain a matched user input item 'Internet of things'.
Step ③, constructing a final user input through a preset template based on the matched user input item 'Internet of things' and the first user input 'what is Internet of things': the problem for the user is what is the internet of things. If the user's question is related to "Internet of things", answer no, otherwise answer yes. The last user input is the second user input.
And providing a second user input to a plurality of large language models, wherein each large language model adopts parallelization and independent decision to obtain a corresponding judgment result.
And 203, carrying out weighted voting on a plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
In this embodiment, a weighted majority voting algorithm is adopted according to the respective corresponding judgment result and weight of each large language model, so as to obtain a final decision result. It will be appreciated that in the initial stage, the weight value assigned to each large language model is typically 1, and the sum of the weights of all large language models corresponds to the number N of large language models.
Specifically, the judgment results corresponding to the large language models are weighted and voted to obtain weighted judgment results, and the result obtained by comparing the weighted judgment results with a preset threshold value is used as a decision result of whether to filter user input. The weighted judgment result can be obtained by the following weighted voting formula (1):
wsum=∑(Xi*wi)/∑(wi) (1)
Wherein w sum represents a weighted judgment result obtained by performing weighted voting on a plurality of corresponding judgment results, w i (i is greater than or equal to 1 and less than or equal to N) represents the weight of the ith large language model, and X i represents a judgment result corresponding to the ith large language model.
And then making a final decision according to the weighted judgment result, for example, using 0.5 as a threshold value, setting that if the weighted judgment result is greater than or equal to the threshold value, or if the weighted judgment result is greater than the threshold value, the final decision result is 1 (yes), which means that the first user input is received; and vice versa 0 (no), indicating that the first user input is filtered out.
Optionally, the number N of the plurality of large language models is set to be an odd number greater than or equal to 3, so that the probability that the weighted judgment result is 0.5 can be reduced, thereby improving the accuracy of the final decision.
Illustratively, the dynamic updating of the weights can also be performed after a certain number of passes (e.g., 10 passes) are accumulated, based on the accuracy of each large language model of the statistics, to accommodate the changes and evolution of the user input content security filtering. For example, after 10 rounds of decision, if the respective judgment results of the 3 large models are compared with the final decision result (the judgment results are the same as the decision results, the judgment is considered to be accurate), the accuracy of the 3 large models is 50%,60% and 70%, and the weight of each large model is adjusted according to the following formula (2):
wi=1/(1-ai) (2)
Wherein w i (1.ltoreq.i.ltoreq.N) represents the weight of the ith large language model, and a i represents the accuracy of the ith large language model. For example, for large model 1: Large model 2: Large model 3:
Thus, according to the final decision result, the safe filtration of the first user input content is completed, whether the first user input is received is judged, if so, the next stage of business processing link is entered, and the processing result of the business system is fed back to the user. If not, the first user input is filtered out and the result is also fed back to the user to prompt the user to improve the first user input.
The method comprises the steps of obtaining a target vector matched with a first user input by matching the similarity between the received first user input and a vector database, filling a text corresponding to the target vector in the first user input to obtain a second user input, and providing the second user input for a plurality of large language models, so that the RAG technology is externally connected to the large language models; and then, carrying out weighted voting on the judgment results corresponding to the large language models to obtain a decision result whether to filter the user input, thereby introducing a parallel decision mechanism and a weighted majority voting mechanism based on the large language models, and improving the efficiency and the accuracy of filtering the user input.
Compared with the prior art, the scheme has the following advantages:
1. through parallel decision of a plurality of large language models, the advantages of the multiple models can be fully utilized, and the accuracy and the effect of safe filtering of the user input content are improved.
2. Different large models are adopted to make decisions, so that the diversity and independence of the decisions can be increased, the accuracy and the robustness are improved, and the advantages of each model can be better utilized through model fusion and weighted voting, so that a more accurate final decision result can be obtained.
3. And the judgment results of the large language models are subjected to decision summarization by adopting a weighted majority voting algorithm, so that a more accurate final decision can be obtained.
4. The dynamic weight updating algorithm can automatically adjust the weight of each large language model according to the decision accuracy of each large model after accumulating for a period of time, and adapt to the change and evolution of content security filtering.
5. The RAG technology and the vector database are introduced, so that more accurate semantic similarity matching can be realized, and the accuracy and efficiency of safe filtering of the user input content are improved.
It should be noted that while in the above embodiments the operations of the methods of embodiments of the present application are described in a particular order, this does not require or imply that the operations must be performed in that particular order or that all of the illustrated operations be performed in order to achieve desirable results. Rather, the steps depicted in the flowcharts may change the order of execution. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform.
Based on the method in the above embodiment, fig. 4 illustrates an exemplary diagram of a user input filtering apparatus based on a large language model according to an embodiment of the present application. As shown in fig. 4, the user input filtering apparatus 400 includes:
and the matching module 410 is configured to perform similarity matching on the received first user input and the vector database, so as to obtain a target vector matched with the first user input. The vector database is used to store vector representations of allowed and/or disallowed user input entries.
And the processing module 420 is configured to fill a text corresponding to the target vector in the first user input to obtain a second user input, and provide the second user input to the plurality of large language models to obtain a judgment result corresponding to each of the plurality of large language models. The architecture of the large language models is the same, but model parameters or pre-training data are different. The preset template comprises preset prompt words for prompting the plurality of large language models to judge.
And the voting module 430 is configured to weight vote a plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
Based on the method in the above embodiment, the embodiment of the application provides an electronic device. The electronic device may include: at least one memory for storing a program; at least one processor for executing the programs stored in the memory. Wherein the processor is adapted to perform the method described in the above embodiments when the program stored in the memory is executed. By way of example, the electronic device may be a cell phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, server, ultra-mobile personal computer, UMPC, netbook, as well as a cellular telephone, personal Digital Assistant (PDA), augmented reality (augmented reality, AR) device, virtual Reality (VR) device, artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) device, wearable device, vehicle device, smart home device, and/or smart city device, the specific type of electronic device being not particularly limited by the embodiments of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It will be appreciated that the various numerical numbers referred to in the embodiments of the present application are merely for ease of description and are not intended to limit the scope of the embodiments of the present application. It should be understood that, in the embodiment of the present application, the sequence number of each process does not mean the sequence of execution, and the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application.
The foregoing embodiments have been provided for the purpose of illustrating the general principles of the present application in further detail, and are not to be construed as limiting the scope of the application, but are merely intended to cover any modifications, equivalents, improvements, etc. based on the teachings of the application.

Claims (10)

1. A method for filtering user input based on a large language model, the method comprising:
performing similarity matching on the received first user input and a vector database to obtain a target vector matched with the first user input; the vector database is used for storing vector representations of allowed and/or disallowed user input items;
filling a text corresponding to the target vector into a preset template to obtain a second user input, and providing the second user input to a plurality of large language models to obtain judging results corresponding to the large language models; the large language models have the same architecture, but different model parameters or pre-training data; the preset template comprises preset prompt words for prompting the large language models to judge;
and carrying out weighted voting on a plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
2. The method according to claim 1, wherein the method further comprises:
obtaining the accuracy of each large language model in the plurality of large language models based on the decision result of the preset round;
and adjusting the weight occupied by each big model in the plurality of big language models when the weighted voting is carried out according to the accuracy rate.
3. The method of claim 2, wherein the adjusting formula for adjusting the weight that each of the plurality of large language models occupies when the weighted voting is performed is:
wi=1/(1-ai),
Where w i represents the weight of the i-th large language model, and a i represents the accuracy of the i-th large language model.
4. The method of claim 1, wherein the formula for weighted voting is:
wsum=∑(Xi*wi)/∑(wi),
Wherein w sum represents a weighted judgment result obtained by performing weighted voting on a plurality of corresponding judgment results, w i represents a weight of the ith large language model, and X i represents a judgment result corresponding to the ith large language model.
5. The method of claim 1, wherein similarity matching the received first user input to a vector database to obtain a target vector matching the first user input, comprises:
vector conversion is carried out on the first user input to obtain a first vector;
carrying out vector operation on each vector in the first vector and the vector database respectively to obtain the similarity corresponding to each vector;
And determining a target vector from the vector database based on the similarity corresponding to each vector.
6. The method of claim 1, wherein said weighting the plurality of said corresponding decisions to obtain a decision result of whether to filter said first user input comprises:
Carrying out weighted voting on a plurality of corresponding judgment results to obtain weighted judgment results;
And comparing the weighted judgment result with a preset threshold value to obtain a result serving as a decision result of whether the user input is filtered.
7. The method according to claim 1, characterized in that the vectors in the vector database are obtained by encoding allowed and/or disallowed user input entries using Sentence Transformer model.
8. A large language model based user input filtering apparatus, the apparatus comprising:
The matching module is used for matching the similarity between the received first user input and the vector database to obtain a target vector matched with the first user input; the vector database is used for storing vector representations of allowed and/or disallowed user input items;
The processing module is used for filling texts corresponding to the first user input and the target vector into a preset template to obtain second user input, and providing the second user input for a plurality of large language models to obtain judging results corresponding to the large language models; the large language models have the same architecture, but different model parameters or pre-training data; the preset template comprises preset prompt words for prompting the large language models to judge;
and the voting module is used for carrying out weighted voting on the plurality of corresponding judgment results to obtain a decision result of whether to filter the first user input.
9. An electronic device, comprising: at least one memory for storing a program; at least one processor for executing the programs stored in the memory; wherein the processor is adapted to perform the method of any of claims 1-7 when the program stored in the memory is executed.
10. A computer readable storage medium storing a computer program which, when run on a processor, causes the processor to perform the method of any one of claims 1-7.
CN202410411258.4A 2024-04-07 2024-04-07 User input filtering method and device based on large language model Pending CN118312605A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410411258.4A CN118312605A (en) 2024-04-07 2024-04-07 User input filtering method and device based on large language model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410411258.4A CN118312605A (en) 2024-04-07 2024-04-07 User input filtering method and device based on large language model

Publications (1)

Publication Number Publication Date
CN118312605A true CN118312605A (en) 2024-07-09

Family

ID=91730410

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410411258.4A Pending CN118312605A (en) 2024-04-07 2024-04-07 User input filtering method and device based on large language model

Country Status (1)

Country Link
CN (1) CN118312605A (en)

Similar Documents

Publication Publication Date Title
CN111310438B (en) Chinese sentence semantic intelligent matching method and device based on multi-granularity fusion model
US20210232762A1 (en) Architectures for natural language processing
US20170200066A1 (en) Semantic Natural Language Vector Space
CN113239169B (en) Answer generation method, device, equipment and storage medium based on artificial intelligence
CN110929515A (en) Reading understanding method and system based on cooperative attention and adaptive adjustment
CN116629235B (en) Large-scale pre-training language model fine tuning method and device, electronic equipment and medium
CN111694940A (en) User report generation method and terminal equipment
CN115270988A (en) Fine adjustment method, device and application of knowledge representation decoupling classification model
CN114817538B (en) Training method of text classification model, text classification method and related equipment
CN116150306A (en) Training method of question-answering robot, question-answering method and device
CN118503494A (en) Multi-source heterogeneous knowledge base-oriented large model question-answering method, device and equipment
CN116738956A (en) Prompt template generation method and device, computer equipment and storage medium
Xu et al. [Retracted] A Multi‐RNN Research Topic Prediction Model Based on Spatial Attention and Semantic Consistency‐Based Scientific Influence Modeling
CN113157892B (en) User intention processing method, device, computer equipment and storage medium
CN118312605A (en) User input filtering method and device based on large language model
CN116955763A (en) Content recommendation method, content recommendation device, computer equipment and computer readable storage medium
CN115129859A (en) Intention recognition method, intention recognition device, electronic device and storage medium
CN115129824B (en) Search type multi-round dialogue method and system
CN117521674B (en) Method, device, computer equipment and storage medium for generating countermeasure information
CN118228718B (en) Encoder processing method, text processing method and related equipment
US11934794B1 (en) Systems and methods for algorithmically orchestrating conversational dialogue transitions within an automated conversational system
CN117786416B (en) Model training method, device, equipment, storage medium and product
CN114492395B (en) Knowledge graph-oriented joint entity disambiguation method and system
CN114328797B (en) Content search method, device, electronic apparatus, storage medium, and program product
CN118673159A (en) Method, apparatus, device, medium and program product for determining answers to questions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination