# US 2026/0073299 A1 · Methods and apparatuses for training prompt injection detection model, storage media, and electronic devices

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

- Number: US 2026/0073299 A1
- Document ID: US20260073299A1
- Status: Published application
- Kind: A1
- Application number: 19/299,621
- Filed: 2025-08-14
- Published: 2026-03-12
- Earliest claimed: 2024-09-09
- Assignees: Ant Group Co., Ltd.
- Applicants: Ant Group Co., Ltd.
- Inventors: Yan LIU; Haiqin WENG
- Web page: https://patentgrep.com/patent/US20260073299A1

## CPC

- G06N 20/00: Machine learning
- H04L 63/1466: {Active attacks involving interception, injection, modification, spoofing of data unit addresses, e.g. hijacking, packet injection or TCP sequence number attacks}
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

Implementations of this specification disclose methods and apparatuses for training a prompt injection detection model. In an implementation, a method comprises obtaining word feature information corresponding to a prompt training sample, obtaining account feature information based on an account attribute of a user corresponding to the prompt training sample, obtaining dialog feature information based on a historical dialog record of the user for a large language model, and training the prompt injection detection model based on the account feature information, the dialog feature information, and the word feature information, to obtain a trained prompt injection detection model.

## Claims

### Claim 1

A method for training a prompt injection detection model, comprising:
obtaining word feature information corresponding to a prompt training sample, wherein the prompt training sample comprises a normal prompt and a prompt subjected to prompt injection;
obtaining account feature information based on an account attribute of a user corresponding to the prompt training sample;
obtaining dialog feature information based on a historical dialog record of the user for a large language model; and
training the prompt injection detection model based on the account feature information, the dialog feature information, and the word feature information, to obtain a trained prompt injection detection model.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the word feature information comprises first indication information indicating whether the prompt training sample comprises content of ignoring an instruction; and wherein
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the first indication information.

### Claim 3 (depends on 2)

The method according to claim 2, wherein the word feature information further comprises second indication information indicating whether the prompt training sample comprises content of executing a new instruction; and wherein
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the second indication information.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the word feature information comprises third indication information indicating whether the prompt training sample comprises role play content; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the third indication information.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the word feature information further comprises fourth indication information indicating whether the prompt training sample comprises content of overriding a specified role in an instruction; and
the obtaining the word feature information corresponding to the prompt training sample comprises:
obtaining the word feature information based on the third indication information and the fourth indication information.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the word feature information comprises fifth indication information indicating whether the prompt training sample comprises content of acquiring an instruction; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the fifth indication information.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the word feature information comprises sixth indication information indicating whether the prompt training sample comprises content of a sensitive instruction is comprised; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the sixth indication information.

### Claim 8 (depends on 1)

The method according to claim 1, wherein the word feature information comprises seventh indication information indicating whether user input content comprises an injected instruction; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on whether the user input content in the prompt training sample comprises at least one instruction.

### Claim 9 (depends on 8)

The method according to claim 8, wherein the obtaining the word feature information corresponding to the prompt training sample comprises:
obtaining the word feature information based on whether a degree of association between the at least one instruction and an instruction in the prompt training sample is greater than or equal to a predetermined threshold.

### Claim 10 (depends on 8)

The method according to claim 8, wherein the obtaining the word feature information corresponding to the prompt training sample comprises:
obtaining the word feature information based on whether a degree of matching between the at least one instruction and a user profile of the user is greater than or equal to a predetermined threshold.

### Claim 11 (depends on 1)

The method according to claim 1, further comprising:
obtaining target word feature information corresponding to a target prompt to be detected;
obtaining corresponding target account feature information based on an account attribute of a target user corresponding to the target prompt;
obtaining target dialog feature information based on a target historical dialog record of the target questioning user for the large language model; and
inputting the target account feature information, the target dialog feature information, and the target word feature information into the trained prompt injection detection model, to obtain an output result for predicting whether the target prompt is subjected to prompt injection.

### Claim 12

An apparatus for training a prompt injection detection model, comprising:
at least one processor; and
one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to perform operations comprising:
obtaining word feature information corresponding to a prompt training sample, wherein the prompt training sample comprises a normal prompt and a prompt subjected to prompt injection;
obtaining account feature information based on an account attribute of a user corresponding to the prompt training sample;
obtaining dialog feature information based on a historical dialog record of the user for a large language model; and
training the prompt injection detection model based on the account feature information, the dialog feature information, and the word feature information, to obtain a trained prompt injection detection model.

### Claim 13 (depends on 12)

The apparatus according to claim 12, wherein the word feature information comprises first indication information indicating whether the prompt training sample comprises content of ignoring an instruction; and wherein
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the first indication information.

### Claim 14 (depends on 13)

The apparatus according to claim 13, wherein the word feature information further comprises second indication information indicating whether the prompt training sample comprises content of executing a new instruction; and wherein
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the second indication information.

### Claim 15 (depends on 12)

The apparatus according to claim 12, wherein the word feature information comprises third indication information indicating whether the prompt training sample comprises role play content; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the third indication information.

### Claim 16 (depends on 15)

The apparatus according to claim 15, wherein the word feature information further comprises fourth indication information indicating whether the prompt training sample comprises content of overriding a specified role in an instruction; and
the obtaining the word feature information corresponding to the prompt training sample comprises:
obtaining the word feature information based on the third indication information and the fourth indication information.

### Claim 17 (depends on 12)

The apparatus according to claim 12, wherein the word feature information comprises fifth indication information indicating whether the prompt training sample comprises content of acquiring an instruction; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the fifth indication information.

### Claim 18 (depends on 12)

The apparatus according to claim 12, wherein the word feature information comprises sixth indication information indicating whether the prompt training sample comprises content of a sensitive instruction is comprised; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on the sixth indication information.

### Claim 19 (depends on 12)

The apparatus according to claim 12, wherein the word feature information comprises seventh indication information indicating whether user input content comprises an injected instruction; and
the obtaining word feature information corresponding to a prompt training sample comprises:
obtaining the word feature information based on whether the user input content in the prompt training sample comprises at least one instruction.

### Claim 20

A non-transitory, computer-readable medium storing one or more instructions executable by at least one processor to perform operations comprising:
obtaining word feature information corresponding to a prompt training sample, wherein the prompt training sample comprises a normal prompt and a prompt subjected to prompt injection;
obtaining account feature information based on an account attribute of a user corresponding to the prompt training sample;
obtaining dialog feature information based on a historical dialog record of the user for a large language model; and
training the prompt injection detection model based on the account feature information, the dialog feature information, and the word feature information, to obtain a trained prompt injection detection model.
