pipelines icon indicating copy to clipboard operation
pipelines copied to clipboard

Google Manifold pipeline needs to be updated to use native system instructions on models other than Gemini 1.5

Open rotemdan opened this issue 1 year ago • 1 comments

Pull request #194 added conservative logic to use the native system instructions only when the model name includes the substring gemini-1.5, since gemini-1.0 doesn't support it:

if "gemini-1.5" in model_id:
    model = genai.GenerativeModel(model_name=model_id, system_instruction=system_message)
else:
    if system_message:
        contents.insert(0, {"role": "user", "parts": [{"text": f"System: {system_message}"}]})
    
    model = genai.GenerativeModel(model_name=model_id)

This doesn't apply to newer Gemini versions like gemini-2.0, gemini-exp and learnlm.

In my own local usage I don't care about using the old 1.0 models and simply changed to always use system_instruction=system_message.

In general, I can't really give a 100% robust solution that would be guaranteed to work on all future versions and variants of Gemini, but it's likely they will allow native system instructions for future models.

Less conservative approach would be to use native system instructions by default, unless it's Gemini 1.0. Something like:

if model_id.startswith("gemini-1.0") or model_id.startswith("gemini-pro"):
    if system_message:
        contents.insert(0, {"role": "user", "parts": [{"text": f"System: {system_message}"}]})

    model = genai.GenerativeModel(model_name=model_id)
else:
    model = genai.GenerativeModel(model_name=model_id, system_instruction=system_message)

I can't make a pull request unless I know exactly what approach the developer prefers. In any case, I don't think that anybody seriously uses Gemini 1.0 anymore, unless for comparison with older models, maybe.

rotemdan avatar Dec 14 '24 08:12 rotemdan

Update: trying to use gemini-1.0-pro-latest currently gives the error:

An error occurred: 404 Gemini 1.0 Pro will be discontinued on February 15th, 2025. Move to a newer Gemini version.

Other model identifiers for Gemini 1.0 still work.

I've submitted a pull request.

rotemdan avatar Dec 14 '24 09:12 rotemdan