Downloads · 30 days
196
78% of all-time downloads
nhminh107/VietRAG-Embed
VietRAG-Embed is a sentence similarity model from nhminh107. Use it when you need a score for how close two texts are. It is set up for sentence-transformers. The card lists the license as mit.
VietRAG-Embed is a Vietnamese dense-retrieval model fine-tuned from intfloat/multilingual-e5-base. It maps queries and passages to normalized 768-dimensional vectors for semantic search, question answering retrieval,…
Downloads · 30 days
196
78% of all-time downloads
All-time downloads
252
Public
Parameters
278M
1.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors1.1 GB · 99%
From the Hugging Face model README
VietRAG-Embed is a Vietnamese dense-retrieval model fine-tuned from intfloat/multilingual-e5-base. It maps queries and passages to normalized 768-dimensional vectors for semantic search, question answering retrieval, and Retrieval-Augmented Generation (RAG).
The model was trained on 937,686 cleaned Vietnamese query–positive–hard-negative records, with an emphasis on web passage QA and scientific retrieval.
Website: minhlab.ai.vn · Source code: VietRAG-Embed-E5-Base
| Property | Value |
|---|---|
| Architecture | XLM-RoBERTa / Sentence Transformers |
| Base model | intfloat/multilingual-e5-base |
| Primary language | Vietnamese |
| Embedding dimension | 768 |
| Maximum sequence length | 512 tokens |
| Pooling | Mean pooling |
| Output normalization | L2 normalization |
| Similarity | Cosine similarity |
| Parameters | 278,043,648 |
VietRAG-Embed is intended for:
This is an embedding model, not a generative language model. It retrieves relevant text but does not generate answers by itself.
Inputs must use the prefixes employed during training:
query: passage: Omitting these prefixes can reduce retrieval quality. Apply the prefix before tokenization and keep the convention identical when indexing and searching.
pip install -U sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("nhminh107/VietRAG-Embed")
queries = [
"query: Thủ đô của Việt Nam là gì?",
]
passages = [
"passage: Hà Nội là thủ đô của nước Cộng hòa xã hội chủ nghĩa Việt Nam.",
"passage: Nước đóng băng ở 0 độ C trong điều kiện áp suất tiêu chuẩn.",
]
query_embeddings = model.encode(
queries,
normalize_embeddings=True,
convert_to_tensor=True,
)
passage_embeddings = model.encode(
passages,
normalize_embeddings=True,
convert_to_tensor=True,
)
scores = model.similarity(query_embeddings, passage_embeddings)
print(scores)
Because embeddings are normalized, cosine similarity is equivalent to the inner product.
import faiss
import numpy as np
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("nhminh107/VietRAG-Embed")
documents = [
"Hà Nội là thủ đô của Việt Nam.",
"Nước đóng băng ở 0 độ C trong điều kiện áp suất tiêu chuẩn.",
"Sao Mộc là hành tinh lớn nhất trong Hệ Mặt Trời.",
]
document_embeddings = model.encode(
[f"passage: {text}" for text in documents],
normalize_embeddings=True,
convert_to_numpy=True,
).astype(np.float32)
index = faiss.IndexFlatIP(document_embeddings.shape[1])
index.add(document_embeddings)
query_embedding = model.encode(
["query: Thủ đô của Việt Nam là gì?"],
normalize_embeddings=True,
convert_to_numpy=True,
).astype(np.float32)
scores, indices = index.search(query_embedding, k=2)
for score, index_id in zip(scores[0], indices[0]):
print(f"{score:.4f} {documents[index_id]}")
For large collections, encode passages in batches and use an approximate FAISS index or another vector database. Store the mapping between vector IDs and document metadata separately.
This in-domain retrieval diagnostic contains 4,599 held-out queries and 7,949 candidate passages sampled from mMARCO-VI shards 04–05. Exact normalized query overlap with the training export was removed.
| Metric | Score |
|---|---|
| Recall@1 | 0.8419 |
| Recall@5 | 0.9533 |
| Recall@10 | 0.9698 |
| MRR@10 | 0.8907 |
| nDCG@10 | 0.9102 |
The median rank of the relevant passage was 1. This benchmark is query-held-out but corpus-shared: 215 passages, or 2.70% of the evaluation corpus, have exact normalized matches in the training corpus. The result should therefore be treated as an in-domain diagnostic rather than a fully independent external benchmark.
| Task | Main retrieval score |
|---|---|
| SciFact-VN | 0.6130 |
| TRECCOVID-VN | 0.6068 |
| Quora-VN | 0.5652 |
VN-MTEB results are reported separately from the custom mMARCO-VI benchmark. Evaluation was run on an NVIDIA Tesla T4 using E5 query and passage prefixes.
Reproduction code and detailed benchmark artifacts are available in the project repository.
The training pipeline uses the following Vietnamese data sources:
| Dataset | Main role |
|---|---|
minhnguyent546/mmarco-vietnamese-split | Web passage QA |
hotchpotch/mmarco-hard-negatives-reranker-score | Reranker-scored hard-negative candidates |
nhminh107/VietEmbed-RAG-Science | Science and technical retrieval |
vietgpt/wikipedia_vi | Vietnamese encyclopedic source corpus |
The final cleaned supervised retrieval export contains 937,686 query–positive–hard-negative records: 869,119 filtered Vietnamese mMARCO records and 68,567 scientific retrieval records. Wikipedia-VI is used as an additional Vietnamese source corpus in the broader data preparation pipeline.
The pipeline applies text normalization, length and distinctness checks, duplicate control, source tracking, and hard-negative quality filtering.
Benchmark data was not used for model selection. The custom mMARCO diagnostic uses later source shards and rejects every exact normalized query found in the training export.
The model was trained with Sentence Transformers and MultipleNegativesRankingLoss.
| Setting | Value |
|---|---|
| Objective | Multiple Negatives Ranking Loss |
| Similarity in loss | Cosine similarity |
| Loss scale | 20.0 |
| Batch size | 24 |
| Effective passes over the data | 2 |
| Optimization steps | 78,142 |
| Learning rate | 5e-6 |
| Warmup ratio | 0.1 |
| Precision | FP16 |
| Seed | 42 |
| Batch sampler | No-duplicates hashed |
| Multi-dataset sampler | Proportional |
Training used a single visible NVIDIA Tesla T4 on Kaggle and took approximately 11.2 hours. Query inputs were prefixed with query: ; positive and hard-negative passages were prefixed with passage: .
SentenceTransformer(
Transformer: XLMRobertaModel
Pooling: mean pooling, dimension 768
Normalize: L2 normalization
)
Do not use embedding similarity as the sole basis for high-impact medical, legal, financial, employment, or safety decisions.
Training environment:
The exported Sentence Transformers model was also verified locally with a fully offline load and inference smoke test.
The model repository is released under the MIT License. Users are responsible for reviewing and complying with the licenses and terms of the upstream base model and datasets for their use case.
@misc{vietrag_embed_2026,
author = {nhminh107},
title = {VietRAG-Embed: Vietnamese Dense Retrieval Embeddings for RAG},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/nhminh107/VietRAG-Embed}}
}
VietRAG-Embed builds on intfloat/multilingual-e5-base, Sentence Transformers, Hugging Face Transformers, MTEB, and FAISS.