[Paper Review] On Extracting Specialized Code Abilities from Large Language Models: A Feasibility Study
This paper investigates the feasibility of extracting specialized code generation abilities—such as code synthesis and translation—from large language models (LLMs) via imitation attacks using medium-sized backbone models. By employing diverse query strategies (zero-shot, in-context, Chain-of-Thought) and response validation, the authors demonstrate that a locally trained model can effectively replicate the target LLM's code-related behaviors with high accuracy, revealing a practical threat surface for model extraction.
Recent advances in large language models (LLMs) significantly boost their usage in software engineering. However, training a well-performing LLM demands a substantial workforce for data collection and annotation. Moreover, training datasets may be proprietary or partially open, and the process often requires a costly GPU cluster. The intellectual property value of commercial LLMs makes them attractive targets for imitation attacks, but creating an imitation model with comparable parameters still incurs high costs. This motivates us to explore a practical and novel direction: slicing commercial black-box LLMs using medium-sized backbone models. In this paper, we explore the feasibility of launching imitation attacks on LLMs to extract their specialized code abilities, such as"code synthesis" and "code translation." We systematically investigate the effectiveness of launching code ability extraction attacks under different code-related tasks with multiple query schemes, including zero-shot, in-context, and Chain-of-Thought. We also design response checks to refine the outputs, leading to an effective imitation training process. Our results show promising outcomes, demonstrating that with a reasonable number of queries, attackers can train a medium-sized backbone model to replicate specialized code behaviors similar to the target LLMs. We summarize our findings and insights to help researchers better understand the threats posed by imitation attacks, including revealing a practical attack surface for generating adversarial code examples against LLMs.
Motivation & Objective
- To investigate whether specialized code abilities of commercial LLMs can be extracted through imitation attacks.
- To evaluate the effectiveness of different query schemes—zero-shot, in-context, and Chain-of-Thought—in eliciting target LLM behavior for imitation.
- To design and apply response checks to refine outputs and improve imitation model performance.
- To assess the downstream impact of extracted abilities, including adversarial example generation.
- To provide insights into the security risks of LLMs and inform mitigation strategies such as watermarking.
Proposed method
- Designing a query generation framework that uses zero-shot, in-context, and Chain-of-Thought prompting to elicit code-related responses from the target LLM.
- Implementing response checks to filter and refine outputs, ensuring higher-quality training data for the imitation model.
- Training a medium-sized backbone model on the collected responses to imitate the target LLM’s code generation behavior.
- Evaluating imitation model performance using CodeBLEU scores and pass@k metrics on code synthesis, translation, and completion tasks.
- Applying the extracted model to generate adversarial code examples, demonstrating its practical utility.
- Exploring the role of watermarking as a potential mitigation technique against such extraction attacks.
Experimental results
Research questions
- RQ1Can medium-sized models successfully imitate specialized code abilities of commercial LLMs through query-based imitation attacks?
- RQ2How do different prompting strategies (zero-shot, in-context, Chain-of-Thought) affect the quality and transferability of extracted code abilities?
- RQ3To what extent can response checks improve the fidelity of imitation model outputs?
- RQ4Can the extracted model be used effectively in downstream tasks such as adversarial example generation?
- RQ5What are the implications of this attack surface for model intellectual property protection?
Key findings
- The imitation model achieved performance comparable to the target LLM on code synthesis, translation, and completion tasks using a reasonable number of queries.
- Chain-of-Thought and in-context prompting schemes significantly improved the quality and correctness of extracted code compared to zero-shot prompting.
- Response checks effectively filtered low-quality or incorrect outputs, enhancing the training data quality and resulting model performance.
- The extracted model successfully generated adversarial code examples, demonstrating its utility in malicious applications.
- The study reveals a practical and cost-effective attack surface for extracting specialized code abilities from black-box LLMs.
- Watermarking is identified as a promising but underutilized defense mechanism, suggesting the need for stronger IP protection strategies in LLM deployment.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.