Method and apparatus for applying large language model

By extracting the true intent of a large language model and removing non-critical information through a two-stage approach, the threat of jailbreak attacks is addressed, ensuring the security and efficiency of the answers.

WO2026001595A1PCT designated stage Publication Date: 2026-01-02BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/099076
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-28
Filing Date
2025-06-04
Publication Date
2026-01-02

AI Technical Summary

Technical Problem

Large Language Models (LLMs) pose a jailbreak attack threat in practical applications, which is difficult to detect and defend against, leading to the generation of harmful content and affecting security.

Method used

A two-stage approach is adopted: first, a soft extraction stage is used to extract the question with the true intent using preset prompts; then, a hard deletion stage is used to remove non-critical information and use security prompts to ensure that the answer complies with security policies.

Benefits of technology

It effectively defends against jailbreak attacks, ensures that the generated answers comply with security policies, improves the security and response efficiency of the model, and reduces computational costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025099076_02012026_PF_FP_ABST
    Figure CN2025099076_02012026_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in embodiments of the present disclosure are a method and apparatus for applying a large language model. A specific implementation of the method comprises: inputting an original question to be queried and a preset prompt into a large language model, and outputting a first question, wherein the prompt is used for instructing the large language model to extract, from the original question, a question reflecting a real intention; deleting non-key information from the first question to obtain a second question; and inputting the second question and a preset security prompt into the large language model, and outputting an answer, wherein the security prompt is used for indicating that the large language model needs to comply with a security policy when answering a question. The implementation can effectively defend against jailbreak attacks having deceptive and implicit intentions.
Need to check novelty before this filing date? Find Prior Art

Description

Method and apparatus for applying large language model

[0001] Cross-reference to Related Applications

[0002] The present application claims priority to Chinese Patent Application 202410850763.9 entitled "Method and apparatus for applying large language model" filed on June 27, 2024, the disclosure of which is hereby incorporated by reference in its entirety into this application as part or parts thereof. TECHNICAL FIELD

[0003] Embodiments of the present disclosure relate to the field of computer technology, in particular to a method and apparatus for applying large language model. BACKGROUND

[0004] With the deep integration of large language models in practical applications, the inherent potential security flaws of these frameworks have come to the surface. These vulnerabilities can be exploited for harmful purposes, such as creating harmful content and supporting illegal activities. One of the main challenges facing LLM (Large Language Model) security is the threat of jailbreaking attacks, which can bypass the calibration mechanisms and security measures of LLMs by embedding malicious queries in carefully designed prompts, leading to the generation of harmful content. These attacks are difficult to detect, and the widespread adoption of LLMs poses a significant obstacle. SUMMARY

[0005] Embodiments of the present disclosure provide a method and apparatus for applying large language model.

[0006] According to a first aspect of the present disclosure, embodiments of the present disclosure provide a method for applying a large language model, comprising: inputting an original question to be queried together with a preset prompt into a large language model, outputting a first question, wherein the prompt is used to instruct the large language model to extract a question reflecting the real intention from the original question; deleting non-key information from the first question to obtain a second question; inputting the second question together with a preset security prompt into the large language model, outputting an answer, wherein the security prompt is used to instruct the large language model to comply with the security policy when answering the question.

[0007] In some embodiments, the first question includes a target sentence; and the removing non-key information from the first question to obtain a second question includes: marking words in the first question to obtain a first mark sequence; removing a predetermined number of marks in any combination from the first mark sequence to obtain at least one second mark sequence; inputting texts corresponding to the at least one second mark sequence into a large language model together with the prompt to obtain a probability of generating the target sentence; and determining a second mark sequence with a probability of generating the target sentence greater than a predetermined threshold as the second question.

[0008] In some embodiments, the determining the second mark sequence with the probability of generating the target sentence greater than the predetermined threshold as the second question includes: calculating a loss value of each second mark sequence according to a negative logarithm of a probability of generating the target sentence by each second mark sequence; and determining a second mark sequence with a minimum loss value as the second question.

[0009] In some embodiments, the determining the second mark sequence with the probability of generating the target sentence greater than the predetermined threshold as the second question includes: calculating a loss value of each second mark sequence according to a negative logarithm of a probability of generating the target sentence by each second mark sequence; calculating a gradient of each mark based on the loss value of each second mark sequence; and removing a mark with a minimum gradient from the first mark sequence to obtain the second question.

[0010] In some embodiments, the determining the second mark sequence with the probability of generating the target sentence greater than the predetermined threshold as the second question includes: marking words in the second question to obtain a third mark sequence; removing a predetermined number of marks in any combination from the third mark sequence to obtain at least one fourth mark sequence; inputting texts corresponding to the at least one fourth mark sequence into a large language model together with the prompt to obtain a probability of generating the target sentence; and determining a fourth mark sequence with a probability of generating the target sentence greater than a predetermined threshold as an updated second question.

[0011] In some embodiments, the method further includes: inputting the second question into a large language model together with a preset prompt to output a third question; and inputting the third question into the large language model together with a preset safety prompt to output an answer.

[0012] In some embodiments, the outputting the answer includes: in response to detecting that the second question does not comply with a safety policy, outputting information of refusing to answer.

[0013] According to a second aspect of the present disclosure, embodiments of the present disclosure provide an apparatus for applying a large language model, comprising: an extraction unit configured to input an original question to be queried and a preset prompt into a large language model, and output a first question, wherein the prompt is used to instruct the large language model to extract a question reflecting a real intention from the original question; a deletion unit configured to delete non-key information from the first question to obtain a second question; and a questioning unit configured to input the second question and a preset security prompt into the large language model, and output an answer, wherein the security prompt is used to instruct the large language model to answer the question in compliance with a security policy.

[0014] According to a third aspect of the present disclosure, embodiments of the present disclosure provide an electronic device, comprising: one or more processors; and a storage device having stored thereon one or more computer programs that, when executed by the one or more processors, cause the one or more processors to implement the method according to any one of the first aspect or the second aspect.

[0015] According to a fourth aspect of the present disclosure, embodiments of the present disclosure provide a computer-readable medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the method according to any one of the first aspect or the second aspect.

[0016] According to a fifth aspect of the present disclosure, embodiments of the present disclosure provide a computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of the first aspect or the second aspect.

[0017] It should be understood that the description in this section is not intended to identify key or essential features of embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0018] Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description when read in conjunction with the accompanying drawings:

[0019] FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure can be applied;

[0020] FIG. 2 is a flowchart of one embodiment of a method for applying a large language model according to the present disclosure;

[0021] FIG. 3 is a schematic diagram of one application scenario of the method for applying a large language model according to the present disclosure;

[0022] FIG. 4 is a flowchart of yet another embodiment of the method for applying a large language model according to the present disclosure;

[0023] Figure 5 is a schematic diagram of a structure of an embodiment of the application of a large language model device according to the present disclosure;

[0024] Figure 6 is a schematic diagram of the structure of a computer system suitable for implementing embodiments of the present disclosure. Detailed Implementation

[0025] The present disclosure will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0026] It should be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0027] Figure 1 illustrates an exemplary system architecture 100 to which embodiments of the Applied Large Language Modeling method or Applied Large Language Modeling apparatus of this disclosure may be applied.

[0028] As shown in Figure 1, the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 serves as the medium for providing communication links between the terminal devices 101, 102, and 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0029] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as large language model applications, 3D video players, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social media platform software, etc.

[0030] Terminal devices 101, 102, and 103 can be either hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices with displays, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, and desktop computers, etc. When terminal devices 101, 102, and 103 are software, they can be installed in the aforementioned electronic devices. They can be implemented as multiple software programs or software modules (e.g., to provide distributed services) or as a single software program or software module. No specific limitations are imposed here.

[0031] Server 105 may be a server equipped with a large language model to provide large language services, such as a question-and-answer server that generates answers to questions submitted by terminal devices 101, 102, and 103. The question-and-answer server can extract the real question from the user's submitted question based on preset prompts and security prompts, simplify the question, generate an answer through the large language model, and then return it to the terminal device.

[0032] It's important to note that a server can be either hardware or software. When a server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When a server is software, it can be implemented as multiple software programs or software modules (e.g., multiple software programs or software modules used to provide distributed services), or as a single software program or software module. No specific limitations are made here. A server can also be a server for a distributed system, or a server integrated with blockchain technology. A server can also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.

[0033] It should be noted that the application of the large language model method provided in the embodiments of this disclosure is generally executed by the server 105, and correspondingly, the application of the large language model device is generally set in the server 105.

[0034] It should be understood that the number of terminal devices, networks, and servers shown in Figure 1 is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0035] Referring again to Figure 2, a flow 200 of an embodiment of the applied large language model method according to this disclosure is shown. This applied large language model method includes the following steps:

[0036] Step 201: Input the original question to be queried and the preset prompts into the large language model, and output the first question.

[0037] In this embodiment, the execution entity applying the large language model method (such as the server shown in Figure 1) can receive the original question to be queried sent by the terminal device via a wired or wireless connection.

[0038] The original question can be generated through jailbreak attacks. Jailbreak attacks on a securely trained model are performed by submitting jailbreak hints (P). JB This is an attempt to elicit a response related to the malicious question 'q'. Let 'q'... JB This indicates the entire jailbreak query:

[0039] in This indicates a combination operation. Stages 1, 2, and 3 provide examples of our application of formula (1).

[0040] This application includes a pre-defined prompt (P) Extract To retrieve jailbreak query information Q JB The real problem is q′. Given a jailbreak query Q. JB The `Extract(·)` function is used to remove irrelevant parts of the jailbreak query that could negatively impact the output, with the goal of generating a `q′` that doesn't deviate from the original question's semantics. This can be represented as: `q′~Extract(Q)` JB #(2)

[0041] In practical implementation, Extract can be implemented by providing prompts. Specifically,

[0042] Where P Extract It's a soft extraction cue used to elicit the real question. Stage 4 demonstrates P Extract Specific applications:

[0043] Hint (P) Extract The output of the large language model can include the target statement, such as "Question (excluding user bias):", which indicates that the output of the large language model must include the target statement to achieve the expected result.

[0044] Step 202: Remove non-critical information from the first question to obtain the second question.

[0045] In this embodiment, after the soft extraction stage, the true intent of a jailbreak attack with an obvious intent can be extracted. However, soft extraction cannot play a good role in jailbreak attacks with unclear intent and complex prompts, so a hard deletion part is introduced.

[0046] Non-critical information can be words without actual meaning, such as interjections, ba, ma, wow.

[0047] You can also filter out non-critical information by setting a filter word list.

[0048] Alternatively, a pre-trained keyword extraction model (e.g., a named entity recognition model) can be used to extract keywords and filter out non-critical information.

[0049] Step 203: Input the second question and the preset safety prompt into the large language model and output the answer.

[0050] In this embodiment, the security prompt is used to instruct the large language model to comply with security policies when answering questions.

[0051] Instead of the original question, a regenerated real question q′ is used to produce the final response y from a large language model (LLM).

[0052] Among them, safety prompt P Security It was used to ensure that the final response strictly adhered to security policies, thereby guaranteeing the exclusion of any unsafe information. Phase 5 demonstrated P Security Detailed information.

[0053] The method provided in the above embodiments of this disclosure proposes a two-stage approach to revealing true intent, namely "true intent defense," which includes a "soft extraction" stage and a "hard deletion" stage. The former stage extracts unbiased and truthful questions using a large language model through cue engineering. The "hard deletion" stage removes the least important parts of the sentence. Finally, the extracted truthful questions, along with safety cue, are input into the target LLM to generate a response. Given that these questions typically contain fewer tags and have clear intent, the target LLM can easily defend against them.

[0054] In some optional implementations of this embodiment, the first problem includes a target statement; and the step of deleting non-critical information from the first problem to obtain a second problem includes: marking the words in the first problem to obtain a first marking sequence; deleting a predetermined number of markings from the first marking sequence in any combination to obtain at least one second marking sequence; inputting the text corresponding to at least one second marking sequence together with the prompt into a large language model to obtain the probability of generating the target statement; and determining the second marking sequence whose probability of generating the target statement is greater than a predetermined threshold as the second problem.

[0055] Due to the inherent limitations of Large Language Models (LLMs), soft extraction frameworks often inadvertently contain irrelevant information when extracting true intent from long-text jailbreak attack queries, failing to reliably uncover the actual intent. To mitigate this issue, this application extracts true intent by removing tags that have the least impact on prediction results in jailbreak attacks. In the soft extraction framework, when the jailbreak query Q... JB When input into an LLM, the entire query Q can be represented as:

[0056] The target output T of the function LLM(Q) is the real question, i.e., "question (excluding user bias): [real question]". The question can be segmented and labeled using a word segmentation algorithm. LLM is derived from a sequence of labeled sequences x. 1:n (where each x) i It is a mapping from the elements of set Q (where n is the number of tags in the entire query Q) to the probability distribution of possible subsequent tags. Specifically, for any x... n+1 ∈T, use the following notation to denote the preceding label x. 1:n In this case, the next label is x n+1 The probability of: p(x) n+1 |x 1:n ), #(6)

[0057] Therefore, writing Let x represent generating a sequence x given all the markers leading to that point. n+1:n+t The probability of each individual label in the array, i.e.:

[0058] Where t represents the size of the target output T. This application focuses on generating a target statement (e.g., the token sequence representing the phrase "Question (excluding user bias):" in the table above) after removing some words from the question. The probability of.

[0059] Each time, a predetermined number of tokens are deleted, which can be one or more. Each token can represent one or more words. For example, three tokens can be deleted each time, and there can be multiple combinations of deletion methods, such as deleting the first three tokens, deleting the last three tokens, etc. Each deletion method will result in a second token sequence.

[0060] The second labeled sequence, whose probability of generating the target statement is greater than a predetermined threshold, is identified as the second problem. If, after deleting some words, the target statement "Problem (excluding user bias):" is still output with a high probability, it indicates that the deleted words will not affect the final result, and this non-critical information can be deleted to optimize the problem.

[0061] In some optional implementations of this embodiment, determining the second labeled sequence whose probability of generating the target statement is greater than a predetermined threshold as the second problem includes: calculating the loss value of each second labeled sequence based on the negative logarithm of the probability of generating the target statement from each second labeled sequence; and determining the second labeled sequence with the smallest loss value as the second problem.

[0062] The jailbreak query loss that this application focuses on consists of some target labeled sequences. (That is, the negative log probability representing the phrase "problem (excluding user bias):")

[0063] Therefore, optimizing jailbreak query tasks can be written as an optimization problem:

[0064] Where x i ∈Q JB This indicates that during the optimization process, only Q... JB Some parts were optimized, while P Extract Some parts are not optimized.

[0065] In some optional implementations of this embodiment, determining the second label sequence whose probability of generating the target statement is greater than a predetermined threshold as the second problem includes: calculating the loss value of each second label sequence based on the negative logarithm of the probability of generating the target statement from each second label sequence; calculating the gradient of each label based on the loss value of each second label sequence; and deleting the label with the smallest gradient from the first label sequence to obtain the second problem.

[0066] To optimize objective (9), optimization can be performed on a series of discrete inputs. The motivation for this method stems from a greedy gradient-based approach: if every tag in the query can be evaluated, the tag with the least impact on the query can be removed, allowing for the use of fewer tags to represent similar semantics. Therefore, the least important tag in the query can be evaluated using the gradient associated with the one-hot tag indicator. Specifically, forward propagation is used to compute a linearized approximation of the i-th tag in the prompt, x. i The gradient is expressed as:

[0067] in Let represent the one-hot vector (i.e., a vector with 1 at one position and 0 at the others) representing the current value of the i-th tag. Note that since large language models typically form embeddings for each tag, they can be written as this value. The function is such that its gradient can be taken immediately. The top p negative values ​​with the largest gradients are selected as markers for deletion and removed from the original query. This complete method is called greedy gradient deletion. Stages 7 and 8 illustrate the optimized query Q in this context. ′ And the real question at the end, q′.

[0068] In some optional implementations of this embodiment, determining the second labeled sequence with a probability greater than a predetermined threshold for generating the target statement as the second question includes: labeling the words in the second question to obtain a third labeled sequence; deleting a predetermined number of labels from the third labeled sequence in any combination to obtain at least one fourth labeled sequence; inputting the text corresponding to the at least one fourth labeled sequence along with the prompt into the large language model to obtain the probability of generating the target statement; and determining the fourth labeled sequence with a probability greater than a predetermined threshold as the updated second question. Unimportant words in the question can be deleted multiple times to further optimize the question and improve the accuracy of the large language model's answer.

[0069] In some optional implementations of this embodiment, the output answer includes: in response to detecting that the second question does not comply with the security policy, outputting a message of refusal to answer. Refusing to answer the question when it is detected that the user's actual intent is to attack can defend against attacks.

[0070] Referring again to Figure 3, which is a schematic diagram of an application scenario of the large language model method according to this embodiment, in the application scenario of Figure 3, during the soft extraction stage, the user submits a jailbreak query Q to the server through the terminal device. JB The server will jailbreak and query Q. JB And soft extraction prompt P ExtractThe input is fed into a large language model, which extracts the real question Q. Then, in the hard deletion phase, unimportant words are removed from the real question, resulting in an optimized real question Q′. Finally, the optimized real question Q′ and the security hint P are compared... Security The input is combined with a large language model. The model determines that the real question does not comply with security policies and refuses to answer. This can help defend against jailbreak attacks.

[0071] Referring further to Figure 4, a flow 400 of another embodiment of the large language model method is illustrated. This flow 400 of the large language model method includes the following steps:

[0072] Step 401: Input the original question to be queried and the preset prompts into the large language model, and output the first question.

[0073] Step 402: Remove non-critical information from the first question to obtain the second question.

[0074] Steps 401-402 are basically the same as steps 201-202, so they will not be described again.

[0075] Step 403: Input the second question and the preset prompts into the large language model, and output the third question.

[0076] In this embodiment, the optimized second question is input into the large language model along with the preset prompts to extract the real question again, which can improve the accuracy of intent recognition and obtain a more accurate question.

[0077] Step 404: Input the third question along with the preset safety prompt into the large language model and output the answer.

[0078] In this embodiment, the difference from step 203 is that the second problem in step 203 is replaced with the third problem, so it will not be described again.

[0079] The proposed solution fully reveals the user's true intent, making defense mechanisms difficult to bypass and preventing attackers from triggering unsafe behavior in the model through carefully crafted inputs. Furthermore, it eliminates the need for extensive computational resources for intent recognition and security checks when handling complex and ambiguous inputs, thereby reducing computational costs and improving the model's response efficiency.

[0080] Referring further to Figure 5, as an implementation of the methods shown in the above figures, this disclosure provides an embodiment of an application of a large language model device, which corresponds to the method embodiment shown in Figure 2, and the device can be specifically applied to various electronic devices.

[0081] As shown in Figure 5, the large language model application device 500 of this embodiment includes: an extraction unit 501, a deletion unit 502, and a questioning unit 503. The extraction unit 501 is configured to input the original question to be queried along with a preset prompt into the large language model and output a first question, wherein the prompt is used to instruct the large language model to extract a question reflecting the true intent from the original question; the deletion unit 502 is configured to delete non-critical information from the first question to obtain a second question; the questioning unit 503 is configured to input the second question along with a preset security prompt into the large language model and output an answer, wherein the security prompt is used to instruct the large language model to comply with security policies when answering the question.

[0082] In this embodiment, the specific processing of the extraction unit 501, deletion unit 502 and questioning unit 503 of the large language model device 500 can be referred to steps 201, 202 and 203 in the embodiment corresponding to Figure 2.

[0083] In some optional implementations of this embodiment, the first problem includes a target statement; and the deletion unit 502 is further configured to: mark the words in the first problem to obtain a first mark sequence; delete a predetermined number of marks from the first mark sequence in any combination to obtain at least one second mark sequence; input the text corresponding to at least one second mark sequence together with the prompt into a large language model to obtain the probability of generating the target statement; and determine the second mark sequence whose probability of generating the target statement is greater than a predetermined threshold as the second problem.

[0084] In some optional implementations of this embodiment, the deletion unit 502 is further configured to: calculate the loss value of each second tag sequence based on the negative logarithm of the probability of generating the target statement according to each second tag sequence; and determine the second tag sequence with the smallest loss value as the second problem.

[0085] In some optional implementations of this embodiment, the deletion unit 502 is further configured to: calculate the loss value of each second label sequence based on the negative logarithm of the probability of generating the target statement according to each second label sequence; calculate the gradient of each label based on the loss value of each second label sequence; and delete the label with the smallest gradient from the first label sequence to obtain the second problem.

[0086] In some optional implementations of this embodiment, the deletion unit 502 is further configured to: mark the words in the second question to obtain a third mark sequence; delete a predetermined number of marks from the third mark sequence in any combination to obtain at least one fourth mark sequence; input the text corresponding to the at least one fourth mark sequence together with the prompt into a large language model to obtain the probability of generating the target sentence; and determine the fourth mark sequence with the probability of generating the target sentence greater than a predetermined threshold as the updated second question.

[0087] In some optional implementations of this embodiment, the device further includes a loop unit (not shown in the figures), configured to: input the second question and a preset prompt into the large language model, and output a third question; input the third question and a preset security prompt into the large language model, and output the answer.

[0088] In some optional implementations of this embodiment, the questioning unit 503 is further configured to: output a message of refusal to answer in response to detecting that the second question does not comply with the security policy.

[0089] It should be noted that the collection, gathering, updating, analysis, processing, use, transmission, and storage of user personal information involved in this disclosed technical solution all comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken to prevent unauthorized access to user personal information data and to safeguard user personal information security, network security, and national security.

[0090] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.

[0091] An electronic device includes: one or more processors; and a storage device having one or more computer programs stored thereon, which, when executed by the one or more processors, cause the one or more processors to implement the method described in process 200 or 400.

[0092] A computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in process 200 or 400.

[0093] Figure 6 illustrates a schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0094] As shown in Figure 6, device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 602 or a computer program loaded from storage unit 608 into random access memory (RAM) 603. RAM 603 may also store various programs and data required for the operation of device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.

[0095] Multiple components in device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of monitors, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0096] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as road planning methods. For example, in some embodiments, the road planning method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the road planning method described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the road planning method by any other suitable means (e.g., by means of firmware).

[0097] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0098] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0099] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0100] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0101] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0102] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be servers in distributed systems or servers incorporating blockchain technology. Servers can also be cloud servers, or intelligent cloud computing servers or intelligent cloud hosts with artificial intelligence technology.

[0103] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0104] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for applying a large language model, comprising: The original question to be queried and the preset prompts are input into the large language model, and the first question is output. The prompts are used to instruct the large language model to extract questions that reflect the true intent from the original question. By removing non-critical information from the first question, we obtain the second question. The second question is input into the large language model along with a preset security prompt, and the answer is output. The security prompt is used to instruct the large language model to comply with security policies when answering the question.

2. The method according to claim 1, wherein, The first question includes the target statement; and The step of deleting non-critical information from the first question to obtain the second question includes: The words in the first question are labeled to obtain the first labeled sequence; A predetermined number of tags are deleted from the first tag sequence in any combination to obtain at least one second tag sequence; Input the text corresponding to at least one second-marked sequence together with the prompt into the large language model to obtain the probability of generating the target sentence; The second labeled sequence with a probability greater than a predetermined threshold for generating the target statement is identified as the second problem.

3. The method according to claim 2, wherein, The step of identifying the second labeled sequence, in which the probability of generating the target statement is greater than a predetermined threshold, as the second problem includes: The loss value of each second-labeled sequence is calculated based on the negative logarithm of the probability of generating the target statement from each second-labeled sequence; The second labeled sequence with the smallest loss value is identified as the second problem.

4. The method according to claim 2, wherein, The step of identifying the second labeled sequence, in which the probability of generating the target statement is greater than a predetermined threshold, as the second problem includes: The loss value of each second-labeled sequence is calculated based on the negative logarithm of the probability of generating the target statement from each second-labeled sequence; The gradient of each label is calculated based on the loss value of each second label sequence; The label with the smallest gradient is removed from the first label sequence, leading to the second problem.

5. The method according to claim 2, wherein, The step of identifying the second labeled sequence, in which the probability of generating the target statement is greater than a predetermined threshold, as the second problem includes: The words in the second question are labeled to obtain the third labeled sequence; A predetermined number of tags are deleted from the third tag sequence in any combination to obtain at least one fourth tag sequence; Input the text corresponding to at least one fourth tag sequence together with the prompt into the large language model to obtain the probability of generating the target sentence; The fourth tag sequence whose probability of generating the target statement is greater than a predetermined threshold is identified as the updated second problem.

6. The method according to claim 1, wherein, The method further includes: Input the second question along with the preset prompts into the large language model, and output the third question; The third question, along with a preset security prompt, is input into the large language model, and the answer is output.

7. The method according to claim 1, wherein, The output answer includes: In response to the detection that the second question does not comply with the security policy, a message of refusal to answer is output.

8. An apparatus for applying a large language model, comprising: The extraction unit is configured to input the original question to be queried along with a preset prompt into the large language model and output a first question, wherein the prompt is used to instruct the large language model to extract a question that reflects the true intent from the original question; The deletion unit is configured to remove non-critical information from the first question to obtain the second question; The questioning unit is configured to input the second question along with a preset security prompt into the large language model and output an answer, wherein the security prompt is used to instruct the large language model to comply with security policies when answering the question.

9. An electronic device, comprising: One or more processors; Storage device, on which one or more computer programs are stored, When the one or more computer programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.

10. A computer-readable medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.

11. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Request processing method and device, electronic equipment and storage medium

    CN116955760A

  • Prison break attack instruction data generation method and device, medium and equipment

    CN117131513A

  • Fuzzy test-based large language model vulnerability detection method and device

    CN117370994A

  • Generation method and device of cue word information of large language model, equipment and medium

    CN117539975A

  • Large language model security test method and device based on tabu search algorithm

    CN118132748A