किसी मॉडल को किए जाने वाले हर कॉल में, मॉडल कॉन्फ़िगरेशन भेजा जा सकता है. इससे यह कंट्रोल किया जा सकता है कि मॉडल जवाब कैसे जनरेट करे. हर मॉडल में कॉन्फ़िगरेशन के अलग-अलग विकल्प होते हैं. जैसे, maxOutputTokens सेट करना या सोच-विचार करने, जवाब देने के तरीके, इमेज, बोली या आवाज़ का पता लगाने की तकनीक (वीएडी) के लिए खास कॉन्फ़िगरेशन.
ज़्यादातर मामलों में, Gemini मॉडल को ऐक्सेस करते समय, GenerationConfig का इस्तेमाल करके मॉडल को कॉन्फ़िगर किया जाता है. हालांकि, अगर आपको Gemini Live API मॉडल को कॉन्फ़िगर करना है, तो LiveGenerationConfig का इस्तेमाल करें.
इस पेज पर, Gemini मॉडल के लिए कॉन्फ़िगरेशन सेट अप करने का तरीका बताया गया है. साथ ही, उपलब्ध पैरामीटर की टेबल दी गई है.
Gemini कॉन्फ़िगरेशन पर जाएं Gemini Live API कॉन्फ़िगरेशन पर जाएं
GenerationConfig, Gemini मॉडल के लिए
|
इस पेज पर, Gemini API की सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट और कोड देखने के लिए, सेवा देने वाली कंपनी के नाम पर क्लिक करें. |
ज़्यादातर Gemini मॉडल के लिए GenerationConfig सेट करें. इनमें सामान्य इस्तेमाल वाले मॉडल, इमेज जनरेट करने वाले (Nano Banana) मॉडल, और लिखे गए शब्दों को सुनने की सुविधा (टीटीएस) वाले मॉडल शामिल हैं.
यह कॉन्फ़िगरेशन, 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',
generationConfig: 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
);
LiveGenerationConfig, Gemini Live API मॉडल के लिए
|
इस पेज पर, 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.googleAI()).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
);
// ...
मॉडल के उपलब्ध पैरामीटर
नीचे दी गई टेबल में, मॉडल कॉन्फ़िगरेशन के लिए उपलब्ध पैरामीटर के बारे में खास जानकारी दी गई है. कुछ पैरामीटर सिर्फ़ चुनिंदा मॉडल पर लागू होते हैं.
| पैरामीटर | ब्यौरा | सीमाएं | डिफ़ॉल्ट वैल्यू |
|---|---|---|---|
ऑडियो का टाइमस्टैंपaudioTimestamp
|
सिर्फ़ ऑडियो वाली इनपुट फ़ाइलों के लिए, टाइमस्टैंप को समझने की सुविधा चालू करता है. |
बूलियन
यह सिर्फ़ तब लागू होता है, जब |
false
|
ज़्यादा से ज़्यादा आउटपुट टोकनmaxOutputTokens
|
इससे तय होता है कि जवाब में ज़्यादा से ज़्यादा कितने टोकन जनरेट किए जा सकते हैं.
|
--- | --- |
सीक्वेंस रोकेंstopSequences
|
इससे स्ट्रिंग की एक सूची तय होती है. अगर जवाब में इनमें से कोई स्ट्रिंग मिलती है, तो मॉडल कॉन्टेंट जनरेट करना बंद कर देता है. |
यह सिर्फ़ तब लागू होता है, जब यह Nano Banana या टीटीएस मॉडल के लिए लागू नहीं है. |
--- |
| खास कॉन्फ़िगरेशन | |||
प्रोसेस जारी हैthinkingConfig
|
जवाब जनरेट करते समय, मॉडल के "सोचने की प्रोसेस" को कंट्रोल करता है.
|
इस्तेमाल की जा सकने वाली वैल्यू: सोचने की क्षमता से जुड़ा दस्तावेज़ देखें टीटीएस मॉडल के लिए लागू नहीं है.
Firebase AI Logic में फ़िलहाल, Live API मॉडल के लिए |
मॉडल पर निर्भर करता है |
जवाब देने के तरीकेresponseModalities
|
इससे आउटपुट का टाइप तय होता है. जैसे, टेक्स्ट, ऑडियो या इमेज. | यह सिर्फ़ तब लागू होता है (और ज़रूरी है), जब Nano Banana, टीटीएस, और Live API मॉडल का इस्तेमाल किया जा रहा हो. | --- |
इमेज की विशेषताएंimageConfig
|
जनरेट की गई इमेज का आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात) और रिज़ॉल्यूशन तय करता है. |
इस्तेमाल की जा सकने वाली वैल्यू: इमेज जनरेट करने की सुविधा को कॉन्फ़िगर करना देखें यह सिर्फ़ Nano Banana मॉडल इस्तेमाल करने पर लागू होता है. |
1:1 आसपेक्ट रेशियो (स्क्वेयर) 1024x1024 रिज़ॉल्यूशन |
बोलने की क्षमता (आवाज़)speechConfig
|
ऑडियो आउटपुट के लिए इस्तेमाल की जाने वाली आवाज़ के बारे में जानकारी देता है. |
यह सिर्फ़ टीटीएस मॉडल और Live API मॉडल का इस्तेमाल करने पर लागू होता है. टीटीएस मॉडल के लिए ज़रूरी है. |
Puck
|
आवाज़ का पता लगाने की तकनीक (वीएडी)realtimeInputConfig
|
यह आवाज़ का पता लगाने की तकनीक (वीएडी), रुकावट को मैनेज करने की सुविधा, और टर्न कॉन्टेक्स्ट कवरेज को कॉन्फ़िगर करता है या अपने-आप वीएडी की सुविधा को बंद करता है. |
इस्तेमाल की जा सकने वाली वैल्यू: वीएडी को कॉन्फ़िगर करना लेख पढ़ें यह सिर्फ़ Live API मॉडल इस्तेमाल करने पर लागू होता है. |
वीएडी चालू है हर सेटिंग के लिए, डिफ़ॉल्ट वैल्यू देखें. |
कॉन्टेंट जनरेट करने की सुविधा को कंट्रोल करने के अन्य विकल्प
- प्रॉम्प्ट डिज़ाइन के बारे में ज़्यादा जानें, ताकि आप मॉडल को अपनी ज़रूरत के हिसाब से आउटपुट जनरेट करने के लिए निर्देश दे सकें.
- सुरक्षा सेटिंग का इस्तेमाल करके, यह तय करें कि आपको नुकसान पहुंचाने वाले जवाब कितने दिखें. इनमें नफ़रत फैलाने वाली भाषा और साफ़ तौर पर सेक्शुअल ऐक्ट दिखाने वाला कॉन्टेंट शामिल है.
- मॉडल के व्यवहार को कंट्रोल करने के लिए, सिस्टम इंस्ट्रक्शन सेट करें. यह सुविधा, मॉडल को असली उपयोगकर्ता से कोई निर्देश मिलने से पहले, उसे दिए जाने वाले शुरुआती निर्देश की तरह है.
- प्रॉम्प्ट के साथ रिस्पॉन्स स्कीमा पास करें, ताकि कोई आउटपुट स्कीमा तय किया जा सके. इस सुविधा का इस्तेमाल, आम तौर पर JSON आउटपुट जनरेट करने के लिए किया जाता है. हालांकि, इसका इस्तेमाल क्लासिफ़िकेशन टास्क के लिए भी किया जा सकता है. जैसे, जब आपको मॉडल से खास लेबल या टैग इस्तेमाल करने हों.