Boyu Zhang
2024
SecCoder: Towards Generalizable and Robust Secure Code Generation
Boyu Zhang
|
Tianyu Du
|
Junkai Tong
|
Xuhong Zhang
|
Kingsum Chow
|
Sheng Cheng
|
Xun Wang
|
Jianwei Yin
Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing
After large models (LMs) have gained widespread acceptance in code-related tasks, their superior generative capacity has greatly promoted the application of the code LM. Nevertheless, the security of the generated code has raised attention to its potential damage. Existing secure code generation methods have limited generalizability to unseen test cases and poor robustness against the attacked model, leading to safety failures in code generation. In this paper, we propose a generalizable and robust secure code generation method SecCoder by using in-context learning (ICL) and the safe demonstration. The dense retriever is also used to select the most helpful demonstration to maximize the improvement of the generated code’s security. Experimental results show the superior generalizability of the proposed model SecCoder compared to the current secure code generation method, achieving a significant security improvement of an average of 7.20% on unseen test cases. The results also show the better robustness of SecCoder compared to the current attacked code LM, achieving a significant security improvement of an average of 7.74%. Our analysis indicates that SecCoder enhances the security of LMs in generating code, and it is more generalizable and robust.
2022
MDCSpell: A Multi-task Detector-Corrector Framework for Chinese Spelling Correction
Chenxi Zhu
|
Ziqiang Ying
|
Boyu Zhang
|
Feng Mao
Findings of the Association for Computational Linguistics: ACL 2022
Chinese Spelling Correction (CSC) is a task to detect and correct misspelled characters in Chinese texts. CSC is challenging since many Chinese characters are visually or phonologically similar but with quite different semantic meanings. Many recent works use BERT-based language models to directly correct each character of the input sentence. However, these methods can be sub-optimal since they correct every character of the sentence only by the context which is easily negatively affected by the misspelled characters. Some other works propose to use an error detector to guide the correction by masking the detected errors. Nevertheless, these methods dampen the visual or phonological features from the misspelled characters which could be critical for correction. In this work, we propose a novel general detector-corrector multi-task framework where the corrector uses BERT to capture the visual and phonological features from each character in the raw sentence and uses a late fusion strategy to fuse the hidden states of the corrector with that of the detector to minimize the negative impact from the misspelled characters. Comprehensive experiments on benchmarks demonstrate that our proposed method can significantly outperform the state-of-the-art methods in the CSC task.
Search
Co-authors
- Tianyu Du 1
- Junkai Tong 1
- Xuhong Zhang 1
- Kingsum Chow 1
- Sheng Cheng 1
- show all...