-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RAG: Upgrade text embedding from text-embedding-004 to text-multilingual-embedding-002 #48
Comments
Quick cursory look at the multiresult.json shows that the two vectors (English and Hungarian equivalent) are very close to each other: the signs of the elements match and the values are mostly very close. Dimensionality of the multi language model is 768 just like the newer English models. |
There's a problem: Apparently https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/text-embeddings-api is Vertex AI and via Gemini API only |
I tested and unfortunately |
Looks like we can use the Firebase Vertex AI Flutter package (https://pub.dev/packages/firebase_vertexai/example) for the multilingual embedding: https://firebase.google.com/docs/vertex-ai/gemini-models#input-output-comparison. If we can transition to Firebase we might be able to eliminate the Gemini API Key in favor of Firebase? (I still want to avoid login if possible though, so maybe we'll use a close function - we already have a pair for STT and TTS). However the Flutter Firebase Vertex AI package indicates it doesn't support function calling and structured output for Gemini 1.5 Flash? https://firebase.google.com/docs/vertex-ai/gemini-models#capabilities-features-comparison |
It'd be good to try The question is if Google AI or Firebase Vertex AI package supports those. List of Vertex AI embedding models regardless of SDK: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions#embeddings_stable_model_versions |
It'd be good to try |
Firebase Vertex AI Flutter setup: Code sample: https://firebase.google.com/docs/vertex-ai/locations?platform=flutter#code-samples |
Note that https://pub.dev/packages/googleai_dart is by langchain Dart, but google_generative_ai almost achieved feature feature parity now so googleai_dart will be retired. |
Firebase Vertex AI Flutter setup: Code sample: https://firebase.google.com/docs/vertex-ai/locations?platform=flutter#code-samples Unfortunately so far Firebase Vertex AI 404s for embedContent: firebase/flutterfire#13269 |
Go could have similar issues: https://discuss.ai.google.dev/t/text-multilingual-embedding-002-is-not-found-for-api-version-v1beta/4721/3 |
Firebase Vertex AI Flutter setup: Code sample: https://firebase.google.com/docs/vertex-ai/locations?platform=flutter#code-samples Unfortunately so far Firebase Vertex AI 404s for embedContent: firebase/flutterfire#13269 |
The workaround will be a cloud function, we'll have to establish another anyway for reranking as well #39 |
Multilingual embedding codes:
But now I'm thinking I should rather go for multi-modal embedding! This way we wouldn't have to describe images and videos.
|
Note that we perform a dimensionality reduction with folding (instead of truncation) which currently leads to non normalized vectors. This means that dot product (the potentially most cost effective distance) is not a valid distance any more https://cloud.google.com/firestore/docs/vector-search#choose-distance-measure |
Maybe the user should decide if they prefer multi lingual embedding or multi modal. Currently it seems that the two together is not possible.
|
See notebooks/official/generative_ai/vertex_sdk_llm_snippets.ipynb and https://cloud.google.com/vertex-ai/docs/start/install-sdk
(we don't override dimensionality, but the empty parameter should be passed differently)
… (default) to 512MB due to OOM #48
Maybe we'll need to indeed have that kwargs. The model has 768 dimensions.
…s & runs, still no effect tho #48
The new embedding function uses both multi modal embedding (for media) and multi lingual embedding (for texts) |
The documentation explicitly states that embedding is not available via Firebase Vertex AI: https://firebase.google.com/docs/vertex-ai/gemini-models#capabilities-features-comparison "Note: Context caching, fine tuning a model, embeddings, and semantic retrieval are supported by various models or the Vertex AI Gemini API, but they're not supported by the Vertex AI in Firebase SDKs." So indeed the only way to go is our own cloud functions. |
This meme #48 (comment) is not true any more. Since v 1.0.0 (https://pub.dev/packages/firebase_vertexai/changelog#100), the GA General Availability, commit firebase/flutterfire@77b4880#diff-82dd2dc26e6d987c08c5710d250ad1167ea7ca874efe5f1f9ca140bec27a11eaR14 (see also firebase/flutterfire#13453) |
CHANDRA got me thinking about the new
text-embedding-preview-0815
model to upgrade fromtext-embedding-004
. However https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/generative_ai/text_embedding_new_api.ipynb shows that:Python and Java code right now (along with the
CODE_RETRIEVAL_QUERY
new task typetext-embedding-preview-0815
introducing) is not a significant purpose of the app as of now, even though users may screenshot a computer screen with code and ask about that. The current multimodal embedding has severe limitations, we'll probably go with transcribing images for vector indexing. The database models are already prepared for that.So both
text-embedding-preview-0815
andtext-embedding-004
models turn out to be English only. To support international use I decided to try thetext-multilingual-embedding-002
, hoping that soon there will be new versions of that as well. Also note that with the introduction of the new dimensionality folding #47 we'll control the vector size regardless of the embedding model's output vector length.multirequest.json:
multiresult.json
The text was updated successfully, but these errors were encountered: