# US 2026/0064971 A1 · Large language model explainability via counterfactuals

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

- Number: US 2026/0064971 A1
- Document ID: US20260064971A1
- Status: Published application
- Kind: A1
- Application number: 18/821,982
- Filed: 2024-08-30
- Published: 2026-03-05
- Earliest claimed: 2024-08-30
- Assignees: Intuit Inc.
- Applicants: Intuit Inc.
- Inventors: Yair HORESH; Aleksandr KIM; Meghan Rose Khemaissa Mergui LAHMI; Jonathan RABIN
- Web page: https://patentgrep.com/patent/US20260064971A1

## CPC

- G06F 40/289: Phrasal analysis, e.g. finite state techniques or chunking
- G06F 40/30: Semantic analysis
- G06F 40/40: Processing or translation of natural language (natural language analysis G06F40/20; semantic analysis G06F40/30)
- G06F 40/56: Natural language generation
- G06N 3/0475: Generative networks
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A method includes obtaining a prompt to a field large language model (LLM) and a corresponding original response generated by the field LLM. A first phrase is selected from the prompt. A syntactic phrase set, and a semantic phrase set are obtained for the first phrase from a domain corpus. A counterfactual set is selected, including phrases co-occurring in the syntactic phrase set and the semantic phrase set. A counterfactual score is assigned for each counterfactual of the counterfactual set. A first counterfactual is selected from a counterfactual subset of the counterfactual set having highest counterfactual scores. The first phrase in the prompt is replaced with the first counterfactual to obtain a modified prompt. The modified prompt is processed by the field LLM to obtain a modified response. The first phrase and first counterfactual identified from the counterfactual subset are stored as a first phrase pair in a data repository.

## Claims

### Claim 1

A method comprising:
obtaining a prompt to a field large language model (LLM) and a corresponding original response generated by the field LLM;
selecting a first phrase from a selected plurality of phrases from the prompt;
obtaining a syntactic phrase set for the first phrase from a domain corpus;
obtaining a semantic phrase set for the first phrase from the domain corpus;
selecting a counterfactual set including phrases co-occurring in the syntactic phrase set and the semantic phrase set;
assigning a counterfactual score for each counterfactual of the counterfactual set;
selecting a first counterfactual from a counterfactual subset of the counterfactual set having highest counterfactual scores;
replacing the first phrase in the prompt with the first counterfactual to obtain a modified prompt and processing the modified prompt by the field LLM to obtain a modified response; and
storing the first phrase and at least one strongest counterfactual of the counterfactual subset as a first phrase pair in a data repository.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
obtaining the syntactic phrase set for the first phrase from the domain corpus by:
obtaining a first syntactic embedding corresponding to the first phrase from a syntactic embedding model,
searching an embedding store for syntactic embeddings corresponding to phrases in the domain corpus that are similar to the first syntactic embedding, and
selecting the phrases in the domain corpus as the syntactic phrase set.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
obtaining the semantic phrase set for the first phrase from the domain corpus by:
obtaining a first semantic embedding corresponding to the first phrase from a semantic embedding model,
searching an embedding store for semantic embeddings corresponding to phrases in the domain corpus that are distant to the first semantic embedding, and
selecting the phrases in the domain corpus as the semantic phrase set.

### Claim 4 (depends on 1)

The method of claim 1, further comprising:
assigning the counterfactual score for each counterfactual of the counterfactual set as a syntactic embedding cosine distance of the each counterfactual with respect to the first phrase, divided with a semantic embedding cosine distance of the each counterfactual with respect to the first phrase.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
prior to storing the first phrase and the at least one strongest counterfactual:
determining a response score corresponding to the modified response as a semantic similarity score of the modified response to the original response based on a scoring function,
replacing the first phrase with each counterfactual from the counterfactual subset to obtain corresponding modified responses and a corresponding set of response scores corresponding to the first phrase, and
determining the at least one strongest counterfactual of the counterfactual subset that corresponds to a lowest response score of the set of response scores corresponding to the first phrase.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
pairing each selected phrase from the selected plurality of phrases with at least one corresponding strongest counterfactual; and
storing the each selected phrase and the at least one corresponding strongest counterfactual as a next phrase-pair in the data repository.

### Claim 7 (depends on 1)

The method of claim 1, further comprising:
constructing an explainability model for the LLM with respect to the prompt based on a plurality of phrase-pairs corresponding the plurality of selected phrases from the prompt.

### Claim 8 (depends on 1)

The method of claim 1, further comprising:
modifying instructions of the prompt based on an explainability model to cause the LLM to generate a new response, wherein the new response is semantically similar to an expected response, and wherein a first response similarity score of the new response to the expected response is higher than a second response similarity score of the original response to the expected response.

### Claim 9 (depends on 1)

The method of claim 1 further comprising:
generating a plurality of syntactic embeddings from the domain corpus by a syntactic embedding model, wherein the syntactic embedding model is trained to generate first word embeddings using a short context window of two words;
storing the plurality of syntactic embeddings in an embedding store;
generating a plurality of semantic embeddings from the domain corpus by a semantic embedding model, wherein the semantic embedding model is trained to generate second word embeddings using a long context window of twenty words; and
storing the plurality of semantic embeddings in the embedding store.

### Claim 10

A system comprising:
at least one computer processor;
a field LLM executing on the at least one computer processor;
an enterprise application executing on the at least one computer processor;
a developer application executing on the at least one computer processor;
a domain corpus in a data repository stored on a physical storage device;
an embedding store in the data repository; and
and a counterfactuals generator executing on the at least one computer processor;
wherein the developer application is configured to:
obtain a prompt to a field large language model (LLM) and a corresponding original response generated by the field LLM from the enterprise application,
select a first phrase from a selected plurality of phrases from the prompt;
obtain, from the counterfactuals generator, a syntactic phrase set for the first phrase from the domain corpus,
obtain, from the counterfactuals generator, a semantic phrase set for the first phrase from the domain corpus,
cause the counterfactuals generator to select a counterfactual set including phrases co-occurring in the syntactic phrase set and the semantic phrase set,
assign a counterfactual score for each counterfactual of the counterfactual set,
select a first counterfactual from a counterfactual subset of the counterfactual set having highest counterfactual scores,
replace the first phrase in the prompt with the first counterfactual to obtain a modified prompt and process the modified prompt by the field LLM to obtain a modified response, and
store the first phrase and at least one strongest counterfactual of the counterfactual subset as a first phrase pair in the data repository.

### Claim 11 (depends on 10)

The system of claim 10, wherein the counterfactuals generator is further configured to:
obtain the syntactic phrase set for the first phrase from the domain corpus by:
obtaining a first syntactic embedding corresponding to the first phrase from a syntactic embedding model,
searching the embedding store for syntactic embeddings corresponding to phrases in the domain corpus that are similar to the first syntactic embedding, and
selecting the phrases in the domain corpus as the syntactic phrase set.

### Claim 12 (depends on 10)

The system of claim 10, wherein the counterfactuals generator is further configured to:
obtain the semantic phrase set for the first phrase from the domain corpus by:
obtaining a first semantic embedding corresponding to the first phrase from a semantic embedding model,
searching the embedding store for semantic embeddings corresponding to phrases in the domain corpus that are distant to the first semantic embedding, and
selecting the phrases in the domain corpus as the semantic phrase set.

### Claim 13 (depends on 10)

The system of claim 10, wherein the developer application is further configured to:
assign the counterfactual score for each counterfactual of the counterfactual set as a syntactic embedding cosine distance of the each counterfactual with respect to the first phrase, divided with a semantic embedding cosine distance of the each counterfactual with respect to the first phrase.

### Claim 14 (depends on 10)

The system of claim 10, wherein the developer application is further configured to:
prior to storing the first phrase and the at least one strongest counterfactual:
determine a response score corresponding to the modified response as a semantic similarity score of the modified response to the original response based on a scoring function,
replace the first phrase with each counterfactual from the counterfactual subset to obtain corresponding modified responses and a corresponding set of response scores corresponding to the first phrase; and
determine the at least one strongest counterfactual of the counterfactual subset that corresponds to a lowest response score of the set of response scores corresponding to the first phrase.

### Claim 15 (depends on 10)

The system of claim 10, wherein the developer application is further configured to:
pair each selected phrase from the selected plurality of phrases with at least one corresponding strongest counterfactual; and
store the each selected phrase and the at least one corresponding strongest counterfactual as a next phrase-pair in the data repository.

### Claim 16 (depends on 10)

The system of claim 10, wherein the developer application is further configured to:
construct an explainability model for the LLM with respect to the prompt based on a plurality of phrase-pairs corresponding the plurality of selected phrases from the prompt.

### Claim 17 (depends on 10)

The system of claim 10, wherein the developer application is further configured to:
modify instructions of the prompt based on an explainability model to cause the LLM to generate a new response,
wherein the new response is semantically similar to an expected response, and
wherein a first response similarity score of the new response to the expected response is higher than a second response similarity score of the original response to the expected response.

### Claim 18 (depends on 10)

The system of claim 10 wherein:
the counterfactuals generator includes a syntactic embedding model and a semantic embedding model;
the syntactic embedding model is trained to generate first word embeddings using a short context window of two words and configured to generate a plurality of syntactic embeddings from the domain corpus;
the semantic embedding model is trained to generate second word embeddings using a long context window of twenty words, and configured to generate a plurality of semantic embeddings from the domain corpus; and wherein
the developer application is configured to:
store the plurality of syntactic embeddings and the plurality of semantic embeddings in the embedding store.

### Claim 19

A method comprising:
obtaining a prompt to a field large language model (LLM) and a corresponding original response generated by the field LLM;
selecting a plurality of phrases from the prompt;
selecting a first phrase from the selected plurality of phrases;
obtaining a syntactic phrase set for the first phrase from a domain corpus by:
obtaining a first syntactic embedding corresponding to the first phrase from a syntactic embedding model,
searching an embedding store for syntactic embeddings corresponding to a first plurality of phrases in the domain corpus that are similar to the first syntactic embedding, and
selecting the first plurality of phrases in the domain corpus as the syntactic phrase set;
obtaining a semantic phrase set for the first phrase from the domain corpus by:
obtaining a first semantic embedding corresponding to the first phrase from a semantic embedding model,
searching the embedding store for semantic embeddings corresponding to a second plurality of phrases in the domain corpus that are distant from the first semantic embedding, and
selecting the second plurality of phrases in the domain corpus as the semantic phrase set;
selecting a counterfactual set including phrases co-occurring in the syntactic phrase set and the semantic phrase set;
assigning a counterfactual score for each counterfactual of the counterfactual set as a syntactic embedding cosine distance of the each counterfactual with respect to the first phrase, divided with a semantic embedding cosine distance of the each counterfactual with respect to the first phrase;
selecting a first counterfactual from a counterfactual subset of the counterfactual set having highest counterfactual scores;
replacing the first phrase in the prompt with the first counterfactual to obtain a modified prompt and processing the modified prompt by the field LLM to obtain a modified response; and
storing the first phrase and at least one strongest counterfactual of the counterfactual subset as a first phrase pair in a data repository.

### Claim 20 (depends on 19)

The method of claim 19, further comprising:
prior to storing the first phrase and the at least one strongest counterfactual:
determining a response score corresponding to the modified response as a semantic similarity score of the modified response to the original response based on a scoring function,
replacing the first phrase with each counterfactual from the counterfactual subset to obtain corresponding modified responses and a corresponding set of response scores corresponding to the first phrase, and
determining the at least one strongest counterfactual of the counterfactual subset that corresponds to a lowest response score of the set of response scores corresponding to the first phrase.
