IP Library Granted Patent US 12,596,873
Granted Patent B2
US 12,596,873 · App. 18/627,842 · Granted Apr 7, 2026

Optimization of retrieval augmented generation using data-driven templates

Inventors: Laurent Boué (Petah Tikva, IL); Kiran Rama (Bangalore, IN)
Assignee: MICROSOFT TECHNOLOGY LICENSING, LLC
G06F40/279
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,596,873
App. No.
18/627,842
Granted
Apr 7, 2026
Kind
B2
Abstract

Systems and methods are disclosed herein for compressing a prompt. In an example system, an importance score listing is obtained that includes a score indicative of an importance of a plurality of dataset keywords. From the importance score listing, a keyword importance score is identified for a plurality of keywords in a current text fragment, such as a text fragment to be compressed. A set of placeholders in an abstract prompt template is populated based on the current text fragment. The current text fragment is compressed based on the importance of the plurality of keywords in the current text fragment to generate a compressed text fragment. In an example, the compressed text fragment is included in the prompt for transmission to a computing entity, such as a large language model of a generative question-answering system.

Claims (58)

1 . A system for compressing a prompt, the system comprising:

a processor; and

a memory device that stores program code structured to cause the processor to:

obtain an importance score listing that includes a score indicative of an importance of a plurality of dataset keywords;

identify, from the importance score listing, a keyword importance score for a plurality of keywords in a current text fragment;

populate a set of placeholders in an abstract prompt template based on the current text fragment; and

compress the populated abstract prompt template based on the keyword importance score for the plurality of keywords in the current text fragment to generate a compressed text fragment, the compressed text fragment included in the prompt for transmission to a computing entity.

2 . The system of claim 1 , wherein the computing entity comprises a large language model (LLM), and

wherein the prompt comprises a query for the LLM to generate an answer thereto.

3 . The system of claim 2 , wherein the current text fragment is obtained from a retrieval augmentation generation (RAG) system in response to the query transmitted thereto.

4 . The system of claim 1 , wherein the program code is further structured to cause the processor to:

identify a set of entities and associated dataset keywords from a text fragment training dataset;

obtain the score for each of the plurality of dataset keywords, the dataset keywords extracted from the text fragment training dataset; and

store, in the importance score listing, each dataset keyword, the score for the dataset keyword, and the entity associated with the dataset keyword.

5 . The system of claim 1 , wherein the program code is further structured to cause the processor to:

identify a set of entities from a text fragment training dataset; and

generate the abstract prompt template that includes a plurality of strings, each string comprising one of the entities of the set of entities and a placeholder for an entity value corresponding to the entity.

6 . The system of claim 5 , wherein the program code is structured to cause the processor to populate the set of placeholders in the abstract prompt template by:

for each of the plurality of keywords, identifying a corresponding keyword entity; and

for each keyword entity, populating a placeholder of a string containing the keyword entity in the abstract prompt template with the keyword corresponding to the keyword entity.

7 . The system of claim 1 , wherein the program code is structured to cause the processor to compress the populated abstract prompt template by:

removing information from the populated abstract prompt template that does not satisfy a budgeting criteria.

8 . The system of claim 7 , wherein the budgeting criteria comprises a compression ratio.

9 . The system of claim 1 , wherein the program code is further structured to cause the processor to:

assign a type to a first keyword of the plurality of keywords; and

transform the first keyword into a second keyword in the compressed text fragment based on the type.

10 . A method for compressing a prompt, comprising:

obtaining an importance score listing that includes a score indicative of an importance of a plurality of dataset keywords;

identifying, from the importance score listing, a keyword importance score for a plurality of keywords in a current text fragment;

populating a set of placeholders in an abstract prompt template based on the current text fragment; and

compressing the populated abstract prompt template based on the keyword importance score for the plurality of keywords in the current text fragment to generate a compressed text fragment, the compressed text fragment included in the prompt for transmission to a computing entity.

11 . The method of claim 10 , wherein the computing entity comprises a large language model (LLM), and

wherein the prompt comprises a query for the LLM to generate an answer thereto.

12 . The method of claim 11 , wherein the current text fragment is obtained from a retrieval augmentation generation (RAG) system in response to the query transmitted thereto.

13 . The method of claim 10 , further comprising:

identifying a set of entities and associated dataset keywords from a text fragment training dataset;

obtaining the score for each of the plurality of dataset keywords, the dataset keywords extracted from the text fragment training dataset; and

storing, in the importance score listing, each dataset keyword, the score for the dataset keyword, and the entity associated with the dataset keyword.

14 . The method of claim 10 , further comprising:

identifying a set of entities from a text fragment training dataset; and

generating the abstract prompt template that includes a plurality of strings, each string comprising one of the entities of the set of entities and a placeholder for an entity value corresponding to the entity.

15 . The method of claim 14 , wherein the populating the set of placeholders in the abstract prompt template comprises:

for each of the plurality of keywords, identifying a corresponding keyword entity; and

for each keyword entity, populating a placeholder of a string containing the keyword entity in the abstract prompt template with the keyword corresponding to the keyword entity.

16 . The method of claim 10 , wherein the compressing the populated abstract prompt template comprises:

removing information from the populated abstract prompt template that does not satisfy a budgeting criteria.

17 . A computer-readable storage medium having computer program code recorded thereon that when executed by at least one processor causes the at least one processor to perform a method comprising:

obtaining an importance score listing that includes a score indicative of an importance of a plurality of dataset keywords;

identifying, from the importance score listing, a keyword importance score for a plurality of keywords in a current text fragment;

populating a set of placeholders in an abstract prompt template based on the current text fragment; and

compressing the populated abstract prompt template based on the keyword importance score for the plurality of keywords in the current text fragment to generate a compressed text fragment, the compressed text fragment included in the prompt for transmission to a computing entity.

18 . The computer-readable storage medium of claim 17 , wherein the computing entity comprises a large language model (LLM), and

wherein the prompt comprises a query for the LLM to generate an answer thereto.

19 . The computer-readable storage medium of claim 18 , wherein the current text fragment is obtained from a retrieval augmentation generation (RAG) system in response to the query transmitted thereto.

20 . The computer-readable storage medium of claim 17 , wherein the method further comprises:

identifying a set of entities and associated dataset keywords from a text fragment training dataset;

obtaining the score for each of the plurality of dataset keywords, the dataset keywords extracted from the text fragment training dataset; and

storing, in the importance score listing, each dataset keyword, the score for the dataset keyword, and the entity associated with the dataset keyword.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 8, 2024
From: BOUÉ, LAURENT; RAMA, KIRAN
To: MICROSOFT TECHNOLOGY LICENSING, LLC
Reel/Frame 067343/0392 →
Continuity (1)
Related Publication 20250315617A1 · Oct 9, 2025
References Cited (8)
US 20250094703A1 · Malak · 2025 [cited by examiner]
US 20250284888A1 · Khullar · 2025 [cited by examiner]
US 20250292014A1 · Sarferaz · 2025 [cited by examiner]
“Gptrim”, Retrieved From: https://github.com/vlad-ds/gptrim, 2024, 2 pages. [cited by applicant]
Jiang, et al., “(Long)LLMLingua: Enhancing Large Language Model Inference via Prompt Compression”, 2024, 10 Pages. [cited by applicant]
Communication pursuant to Rule 69 EPC—Reminder Concerning Payment of the Designation Fee (Art. 79(2) EPC) and of the Examination Fee (Art. 94(1) EPC)—and Invitation Pursuant to Rule 70a(1) EPC Received in European Appli… [cited by applicant]
Extended European Search Report Received in European Patent Application No. 25166367.0 mailed on Aug. 8, 2025, 08 pages. [cited by applicant]
Iulia Brezeanu, “How to Cut RAG Costs by 80% Using Prompt Compression”, Retrieved from the URL: https://towardsdatascience.com/how-to-cut-rag-costs-by-80-using-prompt-compression-877a07c6bedb/, Jan. 4, 2024, 19 Pages. [cited by applicant]