1. generation_config
有指定类:GenarationConfig
具体用法:
- 实例化 GenarationConfig 对象
generation_config = GenerationConfig(
max_output_tokens=8192,
top_k=10,
top_p=0.1,
temperature=1,
)
- 作为参数给 genai.GenerativeModel()
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
generation_config=generation_config,
}
2. safety_settings
- 常用设置:
safety_settings={
HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE,
HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE,
}
- 作为参数,给 genai.GenerativeModel()
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
generation_config=generation_config,
safety_settings=safety_settings,
}
3. system_instruction
这个就不多说了,写上你的提示词就好啦