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