IP Library Granted Patent US 12,373,649
Granted Patent B1
US 12,373,649 · App. 19/052,036 · Granted Jul 29, 2025

Remediating hallucinations in language models

Inventors: Sherin Mathews (Fremont, CA); Samuel Assefa (Watertown, MA)
Assignee: U.S. BANCORP, NATIONAL ASSOCIATION
G06F40/30G06F16/243G06F40/289
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,373,649
App. No.
19/052,036
Granted
Jul 29, 2025
Kind
B1
Abstract

A system includes one or more processors to receive a natural language query; execute the first language model using the natural language query to generate a text-based response to the natural language query; segment the text-based response into a plurality of segments each corresponding to a different fact-based response to the natural language query; convert each of the segments into a set of queries; generate a query response to each query by using the query to search a data repository; generate a factuality score of the query responses for the text-based response to the natural language query; generate an aggregate factuality score for the natural language query based on the factuality score for each query generated for each of the plurality of segments; and executing decontextualized atomic decomposition responsive to determining the factuality score does not satisfy a threshold.

Claims (86)

1. A system for remediating hallucinations in a first language model, the system comprising one or more processors and one or more machine-readable media storing program instructions that, when executed by the one or more processors, causes the one or more processors to perform operations comprising:

receiving, from a chat interface, a natural language query, the natural language query comprising a request for a plurality of facts;

executing the first language model using the natural language query to generate a text-based response to the natural language query;

generating a filtered text-based response including one or more statements from the text-based response that satisfy one or more filtering criteria;

segmenting, using a second language model, the filtered text-based response into a plurality of segments each corresponding to a different fact-based response to the natural language query;

for each of the plurality of segments:

converting the segment into a set of queries each configured to be used to search a data repository;

for each query of the set of queries:

generating a query response to the query by using the query to search the data repository; and

generating a factuality score of the segment for the text-based response to the natural language query based on the set of queries generated for the segment;

generating an aggregate factuality score for the natural language query based on the factuality score for each of the plurality of segments; and

computing atomic decontextualization of the response, responsive to determining the factuality score is below a threshold for metrics in which a high value corresponds with a high factuality or is above the threshold for metrics in which a low value corresponds to an increase in the factuality score.

2. The system of claim 1 , wherein filtering the text-based response comprises removing one or more statements from the text-based response that includes at least one characteristic from a group of characteristics consisting of:

a first-person pronoun;

a presence of one or more question marks;

a pronoun of a defined type; and

an absence of a named entity.

3. The system of claim 1 , wherein the operations further comprise:

generating a plurality of metrics for the natural language query, the plurality of metrics comprising the aggregate factuality score; and

comparing, by the one or more processors, each of the plurality of metrics to a respective threshold.

4. A method for remediating hallucinations in a language model, comprising:

receiving, by one or more processors, a natural language query;

executing, by the one or more processors, the language model using the natural language query to generate a text-based response to the natural language query;

segmenting, by the one or more processors, the text-based response into a plurality of segments that each corresponds to a different fact-based response to the natural language query;

generating, by the one or more processors, one or more queries for each of the plurality of segments, each of the one or more queries configured to be used to search a data repository;

for each query of the one or more queries generated for each of the plurality of segments, generating, by the one or more processors, a query response to the query by using the query to search the data repository;

generating, by the one or more processors, one or more metrics based on the query response generated for each query of the one or more queries generated for each of the plurality of segments; and

performing decontextualization of the response, at an atomic level, by the one or more processors, based on at least one of the one or more metrics not satisfying a threshold.

5. The method of claim 4 , further comprising:

filtering, by the one or more processors, the text-based response to the natural language query by removing language from the text-based response that satisfy one or more filtering criteria,

wherein segmenting the text-based response comprises segmenting, by the one or more processors, the filtered text-based response.

6. The method of claim 5 , wherein filtering the text-based response comprises removing, by the one or more processors, one or more statements from the text-based response that includes at least one characteristic from a group of characteristics consisting of:

a first-person pronoun;

a presence of one or more question marks;

a pronoun of a defined type; and

an absence of a named entity.

7. The method of claim 4 , wherein segmenting the text-based response into a plurality of segments comprises:

identifying, by the one or more processors using a second language model, individual facts included in the text-based response, wherein each individual fact is a segment of the plurality of segments.

8. The method of claim 4 , wherein generating the one or more queries for each of the plurality of segments comprises, for each segment:

generating, by the one or more processors using a second language model, the one or more queries for the segment using a second language model.

9. The method of claim 4 , wherein generating the one or more metrics comprises:

generating, by the one or more processors for each segment of the plurality of segments, a factuality score indicating a factuality of the segment to responding to the text-based response to the natural language query, the method further comprising:

generating, by the one or more processors, an aggregate factuality score for the natural language query based on the factuality score for each segment of the plurality of segments,

wherein performing decontextualization, by the one or more processors, the language model responsive to the aggregate factuality score not satisfying a threshold.

10. The method of claim 4 , wherein generating the one or more metrics comprises, for each query response:

generating, by the one or more processors, a hallucinated named entity error metric,

wherein training the language model comprises training, by the one or more processors, the language model responsive to the hallucinated named entity error not satisfying a threshold.

11. The method of claim 4 , further comprising:

generating, by the one or more processors in response to determining the at least one metric does not satisfy the threshold, a second plurality of metrics for the response to the natural language query;

determining, by the one or more processors, at least one second metric of the second plurality of metrics that does not satisfy a second threshold;

wherein training the language model comprises training, by the one or more processors, the language model using a training technique selected from a plurality of training techniques based on a type of the at least one second metric.

12. The method of claim 4 , further comprising:

storing, by the one or more processors, one or more ground truth sentences; and

generating, by the one or more processors for each query response, one or more query metrics for the query response based on a comparison between the query response and a stored ground truth sentence.

13. The method of claim 4 , wherein generating the one or more metrics comprises:

generating, by the one or more processors, a fluency, a diversity, and a repetition for a segment of the plurality of segments,

wherein training the language model based on the one or more metrics comprises:

determining at least one of the generated fluency diversity, or repetition satisfy the threshold; and

training the language model responsive to the determining the at least one of the generated fluency diversity, or repetition satisfy the threshold.

14. One or more non-transitory, machine-readable media storing program instructions that, when executed by one or more processors, causes the one or more processors to perform operations comprising:

receiving a natural language query;

executing a language model using the natural language query to generate a text-based response to the natural language query;

segmenting the text-based response into a plurality of segments that each corresponds to a different fact-based response to the natural language query;

generating one or more queries for each of the plurality of segments, each of the one or more queries configured to be used to search a data repository;

for each query of the one or more queries generated for each of the plurality of segments, generating a query response to the query by using the query to search the data repository;

generating one or more metrics based on the query response generated for each query of the one or more queries generated for each of the plurality of segments; and

executing atomic level decontextualization of the response, based on the one or more metrics being below a threshold for metrics in which a high value corresponds with a high factuality or being above the threshold for metrics in which a low value corresponds to an increase in the factuality score.

15. The one or more non-transitory, machine-readable media of claim 14 , the operations further comprising:

filtering the text-based response to the natural language query by removing language from the text-based response that satisfy one or more filtering criteria,

wherein segmenting the text-based response comprises segmenting the filtered text-based response.

16. The one or more non-transitory, machine-readable media of claim 15 , wherein filtering the text-based response comprises removing one or more statements from the text-based response that includes at least one characteristic from a group of characteristics consisting of:

a first-person pronoun;

a presence of one or more question marks;

a pronoun of a defined type; and

an absence of a named entity.

17. The one or more non-transitory, machine-readable media of claim 14 , wherein segmenting the text-based response into a plurality of segments comprises:

identifying, by the one or more processors using a second language model, individual facts included in the text-based response, wherein each individual fact is a segment of the plurality of segments.

18. The one or more non-transitory, machine-readable media of claim 14 , wherein generating the one or more queries for each of the plurality of segments comprises, for each segment:

generating, by the one or more processors using a second language model, the one or more queries for the segment using a second language model.

19. The one or more non-transitory, machine-readable media of claim 14 , wherein generating the one or more metrics comprises:

generating for each query response, a factuality score indicating a factuality of the query response to responding to the text-based response to the natural language query, the operations further comprising:

generating, by the one or more processors, an aggregate factuality score for the natural language query based on the factuality score for each query response generated for each of the plurality of segments,

wherein executing decontextualization comprises of atomic level decontextualization responsive to the aggregate factuality score not satisfying a threshold.

20. The one or more non-transitory, machine-readable media of claim 14 , wherein generating the one or more metrics comprises, for each query response:

generating a hallucinated named entity error metric,

wherein training the language model comprises training, by the one or more processors, the language model responsive to the hallucinated named entity error not satisfying a threshold.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 12, 2025
From: MATHEWS, SHERIN; ASSEFA, SAMUEL
To: U.S. BANCORP, NATIONAL ASSOCIATION
Reel/Frame 070199/0278 →
References Cited (48)
US 7447667B2 · Gong · 2008 [cited by examiner]
US 9659056B1 · Chechik · 2017 [cited by examiner]
US 9916348B1 · Madhavan · 2018 [cited by examiner]
US 10977573B1 · Dalton · 2021 [cited by examiner]
US 12067366B1 · Heller · 2024 [cited by examiner]
US 20070288577A1 · Kronlund · 2007 [cited by examiner]
US 20160078149A1 · Gaucher · 2016 [cited by examiner]
US 20170220554A1 · Carter · 2017 [cited by examiner]
US 20170228368A1 · Carter · 2017 [cited by examiner]
US 20180144024A1 · Fu · 2018 [cited by examiner]
US 20190155963A1 · Boxwell · 2019 [cited by examiner]
US 20210124876A1 · Kryscinski et al. · 2021 [cited by applicant]
US 20210209173A1 · Thompson · 2021 [cited by examiner]
US 20210241050A1 · Gunaratna · 2021 [cited by examiner]
US 20220107946A1 · Kaplan · 2022 [cited by examiner]
US 20220164643A1 · Charnock · 2022 [cited by examiner]
US 20220210098A1 · Zhang · 2022 [cited by examiner]
US 20230119109A1 · Choubey · 2023 [cited by examiner]
US 20230274086A1 · Tunstall-Pedoe · 2023 [cited by examiner]
US 20230274089A1 · Tunstall-Pedoe · 2023 [cited by examiner]
US 20230316006A1 · Tunstall-Pedoe · 2023 [cited by examiner]
US 20240176950A1 · Rani · 2024 [cited by examiner]
US 20240242037A1 · Heller · 2024 [cited by examiner]
US 20240273309A1 · Heller · 2024 [cited by examiner]
US 20240273345A1 · Bharadwaj · 2024 [cited by examiner]
US 20240296339A1 · Zhang · 2024 [cited by examiner]
US 20240346342A1 · Lewis · 2024 [cited by examiner]
US 20250005266A1 · Bax · 2025 [cited by examiner]
US 20250045256A1 · Gottlob · 2025 [cited by examiner]
US 20250047622A1 · Bodigutla · 2025 [cited by examiner]
US 20250061116A1 · Leslie · 2025 [cited by examiner]
US 20250061270A1 · Wippich · 2025 [cited by examiner]
US 20250094145A1 · Weber · 2025 [cited by examiner]
US 20250094707A1 · Portisch · 2025 [cited by examiner]
US 20250095798A1 · Shamaei · 2025 [cited by examiner]
US 20250110840A1 · Amarasingham · 2025 [cited by examiner]
US 20250142185A1 · Paley · 2025 [cited by examiner]
US 20250148308A1 · Vinay · 2025 [cited by examiner]
US 20250156642A1 · Serry · 2025 [cited by examiner]
Temiz, title={Fact Extraction and Verification Pipeline for Covid-19 Related User Posts in Social Media}, year={2022}, school={Middle East Technical University (Turkey)}, pp. 1-61 (Year: 2022). [cited by examiner]
Gunjal et al., Molecular Facts: Desiderata for Decontextualization in LLMFact Verification, arXiv:2406.20079v1 [cs.CL] Jun. 28, 2024, pp. 1-17 (Year: 2024). [cited by examiner]
Su et al., title={Mitigating entity-level hallucination in large language models}, booktitle={Proceedings of the 2024 Annual International ACM SIGIR Conference on Research and Development in Information Retrieval in the… [cited by examiner]
Ali, S., Evaluating large language models (LLMs) &#x2013 Insights about transforming trends (2023), 14 pages, Retrieved from the Internet: https://datasciencedojo.com/blog/evaluating-large-language-models-llms/ (retriev… [cited by applicant]
Chuang et al., “Lookback Lens: Detecting and Mitigating Contextual Hallucinations in Large Language Models Using Only Attention Maps,” (2024), 18 pages, Retrieved from the Internet: https://arxiv.org/abs/2407.07071 (ret… [cited by applicant]
Durai, K. “How to Evaluate Response of a RAG Empowered LLM”, Dataworkz, 28 pages, Retrieved from the Internet: URL: https://www.dataworkz.com/how-to-evaluate-response-of-a-rag-empowered-llm/ (retrieved on Feb. 11, 2025). [cited by applicant]
He, K. “Detect Hallucinations Using LLM Metrics”, Fiddler AI, 7 pages, Retrieved from the Internet: URL: https://www.fiddler.ai/blog/detect-hallucinations-using-llm-metrics (retrieved on Feb. 11, 2025). [cited by applicant]
Lee et al., “Factuality Enhanced Language Models for Open-Ended Text Generation,” (2023), 24 pages, Retrieved from the Internet: https://arxiv.org/abs/2206.04624 (retrieved on Feb. 11, 2025). [cited by applicant]
Tripathi, G. “How to Evaluate a Large Language Model (LLM)?”, Analytics Vidhya, 29 pages, Retrieved from the Internet: URL: https://www.analyticsvidhya.com/blog/2023/05/how-to-evaluate-a-large-language-model-llm/ (retri… [cited by applicant]
Cited By (3)
US 12,554,726 US 12,566,769 US 12,670,160