मॉडल को किए गए हर कॉल में, मॉडल कॉन्फ़िगरेशन भेजा जा सकता है. इससे यह कंट्रोल किया जा सकता है कि मॉडल किस तरह से जवाब जनरेट करे. हर मॉडल के लिए कॉन्फ़िगरेशन के अलग-अलग विकल्प उपलब्ध होते हैं. जैसे, maxOutputTokens सेट करना या सोचने, जवाब देने के तरीके, इमेज या स्पीच के लिए खास कॉन्फ़िगरेशन.
Gemini मॉडल को ऐक्सेस करने के ज़्यादातर मामलों में, GenerationConfig का इस्तेमाल करके मॉडल को कॉन्फ़िगर किया जाता है. हालांकि, अगर आपको Gemini Live API मॉडल कॉन्फ़िगर करना है, तो LiveGenerationConfig का इस्तेमाल करें.
इस पेज पर, Gemini मॉडल के लिए कॉन्फ़िगरेशन सेट अप करने का तरीका बताया गया है. साथ ही, हर पैरामीटर के बारे में जानकारी दी गई है.
Gemini कॉन्फ़िगरेशन पर जाएं Gemini Live API कॉन्फ़िगरेशन पर जाएं
Gemini मॉडल के लिए GenerationConfig
|
इस पेज पर, सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट और कोड देखने के लिए, Gemini API पर क्लिक करें. |
GenerationConfig को ज़्यादातर Gemini मॉडल के लिए सेट करें. इनमें
सामान्य इस्तेमाल वाले मॉडल, इमेज जनरेट करने वाले मॉडल ("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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
let config = GenerationConfig(
candidateCount: 1,
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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
val config = generationConfig {
candidateCount = 1
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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.candidateCount = 1;
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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
const generationConfig = {
candidate_count: 1,
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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
final generationConfig = GenerationConfig(
candidateCount: 1,
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.
// Note that temperature, top-K, and top-P are deprecated and ignored by the latest Gemini models.
var generationConfig = new GenerationConfig(
candidateCount: 1,
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 पर क्लिक करें. |
Gemini Live API मॉडल का इस्तेमाल करते समय ही LiveGenerationConfig सेट करें.
कॉन्फ़िगरेशन, 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 = Voices.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(Voices.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 का इस्तेमाल करके, प्रॉम्प्ट और मॉडल कॉन्फ़िगरेशन के साथ एक्सपेरिमेंट किया जा सकता है.पैरामीटर की जानकारी
यहां दी गई टेबल में, उपलब्ध पैरामीटर की खास जानकारी दी गई है. कुछ पैरामीटर सिर्फ़ कुछ मॉडल पर लागू होते हैं.
ध्यान दें कि टेंपरेचर, टॉप-के, और टॉप-पी के इस्तेमाल पर रोक लगा दी गई है. साथ ही, Gemini के नए मॉडल इन्हें अनदेखा करते हैं.
| पैरामीटर | ब्यौरा | सीमाएं | डिफ़ॉल्ट वैल्यू |
|---|---|---|---|
ऑडियो टाइमस्टैंपaudioTimestamp
|
इससे सिर्फ़ ऑडियो वाली इनपुट फ़ाइलों के लिए टाइमस्टैंप समझने की सुविधा चालू होती है. |
बूलियन
यह सुविधा सिर्फ़ तब लागू होती है, जब |
false
|
उम्मीदवारों की संख्याcandidateCount
|
जवाब के अलग-अलग वर्शन की संख्या तय करता है. हर अनुरोध के लिए, आपको सभी कैंडिडेट के आउटपुट टोकन के लिए शुल्क देना होगा. हालांकि, इनपुट टोकन के लिए आपको सिर्फ़ एक बार शुल्क देना होगा. |
इस्तेमाल की जा सकने वाली वैल्यू:
यह सुविधा सिर्फ़
|
1
|
ज़्यादा से ज़्यादा आउटपुट टोकनmaxOutputTokens
|
इससे जवाब में जनरेट किए जा सकने वाले टोकन की ज़्यादा से ज़्यादा संख्या तय की जाती है. | --- | --- |
फ़्रीक्वेंसी पेनल्टीfrequencyPenalty
|
इससे यह कंट्रोल किया जाता है कि जनरेट किए गए जवाब में बार-बार दिखने वाले टोकन को शामिल करने की कितनी संभावना है. पॉज़िटिव वैल्यू, जनरेट किए गए कॉन्टेंट में बार-बार दिखने वाले टोकन को दंडित करती हैं. इससे कॉन्टेंट को दोहराने की संभावना कम हो जाती है. |
यह सुविधा, टीटीएस मॉडल के लिए उपलब्ध नहीं है. | --- |
मौजूदगी की पेनल्टीpresencePenalty
|
इससे यह कंट्रोल किया जाता है कि जनरेट किए गए जवाब में, पहले से मौजूद टोकन को शामिल करने की कितनी संभावना है. पॉज़िटिव वैल्यू, जनरेट किए गए कॉन्टेंट में पहले से मौजूद टोकन को दंडित करती हैं. इससे अलग-अलग तरह का कॉन्टेंट जनरेट होने की संभावना बढ़ जाती है. |
यह सुविधा, टीटीएस मॉडल के लिए उपलब्ध नहीं है. | --- |
सीक्वेंस बंद करनाstopSequences
|
यह स्ट्रिंग की एक सूची तय करता है. अगर जवाब में इनमें से कोई स्ट्रिंग मिलती है, तो मॉडल को कॉन्टेंट जनरेट करने से रोकने के लिए कहा जाता है. |
यह सिर्फ़ यह सुविधा, टीटीएस मॉडल के लिए उपलब्ध नहीं है. |
--- |
| खास कॉन्फ़िगरेशन | |||
सोचा जा रहा हैthinkingConfig
|
यह कुकी, मॉडल के "सोचने की प्रोसेस" को कंट्रोल करती है. ऐसा तब होता है, जब मॉडल कोई जवाब जनरेट कर रहे होते हैं.
|
इस्तेमाल की जा सकने वाली वैल्यू: सोचने से जुड़े दस्तावेज़ देखें यह सुविधा, टीटीएस मॉडल के लिए उपलब्ध नहीं है.
Firebase AI Logic पर, Live API मॉडल के लिए |
मॉडल पर निर्भर करता है |
जवाब देने के तरीकेresponseModalities
|
इससे आउटपुट का टाइप तय होता है. जैसे, टेक्स्ट, ऑडियो या इमेज. | यह सिर्फ़ तब लागू होता है, जब Gemini इमेज मॉडल ("Nano Banana" मॉडल), टीटीएस मॉडल, और Live API मॉडल का इस्तेमाल किया जा रहा हो. साथ ही, ऐसा करना ज़रूरी है. | --- |
इमेज की विशेषताएंimageConfig
|
इससे जनरेट की गई इमेज का आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात) और रिज़ॉल्यूशन तय होता है. |
इस्तेमाल की जा सकने वाली वैल्यू: इमेज जनरेट करने की सुविधा कॉन्फ़िगर करना लेख पढ़ें यह सुविधा सिर्फ़ Gemini इमेज मॉडल ("Nano Banana" मॉडल) का इस्तेमाल करते समय लागू होती है. |
1:1 आसपेक्ट रेशियो (स्क्वेयर) 1024x1024 रिज़ॉल्यूशन |
स्पीच (आवाज़)speechConfig
|
ऑडियो आउटपुट के लिए इस्तेमाल की जाने वाली आवाज़ के बारे में बताता है. |
यह सुविधा, टीटीएस मॉडल और Live API मॉडल का इस्तेमाल करने पर ही लागू होती है. टीटीएस मॉडल के लिए ज़रूरी है. |
Puck
|
कॉन्टेंट जनरेट करने की सुविधा को कंट्रोल करने के अन्य विकल्प
- प्रॉम्प्ट डिज़ाइन के बारे में ज़्यादा जानें, ताकि मॉडल को अपनी ज़रूरतों के हिसाब से आउटपुट जनरेट करने के लिए प्रेरित किया जा सके.
- सुरक्षा सेटिंग का इस्तेमाल करके, ऐसे जवाब मिलने की संभावना को कम किया जा सकता है जिन्हें नुकसान पहुंचाने वाला माना जा सकता है. जैसे, नफ़रत फैलाने वाली भाषा और साफ़ तौर पर सेक्शुअल ऐक्ट दिखाने वाला कॉन्टेंट.
- मॉडल के व्यवहार को कंट्रोल करने के लिए, सिस्टम के निर्देश सेट करें. यह सुविधा, प्रस्तावना की तरह होती है. इसे मॉडल को असली उपयोगकर्ता से कोई और निर्देश मिलने से पहले जोड़ा जाता है.
- किसी खास आउटपुट स्कीमा के बारे में बताने के लिए, प्रॉम्प्ट के साथ जवाब का स्कीमा पास करें. इस सुविधा का इस्तेमाल आम तौर पर, JSON आउटपुट जनरेट करने के लिए किया जाता है. हालांकि, इसका इस्तेमाल क्लासिफ़िकेशन टास्क के लिए भी किया जा सकता है. जैसे, जब आपको मॉडल से किसी खास लेबल या टैग का इस्तेमाल करवाना हो.