EmbeddingGemma-300M π§ β¨
Overview π
EmbeddingGemma-300M is a text-to-vector model that transforms any text into 768-dimensional embeddings. This tool is built upon the amazing work of Google DeepMind and their EmbeddingGemma research. Weβve wrapped their embedding-gemma-300m model to work on Replicate! Allowing us to generate high-quality embeddings for search, recommendations, and AI applications!
Support Google DeepMind and learn more about their work through:
Pre-loaded Efficiency π
The EmbeddingGemma-300M comes pre-loaded with base64 output format for immediate use with 3x smaller response sizes compared to arrays.
Getting Different Dimensions π₯
You can customize your EmbeddingGemma-300Mβs output using Matryoshka representation learning. Hereβs how:
-
Choose your embedding dimension: 128, 256, 512, or 768
-
Set the
embedding_dim
parameter to your desired size -
The model automatically truncates the full 768-dimensional embedding to your chosen size
-
Example usage:
embedding_dim = 256
β Get 256-dimensional vectorsembedding_dim = 512
β Get 512-dimensional vectorsembedding_dim = 768
β Get full 768-dimensional vectors (default)
Note: Smaller dimensions are perfect for storage optimization while maintaining strong performance for most tasks.
Code Examples π
Python:
import replicate, base64, numpy as np
# Get base64 embedding (default)
b64 = replicate.run("zsxkib/embedding-gemma-300m", input={"text": "Hello world"})
# Decode to numpy array
vec = np.frombuffer(base64.b64decode(b64), dtype=np.float32)
print(vec.shape) # (768,)
JavaScript:
const b64 = await replicate.run("zsxkib/embedding-gemma-300m", { input: { text: "Hello world" } });
const embedding = new Float32Array(Buffer.from(b64, 'base64').buffer);
console.log(embedding.length); // 768
Terms of Use π
The use of this embedding model for the following purposes is prohibited:
-
Generating embeddings for harmful or malicious content.
-
Creating systems designed to manipulate or deceive users.
-
Building applications that violate user privacy or data protection laws.
-
Commercial use without proper licensing from Google.
-
Redistributing the model weights without permission.
-
Using embeddings to create biased or discriminatory systems.
Disclaimer βΌοΈ
I am not liable for any direct, indirect, consequential, incidental, or special damages arising out of or in any way connected with the use/misuse or inability to use this software.
β Star the repo on GitHub!
π¦ Follow @zsakib_ on X
π» Check out more projects @zsxkib on GitHub