Jambatypus V0.1
基于Jamba-v0.1在Open-Platypus-Chat数据集上通过QLoRA微调的大语言模型,支持对话任务
下载量 21
发布时间 : 3/29/2024
模型简介
该模型是基于ai21labs/Jamba-v0.1微调的对话模型,使用ChatML模板进行交互,适合聊天和问答场景
模型特点
混合架构
结合Transformer和Mamba架构的优势,提供高效的长序列处理能力
QLoRA微调
使用QLoRA技术在有限资源下高效微调大模型
长上下文支持
支持4096 tokens的上下文长度
ChatML模板支持
使用标准化的ChatML模板格式进行对话交互
模型能力
文本生成
对话交互
问答系统
代码生成
创意写作
使用案例
对话系统
智能助手
构建能够理解自然语言指令的智能对话助手
客服机器人
用于自动回答客户常见问题的客服系统
教育
学习辅导
帮助学生解答学习问题,提供解释和示例
🚀 Jambatypus-v0.1
Jambatypus-v0.1 是一个基于Transformer架构的语言模型,它在特定数据集上进行了微调,能够提供更准确和高效的语言交互能力,适用于多种自然语言处理任务。
🚀 快速开始
本模型是 ai21labs/Jamba-v0.1 在 chargoddard/Open-Platypus-Chat 数据集上经过QLoRA微调后的版本。
它使用我的 LazyAxolotl - Jamba 笔记本,在 2 个 A100 80GB GPU 上进行训练。
本仓库包含了适配器和 FP16 精度的合并模型。
建议使用 ChatML 模板来使用此模型。
✨ 主要特性
- 微调优化:基于特定数据集进行QLoRA微调,提升模型性能。
- 多GPU训练:利用2个A100 80GB GPU进行训练,提高训练效率。
- 双模型支持:仓库包含适配器和FP16精度的合并模型。
📦 安装指南
以下代码用于创建一个与 Jambatypus 交互的 Gradio 聊天界面:
!pip install -qqq -U git+https://github.com/huggingface/transformers
!pip install -qqq mamba-ssm causal-conv1d>=1.2.0
!pip install -qqq accelerate bitsandbytes torch datasets peft gradio
!pip install -qqq flash-attn --no-build-isolation
💻 使用示例
基础用法
import torch
import gradio as gr
from threading import Thread
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextIteratorStreamer
STOP_TOKEN = "<|im_end|>"
def predict(message, history, system_prompt, temperature, max_new_tokens, top_k, repetition_penalty, top_p):
# Format history with a given chat template
stop_token = "<|im_end|>"
instruction = '<|im_start|>system\n' + system_prompt + '\n<|im_end|>\n'
for human, assistant in history:
instruction += '<|im_start|>user\n' + human + '\n<|im_end|>\n<|im_start|>assistant\n' + assistant
instruction += '\n<|im_start|>user\n' + message + '\n<|im_end|>\n<|im_start|>assistant\n'
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
enc = tokenizer([instruction], return_tensors="pt", padding=True, truncation=True)
input_ids, attention_mask = enc.input_ids, enc.attention_mask
generate_kwargs = dict(
{"input_ids": input_ids.to(device), "attention_mask": attention_mask.to(device)},
streamer=streamer,
do_sample=True,
temperature=temperature,
max_new_tokens=max_new_tokens,
top_k=top_k,
repetition_penalty=repetition_penalty,
top_p=top_p
)
t = Thread(target=model.generate, kwargs=generate_kwargs)
t.start()
outputs = []
for new_token in streamer:
if STOP_TOKEN in new_token:
outputs.append(new_token[:-len(stop_token)-1])
yield "".join(outputs)
break
outputs.append(new_token)
yield "".join(outputs)
# Load model
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
tokenizer = AutoTokenizer.from_pretrained("ai21labs/Jamba-v0.1")
# 4-bit precision quant config
quantization_config = BitsAndBytesConfig(
load_in_8bit=True,
llm_int8_skip_modules=["mamba"]
)
# Load model and tokenizer with ChatML format
model = AutoModelForCausalLM.from_pretrained(
"ai21labs/Jamba-v0.1",
trust_remote_code=True,
torch_dtype=torch.cuda.is_bf16_supported() and torch.bfloat16 or torch.float16,
attn_implementation="flash_attention_2",
low_cpu_mem_usage=True,
quantization_config=quantization_config
)
config = PeftConfig.from_pretrained("mlabonne/Jambatypus-v0.1")
model = PeftModel.from_pretrained(model, "mlabonne/Jambatypus-v0.1")
# Create Gradio interface
gr.ChatInterface(
predict,
title="Jambatypus",
description="Chat with Jambatypus!",
examples=[
["Can you solve the equation 2x + 3 = 11 for x?"],
["Write an epic poem about Ancient Rome."],
["Who was the first person to walk on the Moon?"],
["Use a list comprehension to create a list of squares for numbers from 1 to 10."],
["Recommend some popular science fiction books."],
["Can you write a short story about a time-traveling detective?"]
],
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False),
additional_inputs=[
gr.Textbox("Perform the task to the best of your ability.", label="System prompt"),
gr.Slider(0, 1, 0.8, label="Temperature"),
gr.Slider(128, 4096, 1024, label="Max new tokens"),
gr.Slider(1, 80, 40, label="Top K sampling"),
gr.Slider(0, 2, 1.1, label="Repetition penalty"),
gr.Slider(0, 1, 0.95, label="Top P sampling"),
],
theme=gr.themes.Soft(primary_hue="green"),
).queue().launch(share=True)
📚 详细文档
训练超参数
训练过程中使用了以下超参数:
- 学习率:0.0002
- 训练批次大小:1
- 评估批次大小:1
- 随机种子:42
- 分布式类型:多GPU
- 设备数量:2
- 梯度累积步数:8
- 总训练批次大小:16
- 总评估批次大小:2
- 优化器:Adam(betas=(0.9,0.95),epsilon=1e-05)
- 学习率调度器类型:余弦
- 学习率调度器热身步数:10
- 训练轮数:1
训练结果
训练损失 | 轮数 | 步数 | 验证损失 |
---|---|---|---|
0.6274 | 0.01 | 1 | 1.0298 |
0.44 | 0.25 | 42 | 0.9770 |
0.4406 | 0.5 | 84 | 0.9653 |
0.4445 | 0.75 | 126 | 0.9645 |
0.4609 | 1.0 | 168 | 0.9641 |
框架版本
- PEFT 0.10.0
- Transformers 4.40.0.dev0
- Pytorch 2.1.2+cu118
- Datasets 2.18.0
- Tokenizers 0.15.0
📄 许可证
本项目采用 Apache-2.0 许可证。
信息表格
属性 | 详情 |
---|---|
模型类型 | 基于ai21labs/Jamba - v0.1微调的QLoRA模型 |
训练数据 | chargoddard/Open - Platypus - Chat |
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