I am doing a task that gemini-2.0-flash should analyze a user input image according to some rules. For gemini’s better understanding, I tried to use explicit caching to cache some few-shot images. The user input image is put in genai.Content{}.
The overall prompt structure is as below.
genai.Contents: {
rules 1,
user input image,
rules 2
}
cache: {
few-shot 1 description,
few-shot 1 image,
few-shot 2 description,
few-shot 2 image
}
However, I found that after caching the few-shot images, gemini cannot correctly recognize the user input image. It always analyzes the last few-shot image, or even the “image“ that doesn’t exist.
Gemini works fine if I also put the few-shot images in genai.Content{} (no caching), so I think there may be something wrong when caching is used.
Has anyone run into the similar problem before?