SSブログ

ヒガンバナ [相鉄沿線]

まだまだ暑い日が続いていますが、もう9月も中旬なんですね。
今年は(も)忙しくて、まだ夏休みをとれていません....




コスモスも咲き始めていました。






ひさしぶりに、チョットGPT
6月に「Microsoftがたった13億のパラメーターでGPT-3.5超えのHumanEval50.6%をたたき出す「phi-1」を発表」https://gigazine.net/news/20230622-phi-1-large-language-model-microsoft/
という記事が出ていましたが、先週Hugging faceに microsoft/phi-1_5 が公開されていました。
https://huggingface.co/microsoft/phi-1_5
モデルのファイルサイズが3GBしかないので、10万円以下のゲーミングノートパソコンでも動かせるサイズですね。

Hugging faceのサンプルをちょっと変えて、Pythonで、曜日を取得する方法を聞いてみました。
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

torch.set_default_device('cuda')
model = AutoModelForCausalLM.from_pretrained(
    "microsoft/phi-1_5", trust_remote_code=True, torch_dtype="auto")
tokenizer = AutoTokenizer.from_pretrained(
    "microsoft/phi-1_5", trust_remote_code=True, torch_dtype="auto")


inputs = tokenizer(
    'def get_day_of_the_week(d: datetime) -> str:\n    """ ',
     return_tensors="pt", return_attention_mask=False)

outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)


def get_day_of_the_week(d: datetime) -> str:
    """ 
    Given a datetime object, returns the day of the week as a string.
    """
    days_of_week = ["Monday", "Tuesday", "Wednesday", 
        "Thursday", "Friday", "Saturday", "Sunday"]
    return days_of_week[d.weekday()]

<|endoftext|>


ちゃんとできてますね。

これはどうかな?
'Why Do Japanese People Love Sakura so Much ?'

Sakura is a type of flower that blooms in the spring and summer, and is often associated with Japan and its culture. It is a symbol of beauty, grace, and renewal, and is often used in traditional Japanese art and literature. But why do Japanese people love Sakura so much? One reason is that Sakura is a reminder of the beauty and fragility of life. In Japan, life is often seen as a precious gift, and people are encouraged to appreciate the simple things in life. Sakura is a symbol of this appreciation, and is often given as a gift to show love and gratitude. Another reason is that Sakura is a symbol of the changing seasons. In Japan, the seasons are divided into four: spring, summer, autumn, and winter. Each season has its own unique beauty, and Sakura is a symbol of the beauty of spring and summer. It is a reminder that even in the midst of the cold and dark winter months, there is still beauty and hope. But Sakura is not just a symbol of beauty and hope. It is also a symbol of resilience and strength. In Japan, there are many examples of people who have overcome great adversity and hardship. Sakura is a symbol of this resilience, and is often used in traditional Japanese art and literature to represent the strength of the human spirit.

すごい。驚きました。

LLMは、大きなモデルほど性能が良くなると考えられていて、1千億パラメータを超えるモデルもいくつも出てきて、高価なGPUを沢山使って動かすものが増えてきていますが、Microsoft phi-1 は、モデルを大きくするのではなく、AIに学習させるデータの質を良くして、性能を上げているそうです。
学習は、量より質ということなのかな?




nice!(18)  コメント(0) 

nice! 18

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。