zsxkib/embedding-gemma-300m

Turn any text into 768-dimensional vectors for search, classification, and AI apps 🧠✨

Public
76.9K runs

Run time and cost

This model costs approximately $0.00022 to run on Replicate, or 4545 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker.

This model runs on Nvidia T4 GPU hardware. Predictions typically complete within 1 seconds.

Readme

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:

  1. Choose your embedding dimension: 128, 256, 512, or 768

  2. Set the embedding_dim parameter to your desired size

  3. The model automatically truncates the full 768-dimensional embedding to your chosen size

  4. Example usage:

  5. embedding_dim = 256 β†’ Get 256-dimensional vectors
  6. embedding_dim = 512 β†’ Get 512-dimensional vectors
  7. embedding_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