Large language model security identification method and system based on scenario analysis
By constructing multiple evaluation models, we can identify and evaluate the degree of knowledge fusion of large language models in interdisciplinary scenarios, and solve the problem of insecurity of knowledge fusion in interdisciplinary scenarios, and improve the security and credibility of the model.
Patent Information
- Application Number
- CN202510058151.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2045-01-14
AI Technical Summary
In interdisciplinary scenarios, large language models may produce misleading or unsafe knowledge fusion due to lack of professional domain knowledge or insufficient understanding of inter-field associations, resulting in poor knowledge fusion between disciplines.
By constructing a subject knowledge base, input subject matching model, text subject similarity evaluation model, semantic similarity evaluation model and interdisciplinary knowledge fusion scoring model, we can identify the degree of knowledge fusion of large language models in interdisciplinary scenarios, evaluate text subject similarity and semantic similarity, and perform interdisciplinary knowledge fusion scoring.
It effectively reduces the risk of knowledge fusion generating misleading content in interdisciplinary scenarios, and improves the security and credibility of large language models in interdisciplinary knowledge fusion.
Smart Images

Figure CN119474914B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and more specifically, to a large language model security identification method and system based on scenario analysis, which is particularly suitable for knowledge fusion in interdisciplinary scenarios. Background Art
[0002] With the rapid development of large language models, the content they generate has been put into practical use in multiple scenarios. Interdisciplinary knowledge fusion can help teachers evaluate the quality of interdisciplinary course materials in the field of education, and assist in judging the rationality of knowledge fusion in interdisciplinary research results in scientific research, generating positive economic and social benefits. Large language models can be used to integrate knowledge from multiple disciplines. However, since the output content of large language models is inherently random, in interdisciplinary knowledge fusion scenarios, large language models may lack professional domain knowledge or have insufficient understanding of the relationship between domains, which may lead to misleading or unsafe knowledge fusion and poor knowledge fusion between disciplines. Therefore, it is crucial to safely identify and evaluate their output fusion results.
[0003] Therefore, the present invention proposes a large language model security identification method and system based on scenario analysis, which identifies the degree of knowledge fusion of the large language model in the interdisciplinary scenario by performing interdisciplinary scenario identification, similarity assessment and subject knowledge fusion scoring on the input content and the output content, thereby effectively reducing the risk of generating misleading content in the interdisciplinary scenario and improving the security and credibility of the large language model under interdisciplinary knowledge fusion. Summary of the invention
[0004] In view of the shortcomings of the prior art, the present invention proposes a large language model security identification method and system based on scenario analysis. The present invention constructs a subject knowledge base, imports the terms and knowledge points of each subject field into the subject knowledge base, constructs an input subject matching model, imports the input text into the input subject matching model to match the interdisciplinary scenario, constructs a text subject similarity evaluation model, imports the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity, constructs a semantic similarity evaluation model, imports the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text, constructs an interdisciplinary knowledge fusion scoring model, imports the text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model to perform interdisciplinary knowledge fusion scoring, which can effectively reduce the risk of knowledge fusion generating misleading content in interdisciplinary scenarios and improve the security and credibility of the large language model.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A large language model security identification method and system based on scenario analysis includes the following specific steps:
[0007] Build a subject knowledge base and import the terms and knowledge points of each subject area into the subject knowledge base;
[0008] Construct an input subject matching model and import the input text into the input subject matching model to match the interdisciplinary scenario;
[0009] Construct a text subject similarity evaluation model, and import the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity;
[0010] Construct a semantic similarity evaluation model, import the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text;
[0011] Construct an interdisciplinary knowledge fusion scoring model, and import text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring.
[0012] It should be specifically explained here that the construction of the subject knowledge base and the importation of the terms and knowledge points of each subject field into the subject knowledge base include the following specific steps:
[0013] S11. Obtain academic papers, field reports and professional books data for each discipline, and identify terms and knowledge points within the discipline through information extraction software;
[0014] S12. Convert the terms and knowledge points in each subject area into vectors, generate the knowledge base vector of each subject, and construct a subject knowledge base based on the knowledge base vector of each subject. The subject knowledge base construction formula is: ,in, is the knowledge base of the ith subject, n is the total number of subjects, is the union of all disciplines, where the knowledge base set of the i-th discipline is expressed as: ,in, is the jth knowledge point of the ith subject, j is any one of 1 to m, and m is the total number of knowledge points of the ith subject.
[0015] It should be specifically explained here that the construction of the input subject matching model and the importation of the input text into the input subject matching model to match the interdisciplinary scenario include the following specific steps:
[0016] S21, obtaining an input text, dividing the input text into words, identifying keywords in the words through keyword recognition software, and obtaining the frequency of occurrence of the keywords;
[0017] S22, obtain the keywords in the input text and the knowledge base set of each subject, traverse the keyword list of the input text, match each keyword with the term in the subject knowledge base, record the matched subject, import the matched keyword frequency into the matching value calculation formula to calculate the matching value between the input text and each subject, the matching value calculation formula between the input text and the lth subject is: ,in, is the frequency of occurrence of the kth keyword in the lth subject knowledge base, z is the total number of keywords in the input text, is the frequency of occurrence of the kth keyword in the input text, ;
[0018] S23. Arrange the calculated matching values of the input text and the lth subject in descending order, and set the first several subjects as selected subject scenarios.
[0019] It should be specifically explained here that the construction of the text subject similarity evaluation model and the importation of the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity include the following specific steps:
[0020] S31, the subject scenario selected in the input text and the corresponding matching value are expressed in the form of a vector, and the input text matching vector is: ,in, is the lth selected subject scenario, r is the total number of selected subject scenarios, and l belongs to any one of 1 to r. is the matching value between the input text and the lth subject;
[0021] S32, import the output text into the large language model to obtain the output text, substitute the output text into steps S21-S31, and obtain the output text matching vector: ,in, is the lth output subject scenario, r is the total number of output subject scenarios, and l belongs to any item from 1 to r. is the matching value between the input text and the lth subject;
[0022] S33, substituting the input text matching vector and the output text matching vector into the text subject similarity calculation formula to calculate the text subject similarity, wherein the text subject similarity calculation formula is: ,in, and They represent the modulus of the input text matching vector and the modulus of the output text matching vector respectively.
[0023] It should be specifically explained here that the construction of the semantic similarity evaluation model, importing the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text includes the following specific steps:
[0024] S41. Identify the text semantics of the input text and the output text through a large language model to generate a semantic vector of the input text And output text semantic vector , substitute the input text semantic vector and the output text semantic vector into the semantic similarity formula to calculate the semantic similarity between the input text and the output text, where the semantic similarity calculation formula is: ,in, is the input text semantic vector, To output the text semantic vector, and They represent the modulus of the input text semantic vector and the modulus of the output text semantic vector respectively.
[0025] It should be specifically explained here that the construction of the interdisciplinary knowledge fusion scoring model and the importation of text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring include the following specific steps:
[0026] S51. Substitute the text subject similarity and semantic similarity into the interdisciplinary knowledge fusion score calculation formula to calculate the interdisciplinary knowledge fusion score, wherein the interdisciplinary knowledge fusion score calculation formula is: , where F is the semantic similarity and G is the text subject similarity. and Represent the first subject and the Subjects, For the first subject and the The correlation between the first subject and the second subject. The formula for calculating the correlation between subjects is: ,in, and Represent the lth subject knowledge base set and the A collection of subject knowledge bases, is the set of the lth subject knowledge base and the The number of common elements in the subject knowledge base set, is the set of the lth subject knowledge base and the The number of all elements in the subject knowledge base set;
[0027] S52. Compare the interdisciplinary knowledge fusion score with the interdisciplinary knowledge fusion safety threshold. If the interdisciplinary knowledge fusion score is lower than the safety threshold, it is marked as the interdisciplinary knowledge fusion synergy effect cannot meet the fusion needs. If the interdisciplinary knowledge fusion score is greater than the safety threshold, it means that the output text interdisciplinary knowledge fusion synergy effect can meet the fusion needs.
[0028] A large language model security identification system based on scenario analysis is implemented based on the above-mentioned large language model security identification method based on scenario analysis, and specifically includes:
[0029] The subject knowledge base generation module is used to generate a subject knowledge base from the terms and knowledge points in each subject area;
[0030] Input subject matching module, used to match interdisciplinary scenarios through input text;
[0031] A text subject similarity evaluation module is used to evaluate text subject similarity through input text matching vectors and output text matching vectors;
[0032] A semantic similarity evaluation module, used for evaluating the semantic similarity between an input text and an output text through an input text semantic vector and an output text semantic vector;
[0033] The interdisciplinary knowledge fusion scoring module is used to perform interdisciplinary knowledge fusion scoring based on text subject similarity and semantic similarity.
[0034] An electronic device comprises: a processor and a memory, wherein the memory stores a computer program that can be called by the processor;
[0035] The processor executes the above-mentioned large language model security identification method based on scene analysis by calling the computer program stored in the memory.
[0036] A computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned large language model security identification method based on scene analysis.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] The present invention constructs a subject knowledge base, imports the terms and knowledge points of each subject field into the subject knowledge base, constructs an input subject matching model, imports an input text into the input subject matching model to match an interdisciplinary scenario, constructs a text subject similarity evaluation model, imports an input text matching vector and an output text matching vector into the text subject similarity evaluation model to evaluate text subject similarity, constructs a semantic similarity evaluation model, imports an input text semantic vector and an output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text, constructs an interdisciplinary knowledge fusion scoring model, imports text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model to perform interdisciplinary knowledge fusion scoring, which can effectively reduce the risk of knowledge fusion generating misleading content in interdisciplinary scenarios and improve the security and credibility of large language models. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is a schematic diagram of the overall process of the large language model security identification method based on scenario analysis of the present invention;
[0040] Figure 2 A schematic diagram of the scoring process for interdisciplinary knowledge integration;
[0041] Figure 3 This is the workflow diagram for the large language model;
[0042] Figure 4 It is a schematic diagram of the overall framework of the large language model security recognition system based on scenario analysis of the present invention. DETAILED DESCRIPTION
[0043] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0044] Example 1
[0045] See also Figure 1-Figure 3 The present invention provides an embodiment: a large language model security identification method based on scenario analysis, which includes the following specific steps:
[0046] Build a subject knowledge base and import the terms and knowledge points of each subject area into the subject knowledge base;
[0047] Construct an input subject matching model and import the input text into the input subject matching model to match the interdisciplinary scenario;
[0048] Construct a text subject similarity evaluation model, and import the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity;
[0049] Construct a semantic similarity evaluation model, import the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text;
[0050] Construct an interdisciplinary knowledge fusion scoring model, and import text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring.
[0051] In this embodiment, it should be specifically explained that constructing a subject knowledge base and importing the terms and knowledge points of each subject field into the subject knowledge base includes the following specific steps:
[0052] S11. Obtain academic papers, field reports and professional books data for each discipline, pre-process these data, convert PDF, Word and other formats into plain text formats, remove irrelevant information such as headers, footers, references, and perform segmentation, sentence segmentation and word segmentation. Use TF-IDF to extract core keywords from the text according to the importance of vocabulary, use relationship extraction technology to identify the association between terms, and organize the extracted terms and knowledge points into structured data;
[0053] S12. Convert the terms and knowledge points in each subject area into vectors, generate the knowledge base vector of each subject, and construct a subject knowledge base based on the knowledge base vector of each subject. The subject knowledge base construction formula is: ,in, is the knowledge base of the ith subject, n is the total number of subjects, is the union of all disciplines, where the knowledge base set of the i-th discipline is expressed as: ,in, is the jth knowledge point of the ith subject, j is any one of 1 to m, and m is the total number of knowledge points of the ith subject.
[0054] It should be specifically explained in this embodiment that constructing an input subject matching model and importing input text into the input subject matching model to match the interdisciplinary scenario includes the following specific steps:
[0055] S21, obtaining an input text, dividing the input text into words, performing word segmentation processing on the text through a word segmentation tool, dividing the text into independent word units, removing stop words, and after completing the word segmentation, extracting important keywords through a TF-IDF tool according to the frequency of the words in the text and their rarity in the entire corpus, counting the frequency of the keywords in the text, generating a keyword list sorted by frequency, and outputting the statistical results into a readable report or table;
[0056] S22, obtain the keywords in the input text and the knowledge base set of each subject, traverse the keyword list of the input text, match each keyword with the terms in the subject knowledge base, check each keyword in turn whether it exists in the knowledge base of each subject, if a match is found, record the keyword and the corresponding subject field, record the matched subject, import the matched keyword frequency into the matching value calculation formula to calculate the matching value of the input text and each subject, the matching value calculation formula of the input text and the lth subject is: ,in, is the frequency of occurrence of the kth keyword in the lth subject knowledge base, z is the total number of keywords in the input text, is the frequency of occurrence of the kth keyword in the input text, ;
[0057] S23. Arrange the calculated matching values of the input text and the lth subject in descending order, and set the first several subjects as selected subject scenarios.
[0058] It should be specifically explained in this embodiment that constructing a text subject similarity evaluation model and importing the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity includes the following specific steps:
[0059] S31, the subject scenario selected in the input text and the corresponding matching value are expressed in the form of a vector, and the input text matching vector is: ,in, is the lth selected subject scenario, r is the total number of selected subject scenarios, and l belongs to any one of 1 to r. is the matching value between the input text and the lth subject;
[0060] S32, import the output text into the large language model to obtain the output text, substitute the output text into steps S21-S31, and obtain the output text matching vector: ,in, is the lth output subject scenario, r is the total number of output subject scenarios, and l belongs to any item from 1 to r. is the matching value between the input text and the lth subject;
[0061] S321, obtaining the output text, dividing the output text into words, identifying the keywords in the words through keyword recognition software, and obtaining the frequency of occurrence of the keywords;
[0062] S322, obtain the keywords in the output text and the knowledge base set of each subject, traverse the keyword list of the output text, match each keyword with the term in the subject knowledge base, record the matched subject, import the matched keyword frequency into the matching value calculation formula to calculate the matching value between the output text and each subject, the matching value calculation formula between the output text and the lth subject is: ,in, is the frequency of occurrence of the kth keyword in the lth subject knowledge base, z is the total number of keywords in the output text, is the frequency of occurrence of the kth keyword in the output text, ;
[0063] S323, arranging the calculated output text and the matching value of the lth subject in descending order, and obtaining the subject scenarios of the output with the first several subjects arranged first;
[0064] S324, the subject scenario selected in the output text and the corresponding matching value are expressed in the form of a vector, and the output text matching vector is: ,in, is the lth output subject scenario, r is the total number of output subject scenarios, and l belongs to any item from 1 to r. is the matching value between the input text and the lth subject;
[0065] S33, substituting the input text matching vector and the output text matching vector into the text subject similarity calculation formula to calculate the text subject similarity, wherein the text subject similarity calculation formula is: ,in, and They represent the modulus of the input text matching vector and the modulus of the output text matching vector respectively.
[0066] It should be specifically explained in this embodiment that constructing a semantic similarity evaluation model, importing the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text includes the following specific steps:
[0067] S41. Identify the text semantics of the input text and the output text through a large language model to generate a semantic vector of the input text And output text semantic vector , substitute the input text semantic vector and the output text semantic vector into the semantic similarity formula to calculate the semantic similarity between the input text and the output text, where the semantic similarity calculation formula is: ,in, is the input text semantic vector, To output the text semantic vector, and They represent the modulus of the input text semantic vector and the modulus of the output text semantic vector respectively.
[0068] It should be specifically explained in this embodiment that constructing an interdisciplinary knowledge fusion scoring model and importing text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring includes the following specific steps:
[0069] S51. Substitute the text subject similarity and semantic similarity into the interdisciplinary knowledge fusion score calculation formula to calculate the interdisciplinary knowledge fusion score, wherein the interdisciplinary knowledge fusion score calculation formula is: , where F is the semantic similarity and G is the text subject similarity. and Represent the first subject and the Subjects, For the first subject and the The correlation between the first subject and the second subject. The formula for calculating the correlation between subjects is: ,in, and Represent the lth subject knowledge base set and the A collection of subject knowledge bases, is the set of the lth subject knowledge base and the The number of common elements in the subject knowledge base set, is the set of the lth subject knowledge base and the The number of all elements in the subject knowledge base set;
[0070] S52. Collect a large number of interdisciplinary knowledge fusion text samples, import the samples into the interdisciplinary knowledge fusion score calculation formula to calculate the knowledge fusion score of each sample, perform statistical analysis on the knowledge fusion scores of safe samples and unsafe samples, determine the interdisciplinary knowledge fusion safety threshold through ROC curve and expert evaluation, compare the interdisciplinary knowledge fusion score with the interdisciplinary knowledge fusion safety threshold, if the interdisciplinary knowledge fusion score is lower than the safety threshold, it is marked as the interdisciplinary knowledge fusion synergy effect cannot meet the fusion needs, if the interdisciplinary knowledge fusion score is greater than the safety threshold, it means that the output text interdisciplinary knowledge fusion synergy effect can meet the fusion needs, when the interdisciplinary knowledge fusion score is lower than the safety threshold, the large language model is combined with the subject term rewriting template and the semantic reconstruction algorithm to automatically rewrite to eliminate risks, if the output text result is still lower than the safety threshold, based on the error sample analysis, the rewriting rules are manually optimized, the user input and the rewritten output content are used as new training data, and the large language model is fine-tuned again, and through continuous iterative training, the model generates safe subject knowledge fusion in interdisciplinary scenarios.
[0071] Example 2
[0072] like Figure 4 As shown, a large language model security identification system based on scenario analysis is implemented based on the above-mentioned large language model security identification method based on scenario analysis, and specifically includes a subject knowledge base generation module, an input subject matching module, a text subject similarity evaluation module, a semantic similarity evaluation module and an interdisciplinary knowledge fusion scoring module. The subject knowledge base generation module is used to generate a subject knowledge base from the terms and knowledge points of each subject area; the input subject matching module is used to match interdisciplinary scenarios through input text; the text subject similarity evaluation module is used to evaluate text subject similarity through input text matching vectors and output text matching vectors; the semantic similarity evaluation module is used to evaluate the semantic similarity between input text and output text through input text semantic vectors and output text semantic vectors; the interdisciplinary knowledge fusion scoring module is used to perform interdisciplinary knowledge fusion scoring through text subject similarity and semantic similarity.
[0073] Example 3
[0074] This embodiment provides an electronic device, including: a processor and a memory, wherein the memory stores a computer program that can be called by the processor;
[0075] The processor executes the above-mentioned large language model security identification method based on scene analysis by calling the computer program stored in the memory.
[0076] The electronic device may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) and one or more memories, wherein the memory stores at least one computer program, and the computer program is loaded and executed by the processor to implement a multimedia image quality evaluation method based on scene recognition provided by the above method embodiment. The electronic device may also include other components for realizing the functions of the device, for example, the electronic device may also have components such as a wired or wireless network interface and an input and output interface for data input and output. This embodiment will not be described in detail here.
[0077] Example 4
[0078] This embodiment provides a computer-readable storage medium having a rewritable computer program stored thereon;
[0079] When the computer program runs on a computer device, the computer device executes the above-mentioned large language model security identification method based on scenario analysis.
[0080] For example, the computer readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0081] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0082] It should be understood that determining B based on A does not mean determining B only based on A. B can also be determined based on A and / or other information.
[0083] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can 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 or computer programs. When a computer instruction or computer program is loaded or executed on a computer, a process or function according to an embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through a wired network or / and a wireless network. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0084] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0085] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0086] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only one way of division, and there may be other ways of division in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0089] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0090] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to only specific implementation methods. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A large language model security identification method based on scenario analysis, characterized in that: It includes the following specific steps: Build a subject knowledge base and import the terms and knowledge points of each subject area into the subject knowledge base; Construct an input subject matching model and import the input text into the input subject matching model to match the interdisciplinary scenario; Construct a text discipline similarity assessment model, import the input text matching vector and the output text matching vector into the text discipline similarity assessment model to assess the text discipline similarity; represent the selected discipline scenario and the corresponding matching value in the input text in the form of a vector, import the output text into the large language model to obtain the output text and match the discipline scenario, represent the selected discipline scenario and the corresponding matching value in the output text in the form of a vector, substitute the input text matching vector and the output text matching vector into the cosine similarity calculation formula to calculate the text discipline similarity; Construct a semantic similarity evaluation model, import the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text; Construct an interdisciplinary knowledge fusion scoring model, and import text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring.
2. The large language model security identification method based on scenario analysis according to claim 1, characterized in that: The construction of the subject knowledge base and importing the terms and knowledge points of each subject area into the subject knowledge base includes the following specific steps: S11. Obtain academic papers, field reports and professional books data for each discipline, and identify terms and knowledge points within the discipline through information extraction software; S12. Convert the terms and knowledge points in each subject area into vectors, generate the knowledge base vector of each subject, and construct a subject knowledge base based on the knowledge base vector of each subject. The subject knowledge base construction formula is: ,in, is the knowledge base of the ith subject, n is the total number of subjects, is the union of all disciplines, where the knowledge base set of the i-th discipline is expressed as: ,in, is the jth knowledge point of the ith subject, j is any one of 1 to m, and m is the total number of knowledge points of the ith subject.
3. The large language model security identification method based on scenario analysis as claimed in claim 2, characterized in that: The step of constructing an input subject matching model and importing the input text into the input subject matching model to match the interdisciplinary scenario includes the following specific steps: S21, obtaining an input text, dividing the input text into words, identifying keywords in the words through keyword recognition software, and obtaining the frequency of occurrence of the keywords; S22, obtain the keywords in the input text and the knowledge base set of each subject, traverse the keyword list of the input text, match each keyword with the term in the subject knowledge base, record the matched subject, import the matched keyword frequency into the matching value calculation formula to calculate the matching value between the input text and each subject, the matching value calculation formula between the input text and the lth subject is: ,in, is the frequency of occurrence of the kth keyword in the lth subject knowledge base, z is the total number of keywords in the input text, is the frequency of occurrence of the kth keyword in the input text, ; S23. Arrange the calculated matching values of the input text and the lth subject in descending order, and set the first several subjects as selected subject scenarios.
4. The large language model security identification method based on scenario analysis as claimed in claim 3, characterized in that: The construction of the text subject similarity evaluation model and the importation of the input text matching vector and the output text matching vector into the text subject similarity evaluation model to evaluate the text subject similarity include the following specific steps: S31, the subject scenario selected in the input text and the corresponding matching value are expressed in the form of a vector, and the input text matching vector is: ,in, is the lth selected subject scenario, r is the total number of selected subject scenarios, and l belongs to any one of 1 to r. is the matching value between the input text and the lth subject; S32, import the output text into the large language model to obtain the output text, substitute the output text into steps S21-S31, and obtain the output text matching vector: ,in, is the lth output subject scenario, r is the total number of output subject scenarios, and l belongs to any item from 1 to r. is the matching value between the input text and the lth subject; S33, substituting the input text matching vector and the output text matching vector into the text subject similarity calculation formula to calculate the text subject similarity, wherein the text subject similarity calculation formula is: ,in, and They represent the modulus of the input text matching vector and the modulus of the output text matching vector respectively.
5. The large language model security identification method based on scenario analysis as claimed in claim 4, characterized in that: The step of constructing a semantic similarity evaluation model and importing the input text semantic vector and the output text semantic vector into the semantic similarity evaluation model to evaluate the semantic similarity between the input text and the output text comprises the following specific steps: S41. Identify the text semantics of the input text and the output text through a large language model to generate a semantic vector of the input text And output text semantic vector , substitute the input text semantic vector and the output text semantic vector into the semantic similarity formula to calculate the semantic similarity between the input text and the output text, where the semantic similarity calculation formula is: ,in, is the input text semantic vector, To output the text semantic vector, and They represent the modulus of the input text semantic vector and the modulus of the output text semantic vector respectively.
6. The large language model security identification method based on scenario analysis as claimed in claim 5, characterized in that: The construction of the interdisciplinary knowledge fusion scoring model and the introduction of text subject similarity and semantic similarity into the interdisciplinary knowledge fusion scoring model for interdisciplinary knowledge fusion scoring include the following specific steps: S51. Substitute the text subject similarity and semantic similarity into the interdisciplinary knowledge fusion score calculation formula to calculate the interdisciplinary knowledge fusion score, wherein the interdisciplinary knowledge fusion score calculation formula is: , where F is the semantic similarity and G is the text subject similarity. and Represent the first subject and the first Subjects, For the first subject and the The correlation between the first subject and the second subject. The formula for calculating the correlation between subjects is: ,in, and Represent the lth subject knowledge base set and the A collection of subject knowledge bases, is the set of the lth subject knowledge base and the The number of common elements in the subject knowledge base set, is the set of the lth subject knowledge base and the The number of all elements in the subject knowledge base set; S52. Compare the interdisciplinary knowledge fusion score with the interdisciplinary knowledge fusion safety threshold. If the interdisciplinary knowledge fusion score is lower than the safety threshold, it is marked as the interdisciplinary knowledge fusion synergy effect cannot meet the fusion needs. If the interdisciplinary knowledge fusion score is greater than the safety threshold, it means that the output text interdisciplinary knowledge fusion synergy effect can meet the fusion needs.
7. A large language model security identification system based on scenario analysis, which is implemented based on the large language model security identification method based on scenario analysis as claimed in any one of claims 1 to 6, characterized in that: Specifically include: The subject knowledge base generation module is used to generate a subject knowledge base from the terms and knowledge points in each subject area; Input subject matching module, used to match interdisciplinary scenarios through input text; A text subject similarity evaluation module is used to evaluate text subject similarity through input text matching vectors and output text matching vectors; A semantic similarity evaluation module, used for evaluating the semantic similarity between an input text and an output text through an input text semantic vector and an output text semantic vector; The interdisciplinary knowledge fusion scoring module is used to perform interdisciplinary knowledge fusion scoring based on text subject similarity and semantic similarity.
8. An electronic device comprising: A processor and a memory, wherein the memory stores a computer program that can be called by the processor; It is characterized in that the processor executes the large language model security identification method based on scene analysis as described in any one of claims 1 to 6 by calling the computer program stored in the memory.
9. A computer-readable storage medium, characterized in that: Instructions are stored, and when the instructions are executed on a computer, the computer executes the large language model security identification method based on scene analysis as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Author disambiguation method and device based on subject tree clustering
CN111221968A
Intelligent education chat robot training method based on large language model
CN117171322A