In our previous post,
Training a Query Fan-Out Model
, we demonstrated how to generate millions of high-quality query reformulations without human labelling, by navigating the embedding space between a seed query and its target document and then decoding each intermediate vector back into text using a trained query decoder.
That decoder's success critically depends on having an embedding encoder whose latent geometry is fully under our control: off-the-shelf models (e.g. mxbai embed large) optimize for general semantic similarity, not for invertibility, so their embeddings cannot reliably be mapped back into meaningful queries.
To bridge that gap, this article introduces
Gemma-Embed
, a bespoke 256-dim embedding model built by fine-tuning
google/gemma-3-1b-pt
with LoRA adapters and contrastive objectives. By training our own encoder, we lock in a consistent, L2-normalized latent space that the subsequent query decoder can invert with high fidelity.
Quick Recap of the Query Fan-Out Mission
Query Decoder
: Train a T5-based model to invert a fixed retrieval encoder (e.g. GTR) so that any embedding vector produces the original query. Achieved ~96% cosine similarity on reconstruction.
Latent Space Traversal
: For each (query, document) pair, interpolate in the embedding space, decode each point, and retain reformulations that improve retrieval metrics—yielding hundreds of thousands of synthetic examples.
Production Model (qsT5)
: Fine-tune T5 on that synthetic dataset (with and without pseudo-relevance feedback) to internalize traversal patterns—so at inference time it generates diverse, effective reformulations without any explicit vector arithmetic.
Together, these steps automate query fan-out, boost retrieval performance, and open the door to interpretable, language-agnostic search suggestions.
To power a query fan‑out decoder that inverts embeddings back to natural language queries, we need an embedding encoder whose latent geometry we control. Since no off‑the‑shelf Gemma‑3 embedding model exists, we fine‑tune
google/gemma‑3‑1b‑pt
with LoRA and contrastive objectives to produce high‑quality, L2‑normalized 256‑dim embeddings.
Model Architecture
Base Encoder
google/gemma-3-1b-pt
(1 B params)
LoRA Adapters
Target modules
:
q_proj
,
v_proj
Rank (r)
: 8
Alpha (α)
: 16
Dropout
: 0.05
Projection Head
Input
: hidden_size (1024)
MLP
: Linear(1024→512) → ReLU → Linear(512→256)
L2 normalization
Data and Format
Phase 1 – Unsupervised SimCSE
Source
:
text.txt
(wiki sentences or plain text logs)
Size
: 579,719 sentences
Format
: UTF‑8 plain text, one sequence per line
Sample lines
:
Breaking news: stock markets rally as central bank hints at rate cut.
How do I fine‑tune a large language model for embeddings?
The Northern Lights are visible tonight in high‑latitude regions.
SELECT query FROM queries LIMIT 5;
How to bake sourdough at home?
Weather tomorrow in Sydney
Best restaurants near me open now
convert1 mile to kilometers
streamlit file uploader example
triplets.csv
: depends on sources (~500 MB for 4 M rows)
queries.db
: ~200 MB SQLite file
pretokenized_queries.pt
: 13.5 GB
Inference Test
Runs of dejanseo gemma-embed on huggingface.co
0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs
More Information About gemma-embed huggingface.co Model
gemma-embed huggingface.co
gemma-embed huggingface.co is an AI model on huggingface.co that provides gemma-embed's model effect (), which can be used instantly with this dejanseo gemma-embed model. huggingface.co supports a free trial of the gemma-embed model, and also provides paid use of the gemma-embed. Support call gemma-embed model through api, including Node.js, Python, http.
gemma-embed huggingface.co is an online trial and call api platform, which integrates gemma-embed's modeling effects, including api services, and provides a free online trial of gemma-embed, you can try gemma-embed online for free by clicking the link below.
dejanseo gemma-embed online free url in huggingface.co:
gemma-embed is an open source model from GitHub that offers a free installation service, and any user can find gemma-embed on GitHub to install. At the same time, huggingface.co provides the effect of gemma-embed install, users can directly use gemma-embed installed effect in huggingface.co for debugging and trial. It also supports api for free installation.