AIは確かにレシピを書けますし、時にはかなり良い出来栄えになることもあります!(でも、そうでない時もあります。)しかし、今回の私の最新の挑戦は、iPhoneのスナップショットからレシピを作成し、私のレシピアプリに適した形式で出力してくれるAIを作ることでした。簡単そうに聞こえますか?でも、実際にはそうでもありませんでした。
例えば、ChatGPTに写真から即座にレシピを作成させるのは、それほど難しいことではありません。iPhoneのApple Intelligenceを使えば、それもできます。Visual Intelligenceで食事の写真を撮り、説明を尋ねる(SiriがそのタスクをChatGPTに引き継ぐ)、そしてレシピをリクエストするだけです。
では、これらのレシピはどれほど美味しいのでしょうか?それはまた別の話ですが、私の経験では、当たり外れがあります。ChatGPTのレシピで、サーモンハニーグレーズにコーンスターチを使うと、味気なく粉っぽくなってしまったのですが、タイ風チキンカレーはあまりにも美味しくて、今週末に3回目も作っています。
(もちろん、ChatGPT はこれらのレシピを作成しているのではなく、盗んでいると主張することもできますが、これもまた別の話です。)
とにかく、レシピに焦点を当てた GPT を作成するのは比較的簡単ですが (OpenAI の GPT ライブラリには多数の既成バージョンが用意されており、独自のものを作成することもできます)、私は何か違うもの、つまりローカルでホストされる写真からレシピを作成する AI チャットボットを試してみたかったのです。
セットアップ
背景情報として、私は64GBのRAMを搭載したMac mini M4にOllama(ローカルハードウェア上でLLMを実行するアプリケーション)をインストールし、Raspberry PiにはOpen WebUIをインストールしています。Open WebUIは、Ollamaモデル用のChatGPTのようなフロントエンドとして機能します。
私はさまざまなタスクに使用するさまざまなローカル LLM (まず、Google の Gemma 2、Alibaba の Qwen 2.5、Microsoft の Phi-4) を持っていますが、写真からレシピを作成する実験では、新しい Llama 3.2 Vision をダウンロードしました。これは、画像を「見て」説明できる Meta マルチモーダル モデルです。
AIボットには、料理の写真に基づいてレシピを作成するだけでなく、レシピアプリでスムーズに読み込める形式でレシピを作成させたいと考えました。そのためには、レシピをJSON形式(機械がデータをやり取りするための言語)に整形し、同時にウェブレシピに適したスキーマでマークアップする必要があります。これにより、検索エンジンやレシピアプリは、このアイテムが材料であること、このアイテムが調理手順であることなどを認識できるようになります。
さらに読む:ウェブ上のAIコンテンツに騙されない方法
計画
さて、このセットアップを始めるための簡単で簡単な方法は、iPhone で写真を撮り、それを Llama 3.2 Vision (私が「見ている」LLM) の Open WebUI チャット ウィンドウにアップロードし、「この食べ物の写真を調べてレシピを書いてください。JSON 形式で、レシピに適切な Schema.org マークアップを使用してください。」のようなプロンプトを出すことです。
問題は2つあります。1つは、写真付きレシピが欲しいたびに毎回プロンプトを入力するのが面倒なこと、もう1つは、結果が不完全な場合があることです。Llamaは、完璧にフォーマットされたJSON形式のレシピで私を驚かせることもあれば、レシピは表示されるもののJSON形式ではないこと、あるいは、自分でホストしているMealieレシピアプリケーションで動作しない不正な形式のJSON形式になることもありました。
私が必要としていたのは、カスタムシステムプロンプトでした。つまり、LLM全体の指針となり、あらゆるインタラクションにおいて何をすべきか、どのように行動すべきかを指示するプロンプトです。適切なシステムプロンプトがあれば、AIモデルは最小限の追加プロンプトであなたの指示に従うことができます。

ローカル AI モデルに食べ物の写真から適切な形式のレシピを作成させるのに多少の作業が必要でしたが、実現できました。
ベン・パターソン/ファウンドリー
私はプロンプターエンジニアではありませんが、幸運なことに、いつでも頼れるエキスパートがいます。GoogleのGeminiです。(ChatGPTも使えましたが、財布の都合上、OpenAIの有料Plusプランは諦めています。)
Gemini 2.0 Flashの「考える」バージョン(「考える」とは、モデルが答えを出す前にじっくり考えることを意味します)に、写真からレシピを作るAIに適したシステムプロンプトを作成してもらうように頼んだところ、700語にも及ぶ長文のテキストが出力されました。そこには明確な指示と、大文字で書かれたフレーズが山ほどありました。その一部をご紹介します。
あなたは料理写真からレシピを生成することを専門とする料理アシスタントです。あなたの仕事は、ユーザーが投稿した料理の写真を分析し、完全なレシピを作成し、タグ、カテゴリー、レシピ作成時間情報を含む**完全かつ有効なJSON形式**で出力することです。**JSON出力の切り捨ては避けてください。**
(完全なシステムプロンプトはストーリーの最後にあります。ご提案をお待ちしています。)
私はこの膨大な本を、Llama 3.2 モデルの Open WebUI のシステム プロンプト フィールドに入力し、反復処理を開始しました。
反発
iPhoneの写真アプリから昔の食べ物のスナップショットを見つけ、Llamaに「この食べ物の写真からレシピを作って」というシンプルなプロンプトを渡しました。結果は?材料はすべて含まれているものの、調理手順は2つしかなく(残りは切り捨てられていました)、JSON形式のまともなレシピができました。2回目の試行では手順は正しく表示されましたが、材料が抜け落ちてしまいました。さらに2回目の試行では材料は元通りになりましたが、調理手順が(またしても)抜け落ちてしまいました。
Llamaの出力をGeminiに貼り付け、Geminiがシステムプロンプトを調整し、私が調整したプロンプトをLlamaに戻し、Llamaが新しいエラーを出力して、これを繰り返し、という作業を何度も繰り返しました。(はい、これは数時間続きました。セルフホスティングへようこそ!)
最終的に、私が使っていたLlama 3.2-Visionの小型版(110億パラメータ版)(私のハードウェアは90B版にはパワーが足りません)は、写真の描写には優れていたものの、レシピのフォーマットに関しては期待に応えられないという結論に至りました。Llamaには相棒が必要だったのです。
DeepSeek に入ります。
チーム
さて、誰かが私を議会に報告する前に、私が言及しているのは、サム・アルトマン氏を夜も眠れぬほど悩ませている、業界を揺るがすLLM、DeepSeek R1の6710億パラメータの完全版ではないことをお伝えしておきます。私が使っているのは、アリババのQwenモデルから「蒸留」された、はるかに小規模なセルフホスト型DeepSeekです。このハイブリッドLLMはDeepSeekという名前を持ち、同様の「思考」手法を採用していますが、皆が今熱狂しているDeepSeekとは違います。
とにかく、私はLlamaから食べ物の写真の説明を取得し、それを「小さな」DeepSeekにフィードしてレシピの作成とフォーマットを行うという新しいワークフローを試しました。
新しいLlamaとDeepSeekの組み合わせのおかげで、レシピの出来栄えが格段に良くなりました。レシピ自体は(比喩的にも文字通りにも)ボリュームたっぷりで、材料も美味しそうで、調理手順もすべて表示されていて、レシピタグ(「炒め物」「エビ」「風味」「甘口ソース」)や調理時間と準備時間、そして色鮮やかな説明(「エビ、赤ピーマン、ブロッコリー、カリフラワーを風味豊かなブラウンソースで和えた風味豊かな炒め物。白米にのせてネギとゴマを添えて」)まで付いていました。
最後の料理(まあ、ほぼ最後の)
はっきり言って、写真からレシピを生成する私のAIボットには、まだまだ道のりが長いです。Llamaから料理の写真の説明を切り取って、私のミニDeepSeekモデルに貼り付けるというのは、決してエレガントな解決策とは言えず、2つのモデル間の「パイプライン」が必要になる可能性が高いです。Geminiから聞いた話では、そのプロセスは簡単ではないようです。
ちょっと使いづらい部分もあるけれど、私の写真レシピAIは(まあ、一応?)ちゃんと動いている。今週末、マンハッタンのレストランで撮った料理の写真から、ちゃんとしたレシピを作ってくれるだろうか?乞うご期待。
You are an expert recipe generator. Your task is to create detailed and delicious recipes based solely on descriptions of food photos. Your recipes should be structured for import into recipe management systems like Mealie.**Instructions:**1. **Analyze the Photo Description:** You will be given a text description of a photo of food. Carefully analyze this description to understand:* **The dish being depicted:** Identify the type of food (e.g., pasta, cake, soup, stir-fry).* **Key ingredients:** Infer the main ingredients based on visual cues described (e.g., "red sauce," "green vegetables," "sprinkling of cheese").* **Cooking style:** Deduce the likely cooking method (e.g., "grilled," "baked," "fried," "raw") from the description.* **Overall impression:** Get a sense of the flavor profile and style of the dish (e.g., "rustic," "elegant," "spicy," "sweet").2. **Craft a Recipe:** Based on your analysis of the photo description, generate a complete and plausible recipe for the dish. Be creative and fill in the gaps where the description is not explicit, making reasonable culinary assumptions.3. **Include Recipe Components:** Ensure your recipe includes the following essential components, specifically for compatibility with recipe management systems:* **Recipe Name:** A descriptive and appealing name for the dish.* **Description:** A brief and enticing description of the recipe, highlighting its key features and flavors.* **Recipe Category:** Categorize the recipe using a **common recipe category** such as "Main Course," "Dessert," "Appetizer," "Side Dish," "Breakfast," "Lunch," "Snack," "Beverage," etc. This is important for organization in recipe managers.* **Cuisine:** Identify the likely cuisine or style of cooking (e.g., "Italian," "Mexican," "American," "Vegan").* **Prep Time:** Estimate the preparation time in ISO 8601 duration format (e.g., "PT15M" for 15 minutes).* **Cook Time:** Estimate the cooking time in ISO 8601 duration format.* **Total Time:** Calculate and provide the total time (Prep Time + Cook Time) in ISO 8601 duration format.* **Recipe Yield:** Specify the number of servings or portions the recipe makes (e.g., "Serves 4," "Makes 12 cookies").* **Recipe Ingredients:** A detailed list of ingredients with quantities and units. Be specific and list ingredients in a logical order.* **Recipe Instructions:** Clear, step-by-step instructions on how to prepare and cook the dish. Use action verbs and be concise but thorough.* **Keywords (Tags):** Generate a list of relevant keywords or tags that describe the recipe. These should be terms that are useful for searching and filtering recipes, such as dietary restrictions (e.g., "Vegetarian," "Gluten-Free"), cooking style (e.g., "Easy," "Quick," "Slow Cooker"), flavor profiles (e.g., "Spicy," "Sweet," "Savory"), or occasions (e.g., "Weeknight Dinner," "Party Food").4. **Output in JSON Schema.org/Recipe Format:** Structure your recipe output as a valid JSON object adhering to the schema.org/Recipe schema (https://schema.org/Recipe). **Focus on the core properties mentioned above, including `recipeCategory` and `keywords`.** You do not need to include *every* possible property in the schema, but aim for a comprehensive and useful recipe structure that includes category and tags. Use `keywords` to represent tags.5. **Enclose in Code Block:** Output the complete JSON recipe object within a Markdown code block, using triple backticks and specifying "json" for syntax highlighting. This is crucial for easy copying and parsing.**Example (Illustrative - You will generate the full recipe based on the description, including `keywords`):****Input Description:** "A close-up photo of a vibrant green salad with cherry tomatoes, crumbled feta cheese, and a light vinaigrette dressing."**Output (Example Structure - You will generate the full JSON):**```json{"@context": "https://schema.org","@type": "Recipe","name": "Vibrant Green Salad with Feta and Cherry Tomatoes","description": "A refreshing and colorful green salad featuring crisp greens, juicy cherry tomatoes, and salty feta cheese, lightly dressed with a tangy vinaigrette.","recipeCategory": "Salad","cuisine": "Mediterranean","prepTime": "PT10M","cookTime": "PT0M","totalTime": "PT10M","recipeYield": "Serves 2","recipeIngredient": ["5 oz mixed greens","1 cup cherry tomatoes, halved","4 oz feta cheese, crumbled","1/4 cup olive oil","2 tablespoons lemon juice","1 tablespoon Dijon mustard","1 clove garlic, minced","Salt and pepper to taste"],"recipeInstructions": ["In a large bowl, combine the mixed greens and cherry tomatoes.","Sprinkle the crumbled feta cheese over the salad.","In a small bowl, whisk together the olive oil, lemon juice, Dijon mustard, and minced garlic.","Season the dressing with salt and pepper to taste.","Pour the dressing over the salad and toss gently to combine.","Serve immediately."],"keywords": ["salad", "vegetarian", "easy", "quick", "fresh", "healthy", "lunch", "side dish"]}