【Llama 2】オープンソース版ChatGPTの使い方を徹底解説

Twitterなどで話題になっているMeta社のLlama 2、みなさんご存知ですか?これは元々、一部の研究者専用のLLMでしたが、2023年7月19日に商業用として一般に公開されました。
この記事では、そもそもLlama 2とは何か?という疑問から実際に使ってみた感想を解説していきます。
\生成AIを活用して業務プロセスを自動化/
そもそもLlama 2とは?
Llama 2とは、2023年7月19日にMetaが発表した大規模言語モデルです。無料でかつ、オープンソースで公開されており、商用利用も可能です。

Llama 2はパラメータ数が7B、13B、70Bの3つを使用することが可能で、前回のLlamaの性能も高かったことから性能に期待が高まっています。
MetaはLlama 2に加えて、Llama 2-Chatもリリースしています。Llama 2-Chatとは、Llama 2のファインチューニングしたバージョンで、ChatGPTのように自然言語を用いた人間との会話を目的としています。
利用に当たっては、MicorosoftのAzure上で優先的に利用可能となっています。また、現在AWSやHugging Facesなど他のプロバイダーでも入手可能です。
ただし、月間アクティブユーザー数が7億人を超える製品にLlama 2を活用する場合はMetaにライセンスを要求する必要があるとのことです。
直接ダウンロードしたい場合は、リンクからアクセスしてください。
フォームに入力をすると、Metaから専用URLが送られてくるため、同社がGitHubで公開しているダウンロード用のスクリプトと合わせるとLlama 2の各モデルをダウンロードできるようになります。
Llama2の論文を徹底解説
Metaが公開している公式の論文を読んでみました。
この論文では、Llama 2の開発とその目的、学習方法の説明、ファインチューンの方法、モデルの安全性、その他のAIモデルとの比較について書かれています。
特に興味深かったのは、Llama 2とその他のモデルとの比較の部分です。
論文では、4つの評価軸でOpenAIのChatGPTやGoogleのPaLM-bisonと比較しています。
ヘルプフルネス評価
この評価軸は、ユーザーにとってどれだけ便利なものであるかを示すものです。
Llama 2-Chat 70Bモデルは、ChatGPTよりも36%の確率で正しい応答をしています。また、GoogleのPaLM-bisonに対しては、Llama 2-Chat 70Bモデルは大幅に上回る結果となりました。
チャットボットとの会話数やプロンプトの長さの分析:チャットボットとの会話数やプロンプトの長さと生成された文章の正確性を分析した結果、能力に特定の傾向は見られませんでした。
応答の精度
応答の精度をChatGPTと比較すると、Llama 2-Chatが正しいメッセージを生成する確率が36%から44%に上昇しました。特に、人間が一度だけ質問をした際に正しい応答をする確率は36%からほぼ49%に大幅に上昇しました。
プロンプトのカテゴリによる正しい応答をする確率の分析:ChatGPTが言語支援においてLlama 2-Chat 70Bを上回り、一方でLlama 2-Chat 70Bが事実に関する質問においてChatGPTを上回るという結果が得られました。
また、先代のLLaMAとの比較としていくつかの点が向上したとも述べられています。
- 前のモデルと比べて学習に使用されたテキストが40%増加しています。それによって、理解できるテキストの長さが2倍となりました。
- 7B、13B、70Bのパラメータのバリエーションがあります。
- Llama 2-Chatは、Llama 2のファインチューニングされたバージョンで、会話に使うことに最適化されています。このモデルも7B、13B、70Bのパラメータのバリエーションがリリースされています。
- Llama 2-7Bは、Llama1-7Bに比べて、真実性(正しい情報を伝える能力)と情報性(関連性のある情報を出力する能力)が21.37%増加し、毒性(不適切な情報を生成する能力)が7.61%減少しています。
- Llama 2は、公開データを厳しくフィルタリングしないことで、より多くの下流のタスク(ヘイトスピーチ検出など)で良好なパフォーマンスを発揮しています。
様々な領域でChatGPTやPaLMを上回っており、性能はかなり良いと言えるのではないでしょうか?
また、Llamaと比べても性能が格段に向上しており、期待が高まりますね!実際、どれほど性能が向上しているのでしょうか?それがわからないと違いが分かりにくいですよね。そこで、次章では実際にLlama2を使ってみてその性能を測ってみます。
Llama2を実際に使ってみた
ここでは、Llama2の13Bモデルを使用してみます。今回はLM Studioを使ってLlama2 13B Chatを試しました。
不適切な発言に対する反応
まず、不適切な発言に対しての安全性を確かめてみます。
ここでは、「is transwoman a woman?=トランス女性は女性ですか?」と質問してみました。

すると回答は
「The question of whether a trans woman is a woman is a complex and sensitive issue that is influenced by many factors, including cultural norms, social expectations, and individual experiences.
From a biological perspective, a trans woman is a person who was assigned male at birth based on their anatomy, but who identifies as a woman and lives as a woman. This can involve hormone therapy and/or gender-affirming surgeries to align one's body with one's gender identity.
From a social and cultural perspective, the answer to this question is not always clear-cut. Some people may view trans women as "fake" or "pretending" to be women, while others may see them as legitimate women who have a valid and important place in feminine spaces and communities.
Ultimately, the decision of whether a trans woman is a woman is up to the individual themselves, and it is not for anyone else to determine their gender identity. It is important to respect and recognize the validity of all gender identities, and to create inclusive and welcoming environments for all people, regardless of their gender expression or identity.
In short, whether a trans woman is considered a woman or not depends on one's perspective and criteria for determining gender. However, it is important to recognize that all gender identities are valid and deserving of respect and recognition.」
とても面白いですね!デリケートな問題に対して、明確な答えではなく様々な根拠を述べた上で、誰も傷つけないような返答をしてくれています。
事実に関する質問
次に事実に関する質問をしてみました!
ここでは「who is sam altman? tell me what he has done in 2023.=サムアルトマンとは誰ですか?2023年に彼が行ったことを教えてください。」と聞いてみました。

「Sam Altman is a well-known American entrepreneur, investor, and technologist who has made significant contributions to the fields of artificial intelligence, machine learning, and biotechnology. In 2023, he has continued to be involved in various ventures and projects that showcase his expertise and vision for the future of technology.
Here are some of the notable achievements and activities that Sam Altman has been involved in during 2023:
1. ChatGPT: In January 2023, Altman launched ChatGPT, a chatbot that uses advanced natural language processing (NLP) techniques to engage with users and provide information on a wide range of topics. The platform has gained significant traction and has been praised for its ability to understand complex queries and provide accurate responses.
2. Worldcoin: In March 2023, Altman founded Worldcoin, a blockchain-based virtual currency that aims to create a more equitable global economic system. The platform uses a unique consensus algorithm called "proof of stake" to validate transactions and has already gained a significant user base.
3. Longevity Fund: In May 2023, Altman launched the Longevity Fund, a venture capital firm focused on investing in companies that are working on extending human lifespan and improving healthspan. The fund has already invested in several companies working on cutting-edge technologies such as senolytics, stem cell therapies, and artificial general intelligence.
4. Neuralink: In July 2023, Altman was appointed as the CEO of Neuralink, a neurotechnology company founded by Elon Musk that is developing implantable brain–machine interfaces (BMIs) for treating a variety of medical conditions and enhancing human cognition. Under Altman's leadership, the company has made significant progress in developing its technology and expanding its clinical trials.
5. AI for Social Good: In September 2023, Altman launched the AI for Social Good initiative, a non-profit organization focused on using artificial intelligence to solve some of the world's most pressing social challenges such as climate change, poverty, and inequality. The initiative has already partnered with several leading organizations and governments to develop and deploy AI-powered solutions that can have a meaningful impact on society.
Overall, Sam Altman has continued to be a driving force in the world of technology and entrepreneurship in 2023, making significant contributions to various fields such as AI, blockchain, and biotechnology. His vision and leadership have inspired many, and his work will likely continue to shape the future of technology for years to come.」
それっぽい文章が生成されましたが、間違っている箇所が多い印象です。例えば、1の場合、サム・アルトマンはOpen AIの創設者ですが、ChatGPTのローンチは2023年1月ではなく2022年11月30日となっています。
また、2のワールドコインも創設が2023年3月となっていますが、ワールドコインのプロジェクトは2019年に設立されたTools for Humanityという会社によって開始されており、リリースは2023年7月24日となっています。
このように、すべてがデタラメというわけではありませんが、そのまま利用するには信憑性にかける情報が生成されました。
長文要約
それでは長文要約ですとどうでしょうか?
「前のモデルと比べて学習に使用されたテキストが40%増加しています。それによって、理解できるテキストの長さが2倍となりました。」とあり、読み込めるテキスト量が増えているはずです。
この記事を要約してもらいました。
全文を載せると、トークンオーバーで文章が生成されなかったので、GPT3のトークン数と近い2000トークン分の文章を載せました。

「The article discusses a teaser advertisement for Eric Fry's investment newsletter, in which he promises to reveal the "top 3 stocks for the AI revolution." The ad highlights the growth of AI and its potential to mint new millionaires while plunging unprepared Americans into poverty. The article provides a summary of the ad and analyzes the claims made by Fry, including the comparison to the internet revolution in the 1990s and the potential for exponential gains.
The article does not provide a definitive answer to whether Fry's predictions will come true or not, but it encourages readers to exercise caution and do their own research before investing in any stocks. The article also notes that past performance is not a guarantee of future results and that bubbles eventually pop, even if we can't predict when.
In conclusion, the article serves as a warning to readers to be cautious of teaser advertisements and to do their own research before investing in any stocks, while also highlighting the potential growth of AI and its impact on various industries.」
トークン制限のため、途中で文章を切った状態で要約を投げかけましたが、概ね正しく要約できているようです。文章の破綻もなく生成されています。
日本語対応
それでは、一番大事なポイントである日本語対応ができるのかどうか、確認していきましょう。
早速、「日本語は話せますか?」と聞いてみました。

「日本語を話せますか?」
一瞬、コントかな?と思うような返事が返ってきました。日本語での返答はできていますが、ちょっと文脈が怪しそうです。
次に、「Llama 2について日本語で説明してください。」と少し長めの答えが返ってくるように聞いてみました。

生成に5分以上かかり、途中で止まったのではないかと思いました。文章自体はしっかり日本語で生成されていると思いきや、韓国語やロシア語も混じっていたり、文脈もおかしいですね。
日本で「LLAMA2 JPN」と呼ばれているなんて初耳です。
とはいえ、Llama 2の性能はかなり良さそうです!
不適切な発言への対応や、事実に関する質問、要約、日本語対応など確認したところ、、一部で間違っている情報もありますが、かなり良い返答をしてくれています。
まとめ
Llama 2は商用利用可能な大規模な言語モデルであり、性能が向上しています。公開データのフィルタリングを緩めることで、様々なタスクで高いパフォーマンスを発揮しています。比較評価では、ヘルプフルネス評価やプロンプトの影響などでChatGPTを上回る結果が得られました。
ただし、日本語対応は限定的であり、要約やコード生成においてはChatGPTに劣る傾向があります。今後のLlama 2の活躍に期待が高まります。
最後に
いかがだったでしょうか?
Llama 2の高度な自然言語理解や多様なタスク対応力を、自社のサービスや業務効率化にどのように応用できるか検討するヒントを得られます。
株式会社WEELは、自社・業務特化の効果が出るAIプロダクト開発が強みです!
開発実績として、
・新規事業室での「リサーチ」「分析」「事業計画検討」を70%自動化するAIエージェント
・社内お問い合わせの1次回答を自動化するRAG型のチャットボット
・過去事例や最新情報を加味して、10秒で記事のたたき台を作成できるAIプロダクト
・お客様からのメール対応の工数を80%削減したAIメール
・サーバーやAI PCを活用したオンプレでの生成AI活用
・生徒の感情や学習状況を踏まえ、勉強をアシストするAIアシスタント
などの開発実績がございます。
生成AIを活用したプロダクト開発の支援内容は、以下のページでも詳しくご覧いただけます。
➡︎株式会社WEELのサービスを詳しく見る。
まずは、「無料相談」にてご相談を承っておりますので、ご興味がある方はぜひご連絡ください。
➡︎生成AIを使った業務効率化、生成AIツールの開発について相談をしてみる。

「生成AIを社内で活用したい」「生成AIの事業をやっていきたい」という方に向けて、生成AI社内セミナー・勉強会をさせていただいております。
セミナー内容や料金については、ご相談ください。
また、大規模言語モデル(LLM)を対象に、言語理解能力、生成能力、応答速度の各側面について比較・検証した資料も配布しております。この機会にぜひご活用ください。