# Gemini-Embedding-001 Task-Type Asymmetric Retrieval vs OpenAI Symmetric Space

> Google gemini-embedding-001 projects queries and documents into asymmetric subspaces controlled by task_type and title parameters. Calling embedContent without matching RETRIEVAL_DOCUMENT at ingest and RETRIEVAL_QUERY or CODE_RETRIEVAL_QUERY at search degrades retrieval nDCG@10 by 8 to 14 points. Wire strict asymmetric wrappers, or switch to Voxell Forge C_corpus zero-LLM dialect conditioning (0.6652 Stage-1 nDCG@10; 99.04% Recall@20).

Canonical URL: https://voxell.ai/optimize/gemini-task-type-asymmetric-retrieval/


## Why Generic LangChain / LlamaIndex Defaults Hurt `gemini-embedding-001`

OpenAI's `text-embedding-3-large` and `text-embedding-3-small` expose a single symmetric API signature: `input` + `model`. There is no `task_type` flag. Teams swapping OpenAI wrappers for Google `gemini-embedding-001` frequently reuse a single `embed(text)` helper for both indexing and search.

Under the hood, `gemini-embedding-001` conditions its transformer pooling through internal task-instruction prefixes mapped to eight `task_type` enums. Short imperative questions (`"max RDS connections on db.r6g.2xlarge?"`) and 600-word runbook excerpts occupy **different regions of the manifold** unless aligned by asymmetric dual-encoder task routing:

| Workload | Ingest `task_type` (+ `title`) | Search `task_type` (`title` Forbidden) | Penalty When Mismatched / Omitted |
| :--- | :--- | :--- | :--- |
| **Enterprise RAG / Q&A** | `RETRIEVAL_DOCUMENT` + `title` | `RETRIEVAL_QUERY` | `-6.4` to `-11.8` `nDCG@10` pts |
| **Natural-Language Code Search** | `RETRIEVAL_DOCUMENT` + filepath `title` | `CODE_RETRIEVAL_QUERY` | `-9.2` to `-14.5` `MRR@10` pts |
| **Compliance / Claim Grounding** | `RETRIEVAL_DOCUMENT` + policy `title` | `FACT_VERIFICATION` | `-7.1` to `-12.0` `Recall@10` pts |
| **Deduplication / Clustering** | `CLUSTERING` or `SEMANTIC_SIMILARITY` | `CLUSTERING` or `SEMANTIC_SIMILARITY` | Asymmetric head distorts pairwise k-NN |

## Runnable Fix: Type-Safe Asymmetric Dual Client (TypeScript)

Enforce compile-time separation between document ingestion (which **requires** `title` + `RETRIEVAL_DOCUMENT` to anchor orphaned body text) and query encoding (where passing `title` triggers an `HTTP 400` API error), combined with mandatory L2 normalization from [Guide 02](/optimize/gemini-embedding-001-mrl-l2-normalization/):

```typescript
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

export type QueryTask =
  | "RETRIEVAL_QUERY"
  | "CODE_RETRIEVAL_QUERY"
  | "FACT_VERIFICATION"
  | "QUESTION_ANSWERING";

function l2Normalize(vec: number[]): number[] {
  let sumSq = 0;
  for (let i = 0; i < vec.length; i++) sumSq += vec[i] * vec[i];
  const inv = sumSq > 1e-24 ? 1 / Math.sqrt(sumSq) : 1;
  return vec.map((v) => v * inv);
}

export async function embedCorpusChunk(
  title: string,
  body: string,
  dim = 1536
): Promise<number[]> {
  const res = await ai.models.embedContent({
    model: "gemini-embedding-001",
    contents: body,
    config: {
      taskType: "RETRIEVAL_DOCUMENT",
      title, // Legal ONLY on RETRIEVAL_DOCUMENT; adds +2.5 to +4.8 nDCG@10 pts
      outputDimensionality: dim,
    },
  });
  return l2Normalize(res.embeddings![0].values!);
}

export async function embedSearchQuery(
  query: string,
  taskType: QueryTask = "RETRIEVAL_QUERY",
  dim = 1536
): Promise<number[]> {
  const res = await ai.models.embedContent({
    model: "gemini-embedding-001",
    contents: query,
    config: {
      taskType, // Never set `title` here -> Vertex/Gemini throws HTTP 400
      outputDimensionality: dim,
    },
  });
  return l2Normalize(res.embeddings![0].values!);
}
```

## Static Task Prefixes vs Corpus-Conditioned Dialect Alignment (`C_corpus`)

Even with perfect `RETRIEVAL_DOCUMENT` / `RETRIEVAL_QUERY` hygiene, static task prefixes only tell the encoder *"this string is a query"* vs *"this string is a document."* They know **nothing** about your company's internal dialect:

- In hospital EHR notes, `PT` means *prothrombin time* or *physical therapy*; in power-grid telemetry, `PT` means *potential transformer*.
- Static public weights (`text-embedding-3-large` and `gemini-embedding-001`) map proprietary SKU codes, internal protobuf service names, and regulatory cross-references into crowded, anisotropic neighborhoods ([Guide 06](/optimize/embedding-anisotropy-mean-centering-domain-drift/)).

**Voxell Forge** solves both asymmetric routing and domain drift with **zero-LLM `C_corpus` ingest dialect conditioning**, adapting Stage-1 dense geometry directly to your corpus statistics (`0.6652` Stage-1 `nDCG@10` and `99.04% Recall@20` at **$0.25/1M** tokens, or `0.8849 nDCG@10` / `75.93% Strict@1` with `Max` cross-encoder reranking on Team at **$199/mo** annual). Verify on domain jargon right now with zero API key:

```bash
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"name": "substation-spec.md", "text": "Busbar Bay 4 PT secondary winding ratio is 115V nominal with 0.2 metering accuracy class."},
      {"name": "rehab-policy.md", "text": "Outpatient PT coverage includes 24 post-operative sessions per calendar year."}
    ],
    "queries": ["What metering accuracy class applies to the Bay 4 PT secondary winding?"]
  }'
```

Compare end-to-end memory and API bills in the **[Vector RAM & TCO Calculator](/tools/vector-calculator/)**, read **[Flagship 3-Way Model Benchmarks](/optimize/openai-text-embedding-3-large-vs-gemini-embedding-001/)**, or open the **[Forge Console](https://dash.voxell.ai/home)** (**[v4.0 Pricing](/pricing/)**).

## Frequently Asked Questions

### What happens if I omit task_type when calling gemini-embedding-001 for RAG?

Omitting task_type or passing SEMANTIC_SIMILARITY on asymmetric short-question-to-long-passage retrieval forces both strings through a symmetric projection head, costing 8 to 14 nDCG@10 points on technical Q&A, code search, and claim verification workloads.

### Can I pass the title parameter with RETRIEVAL_QUERY in gemini-embedding-001?

No. The Gemini and Vertex AI APIs reject title with HTTP 400 Invalid Argument on every task_type except RETRIEVAL_DOCUMENT. Your ingestion wrapper must pass title only during document indexing and strip it on query calls.

### How does Voxell Forge handle asymmetric query-document alignment and domain jargon?

Voxell Forge handles asymmetric query/document alignment automatically and goes a step further at ingest with C_corpus zero-LLM dialect conditioning, adapting representations to your corpus's exact acronyms, part numbers, and schema dialect for 0.6652 Stage-1 nDCG@10 and 99.04% Recall@20 ($0.25/1M on Pro; $0 forever on Turbo).

---

## Zero-Install Model Context Protocol (MCP) & Keyless Agent Verification

```bash
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
```

- Keyless Retrieval Bake-Off: `POST https://api.voxell.ai/api/v1/agent/bakeoff`
- Keyless Contradiction X-Ray: `POST https://api.voxell.ai/api/v1/agent/xray`
- Machine-Readable Pricing JSON: `https://voxell.ai/api/v1/agent/pricing.json`
- Full LLM Authority Map: `https://voxell.ai/llms-full.txt`
