Closed hemanth closed 6 months ago
Hey @hemanth, great to see you back here! Hope you're ready to tackle some more LlamaIndex mysteries together 🕵️♂️
Thank you for providing detailed information about the issue you're facing. Based on the traceback you've provided, it seems like the InvalidArgument
error is being raised when the get_base_model
function from the google.generativeai.models
module is called with the model name "models/gemini-pro-vision".
The GeminiMultiModal
class in the LlamaIndex codebase is designed to work with Google's Gemini multi-modal models. It seems like the model name "models/gemini-pro-vision" is not recognized as a valid model name by the GeminiMultiModal
class, even though it is included in the GEMINI_MM_MODELS
tuple.
GEMINI_MM_MODELS = (
"models/gemini-pro-vision",
"models/gemini-ultra-vision",
)
This could be due to a discrepancy between the model names recognized by the GeminiMultiModal
class and the model names that the get_base_model
function in the google.generativeai.models
module is expecting.
I found a similar issue in the LlamaIndex repository: specifying the model name isn't working in the latest version. This issue was closed by a pull request: Fix query runner by passing llm_predictor/prompt_helper to the query properly . However, it seems like this issue was related to the way the model name was passed to the query runner, not the get_base_model
function.
Unfortunately, without more information about the get_base_model
function and why it's raising an InvalidArgument
error, it's difficult to provide a definitive solution to your issue. It might be helpful to check the documentation or source code of the google.generativeai.models
module to understand what model names it expects and how it handles invalid model names. If the issue persists, it might be a bug in the LlamaIndex codebase or the google.generativeai.models
module, and you might want to consider opening an issue in the appropriate repository.
I hope this information helps! If you have any more questions or need further clarification, feel free to ask.
Well, same with just invoking GeminiMultiModal()
without a model_name
, it should basically pick up GEMINI_MM_MODELS[0]
model_name: str = Field(
default=GEMINI_MM_MODELS[0], description="The Gemini model to use."
)
>>> import google.generativeai as genai
>>> for m in genai.list_models():
... print(m.name)
...
models/chat-bison-001
models/text-bison-001
models/embedding-gecko-001
models/gemini-1.0-pro
models/gemini-1.0-pro-001
models/gemini-1.0-pro-latest
models/gemini-1.0-pro-vision-latest
models/gemini-pro
models/gemini-pro-vision
models/embedding-001
models/aqa
@hatianzhang does this work for you?
@hemanth could it be that the error is not because of the model name? AFAIK llama-index passes three arguments to the genai.GenerativeModel class, model_name, generation_config, and safety_settings.
self._model = genai.GenerativeModel(
model_name=model_name,
generation_config=final_gen_config,
safety_settings=safety_settings,
)
It may also be that the types for generation_config, and safety_settings is not supported anymore by google. For example, the generation_config type can be a union of three things:
GenerationConfigType = Union[glm.GenerationConfig, GenerationConfigDict, GenerationConfig]
And as far as I understand it, the GenerationConfigDict, which inherits from TypedDict, MUST have four keys: candidate_count: int stop_sequences: Iterable[str] max_output_tokens: int temperature: float
class GenerationConfigDict(TypedDict):
# TODO(markdaoust): Python 3.11+ use `NotRequired`, ref: https://peps.python.org/pep-0655/
candidate_count: int
stop_sequences: Iterable[str]
max_output_tokens: int
temperature: float
In llama-index, if a generation_config is not defined when calling GeminiMultiModal(), a base_gen_config dict is created which contains only temperature as a key/value pair, not the other values.
Tl;dr - can you try defining a generation_config and a safety_settings when calling the GeminiMultiModal class?
Potential quick fixes - Maybe we remove the base_gen_config entirely? Google's generative ai library is able to support if generative_config and satefy_settings are None.
error is not because of the model name
https://github.com/run-llama/llama_index/issues/12094#issuecomment-2008149304
Bug Description
GeminiMultiModal(model_name="models/gemini-pro-vision")
fails even though the model name is valid?Version
0.10.20
Steps to Reproduce
Relevant Logs/Tracbacks