Starcoder2 3b GGUF
StarCoder2-3B是一個擁有30億參數的代碼生成模型,基於17種編程語言數據訓練,能夠生成代碼片段但可能不完全準確。
下載量 300
發布時間 : 3/2/2024
模型概述
StarCoder2-3B是一個專注於代碼生成的AI模型,主要用於輔助編程任務,能夠根據上下文生成代碼片段。
模型特點
多語言支持
基於17種編程語言數據進行訓練,支持多種編程語言的代碼生成
先進注意力機制
採用分組查詢注意力和16384標記的上下文窗口,增強模型理解能力
高效訓練
使用bfloat16精度進行訓練,預訓練超過3萬億標記
量化支持
支持8位和4位量化,顯著降低內存佔用
模型能力
代碼自動補全
代碼片段生成
函數實現
代碼理解
使用案例
開發輔助
函數生成
根據函數簽名自動生成函數實現
可生成基本函數結構但可能需要人工調整
代碼補全
在IDE中提供代碼補全建議
提供上下文相關的代碼建議
教育
編程學習輔助
為學習者提供代碼示例
可展示基本編程概念實現
🚀 StarCoder2
StarCoder2-3B是一個擁有30億參數的模型,它基於17種編程語言的數據進行訓練,能夠生成代碼片段,但生成的代碼不一定能按預期工作。
🚀 快速開始
安裝依賴
首先,確保從源代碼安裝transformers
:
pip install git+https://github.com/huggingface/transformers.git
運行模型
在CPU/GPU/多GPU上運行模型
- 使用全精度
# pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "bigcode/starcoder2-3b"
device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
# for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
Memory footprint: 12624.81 MB
- 使用
torch.bfloat16
# pip install accelerate
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
checkpoint = "bigcode/starcoder2-3b"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
# for fp16 use `torch_dtype=torch.float16` instead
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
Memory footprint: 6312.41 MB
通過bitsandbytes
進行量化版本
- 使用8位精度(int8)
# pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
# to use 4bit use `load_in_4bit=True` instead
quantization_config = BitsAndBytesConfig(load_in_8bit=True)
checkpoint = "bigcode/starcoder2-3b"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
# load_in_8bit
Memory footprint: 3434.07 MB
# load_in_4bit
>>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
Memory footprint: 1994.90 MB
✨ 主要特性
- 訓練數據豐富:基於來自 The Stack v2 的17種編程語言數據進行訓練,排除了選擇退出請求的數據。
- 先進技術應用:使用 Grouped Query Attention、16384個標記的上下文窗口 以及 4096個標記的滑動窗口注意力,並採用 Fill-in-the-Middle目標 進行訓練。
📦 安裝指南
確保從源代碼安裝transformers
:
pip install git+https://github.com/huggingface/transformers.git
📚 詳細文檔
模型概述
StarCoder2-3B模型是一個擁有30億參數的模型,在17種編程語言上進行訓練。
- 項目網站:bigcode-project.org
- 論文:Link
- 聯繫方式:contact@bigcode-project.org
- 支持語言:17種編程語言
預期用途
該模型在GitHub代碼以及其他選定的數據源(如Arxiv和Wikipedia)上進行訓練。因此,它不是一個指令模型,像“編寫一個計算平方根的函數”這樣的命令效果不佳。
歸因及其他要求
該模型的預訓練數據集僅過濾了許可寬鬆的許可證和無許可證的代碼。然而,模型可以逐字生成數據集中的源代碼。代碼的許可證可能要求歸因和/或其他特定要求,必須予以遵守。我們提供了一個 搜索索引,可讓您搜索預訓練數據,以確定生成的代碼來源,並對您的代碼進行適當的歸因。
侷限性
該模型在600多種編程語言的源代碼上進行訓練。源代碼中主要語言是英語,儘管也存在其他語言。因此,該模型能夠在提供一些上下文的情況下生成代碼片段,但生成的代碼不一定能按預期工作。它可能效率低下、包含錯誤或漏洞。有關模型侷限性的深入討論,請參閱 論文。
訓練
模型
- 架構:具有分組查詢和滑動窗口注意力以及Fill-in-the-Middle目標的Transformer解碼器
- 預訓練步驟:120萬步
- 預訓練標記:3萬億以上
- 精度:bfloat16
硬件
- GPU:160個A100
軟件
- 框架:TODO
- 神經網絡:PyTorch
🔧 技術細節
評估指標
任務類型 | 數據集名稱 | 指標類型 | 指標值 |
---|---|---|---|
文本生成 | CruxEval-I | pass@1 | 32.7 |
文本生成 | DS-1000 | pass@1 | 25.0 |
文本生成 | GSM8K (PAL) | 準確率 | 27.7 |
文本生成 | HumanEval+ | pass@1 | 27.4 |
文本生成 | HumanEval | pass@1 | 31.7 |
文本生成 | RepoBench-v1.1 | 編輯相似度 | 71.19 |
📄 許可證
該模型遵循BigCode OpenRAIL-M v1許可協議。您可以在 此處 找到完整協議。
📚 引用
@misc{lozhkov2024starcoder,
title={StarCoder 2 and The Stack v2: The Next Generation},
author={Anton Lozhkov and Raymond Li and Loubna Ben Allal and Federico Cassano and Joel Lamy-Poirier and Nouamane Tazi and Ao Tang and Dmytro Pykhtar and Jiawei Liu and Yuxiang Wei and Tianyang Liu and Max Tian and Denis Kocetkov and Arthur Zucker and Younes Belkada and Zijian Wang and Qian Liu and Dmitry Abulkhanov and Indraneil Paul and Zhuang Li and Wen-Ding Li and Megan Risdal and Jia Li and Jian Zhu and Terry Yue Zhuo and Evgenii Zheltonozhskii and Nii Osae Osae Dade and Wenhao Yu and Lucas Krauß and Naman Jain and Yixuan Su and Xuanli He and Manan Dey and Edoardo Abati and Yekun Chai and Niklas Muennighoff and Xiangru Tang and Muhtasham Oblokulov and Christopher Akiki and Marc Marone and Chenghao Mou and Mayank Mishra and Alex Gu and Binyuan Hui and Tri Dao and Armel Zebaze and Olivier Dehaene and Nicolas Patry and Canwen Xu and Julian McAuley and Han Hu and Torsten Scholak and Sebastien Paquet and Jennifer Robinson and Carolyn Jane Anderson and Nicolas Chapados and Mostofa Patwary and Nima Tajbakhsh and Yacine Jernite and Carlos Muñoz Ferrandis and Lingming Zhang and Sean Hughes and Thomas Wolf and Arjun Guha and Leandro von Werra and Harm de Vries},
year={2024},
eprint={2402.19173},
archivePrefix={arXiv},
primaryClass={cs.SE}
}
模型 bigcode/starcoder2-3b 的量化。 使用 llm-quantizer 管道創建。
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98