모델을 호출할 때마다 모델 구성을 함께 전송하여 모델의 응답 생성 방식을 제어할 수 있습니다. 각 모델은 서로 다른 구성 옵션을 제공합니다.
Google AI Studio를 사용하여 프롬프트 및 모델 구성을 실험할 수도 있습니다.Gemini 구성 옵션으로 이동 Imagen 구성 옵션으로 이동
Gemini 모델 구성
Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. |
이 섹션에서는 Gemini 모델과 함께 사용할 구성 설정 방법을 설명하고 각 매개변수에 관한 설명을 제공합니다.
모델 구성 설정 (Gemini)
일반적인 사용 사례의 구성
구성은 인스턴스 전체 기간 동안 유지됩니다. 다른 구성을 사용하려면 해당 구성으로 새 GenerativeModel
인스턴스를 만듭니다.
Swift
GenerativeModel
인스턴스 생성의 일부로 GenerationConfig
의 매개변수 값을 설정합니다.
import FirebaseAI
// Set parameter values in a `GenerationConfig` (example values shown here)
let config = GenerationConfig(
temperature: 0.9,
topP: 0.1,
topK: 16,
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` (example values shown here)
val config = generationConfig {
maxOutputTokens = 200
stopSequences = listOf("red")
temperature = 0.9f
topK = 16
topP = 0.1f
}
// 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` (example values shown here)
GenerationConfig.Builder configBuilder = new GenerationConfig.Builder();
configBuilder.maxOutputTokens = 200;
configBuilder.stopSequences = List.of("red");
configBuilder.temperature = 0.9f;
configBuilder.topK = 16;
configBuilder.topP = 0.1f;
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` (example values shown here)
const generationConfig = {
max_output_tokens: 200,
stop_sequences: ["red"],
temperature: 0.9,
top_p: 0.1,
top_k: 16,
};
// 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` (example values shown here)
final generationConfig = GenerationConfig(
maxOutputTokens: 200,
stopSequences: ["red"],
temperature: 0.9,
topP: 0.1,
topK: 16,
);
// 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` (example values shown here)
var generationConfig = new GenerationConfig(
maxOutputTokens: 200,
stopSequences: new string[] { "red" },
temperature: 0.9f,
topK: 16,
topP: 0.1f
);
// 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
);
이 페이지의 다음 섹션에서 각 매개변수에 관한 설명을 확인할 수 있습니다.
Gemini Live API 구성
매개변수 설명 (Gemini)
다음은 사용 가능한 매개변수에 대한 대략적인 개요입니다(해당하는 경우). Gemini Developer API 문서에서 매개변수 및 값의 포괄적인 목록을 확인할 수 있습니다.
매개변수 | 설명 | 기본값 |
---|---|---|
오디오 타임스탬프
audioTimestamp
|
오디오 전용 입력 파일의 타임스탬프 이해를 사용 설정하는 불리언입니다.
|
false |
빈도 패널티
frequencyPenalty
|
생성된 응답에 반복적으로 표시되는 토큰을 포함할 가능성을 제어합니다. 양수 값은 생성된 콘텐츠에 반복적으로 표시되는 토큰에 페널티를 적용하여 콘텐츠가 반복될 가능성을 줄입니다. |
--- |
최대 출력 토큰
maxOutputTokens
|
응답에서 생성할 수 있는 토큰의 최대 개수를 지정합니다. | --- |
상태 페널티
presencePenalty
|
생성된 응답에 이미 표시된 토큰을 포함할 가능성을 제어합니다. 양수 값은 생성된 콘텐츠에 이미 표시된 토큰에 페널티를 적용하여 다양한 콘텐츠가 생성될 가능성을 높입니다. |
--- |
중지 시퀀스
stopSequences
|
응답에서 문자열 중 하나가 발견되면 모델에 콘텐츠 생성을 중지하도록 지시하는 문자열 목록을 지정합니다.
|
--- |
온도
temperature
|
응답의 무작위성 수준을 제어합니다. 온도가 낮을수록 더 확정적인 응답이, 온도가 높을수록 더 다양하거나 창의적인 응답이 나옵니다. |
모델에 따라 다름 |
Top-K
topK
|
생성된 콘텐츠에 사용되는 가장 높은 확률의 단어 수를 제한합니다. Top-K 값이 1 이면 다음으로 선택된 토큰이 모델의 어휘에 포함된 모든 토큰 중에서 가장 확률이 높아야 하며, Top-K 값이 n 이면 다음 토큰이 가장 확률이 높은 n개 토큰 중에서 선택되어야 함을 의미합니다(모두 설정된 온도에 따라 결정됨).
|
모델에 따라 다름 |
Top-P
topP
|
생성된 콘텐츠의 다양성을 제어합니다. 토큰은 확률의 합이 Top-P 값과 같아질 때까지 확률이 가장 높은 것부터 (위의 Top-K 참조) 가장 낮은 것까지 선택됩니다. |
모델에 따라 다름 |
응답 모달
responseModality
|
Live API를 사용할 때 스트리밍 출력 유형(예: 텍스트 또는 오디오)을 지정합니다. Live API 및 |
--- |
음성 (소리)
speechConfig
|
Live API를 사용할 때 스트리밍된 오디오 출력에 사용되는 음성을 지정합니다. Live API 및 |
Puck |
Imagen 모델 구성
Imagen API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. |
이 섹션에서는 Imagen 모델과 함께 사용할 구성 설정 방법을 설명하고 각 매개변수에 관한 설명을 제공합니다.
모델 구성 설정 (Imagen)
구성은 인스턴스 전체 기간 동안 유지됩니다. 다른 구성을 사용하려면 해당 구성으로 새 ImagenModel
인스턴스를 만듭니다.
Swift
ImagenModel
인스턴스 생성의 일부로 ImagenGenerationConfig
의 매개변수 값을 설정합니다.
import FirebaseAI
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
let config = ImagenGenerationConfig(
negativePrompt: "frogs",
numberOfImages: 2,
aspectRatio: .landscape16x9,
imageFormat: .jpeg(compressionQuality: 100),
addWatermark: false
)
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `ImagenModel` instance
let model = FirebaseAI.firebaseAI(backend: .googleAI()).imagenModel(
modelName: "IMAGEN_MODEL_NAME",
generationConfig: config
)
// ...
Kotlin
ImagenModel
인스턴스 생성의 일부로 ImagenGenerationConfig
의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
val config = ImagenGenerationConfig {
negativePrompt = "frogs",
numberOfImages = 2,
aspectRatio = ImagenAspectRatio.LANDSCAPE_16x9,
imageFormat = ImagenImageFormat.jpeg(compressionQuality = 100),
addWatermark = false
}
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `GenerativeModel` instance
val model = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
modelName = "IMAGEN_MODEL_NAME",
generationConfig = config
)
// ...
Java
ImagenModel
인스턴스 생성의 일부로 ImagenGenerationConfig
의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
ImagenGenerationConfig config = new ImagenGenerationConfig.Builder()
.setNegativePrompt("frogs")
.setNumberOfImages(2)
.setAspectRatio(ImagenAspectRatio.LANDSCAPE_16x9)
.setImageFormat(ImagenImageFormat.jpeg(100))
.setAddWatermark(false)
.build();
// Specify the config as part of creating the `ImagenModel` instance
ImagenModelFutures model = ImagenModelFutures.from(
FirebaseAI.getInstance(GenerativeBackend.googleAI())
.imagenModel(
"IMAGEN_MODEL_NAME",
config
);
);
// ...
Web
ImagenModel
인스턴스 생성의 일부로 ImagenGenerationConfig
의 매개변수 값을 설정합니다.
// ...
// Initialize the Gemini Developer API backend service
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
const generationConfig = {
negativePrompt: "frogs",
numberOfImages: 2,
aspectRatio: ImagenAspectRatio.LANDSCAPE_16x9,
imageFormat: ImagenImageFormat.jpeg(100),
addWatermark: false
};
// Specify the config as part of creating the `ImagenModel` instance
const model = getImagenModel(ai, { model: "IMAGEN_MODEL_NAME", generationConfig });
// ...
Dart
ImagenModel
인스턴스 생성의 일부로 ImagenGenerationConfig
의 매개변수 값을 설정합니다.
// ...
// Set parameter values in a `ImagenGenerationConfig` (example values shown here)
final generationConfig = ImagenGenerationConfig(
negativePrompt: 'frogs',
numberOfImages: 2,
aspectRatio: ImagenAspectRatio.landscape16x9,
imageFormat: ImagenImageFormat.jpeg(compressionQuality: 100)
addWatermark: false
);
// Initialize the Gemini Developer API backend service
// Specify the config as part of creating the `ImagenModel` instance
final model = FirebaseAI.googleAI().imagenModel(
model: 'IMAGEN_MODEL_NAME',
config: generationConfig,
);
// ...
Unity
Unity에서는 아직 Imagen 사용이 지원되지 않지만 곧 지원될 예정이니 다시 확인해 주세요.
이 페이지의 다음 섹션에서 각 매개변수에 관한 설명을 확인할 수 있습니다.
매개변수 설명 (Imagen)
다음은 사용 가능한 매개변수에 대한 대략적인 개요입니다(해당하는 경우). Google Cloud 문서에서 매개변수 및 값의 포괄적인 목록을 확인할 수 있습니다.
매개변수 | 설명 | 기본값 |
---|---|---|
부정적인 프롬프트
negativePrompt
|
생성된 이미지에서 생략할 항목에 대한 설명
이 매개변수는 아직 |
--- |
결과 수
numberOfImages
|
요청당 반환된 생성된 이미지 수 | 기본값은 Imagen 3 모델의 경우 이미지 1개입니다. |
가로세로 비율
aspectRatio
|
생성된 이미지의 너비 대 높이 비율 | 기본값은 정사각형 (1:1)입니다. |
이미지 형식
imageFormat
|
이미지 형식 (MIME 유형) 및 생성된 이미지의 압축 수준과 같은 출력 옵션 | 기본 MIME 유형은 PNG입니다. 기본 압축은 75입니다 (MIME 유형이 JPEG로 설정된 경우). |
워터마크
addWatermark
|
생성된 이미지에 표시되지 않는 디지털 워터마크 (SynthID라고 함)를 추가할지 여부입니다. | 기본값은 Imagen 3 모델의 경우 true 입니다.
|
사람 생성
personGeneration
|
모델에서 사람을 생성할지 여부 | 기본값은 모델에 따라 다름 |
콘텐츠 생성을 제어하는 기타 옵션
- 모델에 영향을 주어 필요에 맞는 출력을 생성할 수 있도록 프롬프트 디자인에 대해 자세히 알아보세요.
- 안전 설정을 사용하여 증오심 표현 및 성적으로 노골적인 콘텐츠를 포함하여 유해하다고 간주될 수 있는 대답을 받을 가능성을 조정합니다.
- 시스템 안내를 설정하여 모델의 동작을 조정합니다. 이 기능은 모델이 최종 사용자의 추가 안내에 노출되기 전에 추가하는 프리앰블과 같습니다.
- 프롬프트와 함께 응답 스키마를 전달하여 특정 출력 스키마를 지정합니다. 이 기능은 가장 일반적으로 JSON 출력을 생성할 때 사용되지만 분류 작업(예: 모델이 특정 라벨이나 태그를 사용하도록 하려는 경우)에도 사용할 수 있습니다.