Skip to content

Repository files navigation

🚀 TICoder

Reproduction Package of TICoder: A Repository-Level Code Generation Framework with Test-Driven Planning and Implementation-Aware Reuse

Overview

🌟 We propose TICoder, a novel repository-level code generation framework that improves both planning and reuse. TICoder introduces a test-driven iterative planning mechanism that leverages test cases as behavioral specifications to refine implementation steps. Furthermore, TICoder employs an implementation-aware code reuse strategy, which retrieves potential callee functions using a dual-view similarity that captures both functional and implementation aspects.

overlow.png

📝 Scientific Artifacts

Type Name URL License
Dataset CoderEval https://github.com/CoderEval/CoderEval
DevEval https://github.com/seketeam/DevEval
Baselines RepoCoder https://github.com/microsoft/CodeT/tree/main/RepoCoder MIT License
A3Codgen https://github.com/Dianshu-Liao/AAA-Code-Generation-Framework-for-Code-Repository-Local-Aware-Global-Aware-Third-Party-Aware
AllianceCoder https://github.com/Elendil3703/AllianceCoder
RLCoder https://github.com/DeepSoftwareAnalytics/RLCoder
RepoScope https://github.com/Lorien1128/RepoScope
CodeAgent
Models GPT-4o-mini https://platform.openai.com/docs/models/gpt-4o-mini
DeepSeek-V3 https://huggingface.co/deepseek-ai/DeepSeek-V3 MIT License
Qwen2.5-Coder-7B https://huggingface.co/Qwen/Qwen2.5-Coder-7B Apache License
DeepSeek-Coder-6.7B https://huggingface.co/deepseek-ai/deepseek-coder-6.7b-base DEEPSEEK LICENSE AGREEMENT

📂 Project Structure

|-- 📁 datasets # ▶️ download datasets here retrive corpus 
|
|-- 📁 utils
|
|-- 🚀 build_corpus.py       # ▶️ build retrieve corpus and generate RCG by MRCGExtractor
|
|-- 🚀 build_prompt.py       # ▶️ dual-stage select usage patterns and build prompt for generation
|
|-- 🚀 generate_requirement.py       # ▶️ planning
|
|-- 🚀 generate_code.py       # ▶️ generate code
|
|-- 📁 LLMClient.py       # ▶️ load LLMs
|
|-- 🚀 retrieve.py       # ▶️ dual-view similarity retrieval

⚡ QuickStart

📝 1. Build Retrive Corpus

Execute build_corpus.py to build the retrieval corpus for each dataset.

python build_corpus.py \
    --dataset DevEval # Dataset name
    --language python # Dataset language

📝 2. Test-Driven Iterative Planning

Execute generate_requirement.py to generate implementation steps from the original requirement and test cases

python build_corpus.py \
    --dataset DevEval # Dataset name
    --language python # Dataset language
    --num # Number of reflection attempts

📝 3. Dual-view similarity Retrieval

Retrieve the callee functions potentially called by the target function.

python retrieve.py \
    --dataset DevEval # Dataset name
    --language python # Dataset language
    --req_weight 0.8 # Weight of requirement similarity during retrieval
    --code_weight 0.2 # Weight of code similarity during retrieval
    --reflection # Whether reflection is needed

📝 4. Build Prompt

Build the prompt with the original requirement, retrieved callee functions, upstream call examples for the callees, and the target function's test function.

python build_prompt.py\
    --dataset DevEval # Dataset name
    --language python # Dataset language
    --req_weight 0.8 # Weight of requirement similarity during retrieval
    --code_weight 0.2 # Weight of code similarity during retrieval
    --reflection # Whether reflection is needed
    --expand 2 # Number of upstream functions to expand
    --structure_rank # Whether to use structure-based cluster
    --ppl_rank # Whether to use PPL-based filter

📝 5. Generate Code

python generate_code.py\
   --dataset DevEval # Dataset name
   --language python # Dataset language
   --model gpt # LLM name
   --req_weight 0.8 # Weight of requirement similarity during retrieval
   --code_weight 0.2 # Weight of code similarity during retrieval
   --reflection # Whether reflection is needed
   --expand 2 # Number of upstream functions to expand
   --structure_rank # Whether to use structure-based cluster
   --ppl_rank # Whether to use PPL-based filter
   --mode greedy # Generation mode

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages