# US 2025/0165590 A1 · Preventing attacks on generative models

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0165590 A1
- Document ID: US20250165590A1
- Status: Published application
- Kind: A1
- Application number: 18/516,862
- Filed: 2023-11-21
- Published: 2025-05-22
- Earliest claimed: 2023-11-21
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Keegan HINES; Gary David LOPEZ MUNOZ
- Web page: https://patentgrep.com/patent/US20250165590A1

## CPC

- G06F 21/552: {involving long-term monitoring or reporting}
- G06F 40/30: Semantic analysis
- G06F 40/56: Natural language generation
- G06F 2221/033: Test or assess software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A computer-implemented method is provided that prevents prompt injection attacks against generative models. Input data is received, and a first prompt section is generated from the input data. First, second and third instructions are received, which respectively instruct the generative model to carry out a task based on the first prompt section, inform the generative model of a boundary of the first prompt section, and instruct the generative model to ignore any instructions in present in the first prompt section. A prompt for the generative model is generated from the first prompt section and the first instructions, second instructions and third instructions.

## Claims

### Claim 1

A computer-implemented method, comprising:
receiving input data;
generating, from the input data, a first prompt section;
receiving first instructions that instruct a generative model to carry out a task based on the first prompt section;
receiving second instructions that inform the generative model of a boundary of the first prompt section;
receiving third instructions that instruct the generative model to ignore any instructions present in the first prompt section, the first instructions, second instructions and third instructions forming a second prompt section; and
generating a prompt for the generative model, the prompt comprising the first prompt section and the second prompt section.

### Claim 2 (depends on 1)

The method of claim 1, wherein generating the first prompt section comprises applying a transformation to the input data to generate transformed input data, and the second instructions comprise an explanation of the transformation.

### Claim 3 (depends on 2)

The method of claim 2, wherein applying the transformation comprises interleaving the input data with a special character.

### Claim 4 (depends on 2)

The method of claim 2, wherein applying the transformation comprises encoding the input data.

### Claim 5 (depends on 1)

The method of claim 1, wherein generating the first prompt section comprises enclosing the input data in delimiters, and wherein the second instructions explain the delimiters.

### Claim 6 (depends on 1)

The method of claim 1, comprising retrieving a template prompt comprising the first, second and third instructions.

### Claim 7 (depends on 1)

The method of claim 1, comprising receiving user input comprising the first instructions.

### Claim 8 (depends on 1)

The method of claim 1, comprising retrieving the input data from a database.

### Claim 9 (depends on 1)

The method of claim 1, comprising retrieving the input data from a webpage.

### Claim 10 (depends on 1)

The method of claim 1, wherein the task is one of: summarization, question answering, translation, or code generation.

### Claim 11 (depends on 1)

The method of claim 1, comprising:
providing the prompt as input to the generative model; and
receiving a response from the generative model, the response comprising a result of the task.

### Claim 12 (depends on 11)

The method of claim 11, comprising displaying the result of the task on a user interface.

### Claim 13 (depends on 11)

The method of claim 11, comprising carrying out an action based on the result of the task, wherein the action is one of: sending an email, executing a banking transaction, and executing code comprised in the task result.

### Claim 14

A non-transitory computer-readable medium storing a template prompt for a generative model, the template prompt comprising:
a field for receiving a first prompt section generated from input data;
first instructions that instruct the generative model to carry out a task based on the first prompt section;
second instructions that inform the generative model of a boundary of the first prompt section; and
third instructions that instruct the generative model to ignore any instructions in present in the first prompt section.

### Claim 15 (depends on 14)

The non-transitory computer-readable medium of claim 14, wherein the second instructions comprise an explanation of a transformation applied to the input data to generate the first prompt section.

### Claim 16 (depends on 15)

The non-transitory computer-readable medium of claim 15, wherein the transformation is interleaving the input data with a special character.

### Claim 17 (depends on 15)

The non-transitory computer-readable medium of claim 15, wherein the transformation is encoding the input data.

### Claim 18 (depends on 14)

The non-transitory computer-readable medium of claim 14, wherein:
the second instructions explain delimiters used to enclose the first prompt section; and
the template prompt comprises the delimiters.

### Claim 19

A system comprising: a processor and a memory, the memory storing computer-readable instructions, which when executed by the processor, cause the system to perform operations comprising:
receiving input data;
generating, from the input data, a first prompt section;
receiving first instructions that instruct the generative model to carry out a task based on the first prompt section;
receiving second instructions that inform the generative model of a boundary of the first prompt section;
receiving third instructions that instruct the generative model to ignore any instructions present in the first prompt section, the first instructions, second instructions and third instructions forming a second prompt section; and
generating a prompt for the generative model, the prompt comprising the first prompt section and the second prompt section.

### Claim 20 (depends on 19)

The system of claim 19, the memory storing a template prompt for the generative model, the template prompt comprising:
a field for receiving the first prompt section; and
the second prompt section.
