🚀 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}
}
⚠️ 重要提示
本模型僅用於研究目的,請勿用於生產環境。