🚀 Granite-3B-Code-Instruct-128K
Granite-3B-Code-Instruct-128K 是一個具有 30 億參數的長上下文指令模型。它基於 Granite-3B-Code-Base-128K 進行微調,訓練數據不僅包含了用於訓練原始 Granite 代碼指令模型的 許可數據,還加入了專門為解決長上下文問題而合成生成的代碼指令數據集。通過讓模型接觸短上下文和長上下文數據,旨在提升其長上下文處理能力,同時不犧牲短輸入上下文下的代碼生成性能。
🚀 快速開始
預期用途
該模型旨在對長達 128K 的長上下文輸入中的編碼相關指令做出響應,可用於構建編碼助手。
生成示例
以下是一個如何使用 Granite-3B-Code-Instruct 模型的簡單示例:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model_path = "ibm-granite/granite-3b-code-instruct-128k"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
model.eval()
chat = [
{ "role": "user", "content": "Write a code to find the maximum value in a list of numbers." },
]
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
input_tokens = tokenizer(chat, return_tensors="pt")
for i in input_tokens:
input_tokens[i] = input_tokens[i].to(device)
output = model.generate(**input_tokens, max_new_tokens=100)
output = tokenizer.batch_decode(output)
for i in output:
print(i)
✨ 主要特性
- 長上下文處理能力:能夠處理長達 128K 的輸入,有效應對長上下文編碼指令。
- 代碼生成性能:在短輸入上下文下也能保持良好的代碼生成性能。
📦 模型信息
屬性 |
詳情 |
模型類型 |
text-generation |
訓練數據集 |
bigcode/commitpackft、TIGER-Lab/MathInstruct、meta-math/MetaMathQA、glaiveai/glaive-code-assistant-v3、glaive-function-calling-v2、bugdaryan/sql-create-context-instruction、garage-bAInd/Open-Platypus、nvidia/HelpSteer、bigcode/self-oss-instruct-sc2-exec-filter-50k |
評估指標 |
code_eval |
庫名稱 |
transformers |
標籤 |
code、granite |
開發者 |
IBM Research |
GitHub 倉庫 |
ibm-granite/granite-code-models |
論文 |
Scaling Granite Code Models to 128K Context |
發佈日期 |
2024 年 7 月 18 日 |
許可證 |
Apache 2.0 |
📚 詳細文檔
訓練數據
Granite 代碼指令模型在短上下文和長上下文數據的混合數據上進行訓練,具體如下:
基礎設施
IBM 使用兩個超級計算集群(Vela 和 Blue Vela)來訓練 Granite 代碼模型,這兩個集群分別配備了 NVIDIA A100 和 H100 GPU。這些集群為在數千個 GPU 上訓練模型提供了可擴展且高效的基礎設施。
評估結果
任務類型 |
數據集 |
指標 |
值 |
驗證狀態 |
文本生成 |
bigcode/humanevalpack(HumanEvalSynthesis (Python)) |
pass@1 |
53.7 |
未驗證 |
文本生成 |
bigcode/humanevalpack(HumanEvalSynthesis (Average)) |
pass@1 |
41.4 |
未驗證 |
文本生成 |
bigcode/humanevalpack(HumanEvalExplain (Average)) |
pass@1 |
25.1 |
未驗證 |
文本生成 |
bigcode/humanevalpack(HumanEvalFix (Average)) |
pass@1 |
26.2 |
未驗證 |
文本生成 |
repoqa(RepoQA (Python@16K)) |
pass@1 (thresh=0.5) |
48.0 |
未驗證 |
文本生成 |
repoqa(RepoQA (C++@16K)) |
pass@1 (thresh=0.5) |
36.0 |
未驗證 |
文本生成 |
repoqa(RepoQA (Java@16K)) |
pass@1 (thresh=0.5) |
38.0 |
未驗證 |
文本生成 |
repoqa(RepoQA (TypeScript@16K)) |
pass@1 (thresh=0.5) |
39.0 |
未驗證 |
文本生成 |
repoqa(RepoQA (Rust@16K)) |
pass@1 (thresh=0.5) |
29.0 |
未驗證 |
🔧 技術細節
Granite 代碼指令模型主要使用特定編程語言的指令 - 響應對進行微調。因此,在處理領域外的編程語言時,其性能可能會受到限制。在這種情況下,提供少量示例有助於引導模型輸出。此外,開發者在將這些模型部署到關鍵應用程序之前,應進行安全測試和針對特定目標的調整。該模型還繼承了其基礎模型的倫理考量和侷限性。更多信息,請參考 Granite-3B-Code-Base-128K 模型卡片。
📄 許可證
本模型採用 Apache 2.0 許可證。