SSブログ

さくらさく [相鉄沿線]

こども自然公園の桜山の桜
一分咲きぐらいになっていました。


一本桜は、七分咲きぐらいかな?




大きなヤマザクラ


大きな猫







最近、大きなCatGPTじゃなくて、ChatGPTなどの大規模言語モデル(LLM:Large Language Model)が話題になっていますね。
MetaのLLaMAやGoogleのFlan-T5のように、モデルが公開されていて、メモリの大きなパソコンなら動かせるようなものもあるんですね。
メモリ48GBのGPUを使える機会があったので、Flan-T5のXXL( https://huggingface.co/google/flan-t5-xxl )というのを試してみました。

PyTorchとtransformers, sentencepiece, accelerateがインストールしてある環境だとたった3行でmodelを読み込んで使えるらしいです。

from transformers import T5Tokenizer, T5ForConditionalGeneration

tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto")

メモリは、40GBぐらい使うので、まだ普通のノートパソコンで動かすのは無理そうですね。



input_text = "What is the National Flower of Japan?"

input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")

outputs = model.generate(input_ids, max_length=200, bos_token_id=0)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)

sakura
CPU times: user 323 ms, sys: 5.6 ms, total: 329 ms
Wall time: 324 ms

日本の花は、sakuraって0.3秒で返ってきました。

Q.: "Why Do Japanese People Love Sakura so Much?"
A : Japanese people love cherry blossoms
日本人は、なぜそんなに桜がすきなの?って聞いたら、桜の花が好きだからって言うから、子供のなぜなぜ攻撃じゃないけど、

Q : "Why Do Japanese people love cherry blossoms?"
A : they are a symbol of spring

Q : "Why are cherry blossoms a symbol of spring ?"
A : they bloom in spring

なんか、きりがないですね...

Q : "How to enjoy Japanese cherry blossoms ?"
A : Go to a park and look for the cherry blossoms



LLMすごい。

翻訳もできるみたいなので、家にあったフランス語のテキストから
Q : "translate French to English: 'Quel est le plus long fleuve du monde ?' "
A : What is the longest river in the world?

簡単すぎたかな?

Q : "translate French to English: Il ramona soigneusement ses volcans en activite."
A : He carefully monitors his volcanoes in action.

星の王子様が、火山の灰を注意深く、お掃除するお話なのですが、火山の活動を注意深く観測するっていう、常識的な意味になるような意訳をしてきました。

学力テストとかは、どうかな、
英国の学力テストKey Stage 5 の問題例
Q : "How do you investigate vitamin C content in food and drinks?"
A : To determine the vitamin C content of food and drinks, you can use a spectrophotometer.

Key Stage 5 では、回答としてDCPIP(ジクロロフェノールインドフェノール)を使った方法を期待しているのですが(参考: https://practicalbiology.org/health-and-disease/what-s-in-our-food/measuring-the-vitamin-c-content-of-foods-and-fruit-juices ) 、 spectrophotometer (分光光度計)って答えられてしまうと、日本だと学校で教えてないことはバツですってなっちゃいますね。

大学入試レベルのCCEA test questionsの例
Q : "What is a plasmid?"
A : a small circular molecule of DNA

なんか、くやしいな...

Q : "What is the smallest country in the world ?"
A : san marino

初めて、間違えました。

Q : "Which country is smaller than San Marino?"
A : switzerland

Q: "Which is a smaller country, Switzerland or San Marino ?"
A : San Marino

今日は、このへんにしておきましょう。






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

nice! 15

コメント 0

コメントを書く

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