Kervyn Embeddings 100M · Preview

Español   ·   English


Español

🔬 Preview. Es la primera versión pública de los embeddings de Kervyn y todavía está en desarrollo.

  • Funciona y está medido: las cifras de abajo son reales y reproducibles.
  • Los pesos pueden cambiar en próximas versiones. Para fijar esta, usa revision="v1".
  • Tu opinión nos ayuda a mejorarlo.

Kervyn Embeddings convierte textos en español e inglés en vectores para buscar documentos, también entre idiomas: una pregunta en español encuentra la respuesta escrita en inglés.

  • Modelo propio, de cero: arquitectura, tokenizer y pesos de Kervyn, entrenados desde cero.
  • Licencia Apache-2.0.
  • Pareja: está pensado para usarse con Kervyn Rerank 100M · Preview.

Ventajas frente a otros modelos del mercado

  • 🌍 Fuerte entre español e inglés.
    • Pregunta en español, documento en inglés (Belebele ES→EN): 90,1. Son +3,2 sobre multilingual-e5-small y +0,7 sobre multilingual-e5-base, que tiene 2,7 veces más parámetros.
    • Similitud entre frases ES-EN (STS17): 78,0, la más alta de los cuatro modelos comparados, bge-m3 incluido (75,6).
  • ⚖️ Calidad de modelos mucho mayores con una fracción de su tamaño.
    • Con 104M parámetros supera a multilingual-e5-small (118M) en +0,8 de media de búsqueda.
    • Queda a 0,55 de multilingual-e5-base (278M) y a 0,4 de bge-m3 (568M).
  • 💻 El mejor buscando código desde lenguaje natural: 90,1 en CodeSearchNet Python, de +3,8 a +4,8 por encima de los otros tres.
  • 🥇 Con su reranker, la mejor media de la comparación.
    • Kervyn Embeddings + Kervyn Rerank logra 94,45 de media, por encima de bge-m3 + bge-reranker-v2-m3 (94,18).
    • Lo hace con 5 veces menos parámetros (208M frente a 1.136M) y reordena 2,8 veces más rápido en CPU.
    • En las tareas solo de texto, la pareja bge queda ~1 punto por delante (ver Benchmarks).
  • 🔓 100 % propio y Apache-2.0. No hereda licencias ni restricciones de ningún modelo base: puedes usarlo, ajustarlo y desplegarlo en tu producto.
  • 🛠️ Ideal para ajustarlo con los datos de tu empresa. Ver Ajuste fino.

Uso

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Kervyn-AI/Kervyn-Embeddings-100M-Preview")
pasajes = [
    "El contrato puede rescindirse con un preaviso de 30 días.",
    "The warranty covers manufacturing defects for two years.",
]
query = "¿Cuánto dura la garantía?"

doc_vecs = model.encode(pasajes, normalize_embeddings=True)
q_vec = model.encode(query, normalize_embeddings=True)
print(model.similarity(q_vec, doc_vecs))  # el pasaje en inglés puntúa más alto
  • Sin prefijos: las preguntas y los pasajes se codifican igual. No hace falta añadir query: ni passage:.
  • Trocea los documentos en pasajes de ~200 palabras. Se entrenó con pasajes de hasta 256 tokens.
  • Búsqueda en dos etapas (recomendada):
    1. Recupera los 20 mejores pasajes con este modelo.
    2. Reordénalos con Kervyn Rerank 100M · Preview. Su tarjeta trae el código completo.

Ajuste fino con los datos de tu empresa

Kervyn Embeddings es un buen punto de partida para un buscador especializado en tu dominio (legal, soporte, documentación interna, catálogo…):

  • Pequeño: con 104M parámetros, el ajuste completo cabe en una sola GPU de consumo, y con pocos datos incluso funciona en CPU. No hace falta LoRA.
  • Estándar: es un modelo sentence-transformers normal, así que el ajuste son unas líneas.
  • Privado: el ajuste se hace en tu infraestructura y tus datos no salen de ella.
  • Apache-2.0: el modelo ajustado es tuyo.
  • Fuerte en español y entre idiomas de partida.

Solo necesitas pares (pregunta, pasaje que la responde) sacados de tus documentos, de tus tickets o de tus FAQ:

from datasets import Dataset
from sentence_transformers import (SentenceTransformer, SentenceTransformerTrainer,
                                   SentenceTransformerTrainingArguments, losses)
from sentence_transformers.training_args import BatchSamplers

model = SentenceTransformer("Kervyn-AI/Kervyn-Embeddings-100M-Preview")

train = Dataset.from_dict({
    "anchor":   ["¿Cuál es el plazo de devolución?", "¿Cómo descargo una factura?"],
    "positive": ["Las devoluciones se aceptan durante 30 días desde la entrega.",
                 "Las facturas se descargan desde Mi cuenta > Pedidos > Factura."],
})

args = SentenceTransformerTrainingArguments(
    output_dir="kervyn-embeddings-mi-empresa",
    num_train_epochs=1,
    per_device_train_batch_size=64,
    learning_rate=2e-5,
    warmup_ratio=0.1,
    batch_sampler=BatchSamplers.NO_DUPLICATES,  # sin el mismo pasaje dos veces en un lote
)
# El resto de pasajes del lote hace de negativos; scale=50 es la temperatura de su entrenamiento
loss = losses.MultipleNegativesRankingLoss(model, scale=50)
trainer = SentenceTransformerTrainer(model=model, args=args, train_dataset=train, loss=loss)
trainer.train()
model.save_pretrained("kervyn-embeddings-mi-empresa/final")

Para el sistema completo, ajusta también Kervyn Rerank con los mismos pares. Su tarjeta explica cómo.

Benchmarks

Las métricas son estas:

  • Búsqueda: nDCG@10, en español, en inglés y entre idiomas (ES→EN: pregunta en español, pasaje en inglés).
  • kervyn-docs: preguntas reales sobre documentación técnica en español.
  • Similitud: Spearman de STS17.
Tarea Kervyn Emb. 100M multilingual-e5-small multilingual-e5-base bge-m3
Parámetros 104M 118M 278M 568M
Dimensión del vector 768 384 768 1024
Belebele ES 92,19 92,70 94,19 93,96
Belebele EN 93,91 94,82 95,79 95,55
Belebele ES→EN 90,13 86,95 89,46 91,99
XQuAD ES 95,32 96,40 97,18 96,63
XQuAD EN 96,25 97,48 98,03 97,15
XQuAD ES→EN 94,53 94,89 96,15 96,15
kervyn-docs (ES) 75,78 71,96 76,07 74,50
CodeSearchNet Python 90,08 86,31 85,68 85,31
Media de búsqueda (8) 91,02 90,19 91,57 91,41
STS17 ES-ES 85,76 84,83 86,74 87,35
STS17 ES-EN 77,96 72,43 76,56 75,57

Sistema de búsqueda en dos etapas (reordenando el top-20):

Sistema Parámetros Media de búsqueda (8) Media sin código (7)
Kervyn Embeddings + Kervyn Rerank 208M 94,45 94,83
bge-m3 + bge-reranker-v2-m3 1.136M 94,18 95,86
Kervyn Embeddings + bge-reranker-v2-m3 672M 94,23 95,86
  • La pareja Kervyn gana en la media total gracias al código: bge-reranker-v2-m3 baja la búsqueda de código por debajo de la del propio buscador.
  • En texto queda ~1 punto por detrás de una pareja con 5 veces más parámetros.

Velocidad en CPU

Medido en una CPU x86 de servidor con 8 vCPU, PyTorch en fp32:

  • Pasajes: de ~140 tokens, en lotes de 32.
  • Queries: de una en una.
Modelo Pasajes/s Latencia por query (p50)
Kervyn Embeddings 100M 13,1 26 ms
multilingual-e5-small 45,6 11 ms
multilingual-e5-base 13,9 28 ms
bge-m3 4,4 82 ms
  • Comparación: va como multilingual-e5-base y es 3 veces más rápido que bge-m3.
  • Para buscar en tiempo real: 26 ms por query bastan.
  • Cuantización int8 dinámica: no la recomendamos en esta Preview, porque deforma los vectores. Usa fp32.

Detalles del modelo

Campo Valor
Arquitectura Encoder bidireccional: 12 capas × 768, 12 cabezas, atención completa, RoPE
Parámetros 104M
Tokenizer Propio, ~24.600 tokens, entrenado sobre español, inglés y código
Longitud Hasta 512 tokens. Entrenado con pasajes de 256 y queries de 64
Vector 768 dimensiones, media de tokens y normalizado: coseno = producto escalar
Formato sentence-transformers sobre ModernBertModel (safetensors)

Cómo se entrenó:

  1. Preentrenamiento desde cero: 48.000 millones de tokens de web y Wikipedia en español e inglés, más de la mitad en español, con un ~10 % de código.
  2. Contrastivo con pares débiles: títulos y cuerpos, preguntas y respuestas, frases paralelas ES↔EN, noticias, legislación y artículos científicos.
  3. Contrastivo supervisado: 2,6M de queries con negativos difíciles.
    • Kervyn Rerank, propio, limpia los falsos negativos y aporta destilación de sus puntuaciones.
    • Una parte de las queries son sintéticas, escritas a partir de pasajes públicos con modelos abiertos de licencia MIT.
    • No se destila ningún modelo de embeddings de terceros.

Limitaciones

  • Preview: los pesos pueden cambiar. Fija revision="v1" si necesitas reproducibilidad.
  • Búsqueda dentro de un solo idioma: queda algo por detrás de los modelos e5 (de −0,5 a −1,2 frente a multilingual-e5-small en Belebele y XQuAD). Con Kervyn Rerank la diferencia desaparece.
  • Textos largos: a partir de 256 tokens no está entrenado. Trocea los documentos.
  • Idiomas: solo español e inglés. Otros idiomas no están evaluados.
  • Datos de entrenamiento: los datasets públicos listados en datasets. Varios son CC-BY-4.0, y su atribución queda recogida en esa lista.

English

🔬 Preview. This is the first public release of Kervyn's embeddings, and it is still under development.

  • It works and it is measured: the numbers below are real and reproducible.
  • Weights may change in future versions. To pin this one, use revision="v1".
  • Your feedback helps us improve it.

Kervyn Embeddings turns Spanish and English text into vectors to search documents, also across languages: a question in Spanish finds the answer written in English.

  • Own model, from scratch: Kervyn's own architecture, tokenizer and weights, trained from scratch.
  • Apache-2.0 license.
  • Pair: it is designed to be used with Kervyn Rerank 100M · Preview.

Advantages over other models

  • 🌍 Strong across Spanish and English.
    • Spanish question, English document (Belebele ES→EN): 90.1. That is +3.2 over multilingual-e5-small and +0.7 over multilingual-e5-base, which has 2.7× more parameters.
    • Spanish–English sentence similarity (STS17): 78.0, the highest of the four models compared, bge-m3 included (75.6).
  • ⚖️ The quality of much bigger models at a fraction of their size.
    • With 104M parameters it beats multilingual-e5-small (118M) by +0.8 on average retrieval.
    • It is within 0.55 of multilingual-e5-base (278M) and 0.4 of bge-m3 (568M).
  • 💻 The best at code search from natural language: 90.1 on CodeSearchNet Python, +3.8 to +4.8 above the other three.
  • 🥇 With its reranker, the best average in the comparison.
    • Kervyn Embeddings + Kervyn Rerank reach 94.45 on average, above bge-m3 + bge-reranker-v2-m3 (94.18).
    • It does so with 5× fewer parameters (208M vs 1,136M) and reranks 2.8× faster on CPU.
    • On text-only tasks the bge pair is ~1 point ahead (see Benchmark results).
  • 🔓 100% own and Apache-2.0. It inherits no licenses or restrictions from any base model: you can use it, fine-tune it and ship it in your product.
  • 🛠️ Ideal for fine-tuning on your company data. See Fine-tuning.

Usage

from sentence_transformers import SentenceTransformer

model = SentenceTransformer("Kervyn-AI/Kervyn-Embeddings-100M-Preview")
passages = [
    "El contrato puede rescindirse con un preaviso de 30 días.",
    "The warranty covers manufacturing defects for two years.",
]
query = "¿Cuánto dura la garantía?"  # "How long is the warranty?" in Spanish

doc_vecs = model.encode(passages, normalize_embeddings=True)
q_vec = model.encode(query, normalize_embeddings=True)
print(model.similarity(q_vec, doc_vecs))  # the English passage scores highest
  • No prefixes: questions and passages are encoded the same way. There is no need to add query: or passage:.
  • Chunk your documents into passages of ~200 words. It was trained on passages of up to 256 tokens.
  • Two-stage search (recommended):
    1. Retrieve the top 20 passages with this model.
    2. Rerank them with Kervyn Rerank 100M · Preview. Its card has the full code.

Fine-tuning on your company data

Kervyn Embeddings is a good starting point for a search engine specialized in your domain (legal, support, internal documentation, product catalog…):

  • Small: with 104M parameters, full fine-tuning fits on a single consumer GPU, and with little data it even runs on CPU. No LoRA needed.
  • Standard: it is a regular sentence-transformers model, so fine-tuning takes a few lines.
  • Private: fine-tuning runs on your infrastructure and your data never leaves it.
  • Apache-2.0: the fine-tuned model is yours.
  • Strong in Spanish and across languages from the start.

All you need are (question, passage that answers it) pairs taken from your documents, tickets or FAQs:

from datasets import Dataset
from sentence_transformers import (SentenceTransformer, SentenceTransformerTrainer,
                                   SentenceTransformerTrainingArguments, losses)
from sentence_transformers.training_args import BatchSamplers

model = SentenceTransformer("Kervyn-AI/Kervyn-Embeddings-100M-Preview")

train = Dataset.from_dict({
    "anchor":   ["What is the return period?", "How do I download an invoice?"],
    "positive": ["Returns are accepted for 30 days after delivery.",
                 "Invoices can be downloaded from My account > Orders > Invoice."],
})

args = SentenceTransformerTrainingArguments(
    output_dir="kervyn-embeddings-my-company",
    num_train_epochs=1,
    per_device_train_batch_size=64,
    learning_rate=2e-5,
    warmup_ratio=0.1,
    batch_sampler=BatchSamplers.NO_DUPLICATES,  # never the same passage twice in a batch
)
# The other passages in the batch act as negatives; scale=50 is the temperature it was trained with
loss = losses.MultipleNegativesRankingLoss(model, scale=50)
trainer = SentenceTransformerTrainer(model=model, args=args, train_dataset=train, loss=loss)
trainer.train()
model.save_pretrained("kervyn-embeddings-my-company/final")

For the full system, fine-tune Kervyn Rerank on the same pairs as well. Its card explains how.

Benchmark results

These are the metrics:

  • Retrieval: nDCG@10, in Spanish, in English and across languages (ES→EN: Spanish question, English passage).
  • kervyn-docs: real questions about technical documentation in Spanish.
  • Similarity: STS17 Spearman.
Task Kervyn Emb. 100M multilingual-e5-small multilingual-e5-base bge-m3
Parameters 104M 118M 278M 568M
Vector size 768 384 768 1024
Belebele ES 92.19 92.70 94.19 93.96
Belebele EN 93.91 94.82 95.79 95.55
Belebele ES→EN 90.13 86.95 89.46 91.99
XQuAD ES 95.32 96.40 97.18 96.63
XQuAD EN 96.25 97.48 98.03 97.15
XQuAD ES→EN 94.53 94.89 96.15 96.15
kervyn-docs (ES) 75.78 71.96 76.07 74.50
CodeSearchNet Python 90.08 86.31 85.68 85.31
Average retrieval (8) 91.02 90.19 91.57 91.41
STS17 ES-ES 85.76 84.83 86.74 87.35
STS17 ES-EN 77.96 72.43 76.56 75.57

Two-stage search system (reranking the top-20):

System Parameters Average retrieval (8) Average without code (7)
Kervyn Embeddings + Kervyn Rerank 208M 94.45 94.83
bge-m3 + bge-reranker-v2-m3 1,136M 94.18 95.86
Kervyn Embeddings + bge-reranker-v2-m3 672M 94.23 95.86
  • The Kervyn pair wins the overall average thanks to code: bge-reranker-v2-m3 drops code search below the retriever's own score.
  • On text it is ~1 point behind a pair with 5× more parameters.

CPU speed

Measured on an x86 server CPU with 8 vCPU, PyTorch in fp32:

  • Passages: ~140 tokens each, in batches of 32.
  • Queries: one at a time.
Model Passages/s Latency per query (p50)
Kervyn Embeddings 100M 13.1 26 ms
multilingual-e5-small 45.6 11 ms
multilingual-e5-base 13.9 28 ms
bge-m3 4.4 82 ms
  • Comparison: it runs like multilingual-e5-base and 3× faster than bge-m3.
  • For real-time search: 26 ms per query is enough.
  • Dynamic int8 quantization: we do not recommend it in this Preview, because it distorts the vectors. Use fp32.

Model details

Field Value
Architecture Bidirectional encoder: 12 layers × 768, 12 heads, full attention, RoPE
Parameters 104M
Tokenizer Own, ~24,600 tokens, trained on Spanish, English and code
Length Up to 512 tokens. Trained with 256-token passages and 64-token queries
Vector 768 dimensions, mean pooling, normalized: cosine = dot product
Format sentence-transformers on ModernBertModel (safetensors)

How it was trained:

  1. Pre-training from scratch: 48 billion tokens of web and Wikipedia text in Spanish and English, more than half of it Spanish, plus ~10% code.
  2. Contrastive training on weak pairs: titles and bodies, questions and answers, ES↔EN parallel sentences, news, legislation and scientific papers.
  3. Supervised contrastive training: 2.6M queries with hard negatives.
    • Kervyn Rerank, our own reranker, removes false negatives and its scores are distilled into the model.
    • Some of the queries are synthetic, written from public passages with open MIT-licensed models.
    • No third-party embedding model is distilled.

Limitations

  • Preview: weights may change. Pin revision="v1" if you need reproducibility.
  • Single-language retrieval: slightly behind the e5 models (−0.5 to −1.2 vs multilingual-e5-small on Belebele and XQuAD). Kervyn Rerank closes the gap.
  • Long texts: it is not trained beyond 256 tokens. Chunk your documents.
  • Languages: Spanish and English only. Other languages are not evaluated.
  • Training data: the public datasets listed in datasets. Several are CC-BY-4.0, and their attribution is in that list.
Downloads last month
-
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train Kervyn-AI/Kervyn-Embeddings-100M-Preview