🚀 Phi-2 物理问答模型
本项目是基于 ArtifactAI/arxiv-physics-instruct-30k 数据集训练的 Phi-2 模型,主要用于科研目的,请勿用于生产环境。
🚀 快速开始
本模型是在 transformers
库中使用的语言模型,下面为你展示使用该模型的示例脚本。
基础用法
from huggingface_hub import notebook_login
from datasets import load_dataset, Dataset
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model = "ArtifactAI/phi-2-arxiv-physics-instruct"
model = AutoModelForCausalLM.from_pretrained(base_model, trust_remote_code= True)
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
def generate(prompt):
inputs = tokenizer(f'''Below is an instruction that describes a task. Write a response that appropriately completes the request If you are adding additional white spaces, stop writing".\n\n### Instruction:\n{prompt}.\n\n### Response:\n ''', return_tensors="pt", return_attention_mask=False)
streamer = TextStreamer(tokenizer, skip_prompt= True)
_ = model.generate(**inputs, streamer=streamer, max_new_tokens=500)
generate("what is an atom?")
✨ 主要特性
- 模型类型:语言模型
- 支持语言:英语
- 许可证:Apache 2.0
- 相关模型:Phi-1_5
📦 安装指南
文档中未提及具体安装步骤,暂无法提供。
💻 使用示例
基础用法
from huggingface_hub import notebook_login
from datasets import load_dataset, Dataset
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
model = "ArtifactAI/phi-2-arxiv-physics-instruct"
model = AutoModelForCausalLM.from_pretrained(base_model, trust_remote_code= True)
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
def generate(prompt):
inputs = tokenizer(f'''Below is an instruction that describes a task. Write a response that appropriately completes the request If you are adding additional white spaces, stop writing".\n\n### Instruction:\n{prompt}.\n\n### Response:\n ''', return_tensors="pt", return_attention_mask=False)
streamer = TextStreamer(tokenizer, skip_prompt= True)
_ = model.generate(**inputs, streamer=streamer, max_new_tokens=500)
generate("what is an atom?")
📚 详细文档
训练数据
该模型在 ArtifactAI/arxiv-physics-instruct-50k 数据集上进行训练,这是一个问答对数据集。问题使用 t5-base 模型生成,答案使用 GPT-3.5-turbo 模型生成。
📄 许可证
本模型使用 Apache 2.0 许可证。
📄 引用信息
@misc{phi-arxiv-physics-instruct,
title={phi-2-arxiv-physics-instruct},
author={Matthew Kenney},
year={2023}
}
⚠️ 重要提示
本模型仅用于研究目的,请勿用于生产环境。