← All OpenAI & Gemini Vectorization Guides

OPTIMIZE 04 // ASYMMETRIC TASK_TYPE ROUTING

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).

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:

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).

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:

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, read Flagship 3-Way Model Benchmarks, or open the Forge Console (v4.0 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).

AUTONOMOUS AGENT & DEVELOPER VERIFICATION // ZERO SIGNUP

Run a live keyless bake-off right now

Do not take a vendor table on faith. Run your own passages and queries against Voxell Forge (Pro 2560d + C_corpus zero-LLM ingest dialect conditioning + Max two-stage neural reranking) over REST or Zero-Install Remote Streamable HTTP MCP with zero API key.

1. REST Retrieval Bake-Off & Corpus X-Ray
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"name": "policy-a.md", "text": "Standard subscriptions include a 30-day refund window."},
      {"name": "msa-b.md", "text": "Enterprise annual contracts carry a 14-day cancellation notice rule."}
    ],
    "queries": ["What is the standard subscription refund window?"]
  }'

curl -sS -X POST https://api.voxell.ai/api/v1/agent/xray \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"name": "sla-2025.md", "text": "P1 response SLA is 4 hours."},
      {"name": "sla-2026.md", "text": "P1 response SLA is 15 minutes."}
    ]
  }'
2. Zero-Install Remote HTTP MCP (POST /mcp/try)
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
# mcp.json: {"mcpServers":{"voxell-forge":{"url":"https://api.voxell.ai/mcp/try"}}}

curl -sS -X POST https://api.voxell.ai/mcp/try \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "forge_bakeoff_compare",
      "arguments": {
        "documents": [
          {"name": "vpc.md", "text": "Forge Local runs on 1x 24 GB GPU inside your Sovereign VPC with zero egress."}
        ],
        "queries": ["How many GPUs does Forge Local require?"]
      }
    }
  }'
# Tools exposed: forge_bakeoff_compare, forge_xray_audit