🚀 Granite-20B-Code-Instruct-8K
Granite-20B-Code-Instruct-8K 是一個具有 200 億參數的模型,它基於 Granite-20B-Code-Base-8K,在多種 許可寬鬆 的指令數據上進行微調,以增強指令跟隨能力,包括邏輯推理和問題解決能力。
模型信息
屬性 |
詳情 |
模型類型 |
文本生成 |
基礎模型 |
ibm-granite/granite-20b-code-base-8k |
推理功能 |
支持 |
許可證 |
Apache-2.0 |
訓練數據集 |
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 |
評估指標 |
code_eval |
庫名稱 |
transformers |
標籤 |
code、granite |
模型評估結果
任務類型 |
數據集名稱 |
pass@1 值 |
文本生成 |
HumanEvalSynthesis(Python) |
60.4 |
文本生成 |
HumanEvalSynthesis(JavaScript) |
53.7 |
文本生成 |
HumanEvalSynthesis(Java) |
58.5 |
文本生成 |
HumanEvalSynthesis(Go) |
42.1 |
文本生成 |
HumanEvalSynthesis(C++) |
45.7 |
文本生成 |
HumanEvalSynthesis(Rust) |
42.7 |
文本生成 |
HumanEvalExplain(Python) |
44.5 |
文本生成 |
HumanEvalExplain(JavaScript) |
42.7 |
文本生成 |
HumanEvalExplain(Java) |
49.4 |
文本生成 |
HumanEvalExplain(Go) |
32.3 |
文本生成 |
HumanEvalExplain(C++) |
42.1 |
文本生成 |
HumanEvalExplain(Rust) |
18.3 |
文本生成 |
HumanEvalFix(Python) |
43.9 |
文本生成 |
HumanEvalFix(JavaScript) |
43.9 |
文本生成 |
HumanEvalFix(Java) |
45.7 |
文本生成 |
HumanEvalFix(Go) |
41.5 |
文本生成 |
HumanEvalFix(C++) |
41.5 |
文本生成 |
HumanEvalFix(Rust) |
29.9 |

🚀 快速開始
模型概述
使用說明
預期用途
該模型旨在響應與編碼相關的指令,可用於構建編碼助手。
生成示例
以下是一個如何使用 Granite-20B-Code-Instruct-8K 模型的簡單示例:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model_path = "ibm-granite/granite-20b-code-instruct-8k"
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)
✨ 主要特性
該模型基於 Granite-20B-Code-Base-8K 進行微調,在多種許可寬鬆的指令數據上訓練,增強了指令跟隨能力,包括邏輯推理和問題解決能力。
📦 訓練數據
Granite Code Instruct 模型在以下類型的數據上進行訓練:
🔧 技術細節
我們使用 IBM 的兩個超級計算集群 Vela 和 Blue Vela 來訓練 Granite Code 模型,這兩個集群分別配備了 NVIDIA A100 和 H100 GPU。這些集群為我們在數千個 GPU 上訓練模型提供了可擴展且高效的基礎設施。
📄 許可證
本模型採用 Apache 2.0 許可證。
⚠️ 重要提示
Granite 代碼指令模型主要使用特定編程語言的指令 - 響應對進行微調。因此,它們在處理領域外編程語言時的性能可能會受到限制。在這種情況下,提供少量示例有助於引導模型輸出。此外,開發者在將這些模型部署到關鍵應用程序之前,應進行安全測試和特定目標的調優。該模型還繼承了其基礎模型的倫理考量和侷限性。更多信息,請參考 Granite-20B-Code-Base-8K 模型卡片。