[논문 리뷰] ShortCoder: Knowledge-Augmented Syntax Optimization for Token-Efficient Code Generation
ShortCoder는 10개의 Python 구문 단순화 규칙, 규칙 기반+LLM-guided 데이터 합성 파이프라인, 그리고 LoRA 미세조정을 활용해 간결하고 의미적으로 정확한 코드를 생성하며, HumanEval에서 경쟁력 있는 성능과 약 18.1%의 토큰 감소를 달성합니다.
Code generation tasks aim to automate the conversion of user requirements into executable code, significantly reducing manual development efforts and enhancing software productivity. The emergence of large language models (LLMs) has significantly advanced code generation, though their efficiency is still impacted by certain inherent architectural constraints. Each token generation necessitates a complete inference pass, requiring persistent retention of contextual information in memory and escalating resource consumption. While existing research prioritizes inference-phase optimizations such as prompt compression and model quantization, the generation phase remains underexplored. To tackle these challenges, we propose a knowledge-infused framework named ShortCoder, which optimizes code generation efficiency while preserving semantic equivalence and readability. In particular, we introduce: (1) ten syntax-level simplification rules for Python, derived from AST-preserving transformations, achieving 18.1% token reduction without functional compromise; (2) a hybrid data synthesis pipeline integrating rule-based rewriting with LLM-guided refinement, producing ShorterCodeBench, a corpus of validated tuples of original code and simplified code with semantic consistency; (3) a fine-tuning strategy that injects conciseness awareness into the base LLMs. Extensive experimental results demonstrate that ShortCoder consistently outperforms state-of-the-art methods on HumanEval, achieving an improvement of 18.1%-37.8% in generation efficiency over previous methods while ensuring the performance of code generation.
연구 동기 및 목표
- 정확성과 가독성을 해치지 않으면서 코드 생성에서 토큰 사용을 줄이고 생성 효율성을 향상시키는 것.
- AST 보존 구문 단순화 규칙을 활용해 고품질의 간결 코드 코퍼스를 생성한다.
- 효율적인 파인튜닝을 통해 도메인 지식을 LLM에 주입하여 제로샷 간결 코드 생성을 가능하게 한다.
제안 방법
- 기능 손실 없이 18.1%의 토큰 감소를 달성하기 위해 Table I에 실린 10개의 AST 보존 Python 구문 단순화 규칙을 설계한다.
- 룰 기반 및 LLM-가이드 합성을 통해 <원래 코드, 간결 코드> 쌍(828개 검증된 쌍)을 생성하여 ShorterCodeBench를 구축한다.
- LoRA로 Code LLM을 미세조정해 간결성 지식을 주입하고 제로샷 간결 코드 생성을 가능하게 한다.
- 지식 주입을 위한 학습 쌍을 생성하기 위해 규칙 기반 및 LLM 보조 데이터 구성을 수행한다.
- 토큰, 대기시간 등 효율성 지표와 함께 pass@k 지표로 HumanEval을 평가한다.
- 효율성과 성능을 평가하기 위해 CodeLlama-Instruct, CodeGen, DeepSeek-Coder를 기준선과 비교한다.
실험 결과
연구 질문
- RQ1RQ1: ShortCoder가 기능적 정확도와 효율성 측면에서 기준 코드 생성 모델 대비 어떤 성능을 보이는가?
- RQ2RQ2: ShortCoder의 효율성은 프롬프트 기반 효율성 향상 기법과 어떻게 비교되는가?
- RQ3RQ3: ShortCoder가 생성하는 코드의 가독성과 간결성은 기준선 대비 어떠한가(사람 평가)?
주요 결과
| 모델 | 패스@1 | 패스@10 | 패스@100 | 생성토큰 |
|---|---|---|---|---|
| CodeGen | 0.429 | 0.538 | 0.620 | 260.34 |
| CodeLlama-7B-Instruct-hf | 0.474 | 0.579 | 0.650 | 197.80 |
| DeepSeek-Coder-1.3B-Base | 0.324 | 0.457 | 0.690 | 171.35 |
| DeepSeek-Coder-6.7B-Instruct | 0.791 | 0.884 | 0.920 | 186.69 |
| ShortCoder | 0.612 | 0.764 | 0.967 | 162.02 |
- ShortCoder는 기준선에 비해 생성 토큰을 18.1%에서 37.8%까지 감소시킨다.
- HumanEval에서 ShortCoder는 Pass@1=0.612, Pass@10=0.764, Pass@100=0.967를 달성하며 평균 162.02토큰(GenTokens)을 생성한다.
- ShortCoder는 효율성 지표에서 기준선보다 우수하며 더 낮은 토큰 비용으로 최첨단 성능에 근접한다.
- LoRA로 미세조정하면 간결성 패턴의 지식 주입이 가능해 trainable 매개변수를 줄일 수 있다.
- 규칙 가이드 파인튜닝은 프롬프트 기반 방법보다 일관되게 더 나은 효율성을 보이며 평균 문제 대기 시간을 25%-64% 감소시킨다.
- ShortCoder의 접근 방식은 더 짧고 더 읽기 쉬운 코드를 생성하는 동시에 기능적 정확성을 유지하거나 향상시킨다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.