🚀 StarCoderBase
StarCoderBase是一個基於155億參數的模型,在80多種編程語言的代碼數據上進行訓練,具備強大的代碼生成能力,可用於輔助代碼編寫等場景。
🚀 快速開始
你可以在 StarCoder Playground 上體驗該模型。
✨ 主要特性
📦 安裝指南
運行以下命令安裝所需庫:
pip install -q transformers
💻 使用示例
基礎用法
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "bigcode/starcoderbase"
device = "cuda"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to(device)
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
高級用法
Fill-in-the-middle 使用特殊標記來識別輸入和輸出的前綴/中間/後綴部分:
input_text = "<fim_prefix>def print_hello_world():\n <fim_suffix>\n print('Hello world!')<fim_middle>"
inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
📚 詳細文檔
模型概述
StarCoderBase 模型是具有155億參數的模型,在來自 The Stack (v1.2) 的80多種編程語言上進行訓練,排除了選擇退出請求的數據。該模型使用 Multi Query Attention、8192個標記的上下文窗口,並基於 Fill-in-the-Middle目標 在1萬億個標記上進行訓練。
使用說明
預期用途
該模型在 GitHub 代碼上進行訓練,因此它不是一個指令模型,像“編寫一個計算平方根的函數”這樣的命令效果不佳。不過,通過使用 Tech Assistant prompt,可以將其轉變為一個強大的技術助手。
歡迎在社區板塊分享你的生成結果!
歸屬與其他要求
該模型的預訓練數據集僅篩選了許可寬鬆的許可證。儘管如此,模型仍可能逐字生成數據集中的源代碼。代碼的許可證可能要求進行歸屬聲明和/或遵守其他特定要求,必須予以尊重。我們提供了一個 搜索索引,可用於搜索預訓練數據,以確定生成代碼的來源,併為你的代碼進行適當的歸屬聲明。
🔧 技術細節
模型
- 架構:具有多查詢注意力和 Fill-in-the-Middle 目標的 GPT - 2 模型
- 預訓練步驟:250k
- 預訓練標記:1萬億
- 精度:bfloat16
硬件
- GPU:512 個 Tesla A100
- 訓練時間:24 天
軟件
📄 許可證
該模型遵循 BigCode OpenRAIL - M v1 許可協議。你可以在 此處 找到完整協議。
📚 引用
@article{li2023starcoder,
title={StarCoder: may the source be with you!},
author={Raymond Li and Loubna Ben Allal and Yangtian Zi and Niklas Muennighoff and Denis Kocetkov and Chenghao Mou and Marc Marone and Christopher Akiki and Jia Li and Jenny Chim and Qian Liu and Evgenii Zheltonozhskii and Terry Yue Zhuo and Thomas Wang and Olivier Dehaene and Mishig Davaadorj and Joel Lamy-Poirier and João Monteiro and Oleh Shliazhko and Nicolas Gontier and Nicholas Meade and Armel Zebaze and Ming-Ho Yee and Logesh Kumar Umapathi and Jian Zhu and Benjamin Lipkin and Muhtasham Oblokulov and Zhiruo Wang and Rudra Murthy and Jason Stillerman and Siva Sankalp Patel and Dmitry Abulkhanov and Marco Zocca and Manan Dey and Zhihan Zhang and Nour Fahmy and Urvashi Bhattacharyya and Wenhao Yu and Swayam Singh and Sasha Luccioni and Paulo Villegas and Maxim Kunakov and Fedor Zhdanov and Manuel Romero and Tony Lee and Nadav Timor and Jennifer Ding and Claire Schlesinger and Hailey Schoelkopf and Jan Ebert and Tri Dao and Mayank Mishra and Alex Gu and Jennifer Robinson and Carolyn Jane Anderson and Brendan Dolan-Gavitt and Danish Contractor and Siva Reddy and Daniel Fried and Dzmitry Bahdanau and Yacine Jernite and Carlos Muñoz Ferrandis and Sean Hughes and Thomas Wolf and Arjun Guha and Leandro von Werra and Harm de Vries},
year={2023},
eprint={2305.06161},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
⚠️ 重要提示
請在接受之前閱讀 BigCode OpenRAIL - M 許可證 協議。
💡 使用建議
該模型不是指令模型,若要將其轉變為技術助手,可使用 Tech Assistant prompt。同時,對於生成的代碼,需注意其許可證可能要求的歸屬聲明和其他特定要求,可通過 搜索索引 確定代碼來源。