# US 2025/0165648 A1 · Privacy-preserving prompt engineering for generative artificial intelligence

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

- Number: US 2025/0165648 A1
- Document ID: US20250165648A1
- Status: Published application
- Kind: A1
- Application number: 18/513,334
- Filed: 2023-11-17
- Published: 2025-05-22
- Earliest claimed: 2023-11-17
- Assignees: Sap SE
- Applicants: Sap SE
- Inventors: Laurent Gomez
- Web page: https://patentgrep.com/patent/US20250165648A1

## CPC

- G06F 21/6254: {by anonymising data, e.g. decorrelating personal data from the owner's identification}
- G06F 21/606: {by securing the transmission between two devices or processes}
- G06F 21/6227: {where protection concerns the structure of data, e.g. records, types, queries}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Certain aspects of the disclosure concern a computer-implemented method for improved data security when interacting with a large language model. The method includes receiving a prompt query entered through a user interface, detecting sensitive data in the prompt query that violates a security protocol, generating a modified prompt query which anonymizes the sensitive data, submitting the modified prompt query to a large language model, and receiving a reply generated by the large language model. The reply contains anonymized sensitive data. The method further includes generating a modified reply which deanonymizes the anonymized sensitive data and presenting the modified reply on the user interface.

## Claims

### Claim 1

A computer-implemented method comprising:
receiving a prompt query entered through a user interface;
detecting sensitive data in the prompt query that violates a security protocol;
generating a modified prompt query which anonymizes the sensitive data;
submitting the modified prompt query to a large language model;
receiving a reply generated by the large language model, wherein the reply contains anonymized sensitive data;
generating a modified reply which deanonymizes the anonymized sensitive data; and
presenting the modified reply on the user interface.

### Claim 2 (depends on 1)

The method of claim 1, wherein generating the modified prompt query comprises:
hashing the sensitive data using a hash algorithm to convert one or more pieces of the sensitive data into one or more unique hash values; and
replacing the one or more pieces of the sensitive data in the prompt query with the one or more unique hash values.

### Claim 3 (depends on 2)

The method of claim 2, further comprising persisting a mapping between the one or more pieces of the sensitive data and the one or more unique hash values in a local storage.

### Claim 4 (depends on 3)

The method of claim 3, wherein the anonymized sensitive data in the reply comprises the one or more unique hash values, wherein generating the modified reply comprises replacing the one or more unique hash values in the reply with the one or more pieces of the sensitive data based on the mapping persisted in the local storage.

### Claim 5 (depends on 1)

The method of claim 1, wherein generating the modified prompt query comprises combining the prompt query with a context query, wherein the context query is configured to instruct the large language model to generate a script written in a specified programming language in the reply.

### Claim 6 (depends on 5)

The method of claim 5, wherein generating the modified reply comprises executing the script generated by the large language model.

### Claim 7 (depends on 5)

The method of claim 5, wherein the context query is configured to instruct the large language model to conclude the script with a return statement, which is configured to return a data structure containing computed information based on content of the prompted query.

### Claim 8 (depends on 7)

The method of claim 7, wherein the script is written in JavaScript and the data structure is a JSON structure.

### Claim 9 (depends on 5)

The method of claim 5, wherein the context query is configured to instruct the large language model to use anonymized sensitive data contained in the modified prompt query in the script.

### Claim 10 (depends on 5)

The method of claim 5, wherein the context query is configured to instruct the large language model that the generated script is not enclosed within a named function so that the script is directly executable in a global scope.

### Claim 11

A computing system comprising:
memory;
one or more hardware processors coupled to the memory; and
one or more computer readable storage media storing instructions that, when loaded into the memory, cause the one or more hardware processors to perform operations comprising:
receiving a prompt query entered through a user interface;
detecting sensitive data in the prompt query that violates a security protocol;
generating a modified prompt query which anonymizes the sensitive data;
submitting the modified prompt query to a large language model;
receiving a reply generated by the large language model, wherein the reply contains anonymized sensitive data;
generating a modified reply which deanonymizes the anonymized sensitive data; and
presenting the modified reply on the user interface.

### Claim 12 (depends on 11)

The system of claim 11, wherein generating the modified prompt query comprises:
hashing the sensitive data using a hash algorithm to convert one or more pieces of the sensitive data into one or more unique hash values; and
replacing the one or more pieces of the sensitive data in the prompt query with the one or more unique hash values.

### Claim 13 (depends on 12)

The system of claim 12, wherein the operations further comprise persisting a mapping between the one or more pieces of the sensitive data and the one or more unique hash values in a local storage.

### Claim 14 (depends on 13)

The system of claim 13, wherein the anonymized sensitive data in the reply comprises the one or more unique hash values, wherein generating the modified reply comprises replacing the one or more unique hash values in the reply with the one or more pieces of the sensitive data based on the mapping persisted in the local storage.

### Claim 15 (depends on 11)

The system of claim 11, wherein generating the modified prompt query comprises combining the prompt query with a context query, wherein the context query is configured to instruct the large language model to generate a script written in a specified programming language in the reply.

### Claim 16 (depends on 15)

The system of claim 15, wherein generating the modified reply comprises executing the script generated by the large language model.

### Claim 17 (depends on 15)

The system of claim 15, wherein the context query is configured to instruct the large language model to conclude the script with a return statement, which is configured to return a data structure containing computed information based on content of the prompted query.

### Claim 18 (depends on 15)

The system of claim 15, wherein the context query is configured to instruct the large language model to use anonymized sensitive data contained in the modified prompt query in the script.

### Claim 19 (depends on 15)

The system of claim 15, wherein the context query is configured to instruct the large language model that the generated script is not enclosed within a named function so that the script is directly executable in a global scope.

### Claim 20

One or more non-transitory computer-readable media having encoded thereon computer-executable instructions causing one or more processors to perform a method, the method comprising:
receiving a prompt query entered through a user interface;
detecting sensitive data in the prompt query that violates a security protocol;
generating a modified prompt query which anonymizes the sensitive data;
submitting the modified prompt query to a large language model;
receiving a reply generated by the large language model, wherein the reply contains anonymized sensitive data;
generating a modified reply which deanonymizes the anonymized sensitive data; and
presenting the modified reply on the user interface,
wherein generating the modified prompt query comprises combining the prompt query with a context query, wherein the context query is configured to instruct the large language model to generate a script written in a specified programming language in the reply.
