Cadet Tiny
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
下載量 2,691
發布時間 : 4/7/2023
模型概述
Cadet-Tiny是一個基於t5-small預訓練模型微調而成的對話模型,適用於邊緣設備(如樹莓派)的輕量級對話任務。
模型特點
輕量級設計
專為低資源設備優化,可在僅2GB內存的設備上運行
對話記憶
支持對話歷史跟蹤和上下文理解
可調參數
提供temperature等可調參數控制生成多樣性
模型能力
對話生成
上下文理解
角色扮演對話
使用案例
邊緣設備應用
樹莓派聊天機器人
在資源受限的設備上部署輕量級對話助手
可在2GB內存設備上流暢運行
教育應用
編程學習助手
幫助學生理解編程概念的對話助手
🚀 Cadet-Tiny 是什麼?
受 Allen AI 的 Cosmo-XL 啟發,Cadet-Tiny 是一個基於 SODA 數據集訓練的 超小型 對話模型。Cadet-Tiny 旨在用於邊緣推理(甚至可以在僅有 2GB 內存的樹莓派上運行)。
Cadet-Tiny 基於谷歌的 t5-small 預訓練模型進行訓練,因此,它的大小約為 Cosmo-3B 模型的 2%。
這是我製作的第一個 SEQ2SEQ 自然語言處理模型!我非常激動能在 HuggingFace 上與大家分享它!😊
如果您有任何問題或改進建議,請通過以下郵箱聯繫我:tcgoldfarb@gmail.com
📦 模型信息
屬性 | 詳情 |
---|---|
許可證 | OpenRAIL |
訓練數據 | allenai/soda |
語言 | 英語 |
模型類型 | 對話式 |
📚 谷歌 Colab 鏈接
以下是谷歌 Colab 文件的鏈接,我在其中詳細介紹了模型的訓練過程以及如何使用 AI2 的 SODA 公共數據集。 點擊訪問
🚀 快速開始
使用以下代碼片段開始使用 Cadet-Tiny!
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import colorful as cf
cf.use_true_colors()
cf.use_style('monokai')
class CadetTinyAgent:
def __init__(self):
print(cf.bold | cf.purple("Waking up Cadet-Tiny..."))
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
self.tokenizer = AutoTokenizer.from_pretrained("t5-small", model_max_length=512)
self.model = AutoModelForSeq2SeqLM.from_pretrained("ToddGoldfarb/Cadet-Tiny", low_cpu_mem_usage=True).to(self.device)
self.conversation_history = ""
def observe(self, observation):
self.conversation_history = self.conversation_history + observation
# The number 400 below is just a truncation safety net. It leaves room for 112 input tokens.
if len(self.conversation_history) > 400:
self.conversation_history = self.conversation_history[112:]
def set_input(self, situation_narrative="", role_instruction=""):
input_text = "dialogue: "
if situation_narrative != "":
input_text = input_text + situation_narrative
if role_instruction != "":
input_text = input_text + " <SEP> " + role_instruction
input_text = input_text + " <TURN> " + self.conversation_history
# Uncomment the line below to see what is fed to the model.
# print(input_text)
return input_text
def generate(self, situation_narrative, role_instruction, user_response):
user_response = user_response + " <TURN> "
self.observe(user_response)
input_text = self.set_input(situation_narrative, role_instruction)
inputs = self.tokenizer([input_text], return_tensors="pt").to(self.device)
# I encourage you to change the hyperparameters of the model! Start by trying to modify the temperature.
outputs = self.model.generate(inputs["input_ids"], max_new_tokens=512, temperature=0.75, top_p=.95,
do_sample=True)
cadet_response = self.tokenizer.decode(outputs[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
added_turn = cadet_response + " <TURN> "
self.observe(added_turn)
return cadet_response
def reset_history(self):
self.conversation_history = []
def run(self):
def get_valid_input(prompt, default):
while True:
user_input = input(prompt)
if user_input in ["Y", "N", "y", "n"]:
return user_input
if user_input == "":
return default
while True:
continue_chat = ""
# MODIFY THESE STRINGS TO YOUR LIKING :)
situation_narrative = "Imagine you are Cadet-Tiny talking to ???."
role_instruction = "You are Cadet-Tiny, and you are talking to ???."
self.chat(situation_narrative, role_instruction)
continue_chat = get_valid_input(cf.purple("Start a new conversation with new setup? [Y/N]:"), "Y")
if continue_chat in ["N", "n"]:
break
print(cf.blue("CT: See you!"))
def chat(self, situation_narrative, role_instruction):
print(cf.green(
"Cadet-Tiny is running! Input [RESET] to reset the conversation history and [END] to end the conversation."))
while True:
user_input = input("You: ")
if user_input == "[RESET]":
self.reset_history()
print(cf.green("[Conversation history cleared. Chat with Cadet-Tiny!]"))
continue
if user_input == "[END]":
break
response = self.generate(situation_narrative, role_instruction, user_input)
print(cf.blue("CT: " + response))
def main():
print(cf.bold | cf.blue("LOADING MODEL"))
CadetTiny = CadetTinyAgent()
CadetTiny.run()
if __name__ == '__main__':
main()
📄 引用與特別感謝
特別感謝 Hyunwoo Kim 與我討論使用 SODA 數據集的最佳方法。如果您還沒有了解過他們在 SODA、Prosocial-Dialog 或 COSMO 方面的工作,我建議您去看看!同時,也請閱讀關於 SODA 的論文!論文信息如下:
@article{kim2022soda,
title={SODA: Million-scale Dialogue Distillation with Social Commonsense Contextualization},
author={Hyunwoo Kim and Jack Hessel and Liwei Jiang and Peter West and Ximing Lu and Youngjae Yu and Pei Zhou and Ronan Le Bras and Malihe Alikhani and Gunhee Kim and Maarten Sap and Yejin Choi},
journal={ArXiv},
year={2022},
volume={abs/2212.10465}
}
Dialogpt Medium
MIT
DialoGPT 是一個用於多輪對話的大規模預訓練對話響應生成模型,在單輪對話圖靈測試中表現與人類相當。
對話系統
D
microsoft
267.59k
368
Dialogpt Small
MIT
DialoGPT是一個最先進的大規模預訓練的多輪對話響應生成模型,在單輪對話圖靈測試下,其生成的響應質量可以與人類響應質量相媲美。
對話系統
D
microsoft
218.89k
123
Blenderbot 400M Distill
Apache-2.0
該模型通過大規模神經模型和精心設計的訓練策略,實現了多技能融合的開放域對話能力。
對話系統 英語
B
facebook
203.20k
431
Dialogpt Large
MIT
DialoGPT 是一個針對多輪對話的前沿大規模預訓練對話響應生成模型,在單輪對話圖靈測試中生成的響應質量與人類回答相當。
對話系統
D
microsoft
49.90k
276
Blenderbot 3B
Apache-2.0
這是一個基於大規模神經網絡的開放領域對話模型,能夠融合多種對話技能進行自然交流。
對話系統
Transformers 英語

B
facebook
11.92k
150
Blenderbot 90M
Apache-2.0
BlenderBot是一個開放域聊天機器人模型,專注於多輪對話和多種對話技能的融合。
對話系統
Transformers 英語

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

C
ToddGoldfarb
2,691
6
Blenderbot 1B Distill
Apache-2.0
該模型是一個高性能的開放領域聊天機器人,能夠融合多項對話技能,如提問、回答、展現知識和同理心等。
對話系統
Transformers 英語

B
facebook
2,413
37
Blenderbot Small 90M
Apache-2.0
這是一個基於大規模神經網絡的開放域對話系統,能夠進行多輪自然對話並融合多種對話技能。
對話系統 英語
B
facebook
2,407
49
Unieval Dialog
UniEval是針對自然語言生成任務的多維度評估框架,unieval-dialog是其針對對話響應生成任務的預訓練評估器。
對話系統
Transformers

U
MingZhong
2,021
4
精選推薦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