Hugging Face は、豊富なデータとオープンソースモデルリソースを提供する非常に人気のあるAIコミュニティです。Microsoft、Meta、Mistral、Apple、Google など、さまざまな企業が Hugging Face を通じてオープンソースの LLM や SLM を公開しています。
Microsoft Phi ファミリーは Hugging Face 上で公開されています。開発者はシナリオやビジネスに応じて対応する Phi ファミリーのモデルをダウンロードできます。Hugging Face 上で Phi の Pytorch モデルをデプロイするだけでなく、GGUF や ONNX フォーマットを使用した量子化モデルも公開しており、エンドユーザーに選択肢を提供しています。
以下のリンクから Phi ファミリーのモデルをダウンロードできます:
-
Phi-1 / 1.5 https://huggingface.co/collections/microsoft/phi-1-6626e29134744e94e222d572
-
Phi-3 / 3.5 https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3
-
Phi-4 https://huggingface.co/collections/microsoft/phi-4-677e9380e514feb5577a40e4
モデルは、Hugging Face CLI SDK をインストールするか、git clone を使用してダウンロードできます。
- Hugging Face CLI のインストール
pip install -U "huggingface_hub[cli]"
- huggingface-cli を使用してログイン
ユーザーアクセストークン を 設定ページ から取得し、Hugging Face にログインします。
huggingface-cli login --token $HF_TOKEN --add-to-git-credential
- ダウンロード
モデルをダウンロードしてキャッシュに保存できます。
huggingface-cli download microsoft/phi-4
特定の場所に保存することも可能です。
huggingface-cli download microsoft/phi-4 --local-dir $YOUR_PATH
git clone を使用してモデルをダウンロードすることもできます。
git lfs install
git clone https://huggingface.co/microsoft/phi-4
- transformers ライブラリのインストール
pip install transformers -U
- VSCode でコードを実行
import transformers
pipeline = transformers.pipeline(
"text-generation",
model="microsoft/phi-4",
model_kwargs={"torch_dtype": "auto"},
device_map="auto",
)
messages = [
{"role": "user", "content": "I have $20,000 in my savings account, where I receive a 4% profit per year and payments twice a year. Can you please tell me how long it will take for me to become a millionaire? Also, can you please explain the math step by step as if you were explaining it to an uneducated person?"},
]
outputs = pipeline(messages, max_new_tokens=2048)
print(outputs[0]["generated_text"][-1])
It seems like you are asking to translate the text into "mo." Could you clarify what "mo" refers to? Are you referring to a specific language or dialect? For example, are you referring to Māori, Montenegrin, or something else? Let me know, and I will assist you accordingly!