llama2.mojoを試す
超高速にllama2が推論できるというllama2.mojoなるものが登場したらしいので、早速試してみた。今朝はtokenizer.binがなくて試せなかったが、さっき見たら2時間前にtokenizer.binが追加されていた。
早速ためしてみる。
まずはデフォルトの15M版のstories
$ mojo llama2.mojo
num hardware threads: 36 SIMD vector width: 16
checkpoint size: 60816028
<s>
Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, red ball in the sky. It was the sun! She thought it was so pretty.
Lily wanted to play with the ball, but it was too high up in the sky. She tried to jump and reach it, but she couldn't. Then, she had an idea. She would use a stick to knock the ball down.
Lily found a stick and tried to hit the ball. But the stick was too short. She tried again and again, but she couldn't reach it. She felt sad.
Suddenly, a kind man came by and saw Lily. He asked her what was wrong. Lily told him about the ball. The man smiled and said, "I have a useful idea!" He took out a long stick and used it to knock the ball down. Lily was so happy! She thanked the man and they played together in the sunshine.
<s>
Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, red
achieved tok/s: 192.7437641723356
速い。192トークン/秒
できあがった物語を翻訳してみる
次に、110M版のstoriesを試してみる。
$ mojo llama2.mojo
num hardware threads: 36 SIMD vector width: 16
checkpoint size: 438381596
<s>
Once upon a time, there was a little girl named Lily. She loved to play outside in the sunshine. One day, she saw a big, red apple on a tree. She wanted to eat it, but it was too high up.
Lily asked her friend, a little bird, "Can you help me get the apple?"
The bird said, "Sure, I can fly up and get it for you."
The bird flew up to the apple and pecked it off the tree. Lily was so happy and took a big bite. But then, she saw a bug on the apple. She didn't like bugs, so she threw the apple away.
Later that day, Lily's mom asked her to help with the laundry. Lily saw a shirt that was too big for her. She asked her mom, "Can you make it fit me?"
Her mom said, "Yes, I can make it fit you."
Lily was happy that her shirt would fit her. She learned that sometimes things don't fit, but there is always a way to make them fit.
<s>
Once upon a time, there was a little girl named Lily
achieved tok/s: 25.749772796122386
これでも25トークン/秒とまあまあ速い。
棒でりんごを取ろうとする原始人的な話から、小鳥の友達にお願いするという話にバージョンアップした。
これ、GPU使ってないのかな。使ってなさそうに見えるが
GPUなしでこのスピードで生成できるのはすごいな。まあモデルが十分小さいけど。llama2.cのところでも触れられているが、ドメインを十分絞れば小さいモデルでもかなりいい結果が出るのだそう。