The invention provides an enhancement method for a
question answering system during testing based on
reinforcement learning, and belongs to the technical field of
natural language processing. The method aims at solving the technical problems that an existing large
language model (LLM) faces knowledge blind areas, reasoning chain breakage and context length limitation in a question and answer (QA) task, an existing fine adjustment method is high in calculation cost and damaged in generalization ability, and a prompt strategy seriously depends on a limited
context window and lacks long-
term memory. The method comprises the following steps: firstly, collecting reflection experience through multiple attempts and a failure reflection mechanism, and constructing an experience
library; thirdly, performing text embedding, clustering and semantic abstracting on experiences in the experience
library, and constructing an external memory
library; secondly, a memory selection process is formalized into a Markov
decision process (MDP),
reinforcement learning (such as a PPO
algorithm) is used for training a strategy agent, and the agent is optimized with a current task as a state, with memory
item selection as an action and with LLM answer
correctness as a reward; finally, in a test time (
inference) phase, the agent dynamically selects the most helpful memory entry according to the new task and integrates it into the hint of the LLM to generate a final answer. According to the method, under the condition that LLM internal parameters do not need to be updated, the question and answer accuracy is dynamically improved, the calculation overhead is reduced, and the limitation of a
context window is effectively overcome.