# Voyage Law 2

Voyage Law 2 is Voyage AI by MongoDB's legal-specialized embedding model. Trained on one trillion legal tokens, it outperforms OpenAI text-embedding-3-large by 6% across eight legal datasets and achieves 84.44 NDCG@10 on long-context legal retrieval.

- **Model ID:** `voyage/voyage-law-2`
- **Type:** embedding
- **Providers:** voyage
- **Context window:** Not applicable
- **Maximum output tokens:** 0
- **Pricing:** $0.12/1M input tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/voyage-law-2

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { embed } from 'ai';

const result = await embed({
  model: 'voyage/voyage-law-2',
  value: 'Sunny day at the beach',
})
```

## About

Voyage Law 2 is Voyage AI by MongoDB's legal-specialized embedding model, released April 15, 2024. Voyage AI by MongoDB trained it on one trillion high-quality legal tokens using specifically designed positive pairs and a contrastive learning algorithm. The model handles diverse legal content including contracts, congressional bills, court cases, and statutes across multiple jurisdictions: U.S., Chinese, German, and Indian.

Across eight legal retrieval datasets, Voyage Law 2 outperforms OpenAI text-embedding-3-large by 6% on average, with improvements exceeding 10% on LeCaRDv2, LegalQuAD, and GerDaLIR. On long-context legal retrieval, Voyage Law 2 achieves 84.44 NDCG@10 compared to 68.40 for OpenAI. That's a 23% relative improvement reflecting the model's strength on lengthy legal documents.

Voyage AI by MongoDB intentionally mixed legal training data with finance, technology, and intellectual property domains. This ensures Voyage Law 2 performs well on non-legal retrieval tasks while maintaining its legal specialization. Teams with mixed legal and business content don't need a separate general-purpose model for non-legal documents in the same index.

## What to consider

Voyage Law 2 excels on long-context legal retrieval, achieving 84.44 NDCG@10 versus 68.40 for OpenAI. If your legal corpus contains lengthy contracts, court opinions, or statutory texts, this is where Voyage Law 2 provides the largest accuracy gains.

Voyage AI by MongoDB trains and evaluates Voyage Law 2 on U.S., Chinese, German, and Indian legal content. If your practice spans these jurisdictions, Voyage Law 2 handles cross-jurisdictional retrieval within a single index.

Voyage AI by MongoDB's voyage-3-large now outperforms domain-specific models on legal benchmarks. For new deployments with mixed legal and non-legal content, evaluate voyage-3-large or voyage-3.5 as alternatives.

## When to use

### Best For

- **Legal research and discovery** over contracts, case law, and statutes where domain-specific terminology and document structure matter
- **Long-document legal retrieval** where contracts and court opinions span many pages and key passages appear deep in the text
- **Multi-jurisdictional legal search** across U.S., Chinese, German, and Indian legal content within a single index
- **RAG for legal applications** where retrieving precise statutory language, case citations, and contractual clauses improves generated output
- **Compliance and regulatory retrieval** that searches across regulations, guidance, and enforcement actions from multiple legal systems

### Consider Alternatives When

- **Your content spans multiple domains** beyond legal; voyage-3.5 or voyage-3-large provides cross-domain retrieval that includes legal
- **You want Matryoshka dimensionality and quantization**; voyage-3.5 offers these while covering legal content
- **Your legal documents are primarily short-form** (clauses, headnotes) where long-context strength provides less advantage
- **You need code or financial retrieval** alongside legal content; a general-purpose model avoids managing multiple specialized indices

## Best for

- **Legal research and discovery:** Contracts, case law, and statutes where domain-specific terminology and document structure matter
- **Long-document legal retrieval:** Contracts and court opinions span many pages and key passages appear deep in the text
- **Multi-jurisdictional legal search:** U.S., Chinese, German, and Indian legal content within a single index
- **RAG for legal applications:** Retrieving precise statutory language, case citations, and contractual clauses improves generated output
- **Compliance and regulatory retrieval:** Searches across regulations, guidance, and enforcement actions from multiple legal systems

## Consider alternatives

- **Your content spans multiple domains beyond legal:** voyage-3.5 or voyage-3-large provides cross-domain retrieval that includes legal
- **You want Matryoshka dimensionality and quantization:** voyage-3.5 offers these while covering legal content
- **Your legal documents are primarily short-form:** Clauses and headnotes benefit less from long-context strength
- **You need code or financial retrieval alongside legal content:** A general-purpose model avoids managing multiple specialized indices

## Frequently asked questions

### What legal document types does Voyage Law 2 handle?

Contracts, congressional bills, court cases, and statutes. It is trained and evaluated across U.S., Chinese, German, and Indian legal content.

### How does Voyage Law 2 perform on long legal documents?

Voyage Law 2 achieves 84.44 NDCG@10 on long-context legal retrieval, compared to 68.40 for OpenAI text-embedding-3-large. This 23% relative improvement reflects its strength on the lengthy documents common in legal work.

### Should I use Voyage Law 2 or voyage-3-large for legal retrieval?

Voyage AI by MongoDB's voyage-3-large now outperforms domain-specific models on legal benchmarks. For mixed legal and non-legal content, voyage-3-large or voyage-3.5 may be simpler. Use Voyage Law 2 if your workload is exclusively legal and you have existing indices.

### Does Voyage Law 2 work for non-legal content?

Yes. Voyage AI by MongoDB intentionally trained Voyage Law 2 on mixed legal, financial, technical, and intellectual property content. It performs well on non-legal retrieval tasks while maintaining its legal specialization.

### What jurisdictions does Voyage Law 2 cover?

U.S., Chinese, German, and Indian legal systems. The model handles cross-jurisdictional retrieval within a single vector index.

### How do I access Voyage Law 2 through Vercel AI Gateway?

Add your Voyage AI by MongoDB API key in AI Gateway settings, then send embedding requests through AI Gateway. AI Gateway authenticates requests and records usage. You can combine Voyage Law 2 with other embedding models across providers.

### How much legal training data was used for Voyage Law 2?

One trillion high-quality legal tokens, with specifically designed positive pairs and a contrastive learning algorithm. The training data spans contracts, legislation, and case law across multiple jurisdictions.

## Links

- [Model page](https://vercel.com/ai-gateway/models/voyage-law-2)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://docs.voyageai.com/docs/embeddings)
- [Provider pricing](https://docs.voyageai.com/docs/pricing)
