# US 2025/0384281 A1 · Domain-aware large language model governance

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

- Number: US 2025/0384281 A1
- Document ID: US20250384281A1
- Status: Published application
- Kind: A1
- Application number: 18/745,562
- Filed: 2024-06-17
- Published: 2025-12-18
- Earliest claimed: 2024-06-17
- Assignees: Salesforce, Inc.
- Applicants: Salesforce, Inc.
- Inventors: Sarath Shekkizhar; Adam Earle
- Web page: https://patentgrep.com/patent/US20250384281A1

## CPC

- G06N 3/0895: Weakly supervised learning, e.g. semi-supervised or self-supervised learning
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Techniques are described herein for a method of decreasing the likelihood of out-of-domain LLM responses. The method includes determining, by a block of a LLM, a representation of the text input. The method further includes determining a set of coefficients based at least on a reconstruction of the text input using a dictionary and the representation of the text input. The method further includes performing a sparsity check using the set of coefficients. The method further includes generating a response to the text input based at least on the sparsity check.

## Claims

### Claim 1

A method to constrain responses being generated by a large language model (LLM), the method comprising:
generating, by a prompt manager, an input for the LLM, wherein the input comprises a plurality of tokens;
generating, by the LLM being executed on a processing device, a response to the input, wherein the generating includes:
determining, by a block of the LLM, an output that includes a representation of at least one of the plurality of tokens;
determining a set of coefficients based at least on the output and a template predictor, wherein the template predictor was previously determined to predict templates in a dictionary responsive to outputs from the block, wherein the dictionary defines a previously detected sub-space representing outputs of the block that have a characteristic, wherein the characteristic represents one or more portions of a specific domain or alignment with a policy;
performing a sparsity check using the set of coefficients; and
constraining the response being generated by the LLM when it is determined the response being generated is not within the previously detected subspace based at least in part on the sparsity check; and
causing the response to be presented to a user as at least part of a subsequent turn in a conversation in which the user is actively engaged.

### Claim 2 (depends on 1)

The method of claim 1, wherein the performing comprises:
comparing a number of non-zero elements in the set of coefficients to a sparsity pattern.

### Claim 3 (depends on 2)

The method of claim 2, further comprising:
determining that the response being generated is within the previously detected subspace based on the number of non-zero elements in the set of coefficients satisfying the sparsity pattern.

### Claim 4 (depends on 2)

The method of claim 2, further comprising:
determining that the response being generated is not within the previously detected subspace based on the number of non-zero elements in the set of coefficients not satisfying the sparsity pattern.

### Claim 5 (depends on 4)

The method of claim 4, further comprising:
tracking a number of failed sparsity checks.

### Claim 6 (depends on 1)

The method of claim 1, wherein the dictionary is a first dictionary, and the set of coefficients is a first set of coefficients, further comprising:
determining, by a second block of the LLM, a second output that includes a representation of at least one of the plurality of tokens;
determining a second set of coefficients based at least on the second output and a second dictionary; and
performing a second sparsity check using the second set of coefficients, wherein the constraining is also based at least in part on the second sparsity check.

### Claim 7 (depends on 1)

The method of claim 1, wherein the block of the LLM is at least one of an encoder, a decoder, a transformer, a feed-forward layer, a self-attention layer, or a cross-attention layer.

### Claim 8

A non-transitory computer-readable storage medium storing executable instructions, which when executed by a processing device, cause the processing device to perform operations comprising:
generating, by a prompt manager, an input for a large language model (LLM), wherein the input comprises a plurality of tokens;
generating, by the LLM, a response to the input, wherein the generating includes:
determining, by a block of the LLM, an output that includes a representation of at least one of the plurality of tokens;
determining a set of coefficients based at least on the output and a template predictor, wherein the template predictor was previously determined to predict templates in a dictionary responsive to outputs from the block, wherein the dictionary defines a previously detected sub-space representing outputs of the block that have a characteristic, wherein the characteristic represents one or more portions of a specific domain or alignment with a policy;
performing a sparsity check using the set of coefficients; and
constraining the response being generated by the LLM when it is determined the response being generated is not within the previously detected subspace based at least in part on the sparsity check; and
causing the response to be presented to a user as at least part of a subsequent turn in a conversation in which the user is actively engaged.

### Claim 9 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein the performing comprises:
comparing a number of non-zero elements in the set of coefficients to a sparsity pattern.

### Claim 10 (depends on 9)

The non-transitory computer-readable storage medium of claim 9, wherein the operations further comprise:
determining that the response being generated is within the previously detected subspace based on the number of non-zero elements in the set of coefficients satisfying the sparsity pattern.

### Claim 11 (depends on 9)

The non-transitory computer-readable storage medium of claim 9, wherein the operations further comprise:
determining that the response being generated is not within the previously detected subspace based on the number of non-zero elements in the set of coefficients not satisfying the sparsity pattern.

### Claim 12 (depends on 11)

The non-transitory computer-readable storage medium of claim 11, wherein the operations further comprise:
tracking a number of failed sparsity checks.

### Claim 13 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein the operations further comprise:
determining, by a second block of the LLM, a second output that includes a second representation of at least one of the plurality of tokens;
determining a second set of coefficients based at least on the second output and a second dictionary, wherein the second dictionary is different from the dictionary; and
performing a second sparsity check using the second set of coefficients, wherein the constraining is also based at least in part on the second sparsity check.

### Claim 14 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein the block of the LLM is at least one of an encoder, a decoder, a transformer, a feed-forward layer, a self-attention layer, or a cross-attention layer.

### Claim 15

A system comprising:
a memory component; and
a processing device coupled to the memory component, the processing device to perform operations comprising:
generating, by a prompt manager, and input for a large language model (LLM), wherein the input comprises a plurality of tokens;
generating, by the LLM, a response to the input, wherein the generating includes:
determining, by a block of the LLM, an output that includes a representation of at least one of the plurality of tokens;
determining a set of coefficients based at least on the output and a template predictor, wherein the template predictor was previously determined to predict templates in a dictionary responsive to outputs from the block, wherein the dictionary defines a previously detected sub-space representing outputs of the block that have a characteristic, wherein the characteristic represents one or more portions of a specific domain or alignment with a policy;
performing a sparsity check using the set of coefficients; and
constraining the response being generated by the LLM when it is determined the response being generated is not within the previously detected subspace based at least in part on the sparsity check; and
causing the response to be presented to a user as at least part of a subsequent turn in a conversation in which the user is actively engaged.

### Claim 16 (depends on 15)

The system of claim 15, wherein the operations further comprise:
determining, by a second block of the LLM, a second output that includes a second representation of at least one of the plurality of tokens;
determining a second set of coefficients based at least on the second output and a second dictionary, wherein the second dictionary is different from the dictionary; and
performing a second sparsity check using the second set of coefficients, wherein the constraining is also based at least in part on the second sparsity check.

### Claim 17 (depends on 15)

The system of claim 15, wherein the performing comprises:
comparing a number of non-zero elements in the set of coefficients to a sparsity pattern.

### Claim 18 (depends on 17)

The system of claim 17, wherein the operations further comprise:
determining that the response being generated is within the previously detected subspace based on the number of non-zero elements in the set of coefficients satisfying the sparsity pattern.

### Claim 19 (depends on 17)

The system of claim 17, wherein the operations further comprise:
determining that the response being generated is not within the previously detected subspace based on the number of non-zero elements in the set of coefficients not satisfying the sparsity pattern.

### Claim 20 (depends on 15)

The system of claim 15, wherein the operations further comprise: tracking a number of failed sparsity checks.

### Claim 21 (depends on 1)

The method of claim 1, wherein the constraining includes:
generating, based on the coefficients and the dictionary, a reconstruction representing an in-domain replacement for the output from the block; and
replacing the output from the block with the reconstruction as the input to a device next block of the LLM.

### Claim 22 (depends on 1)

The method of claim 1, wherein the constraining includes causing the response generated by the LLM to be a predetermined response rather than one generated using the blocks of the LLM.

### Claim 23 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein the constraining includes:
generating, based on the coefficients and the dictionary, a reconstruction representing an in-domain replacement for the output from the block; and
replacing the output from the block with the reconstruction as the input to a device next block of the LLM.

### Claim 24 (depends on 8)

The non-transitory computer-readable storage medium of claim 8, wherein the constraining includes causing the response generated by the LLM to be a predetermined response rather than one generated using the blocks of the LLM.

### Claim 25 (depends on 15)

The system of claim 15, wherein the constraining includes:
generating, based on the coefficients and the dictionary, a reconstruction representing an in-domain replacement for the output from the block; and
replacing the output from the block with the reconstruction as the input to a device next block of the LLM.

### Claim 26 (depends on 15)

The system of claim 15, wherein the constraining includes causing the response generated by the LLM to be a predetermined response rather than one generated using the blocks of the LLM.
