Model Card for codellama-7b-code-review
Model Details / ๋ชจ๋ธ ์์ธ ์ ๋ณด
๐บ๐ธ English
This model is fine-tuned from Meta's codellama/CodeLlama-7b-hf
to review and provide feedback on code changes (diffs
) from GitHub Pull Requests. It has been primarily trained on JavaScript and React code reviews, aiming to generate constructive feedback from a senior engineer's perspective on topics like code quality, architecture, performance, and conventions.
- Developed by: ken12377
- Model type: Causal Language Model
- Language(s): English, Korean, Diff format
- License: apache-2.0
- Finetuned from model:
codellama/CodeLlama-7b-hf
๐ฐ๐ท ํ๊ตญ์ด
์ด ๋ชจ๋ธ์ Meta์ codellama/CodeLlama-7b-hf
๋ชจ๋ธ์ ๊ธฐ๋ฐ์ผ๋ก, GitHub Pull Request์ ์ฝ๋ ๋ณ๊ฒฝ์ฌํญ(diff
)์ ๋ฆฌ๋ทฐํ๊ณ ํผ๋๋ฐฑ์ ์ ๊ณตํ๋๋ก ํ์ธํ๋๋์์ต๋๋ค. ์ฃผ๋ก JavaScript์ React ์ฝ๋ ๋ฆฌ๋ทฐ์ ์ค์ ์ ๋๊ณ ํ์ต๋์์ผ๋ฉฐ, ์๋์ด ์์ง๋์ด์ ๊ด์ ์์ ์ฝ๋ ํ์ง, ์ํคํ
์ฒ, ์ฑ๋ฅ, ์ปจ๋ฒค์
๋ฑ์ ๋ํ ๊ฑด์ค์ ์ธ ํผ๋๋ฐฑ์ ์์ฑํ๋ ๊ฒ์ ๋ชฉํ๋ก ํฉ๋๋ค.
- ๊ฐ๋ฐ์: ken12377
- ๋ชจ๋ธ ์ข ๋ฅ: ์ธ๊ณผ ๊ด๊ณ ์ธ์ด ๋ชจ๋ธ (Causal Language Model)
- ์ธ์ด: ์์ด, ํ๊ตญ์ด, Diff ํ์
- ๋ผ์ด์ ์ค: apache-2.0
- ํ์ธํ๋ ๊ธฐ๋ฐ ๋ชจ๋ธ:
codellama/CodeLlama-7b-hf
Model Sources / ๋ชจ๋ธ ์์ค
Uses / ์ฌ์ฉ ์ ๋ณด
๐บ๐ธ English
Direct Use
This model can be used directly for code review automation. By providing code changes in diff
format as input, the model will generate review comments.
Warning: The content generated by the model always requires review. The final decision must be made by a human developer.
Downstream Use
This model can be reused as a base for further fine-tuning on specific project's internal coding conventions or more specialized review criteria.
Out-of-Scope Use
This model is specialized for code review tasks. It may not perform well for other purposes such as general-purpose chatbots, code generation, or translation. Especially, inputting code that is not in diff
format may lead to unexpected results.
๐ฐ๐ท ํ๊ตญ์ด
์ง์ ์ฌ์ฉ
์ด ๋ชจ๋ธ์ ์ฝ๋ ๋ฆฌ๋ทฐ ์๋ํ์ ์ง์ ์ฌ์ฉ๋ ์ ์์ต๋๋ค. diff
ํ์์ ์ฝ๋ ๋ณ๊ฒฝ์ฌํญ์ ์
๋ ฅ์ผ๋ก ์ ๊ณตํ๋ฉด, ๋ชจ๋ธ์ ํด๋น ์ฝ๋์ ๋ํ ๋ฆฌ๋ทฐ ์ฝ๋ฉํธ๋ฅผ ์์ฑํฉ๋๋ค.
๊ฒฝ๊ณ : ๋ชจ๋ธ์ด ์์ฑํ๋ ๋ด์ฉ์ ํญ์ ๊ฒํ ๊ฐ ํ์ํ๋ฉฐ, ์ต์ข ๊ฒฐ์ ์ ๊ฐ๋ฐ์๊ฐ ์ง์ ๋ด๋ ค์ผ ํฉ๋๋ค.
๋ค์ด์คํธ๋ฆผ ์ฌ์ฉ
์ด ๋ชจ๋ธ์ ํน์ ํ๋ก์ ํธ์ ๋ด๋ถ ์ฝ๋ฉ ์ปจ๋ฒค์ ์ด๋ ๋ ์ ๋ฌธํ๋ ๋ฆฌ๋ทฐ ๊ธฐ์ค์ ํ์ต์ํค๊ธฐ ์ํ ๊ธฐ๋ฐ ๋ชจ๋ธ๋ก ์ฌ์ฌ์ฉ๋ ์ ์์ต๋๋ค.
์ฌ์ฉ ๋ฒ์ ์ธ
์ด ๋ชจ๋ธ์ ์ฝ๋ ๋ฆฌ๋ทฐ ํ์คํฌ์ ํนํ๋์ด ์์ผ๋ฏ๋ก, ์ผ๋ฐ์ ์ธ ์ฑ๋ด ๋ํ๋ ์ฝ๋ ์์ฑ, ๋ฒ์ญ ๋ฑ์ ๋ค๋ฅธ ๋ชฉ์ ์ผ๋ก๋ ์ข์ ์ฑ๋ฅ์ ๋ณด์ด์ง ์์ ์ ์์ต๋๋ค. ํนํ diff
ํ์์ด ์๋ ์ฝ๋๋ฅผ ์
๋ ฅํ๋ฉด ์์์น ๋ชปํ ๊ฒฐ๊ณผ๊ฐ ๋์ฌ ์ ์์ต๋๋ค.
Bias, Risks, and Limitations / ํธํฅ, ์ํ ๋ฐ ํ๊ณ
๐บ๐ธ English
- Data Bias: The model was trained on public GitHub Pull Request data, so it may be biased towards specific coding styles or patterns present in that data.
- Inaccuracy (Hallucination): The model may occasionally generate feedback that is factually incorrect or out of context. The generated reviews always need verification.
- Limited Knowledge: The model's knowledge is limited to the data at the time of fine-tuning and may not reflect the latest library or framework updates.
๐ฐ๐ท ํ๊ตญ์ด
- ๋ฐ์ดํฐ ํธํฅ: ๋ชจ๋ธ์ ๊ณต๊ฐ๋ GitHub Pull Request ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ต๋์์ผ๋ฏ๋ก, ํด๋น ๋ฐ์ดํฐ์ ์กด์ฌํ๋ ํน์ ์ฝ๋ฉ ์คํ์ผ์ด๋ ํจํด์ ํธํฅ๋์ด ์์ ์ ์์ต๋๋ค.
- ๋ถ์ ํ์ฑ(ํ๊ฐ): ๋ชจ๋ธ์ ๋๋๋ก ์ฌ์ค๊ณผ ๋ค๋ฅด๊ฑฐ๋ ๋ฌธ๋งฅ์ ๋ง์ง ์๋ ํผ๋๋ฐฑ์ ์์ฑํ ์ ์์ต๋๋ค. ์์ฑ๋ ๋ฆฌ๋ทฐ๋ ํญ์ ๊ฒ์ฆ์ด ํ์ํฉ๋๋ค.
- ์ ํ๋ ์ง์: ๋ชจ๋ธ์ ์ง์์ ํ์ธํ๋ ์์ ์ ๋ฐ์ดํฐ๋ก ํ์ ๋์ด ์์ผ๋ฉฐ, ์ต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ํ๋ ์์ํฌ ๋ณ๊ฒฝ์ฌํญ์ ๋ฐ์ํ์ง ๋ชปํ ์ ์์ต๋๋ค.
Recommendations / ๊ถ์ฅ ์ฌํญ
๐บ๐ธ English
Users should treat the code reviews generated by the model as a 'draft' or 'assistive tool' to help the development process, not as a final judgment. It is recommended that a human expert reviews critical changes.๐ฐ๐ท ํ๊ตญ์ด
์ฌ์ฉ์๋ ๋ชจ๋ธ์ด ์์ฑํ ์ฝ๋ ๋ฆฌ๋ทฐ๋ฅผ ์ต์ข ์ ์ธ ํ๋จ์ด ์๋, ๊ฐ๋ฐ ๊ณผ์ ์ ๋๋ '์ด์' ๋๋ '๋ณด์กฐ ๋๊ตฌ'๋ก ํ์ฉํด์ผ ํฉ๋๋ค. ์ค์ํ ๋ณ๊ฒฝ์ฌํญ์ ๋ํด์๋ ๋ฐ๋์ ์ธ๊ฐ ์ ๋ฌธ๊ฐ์ ๊ฒํ ๋ฅผ ๊ฑฐ์น๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.How to Get Started with the Model / ๋ชจ๋ธ ์์ํ๊ธฐ
๐บ๐ธ English
Note: This model may be available in two versions: Adapter and Merged. Use the appropriate code for your model type.
1. Using the Adapter Model (ken12377/codellama-7b-code-review-adapter
)
To use the adapter model, you must first load the base model and then apply the adapter using the peft
library.
2. Using the Merged Model (ken12377/codellama-7b-code-review
)
If the model is fully merged with the base model, you can load it directly without peft
.
๐ฐ๐ท ํ๊ตญ์ด
์ฐธ๊ณ : ์ด ๋ชจ๋ธ์ ์ด๋ํฐ(Adapter) ์ ๋ณํฉ๋(Merged) ๋ ๊ฐ์ง ๋ฒ์ ์ผ๋ก ์ ๊ณต๋ ์ ์์ต๋๋ค. ์์ ์ ๋ชจ๋ธ ํ์ ์ ๋ง๋ ์ฝ๋๋ฅผ ์ฌ์ฉํ์ธ์.
1. ์ด๋ํฐ ๋ชจ๋ธ ์ฌ์ฉ๋ฒ (ken12377/codellama-7b-code-review-adapter
)
์ด๋ํฐ ๋ชจ๋ธ์ ์ฌ์ฉํ๋ ค๋ฉด, ๊ธฐ๋ฐ ๋ชจ๋ธ์ ๋จผ์ ๋ก๋ํ ํ peft
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด ์ด๋ํฐ๋ฅผ ์ ์ฉํด์ผ ํฉ๋๋ค.
2. ๋ณํฉ๋ ๋ชจ๋ธ ์ฌ์ฉ๋ฒ (ken12377/codellama-7b-code-review
)
๋ชจ๋ธ์ด ๊ธฐ๋ฐ ๋ชจ๋ธ๊ณผ ์์ ํ ๋ณํฉ๋ ๊ฒฝ์ฐ, peft
์์ด ์ง์ ๋ชจ๋ธ์ ๋ก๋ํ์ฌ ์ฌ์ฉํ ์ ์์ต๋๋ค.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# --- Configuration (Choose one) ---
# 1. For Adapter Model
use_adapter = True
base_model_name = "codellama/CodeLlama-7b-hf"
adapter_or_model_name = "ken12377/codellama-7b-code-review-adapter"
# 2. For Merged Model
# use_adapter = False
# adapter_or_model_name = "ken12377/codellama-7b-code-review"
# --- Load Model and Tokenizer ---
if use_adapter:
base_model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype=torch.float16,
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(adapter_or_model_name)
model = PeftModel.from_pretrained(base_model, adapter_or_model_name)
else:
tokenizer = AutoTokenizer.from_pretrained(adapter_or_model_name)
model = AutoModelForCausalLM.from_pretrained(
adapter_or_model_name,
torch_dtype=torch.float16,
device_map="auto",
)
model.eval()
# --- Inference ---
diff_code = """
--- a/src/components/LoginForm.js
+++ b/src/components/LoginForm.js
-import React from 'react';
+import React, { useState } from 'react';
-const LoginForm = () => (
- <form>
- <label>Email: <input type="email" /></label>
- <br />
- <label>Password: <input type="password" /></label>
- <br />
- <button type="submit">Log In</button>
- </form>
-);
+const LoginForm = () => {
+ const [credentials, setCredentials] = useState({ email: '', password: '' });
+ /* ... (rest of the diff code) ... */
+};
export default LoginForm;
"""
# Prompt in Korean
# ๋งํฌ๋ค์ด ํ์์ ํผ๋์ ํผํ๊ธฐ ์ํด ์ฝ๋ ๋ธ๋ก ๊ตฌ๋ถ์๋ฅผ ๋ณ์๋ก ๋ง๋ค์ด ์ฌ์ฉํฉ๋๋ค.
diff_block_delimiter = "```"
prompt = f"""### ์ง์:
์ ๊ณต๋ ์ฝ๋๋ pull request์ diff ๋ด์ฉ์
๋๋ค. ์ฝ๋์ ๊ฐ์ ํ ์ ์๋ ๋ถ๋ถ์ ๋ํด ์ต์ 3๊ฐ์ง ํญ๋ชฉ์ผ๋ก ๋๋์ด ์์ธํ๊ณ ๊ตฌ์ฒด์ ์ธ ํผ๋๋ฐฑ์ ์ ๊ณตํด์ฃผ์ธ์.
### ์
๋ ฅ:
{diff_block_delimiter}diff
{diff_code}
{diff_block_delimiter}
### ์๋ต:
1. """
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, repetition_penalty=1.2)
response = tokenizer.decode(outputs[0]len(inputs.input_ids[0]):], skip_special_tokens=True)
print(response)
Training Details / ํ์ต ์์ธ ์ ๋ณด
๐บ๐ธ English
Training Data
This model was fine-tuned using the review_dataset.json
file, which contains public Pull Request data collected from GitHub. The dataset is structured in a instruction
, input
(diff), output
(review comment) format.
Training Procedure
The model was fine-tuned using the QLoRA technique. It utilized the SFTTrainer
from the trl
library, applying 4-bit quantization and LoRA (Low-Rank Adaptation) for efficient training.
Training Hyperparameters
- model:
codellama/CodeLlama-7b-hf
- max_seq_length: 4096
- lora_alpha: 128
- lora_dropout: 0.1
- lora_r: 64
- learning_rate: 2e-4
- optimizer: paged_adamw_32bit
- gradient_accumulation_steps: 8
- per_device_train_batch_size: 2
- max_steps: 1900
๐ฐ๐ท ํ๊ตญ์ด
ํ์ต ๋ฐ์ดํฐ
์ด ๋ชจ๋ธ์ GitHub์์ ์์ง๋ ๊ณต๊ฐ Pull Request ๋ฐ์ดํฐ๋ฅผ ํฌํจํ๋ review_dataset.json
ํ์ผ์ ์ฌ์ฉํ์ฌ ํ์ธํ๋๋์์ต๋๋ค. ๋ฐ์ดํฐ์
์ instruction
, input
(diff), output
(๋ฆฌ๋ทฐ ์ฝ๋ฉํธ) ํ์์ผ๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
ํ์ต ์ ์ฐจ
๋ชจ๋ธ์ QLoRA ๊ธฐ๋ฒ์ ์ฌ์ฉํ์ฌ ํ์ธํ๋๋์์ต๋๋ค. trl
๋ผ์ด๋ธ๋ฌ๋ฆฌ์ SFTTrainer
๋ฅผ ์ฌ์ฉํ์ผ๋ฉฐ, 4-bit ์์ํ์ LoRA(Low-Rank Adaptation)๋ฅผ ์ ์ฉํ์ฌ ํจ์จ์ ์ธ ํ์ต์ ์งํํ์ต๋๋ค.
ํ์ต ํ์ดํผํ๋ผ๋ฏธํฐ
- ๋ชจ๋ธ:
codellama/CodeLlama-7b-hf
- ์ต๋ ์ํ์ค ๊ธธ์ด: 4096
- LoRA Alpha: 128
- LoRA Dropout: 0.1
- LoRA Rank (r): 64
- ํ์ต๋ฅ : 2e-4
- ์ตํฐ๋ง์ด์ : paged_adamw_32bit
- Gradient Accumulation Steps: 8
- ์ฅ์น๋ณ ํ์ต ๋ฐฐ์น ํฌ๊ธฐ: 2
- ์ต๋ ์คํ ์: 1900
Compute Infrastructure / ์ปดํจํ ์ธํ๋ผ
๐บ๐ธ English
- Hardware Type: RunPod Cloud GPU
- Cloud Provider: RunPod
๐ฐ๐ท ํ๊ตญ์ด
- ํ๋์จ์ด ์ข ๋ฅ: RunPod ํด๋ผ์ฐ๋ GPU
- ํด๋ผ์ฐ๋ ์ ๊ณต์ ์ฒด: RunPod
- Downloads last month
- 57
Model tree for ken123777/codellama-7b-code-review-v1
Base model
codellama/CodeLlama-7b-hf