stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?

stable diffusion模型是Stability AI开源的一个text-to-image的扩散模型,其模型在速度与质量上面有了质的突破,玩家们可以在自己消费级GPU上面来运行此模型,本模型基于CompVis 和 Runway 团队的Latent Diffusion Models。本期我们不介绍stable diffusion模型,而是介绍一下Stability AI开源的4款LLM大语言模型。

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第1张图片

也许是ChatGPT的大火,带动了LLM大语言模型的节奏,让各个大厂都开始搭建自己的LLM大语言模型,而作为一个AI绘画起家的Stability AI也开源了自己的四款LLM大语言模型。

Stable Beluga

Stability AI 及其 CarperAI 实验室发布了 Stable Beluga 1 及其后继产品 Stable Beluga 2。这是两个强大的新型开放式大型语言模型 (LLM)。 两种模型在不同的基准测试中都表现出了卓越的推理能力。

  • Stable Beluga 1 利用原始的 LLaMA 65B 基础模型,并使用标准 Alpaca 格式的数据集进行了微调。 
  • Stable Beluga 2 利用 LLaMA 2 70B 基础模型,并进行相关数据集上的微调。

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第2张图片

与其他大模型相比,其Stable Beluga模型取得的不错的效果。且我们可以直接使用transformers模型库来实现Stable Beluga大语言模型。

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第3张图片

首先需要安装transformers库,直接使用pip 进行安装即可。当然其python环境与torch相关的第三方库需要提前配置完成。

pip install transformers

安装完成后,就可以直接使用模型来进行AI对话。

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained("stabilityai/StableBeluga2", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("stabilityai/StableBeluga2", torch_dtype=torch.float16, low_cpu_mem_usage=True, device_map="auto")
system_prompt = "### System:\nYou are Stable Beluga, an AI that follows instructions extremely well. Help as much as you can. Remember, be safe, and don't do anything illegal.\n\n"
message = "Write me a poem please"
prompt = f"{system_prompt}### User: {message}\n\n### Assistant:\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
output = model.generate(**inputs, do_sample=True, top_p=0.95, top_k=0, max_new_tokens=256)
print(tokenizer.decode(output[0], skip_special_tokens=True))

代码运行后,会自动下载相关的预训练模型。

Stable LM

Stability AI 发布的开源语言模型 Stable LM,其 Alpha 版本有 30 亿和 70 亿个参数2种规格的模型,后续还有 150 亿到 650 亿个参数模型。 所有人在遵守 CC BY-SA-4.0 许可的条件下,可以出于商业或研究目的来使用或者调整 Stable LM 基础模型。

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第4张图片

Stable LM 在 The Pile 上构建的新实验数据集上进行训练,该数据集包含 1.5 万亿个标记内容。 尽管该数据集的丰富性使 Stable LM 在会话和编程任务上具有令人惊讶的表现,但是其参数规模较小(只有 3 到 70 亿个参数,相比之下,GPT-3 有 1750 亿个参数)。

同样,Stable LM可以使用transformers库来实现。

from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-base-alpha-7b-v2")
model = AutoModelForCausalLM.from_pretrained(
  "stabilityai/stablelm-base-alpha-7b-v2",
  trust_remote_code=True,
  torch_dtype="auto",)
model.cuda()
inputs = tokenizer("what is you name", return_tensors="pt").to("cuda")
tokens = model.generate(
  **inputs,
  max_new_tokens=64,
  temperature=0.75,
  top_p=0.95,
  do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第5张图片

Stable Code 

顾名思义,stable code是为特定人群提供的code编码LLM大模型,类似Meta开源的code LIama,通过使用三种不同尺寸的模型来帮助编程开发人员进行编码工作,从而提高工作效率。 

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第6张图片

基本模型首先使用BigCode 的堆栈数据集 (v1.2) ,并在多种编程语言进行训练,然后使用 Python、Go、Java、Javascript、C、markdown 和 C++ 等编程语言进行进一步训练。 

from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablecode-completion-alpha-3b-4k")
model = AutoModelForCausalLM.from_pretrained(
  "stabilityai/stablecode-completion-alpha-3b-4k",
  trust_remote_code=True,
  torch_dtype="auto",)
model.cuda()
inputs = tokenizer("import torch\nimport torch.nn as nn", return_tensors="pt").to("cuda")
tokens = model.generate(
  **inputs,
  max_new_tokens=48,
  temperature=0.2,
  do_sample=True,
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?_第7张图片

https://huggingface.co/stabilityai #参考链接

stable diffusion 相关阅读

Stable Diffusion加chilloutmixni真人图片生成模型

代码实现stable-diffusion模型

stable diffusion AI精准绘图——ControlNet控件的安装与使用

动画详解transformer  

更多transformer,VIT,swin tranformer
参考头条号:人工智能研究所
v号:启示AI科技
微信中复制如下链接,打开,免费体验chatgpt
 
https://wx2.expostar.cn/qz/pages/manor/index?id=1137&share_from_id=79482&sid=24

你可能感兴趣的:(stable,diffusion,语言模型,人工智能)