見出し画像

Google Colab で Phi-3.5-mini-instruct を試す

「Google Colab」で「Phi-3.5-mini-instruct」を試したのでまとめました。


1. Phi-3.5-mini-instruct

「Phi-3.5-mini」は、「Phi-3」に使用されるデータセットで構築された軽量で最先端のオープンモデルです。128Kトークンのコンテキスト長をサポートします。

2. Colabでの実行

Colabでの実行手順は、次のとおりです。

(1) パッケージのインストール。

# パッケージのインストール
!pip install transformers==4.43.0 accelerate==0.31.0 flash_attn==2.5.8

(2) モデルとトークナイザーとパイプラインの準備。

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

# モデルとトークナイザーの準備
model = AutoModelForCausalLM.from_pretrained(
    "microsoft/Phi-3.5-mini-instruct", 
    device_map="cuda", 
    torch_dtype="auto", 
    trust_remote_code=True, 
)
tokenizer = AutoTokenizer.from_pretrained(
    "microsoft/Phi-3.5-mini-instruct"
)

# パイプラインの準備
pipe = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
)

(3) 推論の実行。

# メッセージの準備
messages = [
    {"role": "user", "content": "まどか☆マギカでは誰が一番かわいい?"},
]

# 推論の実行
generation_args = {
    "max_new_tokens": 500,
    "return_full_text": False,
    "temperature": 0.0,
    "do_sample": False,
}
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])

まどか☆マギカ(Makaga Mario)は、日本のアニメやゲームのフィギュアキャラクターをモチーフにしたファンタジーのコンテンツです。このコンテンツ内で「一番かわいい」という感情は主観的なものであり、ファンや作者によって異なる可能性があります。

もしあなたがこのコンテンツにおけるキャラクターの魅力を判断したい場合は、以下の点を考慮してみてください:

1. デザインの美しさ
2. キャラクターの性格やストーリー
3. ファンの好みや支持度

ファンやコミュニティからの意見を集めたり、作品内でのキャラクターの役割や展開を評価してみると、「一番かわいい」と感じるキャラクターが見つかるかもしれません。

ただし、具体的なデータや詳細な情報がないと正確な回答を提供することは難しいです。

(4) 英語でも推論

# メッセージの準備
messages = [
    {"role": "user", "content": "Who is the cutest in Madoka Magica?"},
]

# 推論の実行
generation_args = {
    "max_new_tokens": 500,
    "return_full_text": False,
    "temperature": 0.0,
    "do_sample": False,
}
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])

The concept of "cuteness" is subjective and can vary greatly from person to person. In the anime series "Madoka Magica," characters may be perceived as cute by some viewers due to their design, personality, or the way they are portrayed. However, it's important to note that cuteness is a matter of personal taste and not an objective measure.
Here are a few characters from "Madoka Magica" that might be considered cute by some fans:

1. Madoka Kaname: She is the main protagonist, and her innocent and kind nature, along with her beautiful appearance, might be seen as cute by many.

2. Homura Akemi: Homura's character design, with her long black hair and delicate features, along with her determined and gentle personality, could be considered cute by some viewers.

3. Kurisu Makise: Although Kurisu's character is more complex and serious, her youthful appearance and the way she interacts with others might appeal to some fans.

4. Sakura Kinomoto: While not a main character in "Madoka Magica," Sakura Kinomoto is a popular character from another anime series, "Cardcaptor Sakura." Her cute and energetic personality might resonate with fans of both shows.
Remember that cuteness is a matter of personal preference, and different viewers may have different opinions on which characters they find the most cute.

【翻訳】
「かわいさ」という概念は主観的なものであり、人によって大きく異なります。アニメシリーズ「まどか☆マギカ」では、キャラクターのデザイン、性格、または描かれ方により、一部の視聴者はキャラクターをかわいいと感じる場合があります。ただし、かわいさは個人的な好みの問題であり、客観的な基準ではないことに注意することが重要です。

一部のファンがかわいいと思うかもしれない「まどか☆マギカ」のキャラクターをいくつか紹介します。

1. 鹿目まどか:彼女は主人公であり、彼女の純粋で優しい性格と美しい容姿は、多くの人にかわいいと思われるかもしれません。2.暁美ほむら:ほむらのキャラクターデザインは、長い黒髪と繊細な顔立ち、そして決断力のある優しい性格と相まって、一部の視聴者にかわいいと思われるかもしれません。

3. 牧瀬紅里:紅里のキャラクターはより複雑で深刻ですが、彼女の若々しい容姿と他の人との交流の仕方は、一部のファンにアピールするかもしれません。

4. 木之本桜:木之本桜は「まどか☆マギカ」の主人公ではありませんが、別のアニメシリーズ「カードキャプターさくら」の人気キャラクターです。彼女のかわいくて元気な性格は、両方の番組のファンの共感を呼ぶかもしれません。

かわいさは個人の好みの問題であり、どのキャラクターが一番かわいいと思うかについては視聴者によって意見が異なる場合があることを覚えておいてください。

関連



この記事が気に入ったらサポートをしてみませんか?