Instructions to use lau299/ximhai-embedder-es with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lau299/ximhai-embedder-es with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("lau299/ximhai-embedder-es") sentences = [ "Esa es una persona feliz", "Ese es un perro feliz", "Esa es una persona muy feliz", "Hoy es un día soleado" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
ximhai-embedder-es
A Spanish sentence embedder fine-tuned for retrieval over a Mexican secondary-school textbook (Colección Ximhai. Nuestro libro de proyectos. Primer grado, SEP 2023). It is the query/passage encoder of the RAG agent in github.com/lauro299/hackaton-devf-llama.
- Base model:
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 - Output: 384-dim embeddings, mean pooling. Normalize them (
normalize_embeddings=True) to match the index. - Loss:
MultipleNegativesRankingLoss(in-batch negatives) - Training: 6 epochs, batch size 32, 524 train / 58 eval pairs, ~16 s on one AMD RX 7900 XTX (ROCm)
- Validation loss: 0.974 after epoch 1 → 0.198 after epoch 6 (best checkpoint)
Why fine-tune?
The base multilingual model placed the wrong project's chunks closer to a query than the
right one for questions that name a project/reading by title (e.g. "¿qué es Juguemos con
la lengua?": correct chunk at L2 ≈ 0.87 vs unrelated chunks at ≈ 0.81). Training pairs are
generated from the book's own structure (project titles × pedagogical phases × question
templates) plus a handful of curated failure cases. See app/build_finetune_dataset.py
in the GitHub repo.
Usage
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("lau299/ximhai-embedder-es")
emb = model.encode(["¿De qué trata el proyecto de lenguas indígenas?"], normalize_embeddings=True)
print(emb.shape) # (1, 384)
Use the same model that built the vector index. The vectors in the published book.db
were produced by this exact checkpoint.
Training data and copyright
The training pairs pair synthetic questions with passages from the textbook above, which is D.R. © Secretaría de Educación Pública (SEP), 2023. The training dataset is not distributed with this model. You can rebuild it from your own copy of the book with the pipeline in the GitHub repo. This model was built for a non-commercial, educational hackathon project.
Limitations
- Specialized to one textbook's vocabulary and structure. It is not a general-purpose Spanish retriever and may generalize worse than the base model outside this domain.
- Small training set (524 pairs); evaluated only on held-out pairs from the same book.
Citation
Reimers & Gurevych, Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks, EMNLP 2019.
- Downloads last month
- 9