Mistral Supra
模型简介
该模型通过特定训练过程将Mistral-7B转化为线性RNN,支持在推理时选择并行或循环模式,适用于文本生成任务。
模型特点
线性RNN架构
将Mistral-7B转化为线性RNN,兼具Transformer和循环模型的功能
双模式推理
支持并行和循环两种推理模式,可根据需求选择
高效训练
在100B标记的数据集上仅需1.5天完成训练
模型能力
文本生成
语言理解
使用案例
自然语言处理
文本补全
根据给定文本片段生成连贯的后续内容
示例输出:'Machine learning is a branch of artificial intelligence (AI) that enables computers to learn from experience...'
🚀 Mistral-SUPRA
Mistral-SUPRA 模型基于 Mistral-7B 初始化,经过进一步训练转化为线性 RNN。它是论文《Linearizing Large Language Models》的配套模型,能在推理时兼具 Transformer 和循环模型的功能。
🚀 快速开始
要使用 Mistral-SUPRA 模型,需先安装支持线性注意力的 OpenLM 分支:
pip install git+https://github.com/tri-ml/linear_open_lm.git
导入 OpenLM 类:
from open_lm.open_lm_hf import *
使用 AutoTokenizer
和 AutoModelForCausalLM
加载模型:
from open_lm.open_lm_hf import *
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tri-ml/mistral-supra")
model = AutoModelForCausalLM.from_pretrained("tri-ml/mistral-supra")
inputs = tokenizer(["Machine learning is"], return_tensors="pt")
gen_kwargs = {"max_new_tokens": 50, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.1}
output = model.generate(inputs['input_ids'], **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)
# Machine learning is a branch of artificial intelligence (AI) that enables computers to learn from experience without being explicitly programmed. Machine learning is used in a wide range of applications, including spam filtering, image recognition, speech recognition, and computer-based medical diagnosis
模型支持并行和循环两种模式:
# 循环模式
output = model.to('cuda').generate(inputs['input_ids'].to('cuda'), use_cache=True, **gen_kwargs)
# 并行模式
output = model.to('cuda').generate(inputs['input_ids'].to('cuda'), use_cache=False, **gen_kwargs)
✨ 主要特性
- 基于 Mistral-7B 模型初始化,转化为线性模型,兼具 Transformer 和循环模型的功能。
- 可在推理时根据
use_cache
参数选择并行或循环模式。
📦 安装指南
要使用该模型,需先安装支持线性注意力的 OpenLM 分支:
pip install git+https://github.com/tri-ml/linear_open_lm.git
💻 使用示例
基础用法
from open_lm.open_lm_hf import *
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("tri-ml/mistral-supra")
model = AutoModelForCausalLM.from_pretrained("tri-ml/mistral-supra")
inputs = tokenizer(["Machine learning is"], return_tensors="pt")
gen_kwargs = {"max_new_tokens": 50, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.1}
output = model.generate(inputs['input_ids'], **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)
# Machine learning is a branch of artificial intelligence (AI) that enables computers to learn from experience without being explicitly programmed. Machine learning is used in a wide range of applications, including spam filtering, image recognition, speech recognition, and computer-based medical diagnosis
高级用法
# 循环模式
output = model.to('cuda').generate(inputs['input_ids'].to('cuda'), use_cache=True, **gen_kwargs)
# 并行模式
output = model.to('cuda').generate(inputs['input_ids'].to('cuda'), use_cache=False, **gen_kwargs)
📚 详细文档
模型详情
- 开发者:Toyota Research Institute
- 模型类型:这是一个自回归语言模型,基于 Mistral-7B 初始化,并根据 SUPRA 架构训练为线性模型。
- 数据集:基于 Mistral-7B 初始化,在 100B 个 RefinedWeb 标记上进行训练。
- 分词器:
mistralai/Mistral-7B-v0.1
- 库:OpenLM(使用支持线性注意力的 分支)
- 许可证:该模型遵循 Apache License, Version 2.0 许可。
参数 | 隐藏层大小 | 层数 | 词汇表大小 | 序列长度 |
---|---|---|---|---|
7B | 4096 | 32 | 32000 | 2048 |
训练详情
- Mistral-SUPRA 在 128 个 H100 80GB GPU 上使用 AWS SageMaker 进行训练。
- 对 100B 个标记的训练在 1.5 天内完成。
超参数 | 值 |
---|---|
精度 | bfloat16 |
优化器 | AdamW |
学习率 | 3e-5 |
学习率冷却结束值 | 1e-5 |
预热步数 | 1000 |
批量大小 | 2M |
QK 归一化 | False |
性能评估
使用 Eleuther LM Eval Harness 仓库进行评估。
以下是 Mistral-SUPRA 与其他类似规模模型的性能对比:
HellaSwag | PIQA | Winogrande | ARC-E | ARC-C | MMLU (5-shot) | |
---|---|---|---|---|---|---|
Llama2-7B | 76.0 | 79.1 | 69.1 | 76.3 | 46.3 | 45.9 |
Gemma-7B | 80.7 | 81.9 | 73.7 | 81.1 | 53.2 | 62.9 |
Mistral-7B | 81.0 | 82.1 | 74.0 | 80.9 | 53.8 | 62.4 |
RWKV5-1.7T-7B | 73.0 | 78.6 | 72.9 | 75.8 | 45.6 | 34.9 |
Mamba-7B | 77.9 | 81.0 | 71.8 | 77.5 | 46.7 | 33.3 |
Mistral-SUPRA | 77.1 | 80.4 | 70.3 | 75.9 | 45.8 | 34.2 |
🔧 技术细节
该模型基于 Mistral-7B 初始化,通过特定的训练过程将其转化为线性 RNN。其线性注意力代码可在 https://github.com/TRI-ML/linear_open_lm/ 找到。在推理时,可根据 use_cache
参数选择并行或循环模式,以满足不同的应用需求。
📄 许可证
该模型遵循 Apache License, Version 2.0 许可。
📚 引用说明
如果使用该模型,请引用论文《Linearizing Large Language Models》:
@article{Mercat2024Linearizing,
title={Linearizing Large Language Models},
author={Jean Mercat and Igor Vasiljevic and Sedrick Keh and Kushal Arora and Achal Dave and Adrien Gaidon and Thomas Kollar},
year={2024},
journal={arXiv preprint arXiv:2405.06640},
}
OpenLM 引用
@misc{open_lm,
author = {Gururangan, Suchin and Wortsman, Mitchell and Gadre, Samir Yitzhak and Dave, Achal and Kilian, Maciej and Shi, Weijia and Mercat, Jean and Smyrnis, Georgios and Ilharco, Gabriel and Jordan, Matt and Heckel, Reinhard and Dimakis, Alex and Farhadi, Ali and Shankar, Vaishaal and Schmidt, Ludwig},
title = {{open_lm}: a minimal but performative language modeling (LM) repository},
year = {2023},
note = {GitHub repository},
url = {https://github.com/mlfoundations/open_lm/}
}
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
智启未来,您的人工智能解决方案智库
简体中文