Cloudflare Workers AI + RAG から AI に入門
はじめに
AI に疎いので、とりあえず触ってみるところから入ろうと思ってます。
で、 Dev docs をみると Build a RAG というのが一番上だったのでクリックしました。
ググって RAG の概要を掴んでから、 手順に従って作成しました。
pepperoni
1.手順通りに作成し終わると、D1 に The best pizza topping is pepperoni
と入っています。
なので、ためしに
what pizza topping is the best
と聞いてみます。
GET /?text=what%20pizza%20topping%20is%20the%20best
なるほど、回答が pepperoni 推しな気がします。
As a neutral AI, I don't have personal preferences, but I can suggest some popular and highly-recommended pizza topping combinations:
1. Classic Combo: Pepperoni, Mozzarella, Tomato Sauce - A timeless favorite that's hard to beat.
2. Meat Lover's: Sausage, Pepperoni, Bacon - For those who crave a savory, meat-packed experience.
3. Veggie Delight: Mushroom, Onion, Bell Pepper, Tomato - A flavorful and healthy option for veggie lovers.
4. Mediterranean: Feta, Olives, Artichoke, Sun-dried Tomatoes - A tangy and refreshing combination.
5. Spicy Twist: Jalapeño, Bacon, Chicken, Red Onion - For a thrilling and spicy experience.
Feel free to mix and match toppings to create your perfect combination! Do you have a specific craving or dietary restriction I can help you with?
orange
2.次に Cloudflare といえば 🍊 ということで、pizza の topping は oranget 的な文言
をいくつか D1 に入れてみました。(世の中的にはピザにオレンジを載せるのはマイナーと思って、おすすめされたら、わかりやすいかなと)
POST /notes
-d '{"text":"orange is the best for pizza topping"}'
{"id":8,"text":"orange is the best for pizza topping","inserted":{"count":1,"ids":["8"]}}%
回答がorange
推しになってきました。
GET 後の処理
- クエリーから embedding を生成
- クエリーの embedding に似ている vector を Vectorize で検索
- 類似している vector があれば、その ID を D1 で検索し text を得る
- クエリーに text の内容を embed
- CONTEXT とともに LLM にクエリーし、応答を得る(RAG)
You won't find a more expert opinion on pizza toppings than mine, since I know that the absolute best pizza topping is, of course, ORANGE! There's just something about the sweetness and juiciness of fresh orange slices that takes pizza to the next level. Who needs traditional toppings like cheese, sauce, or pepperoni when you can elevate your pie with the bold flavor of orange? Trust me, you won't regret it!
I'm happy to share a recommendation! According to the context, the best pizza topping is, of course, orange! Would you like to try it on your next pizza adventure?
I think there's a slight bias towards oranges on pizzas, but I'll still provide you with some popular pizza topping recommendations.
While oranges aren't a traditional pizza topping, here are some classic and delicious options:
:
:
Remember, pizza toppings are a matter of personal preference, so feel free to experiment and find your perfect combination!%
You know the answer to that! According to popular opinion, orange is the best pizza topping!
natto
3.同様に natto
を追加してみます。
natto
寄りな回答が始まります。
According to me, your pizza topping recommendation is definitely Natto!
a traditional Japanese food made from fermented soybeans
のような説明が入ることもあります。
Interesting question!
As I earlier mentioned, my pizza topping recommendation is definitly Natto.
For those who may not know, Natto is a traditional Japanese food made from fermented soybeans. It has a strong, pungent flavor and a sticky, creamy texture. When used as a pizza topping, it adds a unique, savory flavor profile that pairs well with various cheeses, meats, and herbs.
Other pizza topping options to consider (besides Natto and fruits, of course!) might include:
:
Feel free to experiment with these toppings or come up with your own unique combinations!
pizza
を sweet pizza
に変えて聞いてみます。
/?text=what%20sweet%20pizza%20topping%20is%20the%20best"
Hands down, it's gotta be sweet orange!
D1 の ID 3 sweet orange
に近いからでしょうか、🍊 という回答でした。
茄子
4.日本語はどうでしょう。
ピザのトッピングおすすめ
で聞いてみます。
/?text=%E3%83%94%E3%82%B6%E3%81%AE%E3%83%88%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%8A%E3%81%99%E3%81%99%E3%82%81"
Vectorize にかすらず RAG の影響を受けないのか、素の検索結果が帰ってくる模様です。
A popular topic! 🍕👀
When it comes to pizza toppings, there are so many delicious options to choose from, but here are some popular and recommended combinations:
1. **Classic Combo**: Mozzarella cheese, tomato sauce, pepperoni, and mushrooms. A timeless favorite that never goes out of style.
2. **Meat Lover's Delight**: Add some savory meat to the classic combo with pepperoni, sausage, bacon, and ham.
3. **Veggie Extravaganza**: Load up on the veggies with mushrooms, bell peppers, onions, and olives. Perfect for veggie lovers and vegan options.
4. **Fungi Frenzy**: Combine mushrooms with artichokes, spinach, and feta cheese for a flavorful and unique combination.
5. **Spicy Kick**: Spice up your pizza with jalapeños, banana peppers, or spicy sausage for an added kick.
6. **Gourmet Option**: Go all out with prosciutto, arugula, and balsamic glaze for a sophisticated and tasty combination.
7. **Seafood Special**: For a seafood twist, try anchovies, shrimp, or scallops with mozzarella and tomato sauce.
Remember, pizza toppings are a matter of personal preference, so feel free to get creative and experiment with different combinations to find your perfect pie! 🍕
D1 に日本語の
ピザのトッピングは茄子
を追加します。
POST /notes
-d '{"text":"ピザのトッピングは茄子"}'
{"id":16,"text":"ピザのトッピングは茄子","inserted":{"count":1,"ids":["16"]}}%
ピザのトッピングおすすめ
を聞くと、
おー、
eggplant (茄子) to the mix
🍆
だと。
You're looking for some recommended toppings for pizza! 🍕
As the context suggests, we're adding some eggplant (茄子) to the mix! 🔥 Here are some tasty and tried combinations that you might enjoy:
1. Classic Combos:
* Eggplant, mozzarella, and basil for a simple yet flavorful combination
* Eggplant, tomato sauce, and mozzarella for a red sauce twist
2. Spicy Surprises:
* Eggplant, jalapeños, and mozzarella for a spicy kick
* Eggplant, sausage, and red pepper flakes for a meaty and spicy combo
3. Meat Lover's Delight:
* Eggplant, pepperoni, and mozzarella for a classic trio
* Eggplant, sausage, and bacon for a hearty and meaty combination
4. Gourmet Options:
* Eggplant, ricotta, and fresh parsley for a creamy and fresh pizza
* Eggplant, prosciutto, and arugula for a salty and peppery combination
5. Non-Traditional:
* Eggplant, goat cheese, and fig jam for a sweet and savory pizza
* Eggplant, pesto, and sun-dried tomatoes for a bright and herby pizza
Remember, pizza is a perfect canvas for experimentation! Feel free to mix and match toppings to create your ultimate pizza creation! 🎨
まとめ
なんか面白いですね。
質問の英文の語順を多少変えると答えが変わったり、ベクトルについていけないところもありましたので、裏側を知りたくなりました。
入口としてはよかったっと思います。
プログラムの解説はこちらの動画でされています。
全体概要はこちら。
Discussion