H2ogpt Gm Oasst1 En 2048 Open Llama 3b
基于OpenAssistant/oasst1数据集微调的3B参数大语言模型,使用H2O LLM Studio训练
下载量 139
发布时间 : 6/28/2023
模型简介
该模型是基于Open Llama 3B架构微调的大语言模型,专注于英语文本生成任务,采用Apache-2.0许可证发布。
模型特点
高效微调
使用H2O LLM Studio工具对基础模型进行高效微调
对话优化
基于OpenAssistant对话数据集优化,适合对话场景
开源许可
采用Apache-2.0许可证,允许商业用途
模型能力
文本生成
对话系统
问答系统
使用案例
对话系统
智能客服
用于构建自动客服对话系统
内容生成
文章创作
辅助生成各类文本内容
🚀 模型卡片
本模型基于H2O LLM Studio训练,使用了特定的基础模型和数据集,可借助transformers
库在GPU机器上使用。以下将详细介绍模型的相关信息,包括使用方法、架构、配置等。
🚀 快速开始
本模型使用 H2O LLM Studio 进行训练。
- 基础模型:openlm-research/open_llama_3b
- 数据集准备:OpenAssistant/oasst1 个性化处理
✨ 主要特性
- 基于特定基础模型:以
openlm-research/open_llama_3b
为基础模型进行训练。 - 使用特定数据集:使用
OpenAssistant/oasst1
数据集,并进行了个性化处理。 - 支持
transformers
库:可方便地在支持GPU的机器上使用transformers
库调用该模型。
📦 安装指南
要在配备GPU的机器上使用transformers
库调用此模型,首先要确保已安装transformers
、accelerate
和torch
库。
pip install transformers==4.30.2
pip install accelerate==0.20.3
pip install torch==2.0.0
💻 使用示例
基础用法
import torch
from transformers import pipeline
generate_text = pipeline(
model="h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-3b",
torch_dtype="auto",
trust_remote_code=True,
use_fast=False,
device_map={"": "cuda:0"},
)
res = generate_text(
"Why is drinking water so healthy?",
min_new_tokens=2,
max_new_tokens=1024,
do_sample=False,
num_beams=1,
temperature=float(0.3),
repetition_penalty=float(1.2),
renormalize_logits=True
)
print(res[0]["generated_text"])
你可以在预处理步骤后打印一个示例提示,以查看它是如何输入到分词器中的:
print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
<|prompt|>Why is drinking water so healthy?</s><|answer|>
高级用法
你也可以从加载的模型和分词器自行构建管道,并考虑预处理步骤:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-3b" # either local folder or huggingface model name
# Important: The prompt needs to be in the same format the model was trained with.
# You can find an example prompt in the experiment logs.
prompt = "<|prompt|>How are you?</s><|answer|>"
tokenizer = AutoTokenizer.from_pretrained(
model_name,
use_fast=False,
trust_remote_code=True,
)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map={"": "cuda:0"},
trust_remote_code=True,
)
model.cuda().eval()
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
# generate configuration can be modified to your needs
tokens = model.generate(
**inputs,
min_new_tokens=2,
max_new_tokens=1024,
do_sample=False,
num_beams=1,
temperature=float(0.3),
repetition_penalty=float(1.2),
renormalize_logits=True
)[0]
tokens = tokens[inputs["input_ids"].shape[1]:]
answer = tokenizer.decode(tokens, skip_special_tokens=True)
print(answer)
📚 详细文档
模型架构
LlamaForCausalLM(
(model): LlamaModel(
(embed_tokens): Embedding(32000, 3200, padding_idx=0)
(layers): ModuleList(
(0-25): 26 x LlamaDecoderLayer(
(self_attn): LlamaAttention(
(q_proj): Linear(in_features=3200, out_features=3200, bias=False)
(k_proj): Linear(in_features=3200, out_features=3200, bias=False)
(v_proj): Linear(in_features=3200, out_features=3200, bias=False)
(o_proj): Linear(in_features=3200, out_features=3200, bias=False)
(rotary_emb): LlamaRotaryEmbedding()
)
(mlp): LlamaMLP(
(gate_proj): Linear(in_features=3200, out_features=8640, bias=False)
(down_proj): Linear(in_features=8640, out_features=3200, bias=False)
(up_proj): Linear(in_features=3200, out_features=8640, bias=False)
(act_fn): SiLUActivation()
)
(input_layernorm): LlamaRMSNorm()
(post_attention_layernorm): LlamaRMSNorm()
)
)
(norm): LlamaRMSNorm()
)
(lm_head): Linear(in_features=3200, out_features=32000, bias=False)
)
模型配置
本模型使用H2O LLM Studio进行训练,并采用了 cfg.yaml 中的配置。访问 H2O LLM Studio 以了解如何训练你自己的大语言模型。
🔧 技术细节
本模型基于openlm-research/open_llama_3b
基础模型,使用OpenAssistant/oasst1
数据集进行个性化训练。在训练过程中,通过特定的配置和预处理步骤,使得模型能够更好地适应特定的任务和数据。模型架构为LlamaForCausalLM
,包含多个LlamaDecoderLayer
,通过自注意力机制和多层感知机进行特征提取和文本生成。
📄 许可证
本模型采用 Apache-2.0 许可证。
⚠️ 免责声明
在使用本仓库提供的大语言模型之前,请仔细阅读本免责声明。使用该模型即表示你同意遵守以下条款和条件。
- 偏差与冒犯性:大语言模型是在各种互联网文本数据上进行训练的,这些数据可能包含有偏差、种族主义、冒犯性或其他不适当的内容。使用此模型即表示你承认并接受生成的内容有时可能会表现出偏差或产生冒犯性或不适当的内容。本仓库的开发者不认可、支持或推广任何此类内容或观点。
- 局限性:大语言模型是基于人工智能的工具,而非人类。它可能会产生不正确、无意义或不相关的回复。用户有责任批判性地评估生成的内容,并自行决定是否使用。
- 自担风险:使用此大语言模型的用户必须对使用该工具可能产生的任何后果承担全部责任。本仓库的开发者和贡献者不对因使用或滥用所提供的模型而导致的任何损害、损失或伤害承担责任。
- 道德考量:鼓励用户负责任且合乎道德地使用大语言模型。使用此模型即表示你同意不将其用于宣扬仇恨言论、歧视、骚扰或任何形式的非法或有害活动。
- 问题报告:如果你遇到大语言模型生成的任何有偏差、冒犯性或其他不适当的内容,请通过提供的渠道向仓库维护者报告。你的反馈将有助于改进模型并减轻潜在问题。
- 免责声明的变更:本仓库的开发者保留随时修改或更新本免责声明的权利,无需事先通知。用户有责任定期查看免责声明,以了解任何变更。
使用本仓库提供的大语言模型即表示你同意接受并遵守本免责声明中规定的条款和条件。如果你不同意本免责声明的任何部分,则应避免使用该模型及其生成的任何内容。
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