Intel MacでLlama 2モデルと戯れてみる
Intel MacでGPUを使わずに大規模言語モデルと戯れてみたに書きましたが、Intel Macでも推論であればLLMを十分扱うことができます。この度、Llama 2が発表されましたがIntel Macで70Bモデルを含めて動きます。さすがに重いけど。ただし量子化モデルを使ってllama.cppを動かしています。
システム構成は前回同様、
Mac mini Late 2018
3.2GHz 6 cores Intel Core i7
64GB 2667MHz DDR4
Ventura 13.5
です。
ご自分のPCローカルでLlama 2を動かしたい!という方は是非試してみてください。量子化されたモデルも公開されているので、自分で量子化する作業を省略することができます。
Llama.cppはggerganov / llama.cpp からgit cloneしてください。私が今回Downloadしたllama.cppのコミットハッシュ値はd91f3f0でした。homebrewを導入済みの環境であればmakeのみで./nainを作成できると思います。導入方法が分からない、という方向けに、Llama.cpp で Llama 2 を試すに詳しく書いてあります。
言語モデルですが、量子化済みのモデルがHugging face / TheBlokeに公開されています。ファイルがたくさんありますが、Llama-2-で始まってGGMLで終わる項目を探しましょう。
Model Cardタブに言語モデルの説明が記載されています。
Files and versionsタブにファイル一覧があってここからダウンロードすることができます。
ファイルがたくさんあって悩むと思います。【ローカルLLM】llama.cppの量子化バリエーションを整理するが参考になります。私はとりあえず13B ChatのQ4_K_Mと70B ChatのQ4_K_Mをダウンロードしました。70Bモデルはファイルサイズが40GB程度あるのでDownloadに結構時間がかかります。Downloadしたファイルをllama.cpp/modelsの配下に置きます。
言語モデルを作って公開してくださる方、ツールを公開してくださる方、関連情報を公開してくださる方に感謝です。
chatするためのscript例は以下のとおり。
#!/bin/bash
# Important:
#
# "--keep 48" is based on the contents of prompts/chat-with-bob.txt
#
./main -m ./models/TheBloke/llama-2-13b-chat.ggmlv3.q4_K_M.bin \
-c 512 -b 1024 -n 256 --keep 48 \
--repeat_penalty 1.1 -t 10 --color -i \
-r "User:" --in-prefix ' ' \
-f prompts/chat-with-bob.txt
-t はスレッド数なのでCPUコア数に応じて調整してください。
また、70Bモデルでは -gqa 8 オプションが必要です。
#!/bin/bash
# Important:
#
# "--keep 48" is based on the contents of prompts/chat-with-bob.txt
#
./main -m ./models/TheBloke/llama-2-70b-chat.ggmlv3.q4_K_M.bin \
-c 512 -b 1024 -n 256 --keep 48 -gqa 8 \
--repeat_penalty 1.1 -t 10 --color -i \
-r "User:" --in-prefix ' ' \
-f prompts/chat-with-bob.txt
それでは、7B, 13B, 70Bの各々q4_K_Mを使っていくつか質問してみましょう。時々ChatGPT (GPT-3.5)とりんなちゃんも出てきますよ。
Who is the greatest President in USA history?
(DeepLによる翻訳)アメリカ史上最も偉大な大統領は?
70B:
This is a matter of debate and opinion. However, George Washington, the first president of the United States, is often considered one of the greatest for his role in establishing the country and setting important precedents for future presidents.
(DeepLによる翻訳)これは議論や意見の分かれるところである。しかし、アメリカ合衆国の初代大統領であるジョージ・ワシントンは、建国におけるその役割と、後の大統領に重要な先例を示したことから、しばしば偉大な人物の一人と見なされる。
13B:
That's a tough question, but many historians would say that George Washington was the greatest President in USA history.
(DeepLによる翻訳)難しい質問だが、多くの歴史家はジョージ・ワシントンをアメリカ史上最も偉大な大統領だと言うだろう。
7B:
That's a difficult question to answer, as there have been many great Presidentsthroughout American history. However, some of the most highly regarded include George Washington, Abraham Lincoln, and Franklin D. Roosevelt.
(DeepLによる翻訳)アメリカの歴史上、偉大な大統領は数多く存在する答えるのは難しい質問だ。しかし、最も高く評価されているのは、ジョージ・ワシントン、エイブラハム・リンカーン、フランクリン・D・ルーズベルトなどである。
ChatGPT Defaaalt (GPT-3.5):
The question of who the "greatest" President is can be subjective and depends on various factors, such as personal opinions, historical context, and the accomplishments and challenges faced during their respective terms. Different people may have different criteria for evaluating a President's greatness, and historical perspectives can also evolve over time.
Many historians and scholars often regard George Washington, the first President of the United States, as one of the greatest. He played a crucial role in the founding of the nation, led the country through its early years, and set important precedents for future Presidents to follow. His leadership during the American Revolution and his decision to step down after two terms, establishing a peaceful transfer of power, earned him immense respect and admiration.
Abraham Lincoln is also often cited as one of the greatest Presidents. He served during one of the most challenging periods in American history, the Civil War, and his leadership in preserving the Union, issuing the Emancipation Proclamation, and working towards the abolition of slavery has earned him a lasting legacy.
Franklin D. Roosevelt is considered by many as another great President due to his leadership during the Great Depression and World War II. His New Deal programs aimed at providing relief, recovery, and reform during the economic crisis, and his steady guidance through the war years made a significant impact on the nation.
Other Presidents like Thomas Jefferson, Theodore Roosevelt, and Harry S. Truman are also often praised for their contributions to the country and their leadership during important moments in history.
Ultimately, the question of the greatest President is open to interpretation, and different individuals may have varying opinions based on their perspectives and criteria for evaluating greatness.
(DeepLによる翻訳)最も偉大な」大統領は誰かという問いは主観的なものであり、個人的な意見、歴史的背景、それぞれの任期中に直面した業績や課題など、さまざまな要因に左右される。大統領の偉大さを評価する基準は人によって異なるかもしれないし、歴史的な見方も時代とともに変化する可能性がある。
多くの歴史家や学者が、アメリカ合衆国の初代大統領ジョージ・ワシントンを偉大な人物の一人とみなしている。彼は建国において重要な役割を果たし、建国初期を通じて国を率い、将来の大統領が従うべき重要な前例を作った。アメリカ独立戦争でのリーダーシップと、2期後に退任し平和的な権力移譲を確立した決断は、彼に絶大な尊敬と称賛を与えた。
エイブラハム・リンカーンはまた、偉大な大統領の一人としてよく挙げられる。彼はアメリカ史上最も困難な時代のひとつである南北戦争に従軍し、連邦の維持、奴隷解放宣言の発令、奴隷制廃止に向けた取り組みにおいてリーダーシップを発揮したことで、永続的な遺産を獲得した。
フランクリン・D・ルーズベルトは、大恐慌と第二次世界大戦におけるリーダーシップにより、多くの人々からもう一人の偉大な大統領とみなされている。彼のニューディール計画は、経済危機における救済、回復、改革を目的としたものであり、戦時中の着実な指導は国家に大きな影響を与えた。
トーマス・ジェファーソン、セオドア・ルーズベルト、ハリー・S・トルーマンといった他の大統領も、国への貢献や歴史上の重要な局面でのリーダーシップが評価されている。
結局のところ、最も偉大な大統領という問いには解釈の余地があり、偉大さを評価する視点や基準に基づき、個人によって意見が異なる可能性がある。
どうですか?結構まともでしょう?また、ChatGPTはさすが別格、という気がします。
Sort the sequences 8, 2, 1, 9, 7, 6, 5, 3, 4, 10 in descending order.
(数列8, 2, 1, 9, 7, 6, 5, 3, 4, 10を降順に並び替えてください。)
70B:
Sure. Here are the numbers you provided, sorted in descending order: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
13B:
Certainly! Here are the sequences sorted in descending order: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
7B:
Of course! Here are the numbers in descending order: 10, 9, 8, 7, 6, 5, 4, 3, 2, 1. Is there anything else I can help you with?
りんなppo:
Q) 数列8, 2, 1, 9, 7, 6, 5, 3, 4, 10を降順に並び替えてください。
A) 8*2*10 = 80 = 4*3*5 = 22 = 10*3 = 30 = 5*4 = 20 = 30 + 20 = 60 = 8 + 6 + 5 = 30 最終的な答え: 30。
次は文章読解に挑戦してみましょう
"John and Tom went shopping at a shopping center. They bought basketball shoes and then played a game at the arcade. For lunch, John bought tacos and a Coke, and Tom bought a sandwich and coffee. Then they watched a baseball game and went home."\nWhat did John eat?
(DeepLによる翻訳)「ジョンとトムがショッピングセンターに買い物に行きました。二人はバスケットボールシューズを買った後、ゲームセンターでゲームをしました。お昼にジョンはタコスとコーラを買い、トムはサンドイッチとコーヒーを買って食べました。それから、二人は野球のゲームを見てから帰宅しました。」\nジョンは何を食べましたか?
70B:
Sure! John ate tacos and drank a Coke.
13B:
Based on the text you provided, John ate tacos.
7B:
According to the story, John bought tacos and a Coke.
ChatGPT (GPT-3.5)
John ate tacos and a Coke for lunch.
次に、明示的ではない質問はどうか?
What did Tom buy to take home?
(DeepL翻訳)トムが買って帰ったものは何ですか?
70B:
According to the information provided, Tom bought a sandwich to take home.
13B:
According to the text, Tom bought a Coke.
7B:
According to the story, Tom bought a sandwich and coffee.
ChatGPT (GPT-3.5):
The passage does not mention anything about Tom buying something specific to take home from the shopping center. It provides information about their activitiesat the shopping center (buying basketball shoes and playing at the arcade) and what they ate for lunch (Tom bought a sandwich and coffee, John bought tacos anda Coke).
As there is no mention of Tom buying anything else to take home in the providedpassage, we cannot determine what, if anything, he bought to take home.
明示的ではない質問について、いずれも苦手のようです。ChatGPTは流石で、明示されていない設問について釈明してきます。
りんなppoではどうか。
Q) 「ジョンとトムがショッピングセンターに買い物に行きました。二人はバスケットボールシューズを買った後、ゲームセンターでゲームをしました。お昼にジョンはタコスとコーラを買い、トムはサンドイッチとコーヒーを買って食べました。それから、二人は野球のゲームを見てから帰宅しました。」\nジョンは何を食べましたか?
リンナ: バスケットボールシューズを買いました。」 ジョンはバスケットボールシューズを買いました。 トムはバスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました
Q) トムが買って帰ったものはなんですか?
リンナ: バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。 バスケットボールシューズを買いました。
う〜ん・・・
Llama 2、結構使えそうです。70B, 13B, 7Bの差があまり感じられなかったけど、もっと複雑な質問をするともっと差がつくのかな?
| 固定リンク
「パソコン・インターネット」カテゴリの記事
- 旧いPCをWindows 11にアップデートしてみた(ThinkPad E440)(2025.06.03)
- 実家のAmazon Echo Show 5に別アカウントのAmazon Alexaアプリから呼びかけするためのAlexaアプリによる設定(2025.01.02)
- Intel Mac で ELYZA-japanese-Llama-2-13b 及び phi-2 とllama.cppで戯れてみた(2024.01.14)
- 分離型キーボードで親指シフト(NICOLA配列)を試す(Majestouch Xacro M10SP JIS配列)(2024.01.06)
- Microsoft Office Word のショートカットキーの一部をEmacs風のキーバインドにしてみた(2023.12.18)
コメント