GoogleCloudPlatform / generative-ai

Sample code and notebooks for Generative AI on Google Cloud, with Gemini on Vertex AI
https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
Apache License 2.0
6.97k stars 1.88k forks source link

Random Seed #289

Closed pharringtonp19 closed 8 months ago

pharringtonp19 commented 9 months ago

OpenAI has a way to set the seed. Is there a way to do this with gemini models?

holtskinner commented 8 months ago

@pharringtonp19 You can set the seed in the Vertex AI API as illustrated here for PaLM Text Generation

And here for Image Captioning

It doesn't look like Gemini currently supports providing a seed.

andrewssobral commented 4 months ago

any news on that?

boxabirds commented 4 months ago

Yeah Google Gemini isn't a viable software engineering API if you can't fix the seed to get deterministic output.

taurit commented 2 weeks ago

I think it's possible now. Tested with gemini-1.5-flash and older gemini-1.0-pro. Both seem to respond deterministically with this parameter set:

// POST https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent

{
  "contents": [ { "parts": [ { "text": "What are the capitals of France, Spain, Poland?" } ] } ],
  "generationConfig": {
    "seed": 123456
  }
}

API Reference here.