Codestral Embed model release

TL;DR

Mistral AI announced Codestral Embed, its first embedding model specialized for source code, and demonstrated that it surpasses leading competitors (Voyage Code 3, Cohere Embed v4.0, OpenAI’s large embedding model) on real‑world code retrieval benchmarks.

Model Overview

Codestral Embed is designed for high‑performance code retrieval and semantic understanding. The model can emit embeddings of various dimensions (e.g., 256) and numeric precisions (including int8). Mistral reports that even the smallest configuration (256‑dimensional int8) outperforms every competing model they evaluated. The embedding dimensions are ordered by relevance, allowing users to truncate to any integer n and obtain a smooth trade‑off between retrieval quality and storage cost.

Retrieval quality vs. storage cost trade‑off for Codestral Embed

Benchmark Performance

Codestral Embed was benchmarked across multiple code‑centric retrieval tasks. The results are summarized by category, with detailed benchmark tables provided by Mistral.

Category Representative Benchmarks
Retrieval‑augmented generation SWE‑Bench lite (real GitHub issues → relevant files)
Semantic code search CodeSearchNet (code→code, doc2code)
Similarity & duplicate detection CommitPack (commit message → modified files)
Text‑to‑SQL Spider, WikiSQL, Synthetic Text2SQL
Algorithmic code matching DM code contests, APPS, CodeChef, MBPP+
Data‑science code matching DS 1000

Mistral states that the model achieves the highest average scores in each category and leads the macro‑average across all categories.

Primary Use Cases

1. Retrieval‑augmented generation (RAG)

Codestral Embed enables rapid context retrieval for code completion, editing, or explanation, making it ideal for AI‑powered copilots and coding‑agent frameworks.

2. Semantic code search

The embeddings support accurate search of code snippets from natural‑language or code queries, suitable for integration into developer tools, documentation systems, and copilots.

3. Similarity search & duplicate detection

By capturing functional similarity despite lexical variation, the model helps identify reusable code, prevent duplicate implementations, and enforce licensing policies.

4. Semantic clustering & code analytics

Unsupervised grouping of code by functionality or structure becomes feasible, aiding repository composition analysis, architecture discovery, and automated documentation.

Availability & Pricing

  • API name: codestral-embed-2505
  • Cost: $0.15 per million tokens (standard API) — 50 % discount on the batch API.
  • On‑premises: Available via direct contact with Mistral’s applied AI team.

Documentation, quick‑start guides, and a Colab cookbook are provided:

Recommended Chunking Strategy

For retrieval scenarios, Mistral advises chunking source files into ~3000‑character segments with a 1000‑character overlap. While the model can process up to 8192 tokens, larger chunks degrade retrieval performance.

Benchmark Details

Mistral lists the specific benchmarks used to evaluate Codestral Embed:

Benchmark Description Category
SWE‑Bench lite Retrieve files to fix real GitHub issues swebench_lite
CodeSearchNet (code→code) Retrieve code appearing in the same context code2code
CodeSearchNet doc2code Retrieve code from a docstring query Text2code (github)
CommitPack Retrieve modified files from a commit message Text2code (github)
Spider Retrieve SQL code from a natural‑language query Text2SQL
WikiSQL Retrieve SQL code from a natural‑language query Text2SQL
Synthetic Text2SQL Retrieve SQL code from a synthetic query Text2SQL
DM code contests Match problem descriptions to correct competition solutions Text2Code (Algorithms)
APPS Match problem descriptions to competition solutions Text2Code (Algorithms)
CodeChef Match problem descriptions to competition solutions Text2Code (Algorithms)
MBPP+ Match algorithmic questions to Python solutions Text2Code (Algorithms)
DS 1000 Match data‑science questions to implementations Text2Code (Data Science)

These benchmarks cover a broad spectrum of code retrieval tasks, confirming the model’s versatility across software engineering, data‑science, and algorithmic domains.


All statements are directly derived from Mistral AI’s official announcement dated 2025‑05‑28.

Sources

相关

  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch
  • Dispatch