জেমিনি 2.5 মডেলগুলি একটি অভ্যন্তরীণ "চিন্তা প্রক্রিয়া" ব্যবহার করতে পারে যা তাদের যুক্তি এবং বহু-পদক্ষেপ পরিকল্পনা ক্ষমতাকে উল্লেখযোগ্যভাবে উন্নত করে, যা কোডিং, উন্নত গণিত এবং ডেটা বিশ্লেষণের মতো জটিল কাজগুলির জন্য অত্যন্ত কার্যকর করে তোলে।
চিন্তাশীল মডেলগুলি নিম্নলিখিত কনফিগারেশন এবং বিকল্পগুলি অফার করে:
চিন্তার বাজেট : চিন্তাভাবনা বাজেট ব্যবহার করে একটি মডেল কতটা "চিন্তা" করতে পারে তা আপনি কনফিগার করতে পারেন। এই কনফিগারেশনটি বিশেষভাবে গুরুত্বপূর্ণ যদি লেটেন্সি বা খরচ কমানো একটি অগ্রাধিকার হয়। এছাড়াও, একটি মডেলের চিন্তা করার ক্ষমতা কতটা প্রয়োজন হতে পারে তা নির্ধারণ করতে কাজের অসুবিধাগুলির তুলনা পর্যালোচনা করুন।
চিন্তার সারাংশ : আপনি তৈরি করা প্রতিক্রিয়ার সাথে অন্তর্ভুক্ত করার জন্য চিন্তার সারাংশ সক্ষম করতে পারেন। এই সারাংশগুলি মডেলের কাঁচা চিন্তার সংশ্লেষিত সংস্করণ এবং মডেলের অভ্যন্তরীণ যুক্তি প্রক্রিয়ার অন্তর্দৃষ্টি প্রদান করে।
থট স্বাক্ষর : Firebase AI লজিক SDK গুলি স্বয়ংক্রিয়ভাবে আপনার জন্য চিন্তার স্বাক্ষরগুলি পরিচালনা করে, যা নিশ্চিত করে যে মডেলটি বিশেষত ফাংশন কলিং ব্যবহার করার সময় পূর্ববর্তী বাঁক থেকে চিন্তার প্রসঙ্গে অ্যাক্সেস পেয়েছে৷
চিন্তার মডেলগুলি ব্যবহার করার জন্য সর্বোত্তম অনুশীলন এবং প্রম্পটিং নির্দেশিকা পর্যালোচনা করা নিশ্চিত করুন।
একটি চিন্তা মডেল ব্যবহার করুন
আপনি যেমন অন্য যেমিনি মডেল ব্যবহার করেন ঠিক তেমনি একটি চিন্তার মডেল ব্যবহার করুন (আপনার নির্বাচিত জেমিনি API প্রদানকারীকে শুরু করুন, একটি GenerativeModel
উদাহরণ তৈরি করুন ইত্যাদি)। এই মডেলগুলি পাঠ্য বা কোড তৈরির কাজগুলির জন্য ব্যবহার করা যেতে পারে, যেমন কাঠামোগত আউটপুট তৈরি করা বা মাল্টিমোডাল ইনপুট বিশ্লেষণ করা (যেমন ছবি , ভিডিও , অডিও , বা পিডিএফ )। আপনি যখন আউটপুট স্ট্রিম করছেন তখন আপনি চিন্তার মডেলগুলিও ব্যবহার করতে পারেন।
মডেল যে এই ক্ষমতা সমর্থন করে
শুধুমাত্র জেমিনি 2.5 মডেল এই ক্ষমতা সমর্থন করে।
-
gemini-2.5-pro
-
gemini-2.5-flash
-
gemini-2.5-flash-lite
চিন্তার মডেলগুলি ব্যবহার করার জন্য সর্বোত্তম অনুশীলন এবং প্রম্পটিং নির্দেশিকা
আমরা Google AI স্টুডিও বা Vertex AI স্টুডিওতে আপনার প্রম্পট পরীক্ষা করার পরামর্শ দিই যেখানে আপনি সম্পূর্ণ চিন্তা প্রক্রিয়া দেখতে পারেন। আপনি যেকোন ক্ষেত্র সনাক্ত করতে পারেন যেখানে মডেলটি বিপথে চলে গেছে যাতে আপনি আরও সামঞ্জস্যপূর্ণ এবং সঠিক প্রতিক্রিয়া পেতে আপনার প্রম্পটগুলিকে পরিমার্জন করতে পারেন৷
একটি সাধারণ প্রম্পট দিয়ে শুরু করুন যা পছন্দসই ফলাফল বর্ণনা করে, এবং এটি কীভাবে প্রতিক্রিয়া নির্ধারণ করে সে সম্পর্কে মডেলের প্রাথমিক চিন্তাভাবনাগুলি পর্যবেক্ষণ করুন। প্রতিক্রিয়া আশানুরূপ না হলে, নিম্নলিখিত প্রম্পটিং কৌশলগুলি ব্যবহার করে মডেলটিকে আরও ভাল প্রতিক্রিয়া তৈরি করতে সহায়তা করুন:
- ধাপে ধাপে নির্দেশাবলী প্রদান করুন
- ইনপুট-আউটপুট জোড়ার কয়েকটি উদাহরণ দিন
- আউটপুট এবং প্রতিক্রিয়াগুলি কীভাবে বাক্যাংশ করা উচিত এবং ফর্ম্যাট করা উচিত তার জন্য নির্দেশিকা প্রদান করুন
- নির্দিষ্ট যাচাইকরণ পদক্ষেপ প্রদান করুন
অনুরোধ করার পাশাপাশি, এই সুপারিশগুলি ব্যবহার করার কথা বিবেচনা করুন:
সিস্টেম নির্দেশাবলী সেট করুন, যেটি একটি "প্রস্তাবনা" এর মতো যা আপনি মডেলটি প্রম্পট বা শেষ ব্যবহারকারীর কাছ থেকে আরও নির্দেশাবলীর সংস্পর্শে আসার আগে যোগ করেন৷ তারা আপনাকে আপনার নির্দিষ্ট চাহিদা এবং ব্যবহারের ক্ষেত্রের উপর ভিত্তি করে মডেলের আচরণ পরিচালনা করতে দেয়।
মডেলটি কতটা চিন্তাভাবনা করতে পারে তা কনফিগার করতে একটি চিন্তার বাজেট সেট করুন। যদি আপনি একটি কম বাজেট সেট করেন, তাহলে মডেলটি তার প্রতিক্রিয়া "অতিরিক্ত চিন্তা" করবে না। আপনি যদি একটি উচ্চ বাজেট নির্ধারণ করেন, তাহলে প্রয়োজনে মডেলটি আরও চিন্তা করতে পারে। একটি চিন্তা বাজেট সেট করা প্রকৃত প্রতিক্রিয়ার জন্য মোট টোকেন আউটপুট সীমার বেশি সংরক্ষণ করে।
চিন্তাশীল টোকেনগুলির গণনা এবং চিন্তাভাবনা সক্ষম করা আপনার অনুরোধগুলির লেটেন্সি নিরীক্ষণ করতে Firebase কনসোলে AI মনিটরিং সক্ষম করুন৷ এবং যদি আপনি ভেবে থাকেন যে সারাংশগুলি সক্ষম করা হয়েছে, সেগুলি কনসোলে প্রদর্শিত হবে যেখানে আপনি আপনার প্রম্পটগুলিকে ডিবাগ এবং পরিমার্জন করতে সহায়তা করার জন্য মডেলের বিশদ যুক্তি পরিদর্শন করতে পারেন৷
চিন্তার বাজেট নিয়ন্ত্রণ করুন
মডেলটি তার প্রতিক্রিয়া তৈরি করতে কতটা চিন্তাভাবনা করতে পারে তা নিয়ন্ত্রণ করতে, আপনি এটি ব্যবহার করার জন্য অনুমোদিত বাজেট টোকেনের সংখ্যা নির্দিষ্ট করতে পারেন।
আপনি এমন পরিস্থিতিতে ম্যানুয়ালি চিন্তার বাজেট সেট করতে পারেন যেখানে আপনার ডিফল্ট চিন্তা বাজেটের চেয়ে বেশি বা কম টোকেনের প্রয়োজন হতে পারে। এই বিভাগে পরে টাস্ক জটিলতা এবং প্রস্তাবিত বাজেট সম্পর্কে আরও বিস্তারিত নির্দেশিকা খুঁজুন। এখানে কিছু উচ্চ-স্তরের নির্দেশিকা রয়েছে:
- লেটেন্সি গুরুত্বপূর্ণ হলে বা কম জটিল কাজের জন্য কম চিন্তার বাজেট সেট করুন
- আরও জটিল কাজের জন্য একটি উচ্চ চিন্তার বাজেট সেট করুন
চিন্তা করে বাজেট সেট করুন
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট সামগ্রী এবং কোড দেখতে আপনার Gemini API প্রদানকারীতে ক্লিক করুন। |
GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ চিন্তার বাজেট সেট করুন। কনফিগারেশনটি দৃষ্টান্তের আজীবনের জন্য বজায় রাখা হয়। আপনি যদি বিভিন্ন অনুরোধের জন্য ভিন্ন চিন্তার বাজেট ব্যবহার করতে চান, তাহলে প্রতিটি বাজেটের সাথে কনফিগার করা GenerativeModel
দৃষ্টান্ত তৈরি করুন।
এই বিভাগে পরে সমর্থিত চিন্তা বাজেট মান সম্পর্কে জানুন।
সুইফট
একটি GenerationConfig
এ একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে চিন্তা বাজেট সেট করুন।
// ...
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
let generationConfig = GenerationConfig(
thinkingConfig: ThinkingConfig(thinkingBudget: 1024)
)
// Specify the config as part of creating the `GenerativeModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
)
// ...
Kotlin
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ পরামিতিগুলির মান সেট করুন।
// ...
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
val generationConfig = generationConfig {
thinkingConfig = thinkingConfig {
thinkingBudget = 1024
}
}
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "GEMINI_MODEL_NAME",
generationConfig,
)
// ...
Java
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ পরামিতিগুলির মান সেট করুন।
// ...
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
ThinkingConfig thinkingConfig = new ThinkingConfig.Builder()
.setThinkingBudget(1024)
.build();
GenerationConfig generationConfig = GenerationConfig.builder()
.setThinkingConfig(thinkingConfig)
.build();
// Specify the config as part of creating the `GenerativeModel` instance
GenerativeModelFutures model = GenerativeModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
/* modelName */ "GEMINI_MODEL_NAME",
/* generationConfig */ generationConfig
);
);
// ...
Web
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ পরামিতিগুলির মান সেট করুন।
// ...
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
const generationConfig = {
thinkingConfig: {
thinkingBudget: 1024
}
};
// Specify the config as part of creating the `GenerativeModel` instance
const model = getGenerativeModel(ai, { model: "GEMINI_MODEL_NAME", generationConfig });
// ...
Dart
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ পরামিতিগুলির মান সেট করুন।
// ...
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
final thinkingConfig = ThinkingConfig(thinkingBudget: 1024);
final generationConfig = GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
final model = FirebaseAI.googleAI().generativeModel(
model: 'GEMINI_MODEL_NAME',
config: generationConfig,
);
// ...
ঐক্য
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে একটি GenerationConfig
এ পরামিতিগুলির মান সেট করুন।
// ...
// Set the thinking configuration
// Use a thinking budget value appropriate for your model (example value shown here)
var thinkingConfig = new ThinkingConfig(thinkingBudget: 1024);
var generationConfig = new GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
);
// ...
সমর্থিত চিন্তা বাজেট মান
নিম্নলিখিত সারণীটি চিন্তার বাজেটের মানগুলি তালিকাভুক্ত করে যা আপনি মডেলের thinkingBudget
কনফিগার করে প্রতিটি মডেলের জন্য সেট করতে পারেন।
মডেল | ডিফল্ট মান | চিন্তা বাজেটের জন্য উপলব্ধ পরিসীমা | মান চিন্তা অক্ষম | মান গতিশীল চিন্তা সক্রিয় | |
---|---|---|---|---|---|
সর্বনিম্ন মান | সর্বোচ্চ মান | ||||
Gemini 2.5 Pro | 8,192 | 128 | 32,768 | বন্ধ করা যাবে না | -1 |
মিথুন 2.5 ফ্ল্যাশ | 8,192 | 1 | 24,576 | 0 | -1 |
Gemini 2.5 Flash-Lite | 0 (চিন্তা ডিফল্টরূপে অক্ষম করা হয়) | 512 | 24,576 | 0 (বা মোটেও চিন্তাভাবনা বাজেট কনফিগার করবেন না) | -1 |
চিন্তা অক্ষম করুন
কিছু সহজ কাজের জন্য, চিন্তা করার ক্ষমতা প্রয়োজন হয় না, এবং ঐতিহ্যগত অনুমানই যথেষ্ট। অথবা যদি লেটেন্সি হ্রাস করা একটি অগ্রাধিকার হয়, তাহলে আপনি মডেলটিকে প্রতিক্রিয়া তৈরি করতে প্রয়োজনের চেয়ে বেশি সময় নিতে চান না।
এই পরিস্থিতিতে, আপনি চিন্তা অক্ষম (বা বন্ধ) করতে পারেন:
- Gemini 2.5 Pro : চিন্তা অক্ষম করা যাবে না
- জেমিনি 2.5 ফ্ল্যাশ :
thinkingBudget
0
টোকেনে সেট করুন - Gemini 2.5 Flash-Lite : চিন্তাভাবনা ডিফল্টরূপে অক্ষম করা হয়৷
গতিশীল চিন্তা সক্রিয় করুন
thinkingBudget
-1
এ সেট করে আপনি মডেলটিকে কখন এবং কতটা চিন্তা করেন (যাকে গতিশীল চিন্তা বলে) সিদ্ধান্ত নিতে দিতে পারেন। উপরে তালিকাভুক্ত সর্বোচ্চ টোকেন মান পর্যন্ত মডেলটি যতগুলো টোকেন ব্যবহার করতে পারে তা উপযুক্ত বলে সিদ্ধান্ত নেয়।
টাস্ক জটিলতা
সহজ কাজগুলি - চিন্তাভাবনা বন্ধ করা যেতে পারে
সহজবোধ্য অনুরোধ যেখানে জটিল যুক্তির প্রয়োজন হয় না, যেমন সত্য পুনরুদ্ধার বা শ্রেণীবিভাগ। উদাহরণ:- "ডিপমাইন্ড কোথায় প্রতিষ্ঠিত হয়েছিল?"
- "এই ইমেলটি কি মিটিংয়ের জন্য বলছে নাকি শুধু তথ্য দিচ্ছে?"
মাঝারি কাজ - ডিফল্ট বাজেট বা কিছু অতিরিক্ত চিন্তা বাজেট প্রয়োজন
সাধারণ অনুরোধ যা ধাপে ধাপে প্রসেসিং বা গভীরতর বোঝাপড়া থেকে উপকৃত হয়। উদাহরণ:- "সালোকসংশ্লেষণ এবং বেড়ে ওঠার মধ্যে একটি সাদৃশ্য তৈরি করুন।"
- "বৈদ্যুতিক গাড়ি এবং হাইব্রিড গাড়ির তুলনা এবং বৈসাদৃশ্য।"
কঠিন কাজ - সর্বাধিক চিন্তা বাজেট প্রয়োজন হতে পারে
সত্যিই জটিল চ্যালেঞ্জ, যেমন জটিল গণিত সমস্যা সমাধান বা কোডিং কাজ। এই ধরনের কাজগুলির জন্য মডেলটিকে তার পূর্ণ যুক্তি এবং পরিকল্পনার ক্ষমতাকে নিযুক্ত করতে হবে, প্রায়শই উত্তর দেওয়ার আগে অনেকগুলি অভ্যন্তরীণ পদক্ষেপ জড়িত থাকে। উদাহরণ:- "AIME 2025-এ সমস্যা 1 সমাধান করুন: b > 9 সমস্ত পূর্ণসংখ্যা বেসের যোগফল খুঁজুন যার জন্য 17b হল 97b এর একটি ভাজক।"
- "একটি ওয়েব অ্যাপ্লিকেশনের জন্য পাইথন কোড লিখুন যা ব্যবহারকারীর প্রমাণীকরণ সহ রিয়েল-টাইম স্টক মার্কেট ডেটা ভিজ্যুয়ালাইজ করে। এটিকে যতটা সম্ভব দক্ষ করুন।"
প্রতিক্রিয়াগুলিতে চিন্তার সারাংশ অন্তর্ভুক্ত করুন
চিন্তার সারাংশগুলি মডেলের কাঁচা চিন্তার সংশ্লেষিত সংস্করণ এবং মডেলের অভ্যন্তরীণ যুক্তি প্রক্রিয়ার অন্তর্দৃষ্টি প্রদান করে।
এখানে প্রতিক্রিয়াগুলিতে চিন্তার সারাংশ অন্তর্ভুক্ত করার কিছু কারণ রয়েছে:
আপনি আপনার অ্যাপের UI-তে চিন্তার সারাংশ প্রদর্শন করতে পারেন বা আপনার ব্যবহারকারীদের কাছে সেগুলি অ্যাক্সেসযোগ্য করে তুলতে পারেন। চিন্তার সারাংশটি প্রতিক্রিয়ার একটি পৃথক অংশ হিসাবে ফিরিয়ে দেওয়া হয়েছে যাতে এটি আপনার অ্যাপে কীভাবে ব্যবহার করা হয় তার উপর আপনার আরও নিয়ন্ত্রণ থাকে।
আপনি যদি Firebase কনসোলে AI মনিটরিংও সক্ষম করেন, তাহলে চিন্তার সারাংশ কনসোলে প্রদর্শিত হবে যেখানে আপনি আপনার প্রম্পটগুলিকে ডিবাগ এবং পরিমার্জন করতে সাহায্য করার জন্য মডেলের বিশদ যুক্তি পরিদর্শন করতে পারেন।
এখানে চিন্তার সারাংশ সম্পর্কে কিছু মূল নোট রয়েছে:
চিন্তার সারাংশ চিন্তার বাজেট দ্বারা নিয়ন্ত্রিত হয় না (বাজেট শুধুমাত্র মডেলের কাঁচা চিন্তার জন্য প্রযোজ্য)। যাইহোক, যদি চিন্তা অক্ষম করা হয় , তাহলে মডেলটি চিন্তার সারাংশ ফেরত দেবে না।
চিন্তার সারাংশ মডেলের নিয়মিত জেনারেটেড-টেক্সট প্রতিক্রিয়ার অংশ হিসাবে বিবেচিত হয় এবং আউটপুট টোকেন হিসাবে গণনা করা হয়।
চিন্তার সারাংশ সক্ষম করুন
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট সামগ্রী এবং কোড দেখতে আপনার Gemini API প্রদানকারীতে ক্লিক করুন। |
আপনি আপনার মডেল কনফিগারেশনে includeThoughts
সত্যে সেট করে চিন্তার সারাংশ সক্ষম করতে পারেন। তারপরে আপনি প্রতিক্রিয়া থেকে thoughtSummary
ক্ষেত্রটি পরীক্ষা করে সারাংশটি অ্যাক্সেস করতে পারেন।
প্রতিক্রিয়া সহ চিন্তার সারাংশ কীভাবে সক্ষম এবং পুনরুদ্ধার করতে হয় তা প্রদর্শন করে এখানে একটি উদাহরণ রয়েছে:
সুইফট
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
let generationConfig = GenerationConfig(
thinkingConfig: ThinkingConfig(includeThoughts: true)
)
// Specify the config as part of creating the `GenerativeModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
)
let response = try await model.generateContent("solve x^2 + 4x + 4 = 0")
// Handle the response that includes thought summaries
if let thoughtSummary = response.thoughtSummary {
print("Thought Summary: \(thoughtSummary)")
}
guard let text = response.text else {
fatalError("No text in response.")
}
print("Answer: \(text)")
Kotlin
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
val generationConfig = generationConfig {
thinkingConfig = thinkingConfig {
includeThoughts = true
}
}
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "GEMINI_MODEL_NAME",
generationConfig,
)
val response = model.generateContent("solve x^2 + 4x + 4 = 0")
// Handle the response that includes thought summaries
response.thoughtSummary?.let {
println("Thought Summary: $it")
}
response.text?.let {
println("Answer: $it")
}
Java
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
ThinkingConfig thinkingConfig = new ThinkingConfig.Builder()
.setIncludeThoughts(true)
.build();
GenerationConfig generationConfig = GenerationConfig.builder()
.setThinkingConfig(thinkingConfig)
.build();
// Specify the config as part of creating the `GenerativeModel` instance
GenerativeModelFutures model = GenerativeModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
/* modelName */ "GEMINI_MODEL_NAME",
/* generationConfig */ generationConfig
);
);
// Handle the response that includes thought summaries
ListenableFuture responseFuture = model.generateContent("solve x^2 + 4x + 4 = 0");
Futures.addCallback(responseFuture, new FutureCallback() {
@Override
public void onSuccess(GenerateContentResponse response) {
if (response.getThoughtSummary() != null) {
System.out.println("Thought Summary: " + response.getThoughtSummary());
}
if (response.getText() != null) {
System.out.println("Answer: " + response.getText());
}
}
@Override
public void onFailure(Throwable t) {
// Handle error
}
}, MoreExecutors.directExecutor());
Web
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
const generationConfig = {
thinkingConfig: {
includeThoughts: true
}
};
// Specify the config as part of creating the `GenerativeModel` instance
const model = getGenerativeModel(ai, { model: "GEMINI_MODEL_NAME", generationConfig });
const result = await model.generateContent("solve x^2 + 4x + 4 = 0");
const response = result.response;
// Handle the response that includes thought summaries
if (response.thoughtSummary()) {
console.log(`Thought Summary: ${response.thoughtSummary()}`);
}
const text = response.text();
console.log(`Answer: ${text}`);
Dart
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
final thinkingConfig = ThinkingConfig(includeThoughts: true);
final generationConfig = GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
final model = FirebaseAI.googleAI().generativeModel(
model: 'GEMINI_MODEL_NAME',
generationConfig: generationConfig,
);
final response = await model.generateContent('solve x^2 + 4x + 4 = 0');
// Handle the response that includes thought summaries
if (response.thoughtSummary != null) {
print('Thought Summary: ${response.thoughtSummary}');
}
if (response.text != null) {
print('Answer: ${response.text}');
}
ঐক্য
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
var thinkingConfig = new ThinkingConfig(includeThoughts: true);
var generationConfig = new GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
);
var response = await model.GenerateContentAsync("solve x^2 + 4x + 4 = 0");
// Handle the response that includes thought summaries
if (response.ThoughtSummary != null) {
Debug.Log($"Thought Summary: {response.ThoughtSummary}");
}
if (response.Text != null) {
Debug.Log($"Answer: {response.Text}");
}
# Example Response:
# Okay, let's solve the quadratic equation x² + 4x + 4 = 0.
# ...
# **Answer:**
# The solution to the equation x² + 4x + 4 = 0 is x = -2. This is a repeated root (or a root with multiplicity 2).
# Example Thought Summary:
# **My Thought Process for Solving the Quadratic Equation**
#
# Alright, let's break down this quadratic, x² + 4x + 4 = 0. First things first:
# it's a quadratic; the x² term gives it away, and we know the general form is
# ax² + bx + c = 0.
#
# So, let's identify the coefficients: a = 1, b = 4, and c = 4. Now, what's the
# most efficient path to the solution? My gut tells me to try factoring; it's
# often the fastest route if it works. If that fails, I'll default to the quadratic
# formula, which is foolproof. Completing the square? It's good for deriving the
# formula or when factoring is difficult, but not usually my first choice for
# direct solving, but it can't hurt to keep it as an option.
#
# Factoring, then. I need to find two numbers that multiply to 'c' (4) and add
# up to 'b' (4). Let's see... 1 and 4 don't work (add up to 5). 2 and 2? Bingo!
# They multiply to 4 and add up to 4. This means I can rewrite the equation as
# (x + 2)(x + 2) = 0, or more concisely, (x + 2)² = 0. Solving for x is now
# trivial: x + 2 = 0, thus x = -2.
#
# Okay, just to be absolutely certain, I'll run the quadratic formula just to
# double-check. x = [-b ± √(b² - 4ac)] / 2a. Plugging in the values, x = [-4 ±
# √(4² - 4 * 1 * 4)] / (2 * 1). That simplifies to x = [-4 ± √0] / 2. So, x =
# -2 again - a repeated root. Nice.
#
# Now, let's check via completing the square. Starting from the same equation,
# (x² + 4x) = -4. Take half of the b-value (4/2 = 2), square it (2² = 4), and
# add it to both sides, so x² + 4x + 4 = -4 + 4. Which simplifies into (x + 2)²
# = 0. The square root on both sides gives us x + 2 = 0, therefore x = -2, as
# expected.
#
# Always, *always* confirm! Let's substitute x = -2 back into the original
# equation: (-2)² + 4(-2) + 4 = 0. That's 4 - 8 + 4 = 0. It checks out.
#
# Conclusion: the solution is x = -2. Confirmed.
স্ট্রীম চিন্তা সারাংশ
আপনি যদি generateContentStream
ব্যবহার করে একটি প্রতিক্রিয়া স্ট্রিম করতে চান তবে আপনি চিন্তার সারাংশও দেখতে পারেন। এটি রেসপন্স জেনারেশনের সময় রোলিং, ইনক্রিমেন্টাল সারাংশ ফেরত দেবে।
সুইফট
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
let generationConfig = GenerationConfig(
thinkingConfig: ThinkingConfig(includeThoughts: true)
)
// Specify the config as part of creating the `GenerativeModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
)
let stream = try model.generateContentStream("solve x^2 + 4x + 4 = 0")
// Handle the streamed response that includes thought summaries
var thoughts = ""
var answer = ""
for try await response in stream {
if let thought = response.thoughtSummary {
if thoughts.isEmpty {
print("--- Thoughts Summary ---")
}
print(thought)
thoughts += thought
}
if let text = response.text {
if answer.isEmpty {
print("--- Answer ---")
}
print(text)
answer += text
}
}
Kotlin
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
val generationConfig = generationConfig {
thinkingConfig = thinkingConfig {
includeThoughts = true
}
}
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "GEMINI_MODEL_NAME",
generationConfig,
)
// Handle the streamed response that includes thought summaries
var thoughts = ""
var answer = ""
model.generateContentStream("solve x^2 + 4x + 4 = 0").collect { response ->
response.thoughtSummary?.let {
if (thoughts.isEmpty()) {
println("--- Thoughts Summary ---")
}
print(it)
thoughts += it
}
response.text?.let {
if (answer.isEmpty()) {
println("--- Answer ---")
}
print(it)
answer += it
}
}
Java
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
ThinkingConfig thinkingConfig = new ThinkingConfig.Builder()
.setIncludeThoughts(true)
.build();
GenerationConfig generationConfig = GenerationConfig.builder()
.setThinkingConfig(thinkingConfig)
.build();
// Specify the config as part of creating the `GenerativeModel` instance
GenerativeModelFutures model = GenerativeModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
/* modelName */ "GEMINI_MODEL_NAME",
/* generationConfig */ generationConfig
);
);
// Streaming with Java is complex and depends on the async library used.
// This is a conceptual example using a reactive stream.
Flowable responseStream = model.generateContentStream("solve x^2 + 4x + 4 = 0");
// Handle the streamed response that includes thought summaries
StringBuilder thoughts = new StringBuilder();
StringBuilder answer = new StringBuilder();
responseStream.subscribe(response -> {
if (response.getThoughtSummary() != null) {
if (thoughts.length() == 0) {
System.out.println("--- Thoughts Summary ---");
}
System.out.print(response.getThoughtSummary());
thoughts.append(response.getThoughtSummary());
}
if (response.getText() != null) {
if (answer.length() == 0) {
System.out.println("--- Answer ---");
}
System.out.print(response.getText());
answer.append(response.getText());
}
}, throwable -> {
// Handle error
});
Web
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
const generationConfig = {
thinkingConfig: {
includeThoughts: true
}
};
// Specify the config as part of creating the `GenerativeModel` instance
const model = getGenerativeModel(ai, { model: "GEMINI_MODEL_NAME", generationConfig });
const result = await model.generateContentStream("solve x^2 + 4x + 4 = 0");
// Handle the streamed response that includes thought summaries
let thoughts = "";
let answer = "";
for await (const chunk of result.stream) {
if (chunk.thoughtSummary()) {
if (thoughts === "") {
console.log("--- Thoughts Summary ---");
}
// In Node.js, process.stdout.write(chunk.thoughtSummary()) could be used
// to avoid extra newlines.
console.log(chunk.thoughtSummary());
thoughts += chunk.thoughtSummary();
}
const text = chunk.text();
if (text) {
if (answer === "") {
console.log("--- Answer ---");
}
// In Node.js, process.stdout.write(text) could be used.
console.log(text);
answer += text;
}
}
Dart
একটি GenerativeModel
উদাহরণ তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
final thinkingConfig = ThinkingConfig(includeThoughts: true);
final generationConfig = GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
final model = FirebaseAI.googleAI().generativeModel(
model: 'GEMINI_MODEL_NAME',
generationConfig: generationConfig,
);
final responses = model.generateContentStream('solve x^2 + 4x + 4 = 0');
// Handle the streamed response that includes thought summaries
var thoughts = '';
var answer = '';
await for (final response in responses) {
if (response.thoughtSummary != null) {
if (thoughts.isEmpty) {
print('--- Thoughts Summary ---');
}
thoughts += response.thoughtSummary!;
}
if (response.text != null) {
if (answer.isEmpty) {
print('--- Answer ---');
}
answer += response.text!;
}
}
ঐক্য
একটি GenerativeModel
দৃষ্টান্ত তৈরির অংশ হিসাবে GenerationConfig
এ চিন্তার সারাংশ সক্ষম করুন।
// ...
// Set the thinking configuration
// Optionally enable thought summaries in the generated response (default is false)
var thinkingConfig = new ThinkingConfig(includeThoughts: true);
var generationConfig = new GenerationConfig(
thinkingConfig: thinkingConfig
);
// Specify the config as part of creating the `GenerativeModel` instance
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
);
var stream = model.GenerateContentStreamAsync("solve x^2 + 4x + 4 = 0");
// Handle the streamed response that includes thought summaries
var thoughts = "";
var answer = "";
await foreach (var response in stream)
{
if (response.ThoughtSummary != null)
{
if (string.IsNullOrEmpty(thoughts))
{
Debug.Log("--- Thoughts Summary ---");
}
Debug.Log(response.ThoughtSummary);
thoughts += response.ThoughtSummary;
}
if (response.Text != null)
{
if (string.IsNullOrEmpty(answer))
{
Debug.Log("--- Answer ---");
}
Debug.Log(response.Text);
answer += response.Text;
}
}
চিন্তার স্বাক্ষর বুঝুন
মাল্টি-টার্ন ইন্টারঅ্যাকশনে চিন্তাভাবনা ব্যবহার করার সময়, মডেলটির পূর্ববর্তী বাঁক থেকে চিন্তার প্রসঙ্গে অ্যাক্সেস থাকে না। যাইহোক, আপনি যদি ফাংশন কলিং ব্যবহার করে থাকেন, তাহলে আপনি চিন্তার প্রসঙ্গ ধরে রাখার জন্য চিন্তার স্বাক্ষরের সুবিধা নিতে পারেন। চিন্তার স্বাক্ষরগুলি মডেলের অভ্যন্তরীণ চিন্তা প্রক্রিয়ার এনক্রিপ্ট করা উপস্থাপনা, এবং চিন্তাভাবনা এবং ফাংশন কলিং ব্যবহার করার সময় এগুলি উপলব্ধ। বিশেষত, চিন্তার স্বাক্ষর তৈরি হয় যখন:
- চিন্তা সক্রিয় করা হয় এবং চিন্তা উত্পন্ন হয়.
- অনুরোধ ফাংশন ঘোষণা অন্তর্ভুক্ত.
চিন্তা স্বাক্ষরের সুবিধা নিতে, স্বাভাবিক হিসাবে ফাংশন কলিং ব্যবহার করুন। Firebase AI লজিক SDKগুলি স্টেট ম্যানেজ করে এবং আপনার জন্য চিন্তার স্বাক্ষরগুলি স্বয়ংক্রিয়ভাবে পরিচালনা করে প্রক্রিয়াটিকে সহজ করে। SDK গুলি স্বয়ংক্রিয়ভাবে একটি Chat
সেশনে পরবর্তী sendMessage
বা sendMessageStream
কলগুলির মধ্যে যেকোনও তৈরি চিন্তা স্বাক্ষর পাস করে৷
মূল্য নির্ধারণ এবং চিন্তা টোকেন গণনা
চিন্তা টোকেন টেক্সট-আউটপুট টোকেন হিসাবে একই মূল্য ব্যবহার করে. আপনি চিন্তার সারাংশ সক্ষম করলে, সেগুলিকে চিন্তার টোকেন হিসাবে বিবেচনা করা হয় এবং সেই অনুযায়ী মূল্য নির্ধারণ করা হয়।
আপনি Firebase কনসোলে এআই মনিটরিং সক্ষম করতে পারেন যাতে চিন্তাভাবনা সক্ষম করা অনুরোধের জন্য চিন্তার টোকেনের গণনা নিরীক্ষণ করা যায়।
আপনি প্রতিক্রিয়ার usageMetadata
অ্যাট্রিবিউটে thoughtsTokenCount
ফিল্ড থেকে মোট চিন্তা টোকেনের সংখ্যা পেতে পারেন:
সুইফট
// ...
let response = try await model.generateContent("Why is the sky blue?")
if let usageMetadata = response.usageMetadata {
print("Thoughts Token Count: \(usageMetadata.thoughtsTokenCount)")
}
Kotlin
// ...
val response = model.generateContent("Why is the sky blue?")
response.usageMetadata?.let { usageMetadata ->
println("Thoughts Token Count: ${usageMetadata.thoughtsTokenCount}")
}
Java
// ...
ListenableFuture<GenerateContentResponse> response =
model.generateContent("Why is the sky blue?");
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
String usageMetadata = result.getUsageMetadata();
if (usageMetadata != null) {
System.out.println("Thoughts Token Count: " +
usageMetadata.getThoughtsTokenCount());
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
// ...
const response = await model.generateContent("Why is the sky blue?");
if (response?.usageMetadata?.thoughtsTokenCount != null) {
console.log(`Thoughts Token Count: ${response.usageMetadata.thoughtsTokenCount}`);
}
Dart
// ...
final response = await model.generateContent(
Content.text("Why is the sky blue?"),
]);
if (response?.usageMetadata case final usageMetadata?) {
print("Thoughts Token Count: ${usageMetadata.thoughtsTokenCount}");
}
ঐক্য
// ...
var response = await model.GenerateContentAsync("Why is the sky blue?");
if (response.UsageMetadata != null)
{
UnityEngine.Debug.Log($"Thoughts Token Count: {response.UsageMetadata?.ThoughtsTokenCount}");
}
গণনা টোকেন গাইডে টোকেন সম্পর্কে আরও জানুন।