মডেলের প্রতিটি কলে, মডেল কীভাবে উত্তর জেনারেট করবে তা নিয়ন্ত্রণ করতে
আপনি মডেল কনফিগারেশন পাঠাতে পারেন। প্রতিটি মডেল আলাদা আলাদা কনফিগারেশন
বিকল্পে কাজ করে, যেমন maxOutputTokens সেট করা বা চিন্তা করা,
উত্তর দেওয়ার পদ্ধতি, ছবি বা স্পিচের জন্য বিশেষ কনফিগারেশন।
Gemini মডেল অ্যাক্সেস করার সময় বেশিরভাগ ব্যবহারের ক্ষেত্রে, আপনি
GenerationConfig ব্যবহার করে মডেল কনফিগার করেন। তবে, আপনি যদি কোনও
Gemini Live API মডেল কনফিগার করেন, তাহলে আপনাকে LiveGenerationConfig ব্যবহার করতে হবে।
এই পৃষ্ঠায় Gemini মডেলের জন্য কীভাবে কনফিগারেশন সেট-আপ করতে হয় তা দেখানো হয়েছে এবং প্রতিটি প্যারামিটারের বিবরণ দেওয়া হয়েছে।
Gemini কনফিগে যান Gemini Live API কনফিগে যান
Gemini মডেলের জন্য GenerationConfig
|
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট কন্টেন্ট ও কোড দেখতে আপনার Gemini API প্রদানকারীর আইকনে ক্লিক করুন। |
সাধারণ ব্যবহারের মডেল, ছবি তৈরি করা মডেল ("Nano Banana" মডেল) এবং
টেক্সট-টু-স্পিচ (TTS) মডেল সহ
বেশিরভাগ Gemini মডেলের জন্য GenerationConfig সেট করুন।
GenerativeModel
ইনস্ট্যান্সের লাইফটাইম ধরে কনফিগারেশন বজায় থাকে। আপনি অন্য কোনও কনফিগারেশন ব্যবহার করতে চাইলে, অন্য কনফিগারেশন সহ একটি নতুন ইনস্ট্যান্স
তৈরি ও ব্যবহার করুন।
Swift
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
import FirebaseAILogic
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
let config = GenerationConfig(
maxOutputTokens: 200,
stopSequences: ["red"]
)
// Initialize the Gemini Developer API backend service.
// Specify the config as part of creating the `GenerativeModel` instance.
let model = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: config
)
// ...
Kotlin
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
val config = generationConfig {
maxOutputTokens = 200
stopSequences = listOf("red")
}
// Initialize the Gemini Developer API backend service.
// Specify the config as part of creating the `GenerativeModel` instance.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "GEMINI_MODEL_NAME",
generationConfig = config
)
// ...
Java
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.maxOutputTokens = 200;
configBuilder.stopSequences = List.of("red");
GenerationConfig config = configBuilder.build();
// Specify the config as part of creating the `GenerativeModel` instance.
GenerativeModelFutures model = GenerativeModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel(
"GEMINI_MODEL_NAME",
config
);
);
// ...
Web
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
const generationConfig = {
maxOutputTokens: 200,
stopSequences: ["red"],
};
// Specify the config as part of creating the `GenerativeModel` instance.
const model = getGenerativeModel(ai, { model: "GEMINI_MODEL_NAME", generationConfig });
// ...
Dart
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
final generationConfig = GenerationConfig(
maxOutputTokens: 200,
stopSequences: ["red"],
);
// Initialize the Gemini Developer API backend service.
// Specify the config as part of creating the `GenerativeModel` instance.
final model = FirebaseAI.googleAI().generativeModel(
model: 'GEMINI_MODEL_NAME',
config: generationConfig,
);
// ...
Unity
GenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
GenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `GenerationConfig`.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
// For the latest general-use Gemini models, the following parameters are now unsupported:
// temperature, top-K, top-P, frequency penalty, presence penalty, and candidate count
var generationConfig = new GenerationConfig(
maxOutputTokens: 200,
stopSequences: new string[] { "red" }
);
// Initialize the Gemini Developer API backend service.
// Specify the config as part of creating the `GenerativeModel` instance.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
var model = ai.GetGenerativeModel(
modelName: "GEMINI_MODEL_NAME",
generationConfig: generationConfig
);
এই পৃষ্ঠার পরবর্তী বিভাগে আপনি প্রতিটি প্যারামিটারের বিবরণ পাবেন।
আপনি Google AI Studio ব্যবহার করে প্রম্পট ও মডেল কনফিগারেশন নিয়ে এক্সপেরিমেন্ট করতে পারবেন।Gemini Live API মডেলের জন্য LiveGenerationConfig
|
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট কন্টেন্ট ও কোড দেখতে আপনার Gemini API প্রদানকারীর আইকনে ক্লিক করুন। |
LiveGenerationConfig মডেল ব্যবহার করার সময় Gemini Live API সেট করুন।
LiveModel
ইনস্ট্যান্সের লাইফটাইম ধরে কনফিগারেশন বজায় থাকে। আপনি অন্য কোনও কনফিগারেশন ব্যবহার করতে চাইলে, অন্য কনফিগারেশন সহ একটি নতুন ইনস্ট্যান্স
তৈরি ও ব্যবহার করুন।
Swift
LiveModel ইনস্ট্যান্সের ইনিশিয়ালাইজেশনের সময়
liveGenerationConfig
প্যারামিটারের ভ্যালু সেট করুন:
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
let config = LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: [.audio],
speech: SpeechConfig(voiceName: "Fenrir"),
)
// Specify the config as part of creating the `liveModel` instance.
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "GEMINI_LIVE_MODEL_NAME",
generationConfig: config
)
// ...
Kotlin
LiveModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
LiveGenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
val config = liveGenerationConfig {
maxOutputTokens = 200
responseModality = ResponseModality.AUDIO
speechConfig = SpeechConfig(voice = Voice("FENRIR"))
}
// Specify the config as part of creating the `LiveModel` instance.
val liveModel = Firebase.ai(backend = GenerativeBackend.agentPlatform()).liveModel(
modelName = "GEMINI_LIVE_MODEL_NAME",
generationConfig = config
)
// ...
Java
LiveModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
LiveGenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
LiveGenerationConfig.Builder configBuilder = new LiveGenerationConfig.Builder();
configBuilder.setMaxOutputTokens(200);
configBuilder.setResponseModality(ResponseModality.AUDIO);
configBuilder.setSpeechConfig(new SpeechConfig(new Voice("FENRIR")));
LiveGenerationConfig config = configBuilder.build();
// Specify the config as part of creating the `LiveModel` instance.
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"GEMINI_LIVE_MODEL_NAME",
config
);
// ...
Web
LiveGenerativeModel ইনস্ট্যান্সের ইনিশিয়ালাইজেশনের সময়
LiveGenerationConfig
প্যারামিটারের ভ্যালু সেট করুন:
// ...
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
const liveGenerationConfig = {
maxOutputTokens: 200,
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: {
prebuiltVoiceConfig: { voiceName: "Fenrir" },
},
},
};
// Specify the config as part of creating the `LiveGenerativeModel` instance.
const liveModel = getLiveGenerativeModel(ai, {
model: "GEMINI_LIVE_MODEL_NAME",
liveGenerationConfig,
});
// ...
Dart
LiveGenerativeModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
LiveGenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
final config = LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'Fenrir'),
);
// Specify the config as part of creating the `liveGenerativeModel` instance.
final liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'GEMINI_LIVE_MODEL_NAME',
liveGenerationConfig: config,
);
// ...
Unity
LiveModel ইনস্ট্যান্স তৈরি করার অংশ হিসেবে
LiveGenerationConfig
এ প্যারামিটারের ভ্যালু সেট করুন।
// ...
// Set parameter values in a `LiveGenerationConfig` (example values shown here).
var config = new LiveGenerationConfig(
maxOutputTokens: 200,
responseModalities: new[] { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("Fenrir")
);
// Specify the config as part of creating the `LiveModel` instance.
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "GEMINI_LIVE_MODEL_NAME",
liveGenerationConfig: config
);
// ...
এই পৃষ্ঠার পরবর্তী বিভাগে আপনি প্রতিটি প্যারামিটারের বিবরণ পাবেন।
আপনি Google AI Studio ব্যবহার করে প্রম্পট ও মডেল কনফিগারেশনের সাথে এক্সপেরিমেন্ট করতে পারবেন।প্যারামিটারের বিবরণ
নিচে দেওয়া সারণী থেকে উপলভ্য প্যারামিটার সম্পর্কে এক নজরে জানতে পারবেন। কিছু প্যারামিটার শুধুমাত্র নির্দিষ্ট মডেলের ক্ষেত্রেই প্রযোজ্য।
| প্যারামিটার | বিবরণ | সীমাবদ্ধতা | ডিফল্ট মান |
|---|---|---|---|
অডিও টাইমস্ট্যাম্পaudioTimestamp
|
শুধুমাত্র অডিও ইনপুট ফাইলের জন্য টাইমস্ট্যাম্প বোঝার সুবিধা চালু করে। |
Boolean
|
false
|
সর্বাধিক আউটপুট টোকেনmaxOutputTokens
|
উত্তরে জেনারেট করা টোকেনের সর্বাধিক সংখ্যা নির্দিষ্ট করে। | --- | --- |
সিকোয়েন্স বন্ধ করুনstopSequences
|
স্ট্রিংয়ের একটি তালিকা নির্দিষ্ট করে যা মডেলকে বলে যে উত্তরে স্ট্রিংগুলির মধ্যে একটি দেখতে পেলে কন্টেন্ট জেনারেট করা বন্ধ করতে হবে। |
এগুলি প্রযোজ্য নয়: ইমেজ মডেল ("Nano Banana") বা TTS মডেল। |
--- |
| বিশেষ কনফিগারেশন | |||
ভাবছিthinkingConfig
|
মডেলগুলি উত্তর জেনারেট করার সময় সেগুলির "চিন্তন প্রক্রিয়া" নিয়ন্ত্রণ করে।
|
সাপোর্ট করা ভ্যালু: থিংকিং ডকুমেন্টেশন দেখুন TTS মডেলের ক্ষেত্রে প্রযোজ্য নয়।
Firebase AI Logic Live API মডেলের জন্য
|
মডেলের উপর নির্ভর করে |
উত্তর দেওয়ার পদ্ধতিresponseModalities
|
আউটপুটের ধরন নির্দিষ্ট করে (যেমন, টেক্সট, অডিও বা ছবি)। | শুধুমাত্র তখনই প্রযোজ্য (এবং প্রয়োজনীয়) যখন Gemini ইমেজ মডেল ("Nano Banana" মডেল), TTS মডেল এবং Live API মডেল ব্যবহার করা হয়। | --- |
ছবির বৈশিষ্ট্যimageConfig
|
জেনারেট করা ছবির অ্যাস্পেক্ট রেশিও ও রেজোলিউশন নির্দিষ্ট করে। |
সাপোর্ট করা ভ্যালু: ছবি তৈরি করা কনফিগার করুন Gemini ছবি মডেল ("Nano Banana" মডেল) ব্যবহার করলেই শুধু প্রযোজ্য। |
১:১ অ্যাস্পেক্ট রেশিও (বর্গাকার) ১০২৪x১০২৪ রেজোলিউশন |
স্পিচ (ভয়েস)speechConfig
|
অডিও আউটপুটের জন্য ব্যবহৃত ভয়েস নির্দিষ্ট করে। |
TTS মডেল ও Live API মডেল ব্যবহার করলেই শুধু প্রযোজ্য। TTS মডেলের জন্য প্রয়োজন। |
Puck
|
কন্টেন্ট জেনারেশন কন্ট্রোল করার অন্যান্য বিকল্প
- প্রম্পট ডিজাইন সম্পর্কে আরও জানুন যাতে আপনার প্রয়োজন অনুযায়ী আউটপুট তৈরি করার জন্য আপনি মডেলকে প্রভাবিত করতে পারেন।
- নিরাপত্তা সেটিংস ব্যবহার করে এমন উত্তর পাওয়ার সম্ভাবনা অ্যাডজাস্ট করুন যা ঘৃণাত্মক বক্তব্য ও যৌনতাপূর্ণ কন্টেন্ট সহ ক্ষতিকারক বলে বিবেচিত হতে পারে।
- মডেলের আচরণ নিয়ন্ত্রণ করতে সিস্টেম নির্দেশাবলী সেট করুন। এই ফিচারটি হল একটি ভূমিকা যা আপনি মডেলটি ব্যবহারকারীর থেকে কোনও আরও নির্দেশাবলী পাওয়ার আগে যোগ করেন।
- নির্দিষ্ট আউটপুট স্কিমা উল্লেখ করতে, প্রম্পটের সাথে একটি উত্তর স্কিমা পাস করুন। এই ফিচারটি সাধারণত JSON আউটপুট জেনারেট করার সময় ব্যবহার করা হয়, তবে এটি শ্রেণীবিভাজন সংক্রান্ত টাস্কের ক্ষেত্রেও ব্যবহার করা যেতে পারে (যেমন, আপনি যদি চান যে মডেলটি নির্দিষ্ট লেবেল বা ট্যাগ ব্যবহার করুক)।