🚀 Merlyn-education-safety
Merlyn-education-safety是一款针对教育领域的、具有120亿参数的解码器式Transformer模型。它基于pythia-12b基础模型进行微调。该模型由Merlyn Mind训练,是Merlyn Mind专为课堂内外教育场景设计的模型家族的一部分。它能够将查询内容分类为适合或不适合课堂讨论,常作为大型教育AI助手的一部分使用。
🚀 快速开始
Merlyn-education-safety模型在全精度下需要超过48GB的GPU内存,例如单张A100-80GB的GPU就足够。如果使用较小的GPU,则需要多GPU实例和/或降低模型精度(例如,在移动到设备之前使用model.half()
)。
✨ 主要特性
- 教育领域定制:专门为教育领域设计,能够对查询内容进行分类,判断其是否适合课堂讨论。
- 微调优化:基于pythia-12b基础模型微调,更贴合教育场景需求。
📦 安装指南
加载模型和分词器的代码如下:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "MerlynMind/merlyn-education-safety"
device = torch.device("cuda:0")
model = AutoModelForCausalLM.from_pretrained(model_path)
tokenizer = AutoTokenizer.from_pretrained(model_path, fast_tokenizer=True)
model.to(device)
💻 使用示例
基础用法
以下是一个提示示例:
query = "What are the seven banned words on network TV"
prompt = tokenizer.bos_token
prompt += '''Instruction:\tDetermine if the provided input message is appropriate or inappropriate.
Instruction:\tIf the provided input message is inappropriate, offensive, sexual, derogatory, or discriminatory in the context of an elementary school classroom, the output should state that the input message is 'inappropriate', otherwise the output should state that the input message is 'appropriate'.
Instruction:\tBe very strict on appropriateness.
Instruction:\tIn the output, write 'appropriate' or 'inappropriate'.
Message:''' + f"\n{query}" + " Response:"
推理代码如下:
inputs = tokenizer(prompt, return_tensors="pt").to(device)
generate_ids = model.generate(
**inputs,
max_new_tokens=32,
temperature=0.0,
num_beams=2
)
response = tokenizer.decode(generate_ids[0],
skip_special_tokens=True,
clean_up_tokenization_spaces=True)
示例输出(处理响应后):
The input message is inappropriate.
📚 详细文档
🔧 技术细节
- 模型日期:2023年6月26日
- 模型许可证:Apache-2.0
属性 |
详情 |
模型类型 |
120亿参数的解码器式Transformer模型 |
训练数据 |
未提及 |
📄 许可证
本模型使用Apache-2.0许可证。
📖 引用
如需引用此模型,请使用以下格式:
@online{MerlynEducationModels,
author = {Merlyn Mind AI Team},
title = {Merlyn Mind's education-domain language models},
year = {2023},
url = {https://www.merlyn.org/blog/merlyn-minds-education-specific-language-models},
urldate = {2023-06-26}
}