快速开始
[hidecontent type="logged" desc="隐藏内容:登录后可查看"]
所有 StableLM 模型都托管在Hugging Face hub上。查看此笔记本以使用有限的 GPU 功能运行推理。
StableLM-Tuned-Alpha
使用以下代码片段开始聊天:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList
tokenizer = AutoTokenizer.from_pretrained("stabilityai/stablelm-tuned-alpha-7b")
model = AutoModelForCausalLM.from_pretrained("stabilityai/stablelm-tuned-alpha-7b")
model.half().cuda()
class StopOnTokens(StoppingCriteria):
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
stop_ids = set([50278, 50279, 50277, 1, 0])
return input_ids[0][-1] in stop_ids
system_prompt = """<|SYSTEM|># StableLM Tuned (Alpha version)
- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
- StableLM will refuse to participate in anything that could harm a human.
"""
prompt = f"{system_prompt}<|USER|>What's your mood today?<|ASSISTANT|>"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
tokens = model.generate(
**inputs,
max_new_tokens=64,
temperature=0.7,
do_sample=True,
stopping_criteria=StoppingCriteriaList([StopOnTokens()])
)
print(tokenizer.decode(tokens[0], skip_special_tokens=True))
StableLM Tuned 应与格式化为的提示一起使用<|SYSTEM|>...<|USER|>...<|ASSISTANT|>...
系统提示为
<|SYSTEM|># StableLM Tuned (Alpha version)
- StableLM is a helpful and harmless open-source AI language model developed by StabilityAI.
- StableLM is excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.
- StableLM is more than just an information source, StableLM is also able to write poetry, short stories, and make jokes.
- StableLM will refuse to participate in anything that could harm a human.
StableLM-Tuned-Alpha 的乐趣
本节包含一系列精选的有趣示例,说明您可以使用stablelm-tuned-alpha
.
闲聊
正式写作
创意写作
编写代码
StableLM-Tuned-Alpha 的选定故障模式
本节包含 . 的选定故障模式的集合stablelm-tuned-alpha
Yann LeCun 齿轮(线性)
Yann LeCun 齿轮(圆形)
[/hidecontent]