見出し画像

【Falcon】英語解説を日本語で読む【2023年6月9日|@Dave Ebbelaar】

オープンソースの代替モデルであるFalconモデルが紹介され、OpenAIのDaVinci 3モデルとのテキスト要約タスクで比較されています。デモンストレーションでは、この実験でOpenAIのモデルの方が優れた性能を示しています。ビデオでは、特定のユースケースに基づいてモデルを理解し比較することの重要性が強調されています。
公開日:2023年6月9日
※動画を再生してから読むのがオススメです。


So, if you are serious about learning how to work with large language models, then this is an essential skill.

さて、大規模な言語モデルの扱い方を真剣に学ぶのであれば、これは必須のスキルなのです。

You must be able to work with different models.

さまざまなモデルを扱うことができるようにならなければなりません。

If you are into creating applications with large language models, then you know that the current golden standard is to use the models from OpenAI and then pair it up with a framework like LangChain to hook it all up and create your applications.

もしあなたが大規模な言語モデルを使ってアプリケーションを作ることに興味があるなら、現在のゴールデンスタンダードは、OpenAIのモデルを使い、それをLangChainのようなフレームワークと組み合わせて、すべてをフックアップしてアプリケーションを作ることだと知っているはずです。

And that is something I've been covering on my YouTube channel.

これは、私のYouTubeチャンネルで取り上げているものです。

Lots of examples there.

たくさんの事例があります。

But there are some downsides to using just the models from OpenAI.

しかし、OpenAIのモデルだけを使うには、いくつかの欠点があります。

First of all, the API costs money.

まず、APIにお金がかかることです。

That's one.

これが1つ目です。

And the second one is that you might not want to share all data that you want to send to these large language models with OpenAI.

そしてもうひとつは、大規模な言語モデルに送信するすべてのデータをOpenAIと共有したくない場合があることです。

So these could be sensitive private information or company information that you want to keep secret.

機密性の高い個人情報や、秘密にしておきたい企業情報などです。

So I've also been getting tons of questions on how to counter this, how to go about that.

そのため、これにどう対抗すればいいのか、どうすればいいのか、という質問もたくさん受けています。

So in this video, I'm going to show you how you can work with open-source large language models as well.

そこで、このビデオでは、オープンソースの大規模言語モデルとも連携できる方法を紹介します。

And in particular, the Falcon model, which has been getting a lot of attention and hype lately because it's been outperforming all the other open-source models that are currently out there if we look at the leaderboards from Hugging Face.

特に、Falconモデルには、最近多くの注目とハイプが集まっています。なぜなら、現在存在する他のオープンソースモデルすべてを上回るパフォーマンスを発揮しているからです。これはHugging Faceのリーダーボードを見ると明らかです。

So, I've prepared an example for you which we will run through together.

そこで、皆さんのために例を用意しましたので、一緒に実行しましょう。

So, there are some instructions and there is some code that you can access, but what we are going to do is we are going to test the Falcon, and then in particular, the 7 billion parameter one.

説明書もありますし、アクセスできるコードもありますが、これから行うのはファルコンのテスト、特に70億パラメータのテストです。

So that's not the fully trained one with the 40 billion parameters because that takes forever to ask questions and it takes a really long time to load.

400億のパラメータを持つ完全に訓練されたものではないのですが、これは質問するのに時間がかかり、ロードに本当に長い時間がかかるからです。

And I found that the 7 billion one, and particularly the Instruct version, is something you can work really well with using the code that I will provide to you.

70億のパラメータ、特にInstructバージョンは、私が提供するコードを使って、とてもうまく動作させることができることがわかりました。

So we are going to do some experiments where we compare it to the text DaVinci 3 model from OpenAI and then put it to the test in a task summarization task.

そこで、OpenAIのテキスト・ダヴィンチ3モデルと比較し、タスクの要約タスクでテストする実験を行う予定です。

So this is going to be pretty interesting.

これはかなり面白いことになりそうですね。

You'll learn how to use open-source large language models from Hugging Face, then you'll learn how to set them up and compare them to OpenAI models.

Hugging Faceのオープンソースの大規模言語モデルの使い方を学び、それをどのように設定し、OpenAIのモデルと比較するのかを学びます。

And as a bonus of this video, you'll also learn how to summarize large text using LangChain and the summarization methods that are in there.

そして、このビデオのボーナスとして、LangChainとそこに含まれる要約メソッドを使って、大きなテキストを要約する方法も学びます。

So this is going to be a very important video because as we progress in the era of AI and other open-source models will come out.

というわけで、AIの時代が進むと他のオープンソースモデルが出てくるので、これは非常に重要なビデオになると思います。

The gap between where OpenAI currently is with their models and open-source models will likely get smaller and smaller and smaller until, potentially, and many believe this will be the case, open-source models will be better than what OpenAI is currently offering.

OpenAIが現在そのモデルであるところとオープンソースモデルとの間のギャップは、おそらくますます小さくなり、多くの人がこれが事実だと信じていますが、オープンソースモデルはOpenAIが現在提供しているものよりも優れているでしょう。

So if you're serious about learning how to work with large language models, then I would say this is an essential skill.

ですから、もしあなたが大規模な言語モデルの扱い方を真剣に学びたいと考えているならば、これは必須のスキルだと言えるでしょう。

Knowing how to work with various models, paid models, different APIs, but also the open-source models.

様々なモデル、有料モデル、様々なAPI、そしてオープンソースのモデルを扱う方法を知ることです。

Which are, for example, available on Hugging Face, and then setting up quick little experiments to compare and validate all the models and the results in order to pick the model that is the best suitable for your specific use case.

例えば、Hugging Faceで利用可能なオープンソースのモデルです。そして、特定のユースケースに最も適したモデルを選ぶために、すべてのモデルとその結果を比較・検証する簡単な実験を設定します。

So, that is what we will do in this video.

このビデオでは、そのようなことを行います。

Let's get into it.

では、さっそくやってみましょう。

So, in order to follow along, you first of all need access to this repository over here (the link will be in the description), and we will be working from the models directory in here where the example is, and also the Python file that we will be using.

だから、この手順に従うためには、まずこのリポジトリへのアクセスが必要です(リンクは説明欄にあります)。そして、ここにあるモデルのディレクトリから作業を開始し、例となるもの、そして使用するPythonファイルを見ていきます。

Now, in order to follow along, you need a Python installation and some basic understanding about LangChain.

さて、この作業を進めるには、PythonのインストールとLangChainに関する基本的な理解が必要です。

If you don't have that already, I would recommend you watch my previous video on working with LangChain.

もしまだ持っていないのであれば、LangChainを使った作業に関する私の以前のビデオを見ることをお勧めします。

That will set you up and explain how everything works.

このビデオでセットアップができ、すべての動作が説明されます。

But if you already understand this, then we can dive straight into it.

しかし、もしあなたがすでにこのことを理解しているのであれば、私たちはまっすぐにこのことに飛び込むことができます。

What you can do is, first of all, clone this repository.

まず、このリポジトリをクローンしてください。

Then, more specifically, go into the models folder within your favorite IDE (so your IDE of choice, for me that is VSCode). I've opened up the file over here, and we're in the falconmodel.Pi.

そして、より具体的には、お気に入りのIDE(つまり、あなたのIDE、私の場合はVSCodeです)の中にあるmodelsフォルダに入ります。ここでファイルを開き、falconmodel.Pi.に入っています。

So if I load up a Python interactive session over here (which is something I've also been getting tons of questions about, them how to do that link to set that up in VSCode will be also in the description), we can do some basic imports.

ここでPythonの対話型セッションを読み込むと(これについてもたくさんの質問をいただいています、VSCodeで設定するためのリンクは説明の中にあります)、基本的なインポートを行うことができます。

And then, to configure everything, the only thing you need if you want to run the open-source models from Hugging Face is a Hugging Face API token.

そして、すべてを設定するために、Hugging Faceのオープンソースモデルを実行したい場合に必要なものは、Hugging Face APIトークンだけです。

So if we go to huggingface.co, then log in, create an account (it's free if you don't have one already), and you go to the settings and then the access tokens, you can create a new API key over here.

huggingface.coに行き、ログインしてアカウントを作成し(まだ持っていない場合は無料です)、設定からアクセストークンを開くと、ここで新しいAPIキーを作成することができます。

So, as you can see, I've got one for LangChain already with read accessibility, but you can create a new one, say what's it for, and then either read or write (read would be sufficient), generate the token, you can show it, and then copy it.

だから、ご覧の通り、私は既にLangChain用のものを持っていて、それは読み取り可能です。しかし、新しいものを作成することもできます。それが何のためのものかを述べ、そして読み取りまたは書き込み(読み取りで十分)を選択し、トークンを生成します。それを表示し、それをコピーします。

And then, the next step that you have to do is set that up in an environment file.

そして、次のステップとして、環境ファイルに設定する必要があります。

So, within the GitHub repository, there is an example already (it's an empty one), but what you can do is, if you turn or change this name into .end like you see over here, and then just change the Hugging Face API AI token with the token you've just generated, then you're good to go.

だから、GitHubのリポジトリ内にはすでに例があります(空のものですが)、あなたができることは、この名前をここに見られるように.endに変更したり、Hugging Face API AIのトークンをあなたが生成したトークンに変更するだけです、それからスタートできます。

What this basically allows us to do is use the .end library to load our environment variable of the key into our variable over here, and that will allow us to communicate with Hugging Face.

これで基本的にできることは、.endライブラリを使って環境変数のキーをこちらの変数にロードすることで、Hugging Faceと通信することができるようになります。

Alright, so there will also be a requirements.txt for this project to make sure you have all the dependencies and all the PIP libraries basically installed, but it's .end, LangChain, and I think that's it, then you're good to go.

このプロジェクトにはrequirements.txtがあり、依存関係やPIPライブラリがすべてインストールされていることを確認することができますが、.end、LangChain、これだけです。

Alright, so with those instructions out of the way, we can now get started with the models from Hugging Face.

さて、以上の説明で、Hugging Faceのモデルを使い始めることができるようになりました。

So first, what we do is we do load.f, anyfine.end to load our environment variable that we just set, and then make sure that the token is accessible over here.

まず、load.f、anyfine.endで、先ほど設定した環境変数を読み込み、トークンにアクセスできることを確認します。

And then we can continue to the actual interesting part.

そして、実際に面白い部分に進みます。

And that is using the Hugging Face hub from LangChain.

LangChainのHugging Faceハブを使用します。

So, you can see we import that over here, and then what we can do is I'll show you how to interact with these models.

このハブをインポートして、このモデルとのインタラクションをお見せします。

So it starts off with a repository ID.

まず、リポジトリIDから始めます。

And if we come back to Hugging Face, you can see that each model basically that we're looking at right now has a repo, and you can basically copy that, and then we can use that to interact with the model.

Hugging Faceに戻ると、今見ている各モデルには基本的にリポジトリがあり、それをコピーして、それを使ってモデルと対話できることがわかります。

Now, like I've set, the 40 billion one, I've tried it, but it takes forever to load.

さて、私が言ったように、400億のものは試してみましたが、ロードには永遠に時間がかかります。

I don't know if it's even possible to do it through the API, or that you have to set it up on some kind of heavy server.

APIでできるのか、それとも重いサーバーに設置する必要があるのかは分かりませんが。

But the 7 billion one, and like I said, the Instruct version works really well.

でも、70億の方は、さっき言ったように、Instructの方はすごくよく動くんです。

So we are going to copy that.

だから、それをコピーすることになります。

It's already in there, but you can basically put that in here.

すでにあるものですが、基本的にはここに入れても大丈夫です。

But you can also swap that around with some of the other models that are available on Hugging Face or in the leaderboards, so that's really an interesting part.

でも、それをハギング・フェイスやリーダーボードにある他のモデルと入れ替えることもできるので、そこは本当に面白いところです。

So that's how you can swap them out, and then basically we are going to create our large language model through a LangChain object, basically like we normally do, and we can give some model parameters in there as well.

そして、LangChainオブジェクトで大規模な言語モデルを作成し、通常行うように、モデル・パラメータを与えます。

So through this, we basically specified your repository idea, and for now, we set a pretty low temperature, and we set the max new tokens to 500, meaning that the response that we get from the model will add a maximum of 500 tokens.

これにより、基本的にあなたのリポジトリのIDを指定しました。そして今のところ、かなり低い温度を設定し、最大新トークン数を500に設定しました。これは、モデルから得られるレスポンスが最大で500トークンを追加することを意味します。

So let's run that and store that within our interactive session.

それでは、これを実行し、インタラクティブ・セッション内に保存しましょう。

You can refer to the Hugging Face HOP documentation here in the LangChain documentation to get a bit of an understanding of how this works, but it's basically the same example that I've just walked you through.

LangChainのドキュメントにあるHugging Face HOPのドキュメントを参照すると、この仕組みが少し理解できると思いますが、基本的には今説明した例と同じです。

But this is where the original documentation is from, and here you can also see that they're using a Google model in this example, so that is how that would work.

しかし、これはオリジナルのドキュメントで、この例ではGoogleのモデルを使っていることがわかります。

So the next step over here is to create a prompt template and a large language model chain, and we're just following along with the sample from LangChain.

次のステップは、プロンプトテンプレートと大規模な言語モデルチェーンを作成することで、LangChainのサンプルに従います。

Where the template is, Hey, here's a question, and then we fill in our actual prompts that we fill in later, and then we say, Answer this question.

テンプレートは、「質問です」、そして実際のプロンプトを後で記入し、「この質問に答えてください」と言います。

Basically, let's think step by step.

基本的には、ステップバイステップで考えていきましょう。

So we create a prompt template and then a large language model chain.

そこで、プロンプトのテンプレートを作成し、次に大きな言語モデルチェーンを作成します。

Again, if all of these concepts are new to you and you don't understand them, I refer back to my previous video on the basics of working with LangChain, and then it will make sense for you.

もし、これらの概念が初めてで理解できない場合は、以前のLangChainを使った作業の基本についてのビデオを参照してください。

I'm assuming you already understand that, and then we're going to run this chain.

すでに理解していると仮定して、このチェーンを実行することにします。

Let me first quickly complete or store this code, and then we have a question.

まずこのコードを素早く完成させるか保存して、それから質問をさせてください。

So we start off with a very interesting, very hard question: How do I make a sandwich?

ではまず、とても興味深く、とても難しい質問から始めます: サンドイッチを作るにはどうしたらいいのでしょうか?

And we are going to check, like, okay, how is the Falcon 7 billion model going to respond to this?

そして、ファルコン70億のモデルはこれにどう対応するのか、ということを確認することになります。

So we have the question.

という質問です。

We basically first get the response, goes pretty quickly, and then we can wrap that.

基本的には、まず回答を得て、かなり早い段階で、それをラッピングします。

That is basically just to make it nice and pretty when we print it, and there we go, we have our first response.

これは、印刷するときにきれいに仕上げるためのもので、これで最初の回答ができたことになります。

So you need to gather the ingredients.

では、材料を集める必要があります。

You'll need bread, meat, cheese, condiments, and toppings.

パン、肉、チーズ、調味料、トッピングが必要です。

Once you have all your ingredients, you need to take a slice of bread.

材料が揃ったら、パンを一切れ取ってください。

Okay, sounds like a pretty solid instruction on how to create a sandwich.

なるほど、サンドイッチの作り方をしっかり教えてくれているようですね。

This is pretty cool, right?

これはかなりクールでしょう?

Because this is a completely free model, like no credit card required, no data sharing with OpenAI.

クレジットカードも必要なく、OpenAIとデータを共有することもない、完全に無料のモデルなのですから。

Not so interesting question, but hey, we're just getting started.

あまり面白い質問ではありませんが、私たちはまだ始めたばかりです。

So we already have it up and running with just these few lines of code, and to me, that is still like so amazing.

たった数行のコードですでに稼働しているわけですから、私にとっては、これでもすごいことなんです。

How these open source models, if they are made available and if they work really well, you can just access them with a couple lines of code, and you can basically create cool applications with them, completely for free.

オープンソースのモデルが利用可能になり、それがうまく機能すれば、数行のコードでアクセスでき、基本的には完全に無料で、それを使ってクールなアプリケーションを作ることができるのです。

I'm really excited to see how these models will develop over time, and when we have, like, the cross point where these open source models are really better than the ones from OpenAI.

このようなモデルが時間とともにどのように発展し、いつオープンソースのモデルがOpenAIのモデルよりも優れたクロスポイントになるのか、私はとても楽しみにしています。

But now let's take it a step further and set up a quick little experiment that we can do.

しかし、ここでさらに一歩踏み込んで、ちょっとした実験をセットアップしてみましょう。

So I'm going to download one of the transcripts from my YouTube videos, and this one, in particular, that I did recently on Flowwise.

私のYouTubeの動画から、特に最近Flowwiseで行ったこの動画のトランスクリプトを1つダウンロードします。

And through the YouTube loader, also from LangChain, we are going to put in that video URL and then we're going to get the transcript.

LangChainのYouTubeローダーを使って、ビデオのURLを入力し、トランスクリプトを取得します。

So, this is how that works, and again, that's also covered in one of my previous videos.

この仕組みは、私の以前のビデオでも紹介しました。

But we can basically load the transcript, and here you can see we just have the whole transcript basically of that video, which is automatically generated by YouTube.

しかし、トランスクリプトを基本的にロードすることができます。そしてここでは、そのビデオの全トランスクリプトを見ることができます。これはYouTubeによって自動的に生成されます。

So, for every video, this is publicly available information.

つまり、すべての動画について、これは一般に公開されている情報なのです。

You can plug in any URL, and you can get the transcription based on the YouTube algorithm.

URLを入力すれば、YouTubeのアルゴリズムに基づいたトランスクリプションを得ることができます。

And then we are going to split this up into different documents, basically because, as you might know, when you work with large language models and these APIs, you are limited by the amount of tokens that you can send to these APIs.

そして、これを異なる文書に分割することになります。なぜなら、大規模な言語モデルとこれらのAPIを使用するとき、あなたがこれらのAPIに送信できるトークンの量に制限があることをご存知かもしれません。

So, we're going to set up a text splitter, and basically what this will do is we'll just chunk this whole document, this whole transcript, up into various documents, and we can have a look over here.

そこで、テキストスプリッターを設定します。基本的には、この文書全体、つまりトランスクリプト全体をさまざまな文書に分割して、ここで見てみましょう。

So, there's about six documents in total, seems to be yes, so six splits basically.

全部で6つの文書がありますね、そうですね、6つの分割が基本です。

So, we took the whole transcript and we chopped it up.

つまり、この原稿を全部、切り刻んだわけです。

And now, this next part is pretty interesting, and this is summarization.

そして、次の部分が非常に興味深いのですが、これは要約です。

So, this again is something that large language models currently struggle with due to these limitations in the amount of tokens that you can send to the API.

APIに送信できるトークンの量に制限があるため、大規模な言語モデルで苦労している点です。

So, LangChain has a cool little built-in method, load_summarize_chain basically, where you can do or create this summarization iteratively.

LangChainには、load_summarize_chainという小さな組み込みメソッドがあり、これを使えば、要約を反復的に行うことができます。

So, you first, like, split the whole transcript and then create a little summarization for each of the splits basically that you've created.

つまり、まずトランスクリプト全体を分割し、分割したそれぞれのトランスクリプトについて、要約を作成します。

And then you throw those onto one pile again and then go iteratively basically on that to create your final summarization.

そして、それをまた1つの山に放り込み、最終的な要約を作成するために、基本的にそれを繰り返していくのです。

Now, that is exactly what we will be testing this Falcon 7 billion parameter model with and then compare it to OpenAI to see how it performs.

これで、ファルコン70億のパラメータモデルをテストし、OpenAIと比較し、そのパフォーマンスを確認することができます。

So, we've split up the documents, and now the next step is to load this chain.

さて、ドキュメントを分割しましたので、次はこのチェーンを読み込むことになります。

And a quick little side tip that you can do if you print the prompt template and also the combine template, you can see how LangChain is handling this.

プロンプト・テンプレートとコンバイン・テンプレートを印刷すると、LangChainがどのようにこれを処理しているかがわかりますよ。

So, it basically is a prompt to say, like, Write a concise summary of the following, and then you put in the text, and then it will give you the concise summary.

これは基本的にプロンプトで、例えば「次の内容を簡潔にまとめてください」と書いて、テキストを入れると、簡潔にまとめたものが表示されます。

And by default, as you can see, this template is basically the same for first creating the initial summarizations and then also when you combine everything and create a summarization of depth, it will use the same prompt template.

そして、デフォルトでは、ご覧のように、このテンプレートは、最初に最初の要約を作成するときと、すべてを組み合わせて深さのある要約を作成するときとで、基本的に同じプロンプト・テンプレートが使用されます。

But you can change that by using the parameters, as you can see it's in the comments over here, but you can just add a map prompt over here and then just change that.

しかし、パラメータを使って変更することができます。コメント欄に書いてありますが、ここにマッププロンプトを追加して、それを変更するだけです。

So, map prompt equals and then you give your map prompt over here, and you can also change the combined prompt.

つまり、マッププロンプトがイコールで、ここにマッププロンプトを指定し、組み合わせたプロンプトを変更することも可能です。

So, that is how you would do that.

つまり、このような方法で行います。

But for now, we're just going to leave it at default, and we're just going to run the docs, and we set both to true, so it will also show us kind of like what's going on under the hood.

しかし今のところ、私たちはデフォルトのままにしておきます。そしてドキュメントを実行し、両方をtrueに設定します。そうすれば、何が進行中かを見ることができます。

So, here you can see all the chunks, basically, first write a concise summary of the following, and then this is the first introduction sentence that I basically start with, and then this is somewhere later in the video, and so on and so on.

だから、ここではすべてのチャンクを見ることができます。基本的には、まず以下の要約を簡潔に書きます。そしてこれが私が基本的に始める最初の紹介文、そしてこれがビデオの後半部分で、という具体的なことを続けます。

And then it basically combines all of that, and then finally, if we look at the output summary, we can see that we have a string of text over here, and then we can just wrap that so that if we print it, we have that on one line.

そして、基本的にそのすべてを組み合わせます。最後に、出力の概要を見ると、ここにテキストの文字列があり、それを印刷すると1行にまとまります。

And what we have, flow-wise, is a visual UI builder that allows users to build large language models apps in minutes.

このような流れで、大規模な言語モデルアプリを数分で構築できるビジュアルUIビルダーが完成しました。

That's a good one, that's basically how I start the video.

これは良いものですね、基本的にはこのような感じでビデオを始めています。

The tutorial covers setting up a free API key and cloning the Flowwise repository.

チュートリアルでは、無料のAPIキーの設定とFlowwiseのリポジトリのクローンについて説明しています。

I believe that's also correct because we use, not...

私たちが使っているのは、...ではなく、...なので、これも正しいと思っています。

it's not really we use a free Pinecone API key, but we also use the OpenAI API key which is free to set up, but it costs money if we want to interact with the API.

というのも、私たちは無料のPinecone APIキーを使っていますが、OpenAI APIキーも使っているからです。

We do clone the Flowwise repository, so that is correct, and then the project is then cloned in a Lang Chain experiment.

Flowwiseのリポジトリをクローンして、Lang Chainの実験でプロジェクトをクローンしていますね。

The project is opened in a terminal, that's also correct.

プロジェクトはターミナルで開いています、これも正しいです。

The tutorial concludes with a step-by-step guide on how to integrate Chip GPT with company data.

チュートリアルの最後には、Chip GPTを会社のデータと統合する方法について、ステップバイステップで説明しています。

That's not entirely true, that's basically an example of me explaining kind of projects that I'm currently working on for my freelance work, but okay, it seems to be at least the start is quite accurate.

これは、私が現在フリーランスの仕事で取り組んでいるプロジェクトの一種を説明する例であり、完全に正しいわけではありませんが、まあ、少なくともスタートはかなり正確であるようです。

And remember, this is a totally free model, and also text summarization using this method is pretty hard because we are splitting up all the context basically.

これは完全に自由なモデルであり、また、この方法によるテキストの要約はかなり困難です。なぜなら、基本的にすべての文脈を分割してしまうからです。

And if the cut or the split is right in the middle of like a talking point, then the ending and the beginning of the other chunk doesn't really make sense.

なぜなら、基本的にすべての文脈を分割しているからです。また、カットや分割がトーキングポイントのちょうど真ん中である場合、他のチャンクの終わりと始まりは本当に意味を成しません。

So if you summarize it separately, it could get messy.

だから、それを別々に要約すると、混乱する可能性があります。

So it's a pretty interesting task to compare these models on.

ですから、このモデルを比較するのは、かなり面白い作業です。

So now let's see what we get if we use OpenAI.

では、OpenAIを使うとどうなるかを見てみましょう。

So we have another text splitter over here, which is kind of redundant because we're using the same, but now we're just going to say,Hey, we are going to create a new large language model object, basically new LLM, but now we use OpenAI.

ここには別のテキストスプリッターがありますが、私たちは同じものを使っているので、それはちょっと冗長です。しかし、今回は「ねえ、新しい大規模言語モデルオブジェクト、基本的に新しいLLMを作成しますが、今回はOpenAIを使用します」と言います。

So let's run this, and again, if you want to follow along, this does require you to put in your OpenAI API key in the .env file as well, so you need one free to set up, but you do get charged once you query it.

.envファイルにOpenAIのAPIキーを入れる必要があるので、セットアップには無料で1つ必要ですが、クエリを実行すると課金されます。

So we set up the model and then we create another chain and then we plug the OpenAI LLM in here.

モデルをセットアップし、別のチェーンを作成し、ここにOpenAI LLMを接続します。

Everything else works the same, that's the nice thing about using Lang Chain.

他はすべて同じように動作します。これがラングチェーンを使う良いところです。

It's unified in a way that you just specify the model and then once you have that in place, you have that object.

モデルを指定するだけで、あとはそのオブジェクトが出来上がるという形で統一されているのです。

You can just, like, completely copy your code.

コードを完全にコピーすることができるんです。

That's really awesome.

これは本当にすごいことです。

So we can again create the output summary by running it, and here you can see basically the same thing.

では、再び出力サマリーを作成し、実行すると、基本的に同じものが表示されます。

So now the model will go to action, and we will iteratively query the OpenAI API to get the summaries of all the chunks, and then boom, it's finished.

これでモデルはアクションに移行し、OpenAI APIに繰り返し問い合わせ、すべてのチャンクのサマリーを取得します。

Over here we can wrap the text again and then print it.

ここで、テキストを再びラップして、印刷することができます。

Okay, so what do we have over here?

さて、ここで何があるのでしょうか?

So this article discusses Flowwise AI and open-source visual UI builder that allows users to quickly build large language models apps.

この記事では、Flowwise AIと、大規模な言語モデルアプリを素早く構築できるオープンソースのビジュアルUIビルダーについて説明しています。

So the first sentence is kind of like the same, although this says that it's an article, but they do talk about Flowwise and they recognize that it's an open-source visual UI builder to quickly create large language models apps.

最初の文章は同じようなものですが、これは記事と書いてありますが、Flowwiseについて述べており、大規模な言語モデルアプリを素早く作成するためのオープンソースのビジュアルUIビルダーであることを認識しているようです。

So those are the same, and then it refers back to like the article, which is the video.

だから、それらは同じであり、そして、記事のようなものを参照し、それがビデオである。

But okay, it explains how to set up Flowwise connected to data and build a conversational AI.

Flowwiseをデータにつなげて、会話型AIを構築する方法を説明しています。

This I would say is a lot better already because this is really what we do in this video.

このビデオでやっていることは本当にその通りなので、これはもうかなり良いと言っていいでしょう。

It also explains how to use Lang Chain, a comprehensive framework for developing applications powered by large language models.

また、大規模な言語モデルを搭載したアプリケーションを開発するための包括的なフレームワークであるLang Chainの使い方も解説しています。

So it's Lang Chain under the hood.

つまり、これはLang Chainを使ったものなのです。

So yeah, in some way, I talk about language and how to use Flowwise AI to quickly prototype AI projects.

そうそう、ある意味、言語について、そしてFlowwise AIを使ってAIプロジェクトを素早くプロトタイプ化する方法について話しているんだ。

Finally, it shows how to use Flowwise AI to sell AI service to clients as a freelancer.

最後に、Flowwise AIを使って、フリーランサーとしてクライアントにAIサービスを販売する方法が紹介されています。

Okay, so this is definitely the winner because really the main message of that video was how you can use Flowwise to quickly prototype AI projects.

このビデオのメインメッセージは、Flowwiseを使ってAIプロジェクトを素早くプロトタイプ化する方法でしたから。

And then I conclude this video by basically saying, Hey, I work as a freelancer.

そして、このビデオの最後には、「私はフリーランサーとして働いています。

I work with clients, and this, I could see how I could use this as a tool to quickly spin up demos and prototypes and then go from there, basically.

このビデオは、デモやプロトタイプを素早く作成し、そこから進めていくためのツールとして使用することができます。

So overall, the OpenAI model is still the clear winner.

全体としては、やはりOpenAIのモデルが明らかに勝者です。

But if we compare the workflow and what we're getting, it's getting close.

しかし、ワークフローと得られるものを比較すれば、近いものがあると思います。

So let's see.

では、見てみましょう。

The temperature is set pretty low, but let's just see if we run it one more time.

温度はかなり低めに設定していますが、もう1回だけ走らせて見ましょう。

Let's also see how deterministic this one is.

これがどの程度決定論的なのかも見てみましょう。

So I load the Falcon model again.

ということで、もう一度ファルコンモデルをロードしてみます。

I will create a summary one more time.

もう一回サマリーを作ってみます。

Go over it.

それを調べてみてください。

It is really fast though, which is quite interesting.

しかし本当に速いですね、なかなか興味深いです。

It's faster than OpenAI for sure right now.

今は確実にOpenAIより速いです。

So what do we have?

さて、どうでしょうか?

Do we have kind of a similar answer?

同じような答えがあるでしょうか?

So Flowwise visual UI Builder, yeah, seems to be the same.

FlowwiseのビジュアルUIビルダーは、そうですね、同じような感じです。

Okay, so that's good because we set the temperature pretty low, so to 0.1.

0.1というかなり低い温度に設定したので、それは良いことです。

So we would expect no creative styles here, basically, and just giving us the results.

ですから、ここでは基本的にクリエイティブなスタイルは期待せず、ただ結果を出してくれることを期待しています。

Basically, it is good in that sense.

基本的に、その意味では良いことだと思います。

But I would say, at least from this little experiment, it's nowhere near the capabilities of OpenAI's models right now.

しかし、少なくともこの小さな実験では、今のところOpenAIのモデルの能力には遠く及ばないというのが私の意見です。

But I will definitely run more experiments with this.

でも、これを使ってもっと実験をすることは間違いないでしょう。

And also, keep in mind that this is the 7 billion parameter model, and the one that has been getting all the hype is the 14 billion parameter one.

また、これは70億パラメータのモデルであり、大騒ぎになっているのは140億パラメータのモデルであることも覚えておいてください。

So if you know a way how to run this effectively on your local machine or through some server, please let me know in the comments because I do want to experiment with this one.

もし、このモデルをローカルマシンやサーバーで効果的に実行する方法をご存知でしたら、ぜひコメントで教えてください!このモデルで実験してみたいのです。

Alright, so you now know how to work with the open-source models from Hugging Face, like I've said, very valuable skill to have if you're serious about learning how to work with large language models.

さて、これでHugging Faceのオープンソースモデルの扱い方がわかったと思いますが、大規模言語モデルの扱い方を真剣に学びたいのであれば、非常に価値のあるスキルです。

We've looked at the Falcon 7 billion parameter model.

私たちは、Falcon 70億パラメータ・モデルを見てきました。

We set up a quick little experiment, created some text summarization, and it's overall to give you an understanding, a good idea of how to go about working with different models, how you can compare them.

簡単な実験を行い、テキストの要約を作成しました。全体的に、さまざまなモデルをどのように扱うべきか、どのように比較できるかを理解し、良いアイデアを得るためのものです。

And it's really up to you and the use case at hand to determine what the best model is.

どのようなモデルが最適かは、実際に使用するケースに応じて判断してください。

Is there a budget?

予算はあるのか?

Can you share data with OpenAI?

OpenAIとデータを共有できるか?

How fast does the model have to be?

モデルはどれくらいのスピードが必要なのか?

These are all questions that you have to ask yourself if you're working on a project with large language models.

これらはすべて、大規模な言語モデルを使ったプロジェクトに取り組む場合に、自問自答しなければならない質問です。

Alright, and that's it for this video.

さて、今回の動画はここまでです。

Now, please leave a like down below and also subscribe to the channel to make sure you stay up to date on all things going on with large language models and AI.

このビデオでは、大規模言語モデルとAIに関する最新情報をお届けします。

And now, if you're interested in using these skills to sell them as a service to potential clients as a freelancer, but you don't know where to start, then check out Data Freelancer, first link in the description.

そして、もしあなたがこれらのスキルを使って、フリーランサーとして潜在的なクライアントにサービスとして売ることに興味があるけれど、何から始めたらいいかわからないなら、説明文の最初のリンクにあるData Freelancerをチェックしてみてください。

That's it for now, and then I'll see you in the next one.

それでは、また次回にお会いしましょう。

Thank you.

ありがとうございました。

この記事が気に入ったらサポートをしてみませんか?