Gemini के बारे में सोच

Gemini 3 और 2.5 सीरीज़ के मॉडल, "सोचने की प्रोसेस" का इस्तेमाल करते हैं. इससे, गहराई से विश्लेषण करने और कई चरणों वाली प्लानिंग करने की उनकी क्षमता बेहतर होती है. इस वजह से, ये मॉडल कोडिंग, ऐडवांस गणित, और डेटा ऐनलिसिस जैसे मुश्किल कामों को बेहतर तरीके से कर पाते हैं.

सोचने की प्रोसेस का इस्तेमाल करने वाले मॉडल का इस्तेमाल करने पर, Gemini जवाब देने से पहले जानकारी का विश्लेषण करता है. Interactions API, thought चरणों के ज़रिए इस गहराई से विश्लेषण को दिखाता है. ये चरण, फ़ंक्शन कॉल, उपयोगकर्ता के इनपुट या steps कलेक्शन में मॉडल के आउटपुट के साथ-साथ, क्रम से दिखते हैं.

हर चरण में दो फ़ील्ड होते हैं:

फ़ील्ड ज़रूरी है ब्यौरा
signature ✅ हां मॉडल के इंटरनल विश्लेषण की स्थिति का एन्क्रिप्ट किया गया वर्शन. यह हमेशा मौजूद होता है, भले ही मॉडल ने कम से कम गहराई से विश्लेषण किया हो.
summary ❌ नहीं कॉन्टेंट (टेक्स्ट और/या इमेज) का कलेक्शन, जिसमें विश्लेषण की खास जानकारी दी गई हो. thinking_summaries कॉन्फ़िगरेशन, मॉडल ने ज़रूरत के मुताबिक गहराई से विश्लेषण किया है या नहीं, या कॉन्टेंट के टाइप के आधार पर, यह खाली हो सकता है. उदाहरण के लिए, इमेज के लेटेंट में टेक्स्ट की खास जानकारी नहीं हो सकती है.

सोचने की प्रोसेस के साथ इंटरैक्शन

सोचने की प्रोसेस का इस्तेमाल करने वाले मॉडल के साथ इंटरैक्शन शुरू करने का तरीका, किसी अन्य इंटरैक्शन के अनुरोध जैसा ही होता है. `model` फ़ील्ड में, सोचने की प्रोसेस का इस्तेमाल करने वाले किसी एक `मॉडल के बारे में बताएं`:

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input="Explain the concept of Occam's Razor and provide a simple, everyday example."
)
print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: "Explain the concept of Occam's Razor and provide a simple, everyday example."
});
console.log(interaction.output_text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.6-flash",
    "input": "Explain the concept of Occam'\''s Razor and provide a simple example."
  }'

विश्लेषण की खास जानकारी

विश्लेषण की खास जानकारी से, मॉडल की इंटरनल विश्लेषण प्रोसेस के बारे में अहम जानकारी मिलती है. डिफ़ॉल्ट रूप से, सिर्फ़ फ़ाइनल आउटपुट दिखाया जाता है. thinking_summaries की मदद से, विश्लेषण की खास जानकारी चालू की जा सकती है:

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input="What is the sum of the first 50 prime numbers?",
    generation_config={
        "thinking_summaries": "auto"
    }
)

for step in interaction.steps:
    if step.type == "thought":
        print("Thought summary:")
        if step.summary:
            for content_block in step.summary:
                if content_block.type == "text":
                    print(content_block.text)
        print()
    elif step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "text":
                print("Answer:")
                print(content_block.text)
                print()

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: "What is the sum of the first 50 prime numbers?",
    generation_config: {
        thinking_summaries: "auto"
    }
});

for (const step of interaction.steps) {
    if (step.type === "thought") {
        console.log("Thought summary:");
        if (step.summary) {
            for (const contentBlock of step.summary) {
                if (contentBlock.type === "text") console.log(contentBlock.text);
            }
        }
    } else if (step.type === "model_output") {
        for (const contentBlock of step.content) {
            if (contentBlock.type === "text") {
                console.log("Answer:");
                console.log(contentBlock.text);
            }
        }
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.6-flash",
    "input": "What is the sum of the first 50 prime numbers?",
    "generation_config": {
      "thinking_summaries": "auto"
    }
  }'

इन मामलों में, विश्लेषण के ब्लॉक में सिर्फ़ सिग्नेचर हो सकता है और खास जानकारी नहीं:

  • सामान्य अनुरोध, जिनमें मॉडल ने खास जानकारी जनरेट करने के लिए ज़रूरत के मुताबिक विश्लेषण नहीं किया
  • thinking_summaries: "none", जहां खास जानकारी की सुविधा साफ़ तौर पर बंद की गई हो
  • विश्लेषण के कुछ कॉन्टेंट टाइप, जैसे कि इमेज में टेक्स्ट की खास जानकारी नहीं हो सकती है

आपके कोड को हमेशा विश्लेषण के उन ब्लॉक को हैंडल करना चाहिए जिनमें summary खाली हो या मौजूद न हो.

सोचने की प्रोसेस के साथ स्ट्रीमिंग

जनरेशन के दौरान, विश्लेषण की खास जानकारी पाने के लिए स्ट्रीमिंग का इस्तेमाल करें. विश्लेषण के ब्लॉक, Server-Sent Events (SSE) का इस्तेमाल करके डिलीवर किए जाते हैं. इनमें दो अलग-अलग डेल्टा टाइप होते हैं:

डेल्टा टाइप इसमें शामिल है यह डेटा कब भेजा जाता है
thought_summary टेक्स्ट या इमेज की खास जानकारी वाला कॉन्टेंट खास जानकारी के साथ एक या उससे ज़्यादा डेल्टा
thought_signature क्रिप्टोग्राफ़िक सिग्नेचर step.stop से पहले का आखिरी डेल्टा

Python

from google import genai

client = genai.Client()

prompt = """
Alice, Bob, and Carol each live in a different house on the same street: red, green, and blue.
Alice does not live in the red house.
Bob does not live in the green house.
Carol does not live in the red or green house.
Which house does each person live in?
"""

thoughts = ""
answer = ""

stream = client.interactions.create(
    model="gemini-3.6-flash",
    input=prompt,
    generation_config={
        "thinking_summaries": "auto"
    },
    stream=True
)

for event in stream:
    if event.event_type == "step.delta":
        if event.delta.type == "thought_summary":
            if not thoughts:
                print("Thinking...")
            summary_text = event.delta.content.text
            print(f"[Thought] {summary_text}", end="")
            thoughts += summary_text
        elif event.delta.type == "text" and event.delta.text:
            if not answer:
                print("\nAnswer:")
            print(event.delta.text, end="")
            answer += event.delta.text

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const prompt = `Alice, Bob, and Carol each live in a different house on the same
street: red, green, and blue. Alice does not live in the red house.
Bob does not live in the green house.
Carol does not live in the red or green house.
Which house does each person live in?`;

let thoughts = "";
let answer = "";

const stream = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: prompt,
    generation_config: {
        thinking_summaries: "auto"
    },
    stream: true
});

for await (const event of stream) {
    if (event.event_type === "step.delta") {
        if (event.delta.type === "thought_summary") {
            if (!thoughts) console.log("Thinking...");
            const text = event.delta.content?.text || "";
            process.stdout.write(`[Thought] ${text}`);
            thoughts += text;
        } else if (event.delta.type === "text" && event.delta.text) {
            if (!answer) console.log("\nAnswer:");
            process.stdout.write(event.delta.text);
            answer += event.delta.text;
        }
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  --no-buffer \
  -d '{
    "model": "gemini-3.6-flash",
    "input": "Alice, Bob, and Carol each live in a different house on the same street: red, green, and blue. Alice does not live in the red house. Bob does not live in the green house. Carol does not live in the red or green house. Which house does each person live in?",
    "generation_config": {
      "thinking_summaries": "auto"
    },
    "stream": true
  }'

स्ट्रीमिंग रिस्पॉन्स, Server-Sent Events (SSE) का इस्तेमाल करता है. इसमें चरण और इवेंट शामिल होते हैं. उदाहरण के लिए:

event: interaction.created
data: {"interaction":{"id":"v1_xxx","status":"in_progress","object":"interaction","model":"gemini-3.7-flash"},"event_type":"interaction.created"}

event: step.start
data: {"index":0,"step":{"signature":"","summary":[{"text":"**Evaluating the clues**\n\nI'm considering...","type":"text"}],"type":"thought"},"event_type":"step.start"}

event: step.delta
data: {"index":0,"delta":{"signature":"EpoGCpcGAXLI2nx/...","type":"thought_signature"},"event_type":"step.delta"}

event: step.stop
data: {"index":0,"event_type":"step.stop"}

event: step.start
data: {"index":1,"step":{"content":[{"text":"Based on the clues provided, here","type":"text"}],"type":"model_output"},"event_type":"step.start"}

event: step.delta
data: {"index":1,"delta":{"text":" is the answer to your question...","type":"text"},"event_type":"step.delta"}

event: step.stop
data: {"index":1,"event_type":"step.stop"}

event: interaction.completed
data: {"interaction":{"id":"v1_xxx","status":"completed","usage":{"total_tokens":530,"total_input_tokens":62,"total_output_tokens":171,"total_thought_tokens":297}},"event_type":"interaction.completed"}

event: done
data: [DONE]

सोचने की प्रोसेस को कंट्रोल करना

Gemini मॉडल, डिफ़ॉल्ट रूप से डाइनैमिक तरीके से सोचते हैं. ये अनुरोध की मुश्किल के हिसाब से, विश्लेषण की कोशिश को अपने-आप कम या ज़्यादा करते हैं. thinking_level पैरामीटर का इस्तेमाल करके, इस व्यवहार को कंट्रोल किया जा सकता है.

मॉडल डिफ़ॉल्ट रूप से सोचने की प्रोसेस इस्तेमाल किए जा सकने वाले लेवल
gemini-3.7-flash चालू (मीडियम) low, medium, high
gemini-3.6-flash चालू (मीडियम) minimal, low, medium, high
gemini-3.5-flash-lite चालू (मिनिमल) minimal, low, medium, high
gemini-3.1-pro-preview चालू (हाई) low, medium, high
gemini-3.1-flash-lite-image चालू (मिनिमल) minimal, high
gemini-3-flash-preview चालू (हाई) minimal, low, medium, high
gemini-3-pro-preview चालू (हाई) low, high
gemini-3.5-flash चालू (मीडियम) minimal, low, medium, high
gemini-2.5-pro चालू low, medium, high
gemini-2.5-flash चालू low, medium, high
gemini-2.5-flash-lite बंद है low, medium, high

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input="Provide a list of 3 famous physicists and their key contributions",
    generation_config={
        "thinking_level": "low"
    }
)
print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    model: "gemini-3.6-flash",
    input: "Provide a list of 3 famous physicists and their key contributions",
    generation_config: {
        thinking_level: "low"
    }
});
console.log(interaction.output_text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.6-flash",
    "input": "Provide a list of 3 famous physicists and their key contributions",
    "generation_config": {
      "thinking_level": "low"
    }
  }'

विश्लेषण के सिग्नेचर

विश्लेषण के सिग्नेचर, मॉडल के इंटरनल विश्लेषण के एन्क्रिप्ट किए गए वर्शन होते हैं. सिलसिलेवार बातचीत में, गहराई से विश्लेषण की प्रोसेस को जारी रखने के लिए इनकी ज़रूरत होती है.

Interactions API की मदद से, विश्लेषण के सिग्नेचर को generateContent API के मुकाबले ज़्यादा आसानी से हैंडल किया जा सकता है.

डिफ़ॉल्ट रूप से, स्टेटफ़ुल मोड में Interactions API का इस्तेमाल करने पर (यानी, store: true सेट करने और बाद के चरणों में previous_interaction_id पास करने पर), सर्वर बातचीत की स्थिति को अपने-आप मैनेज करता है. इसमें विश्लेषण के सभी ब्लॉक और सिग्नेचर शामिल होते हैं. इस मोड में, आपको सिग्नेचर के बारे में कुछ भी करने की ज़रूरत नहीं होती. इन्हें पूरी तरह से सर्वर साइड पर हैंडल किया जाता है.

स्टेटलेस मोड

अगर बातचीत की स्थिति को खुद मैनेज किया जा रहा है (स्टेटलेस मोड) और हर अनुरोध में इनपुट और आउटपुट का पूरा इतिहास पास किया जा रहा है, तो:

  • आपको हमेशा MUST के सभी thought ब्लॉक, मॉडल से मिले उसी फ़ॉर्मैट में फिर से भेजने होंगे.
  • आपको इतिहास से विश्लेषण के ब्लॉक नहीं हटाने या उनमें बदलाव नहीं करना चाहिए, क्योंकि इनमें वे सिग्नेचर शामिल होते हैं जिनकी मदद से मॉडल, विश्लेषण की प्रोसेस को जारी रख सकता है.
  • किसी सेशन में मॉडल बदलने पर भी, आपको पिछले मॉडल के विश्लेषण के ब्लॉक फिर से भेजने चाहिए. बैकएंड, कंपैटिबिलिटी को मैनेज करता है.

कीमत

सोचने की प्रोसेस चालू होने पर, जवाब की कीमत, आउटपुट टोकन और विश्लेषण के टोकन के योग के बराबर होती है. total_thought_tokens फ़ील्ड से, जनरेट किए गए विश्लेषण के टोकन की कुल संख्या पाई जा सकती है.

Python

print("Thoughts tokens:", interaction.usage.total_thought_tokens)
print("Output tokens:", interaction.usage.total_output_tokens)

JavaScript

console.log(`Thoughts tokens: ${interaction.usage.total_thought_tokens}`);
console.log(`Output tokens: ${interaction.usage.total_output_tokens}`);

सोचने की प्रोसेस का इस्तेमाल करने वाले मॉडल, फ़ाइनल जवाब की क्वालिटी को बेहतर बनाने के लिए, पूरी तरह से विश्लेषण करते हैं. इसके बाद, विश्लेषण की प्रोसेस के बारे में जानकारी देने के लिए, खास जानकारी दिखाते हैं. कीमत, मॉडल को जनरेट करने के लिए ज़रूरी विश्लेषण के टोकन के आधार पर तय की जाती है. भले ही, एपीआई से सिर्फ़ खास जानकारी दिखाई गई हो.

टोकन के बारे में ज़्यादा जानने के लिए, टोकन की गिनती करने से जुड़ा लेख पढ़ें.

सबसे सही तरीके

इन दिशा-निर्देशों का पालन करके, सोचने की प्रोसेस का इस्तेमाल करने वाले मॉडल का बेहतर तरीके से इस्तेमाल करें.

  • गहराई से विश्लेषण की समीक्षा करना: गड़बड़ियों को समझने और प्रॉम्प्ट को बेहतर बनाने के लिए, खास जानकारी का विश्लेषण करें.
  • विश्लेषण के बजट को कंट्रोल करना: टोकन बचाने के लिए, मॉडल को लंबे आउटपुट के लिए कम विश्लेषण करने के लिए प्रॉम्प्ट करें.
  • सामान्य टास्क: फ़ैक्ट की जानकारी पाने या कैटगरी में बांटने के लिए, कम या सामान्य विश्लेषण का इस्तेमाल करें. जैसे, "DeepMind की स्थापना कहां हुई थी?".
  • मीडियम टास्क: कॉन्सेप्ट की तुलना करने या क्रिएटिव विश्लेषण के लिए, डिफ़ॉल्ट रूप से सोचने की प्रोसेस का इस्तेमाल करें. जैसे, इलेक्ट्रिक और हाइब्रिड कारों की तुलना करें.
  • मुश्किल टास्क: ऐडवांस कोडिंग, गणित या कई चरणों वाली प्लानिंग के लिए, ज़्यादा से ज़्यादा विश्लेषण का इस्तेमाल करें. जैसे, AIME के गणित के सवाल हल करें.

आगे क्या करना है