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
智启未来,您的人工智能解决方案智库
简体中文