Code large model robustness enhancement method based on context processing and post-training

By constructing adversarial perturbation samples and conducting targeted training based on context processing and post-training robustness enhancement methods, the problem of insufficient robustness of large language models in code generation tasks is solved, and the stability and consistency of the model in the face of input perturbations are improved. It is applicable to a variety of programming languages ​​and model types.

CN122173097APending Publication Date: 2026-06-09NANJING UNIV
0 Cites 0 Cited by

Patent Information

Application Number
CN202610370026.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-25
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Large language models are not robust enough in code generation tasks, especially in terms of stability and anti-interference ability when faced with input perturbations, and cannot guarantee the correctness and consistency of the output.

Method used

We employ a robustness enhancement method based on context processing and post-training. We construct adversarial perturbation samples through equivalent semantic transformation to fine-tune the target large language model. We also combine greedy search and simulated annealing algorithms to generate high-quality adversarial perturbation samples and use supervised fine-tuning and direct preference optimization reinforcement learning for training to enhance the model's stability and generalization ability.

Benefits of technology

It significantly improves the robustness and reliability of large language models in code generation tasks. Through systematic evaluation and training methods, it enhances the stability and consistency of the model when faced with input perturbations, and is applicable to various programming languages ​​and model types.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The invention discloses a large code model robustness enhancement method based on context processing and post-training. An enhancement method is selected according to the type of a model to be enhanced. And when post-training enhancement is carried out, carrying out equivalent semantic conversion, greedy search and simulated annealing on a given source code to generate an adversarial disturbance sample, and inputting the adversarial disturbance sample into a post-training framework to carry out fine tuning training on the target large language model. When context enhancement is carried out, backup codes are used for generating a backup data set, an optimal example subset closest to the semantics of a current problem is screened out by calculating the similarity, then existing dead codes are normalized, and the number of the optimal example subsets is selected in a self-adaptive mode; and dynamically adjusting and constructing a context prompt according to the task complexity to input the target large language model. And finally outputting an evaluation index and the target large language model after code robustness enhancement. The method supports various mainstream programming languages and open source and closed source models, and has good universality and expandability.
Need to check novelty before this filing date? Find Prior Art