| CPC G06F 16/24578 (2019.01) [G06N 3/092 (2023.01)] | 14 Claims |

|
1. A computer-implemented method for context reduction, comprising:
identifying a context document relating to a query;
training a policy using reinforcement learning to balance a token ratio and an accuracy difference, including a reward function:
![]() where τ=t/T is a token ratio between a number of tokens t in the reduced context and a number of tokens T in the context document, r is a score representing accuracy of an output generated by the language model using the reduced context, r* is a score representing accuracy of an output generated by the language model using the context document, and α is a weighting parameter;
determining a number of sentences of the context document to preserve, including applying the query and the context document to the policy to select a proportion of the context document to preserve;
ranking the sentences of the context document according to respective similarities between the sentences and the query;
generating a reduced context that preserves the determined number of highest ranked sentences of the context document and eliminates other sentences from the context document; and
executing the query with a language model, including the reduced context in a prompt, to generate a response.
|