Skip to page content
SAVRN
Search Plan a project

Open-weight model · Sentence similarity

ViDense

by Dang Phuong Nam namdp-ptit/ViDense

ViDense is an open-weight model for sentence similarity from Dang Phuong Nam, released under Apache License 2.0. It has 8,194-token context. Its published files total 2.3 GB. It draws 374 downloads a month.

ViDense is a VietNamese Embedding Model. Fine-tuned and enhanced with tailored methods, ViDense incorporates advanced techniques to optimize performance for text embeddings in various applications. Trained for 10 epochs with a train batch size of 2048.

Parameters—
Context8,194
Weights2.3 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads374

Model Card

By Dang Phuong Nam, published under apache-2.0, revision e98ede2e2197.

ViDense is a VietNamese Embedding Model. Fine-tuned and enhanced with tailored methods, ViDense incorporates advanced techniques to optimize performance for text embeddings in various applications. Trained for 10 epochs with a train batch size of 2048. Utilizes a 3-phase training approach, where the best checkpoint from each phase serves as the base model for the next. Momentum Encoder: Incorporates MoCo (Momentum Contrast) to enhance in-batch negative sampling. of positives as relevant to the anchor, it reranks the corpus using the Spearman metric and integrates Spearman weights into the loss calculation for improved ranking. Below is a comparision table of the results I achieved compared…

Read Dang Phuong Nam's full model card

Table of contents

  • Introduce
  • Usage
  • Performance
  • Contact
  • Support The Project
  • Citation

Introduce

ViDense is a VietNamese Embedding Model. Fine-tuned and enhanced with tailored methods, ViDense incorporates advanced techniques to optimize performance for text embeddings in various applications.

Model Configuration and Methods:

  • Base Model: FacebookAI/xlm-roberta-large
  • Trained for 10 epochs with a train batch size of 2048.
  • Utilizes a 3-phase training approach, where the best checkpoint from each phase serves as the base model for the next.
  • Position Encoding: Rotary Position Encoding
  • Attention: Blockwise Parallel Transformer
  • Pooling: Mean Pooling
  • Momentum Encoder: Incorporates MoCo (Momentum Contrast) to enhance in-batch negative sampling.
  • Rank Encoder: Introduces a Rank Encoder to account for transitive positive relationships. By considering positives of positives as relevant to the anchor, it reranks the corpus using the Spearman metric and integrates Spearman weights into the loss calculation for improved ranking.
  • Loss Function: Cross Entropy Loss (Sim Scores) + MSE Loss (Spearman Scores)

Usage

pip install -U transformers
import torch
from transformers import AutoModel, AutoTokenizer


def avg_pooling(attention_mask, outputs):
    last_hidden = outputs.last_hidden_state
    return (last_hidden * attention_mask.unsqueeze(-1)).sum(1) / attention_mask.sum(-1).unsqueeze(-1)


tokenizer = AutoTokenizer.from_pretrained('namdp-ptit/ViDense')
model = AutoModel.from_pretrained('namdp-ptit/ViDense')

sentences = [
    'Tỉnh nào có diện tích lớn nhất Việt Nam',
    'Tỉnh nào có diện tích nhỏ nhất Việt Nam',
    'Tỉnh nào có diện tích rộng nhất Việt Nam'
]

inputs = tokenizer(sentences, return_tensors='pt', padding=True)

with torch.no_grad():
    outputs = model(**inputs)
    outputs = avg_pooling(inputs['attention_mask'], outputs)

cosine_sim_1 = torch.nn.functional.cosine_similarity(
    outputs[0].unsqueeze(0),
    outputs[1].unsqueeze(0)
)
cosine_sim_2 = torch.nn.functional.cosine_similarity(
    outputs[0].unsqueeze(0),
    outputs[2].unsqueeze(0)
)

print(cosine_sim_1.item())  # 0.056096598505973816
print(cosine_sim_2.item())  # 0.9861876964569092

Performance

Below is a comparision table of the results I achieved compared to some other embedding models on three benchmarks: ZAC, WebFaq, OwiFaq, ViQuAD2.0, ViLegal with metric Recall@3

Model Name ZAC WebFaq ViQuAD2.0 ViLegal
namdp-ptit/ViDense 54.72 82.26 61.28 58.42
VoVanPhuc/sup-SimCSE-VietNamese-phobert-base 53.64 81.52 59.12 55.70
keepitreal/vietnamese-sbert 50.45 80.54 52.67 51.86
BAAI/bge-m3 46.12 83.45 58.27 49.02

Here are the information of these 3 benchmarks:

  • ZAC: merge train and test into a new benchmark, ~ 3200 queries, ~ 330K documents in corpus.
  • WebFAQ and OwiFaq: merge train and test into a new benchmark, ~ 124K queries, ~ 124K documents in corpus.
  • ViQuAD2.0: merge train, validation and test into a new benchmark, ~ 39.6K queries, ~ 39.6K documents in corpus.
  • ViLegal: ~ 144K queries, ~ 144K documents in corpus.

Contact

Email: [email protected]

LinkedIn: Dang Phuong Nam

Facebook: Phương Nam

Support The Project

If you find this project helpful and wish to support its ongoing development, here are some ways you can contribute:

  1. Star the Repository: Show your appreciation by starring the repository. Your support motivates further development and enhancements.
  2. Contribute: I welcome your contributions! You can help by reporting bugs, submitting pull requests, or suggesting new features.
  3. Donate: If you’d like to support financially, consider making a donation. You can donate through:
    • Vietcombank: 9912692172 - DANG PHUONG NAM

Thank you for your support!

Citation

Please cite as

@misc{ViDense,
  title={ViDense: An Embedding Model for Vietnamese Long Context},
  author={Nam Dang Phuong},
  year={2025},
  publisher={Huggingface},
}

Beta 0 / 0 used queries 1

Configuration

Architecture
ViDense
Context length (tokens)
8,194
Layers
24
Hidden size
1,024
Feed-forward size
4,096
Attention heads
16
Vocabulary size
250,002
Stored precision
float32
Model type
xlm-roberta

Identity and Version

Repository
namdp-ptit/ViDense
Publisher
Dang Phuong Nam
Task
Sentence similarity
Modality
Text
Library
transformers
Parameters
Not stated by the source
Languages
vi
Revision
e98ede2e21974acb478885760830cf8a9788e09b
First published
2025-06-18
Last updated
2026-09-24

Files and Weights

13 files, 2.3 GB in total. The weights are 3 files totalling 2.3 GB in bin, pt.

Weights3 files · 2.3 GB
Configuration5 files · 2.2 KB
Tokenizer2 files · 17.1 MB
Documentation1 file · 6.0 KB
Other1 file · 5.1 MB
Repository1 file · 1.6 KB
Every file
FileTypeSizeSHA-256
colbert_linear.ptWeights2.1 MB 19bfbae397c2
pytorch_model.binWeights2.3 GB b5e0ce3470ab
sparse_linear.ptWeights3.5 KB 45c93804d214
1_Pooling/config.jsonConfiguration191 B —
config.jsonConfiguration686 B —
modules.jsonConfiguration349 B —
sentence_bert_config.jsonConfiguration54 B —
special_tokens_map.jsonConfiguration964 B —
README.mdDocumentation6.0 KB —
sentencepiece.bpe.modelOther5.1 MB cfc8146abe2a
.gitattributesRepository1.6 KB —
tokenizer.jsonTokenizer17.1 MB 249df0778f23
tokenizer_config.jsonTokenizer1.2 KB —

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
2.3 GB
Download from Dang Phuong Nam

Released by Dang Phuong Nam through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published2.3 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About ViDense

Can I use ViDense commercially?

Yes. ViDense is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

What is ViDense's context length?

8,194 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Sentence similarity

bge-m3

Beijing Academy of Artificial Intelligence

For more details please refer to our github repo: https://github.com/FlagOpen/FlagEmbedding In this project, we introduce BGE-M3, which is distinguished for its versatility in Multi-Functionality, Multi-Linguality, and Multi-Granularity. Some suggestions for retrieval pipeline in RAG We recommend to use the following pipeline: hybrid retrieval + re-ranking. - Hybrid retrieval leverages the strengths of various methods, offering higher accuracy and stronger generalization capabilities. Now, you can try to use BGE-M3, which supports both embedding and sparse retrieval. This allows you to obtain token weights (similar to the BM25) without any additional cost when generate dense embeddings. To…

Open weights mit 8,194 tokens sentence-transformers

Model · Sentence similarity

bge-small-en-v1.5-onnx-Q

Qdrant

Quantized ONNX port of BAAI/bge-small-en-v1.5 for text classification and similarity searches. Here's an example of performing inference using the model with FastEmbed.

Open weights mit 512 tokens transformers

Model · Sentence similarity

all-MiniLM-L6-v2-onnx

Qdrant

ONNX port of sentence-transformers/all-MiniLM-L6-v2 for text classification and similarity searches. Here's an example of performing inference using the model with FastEmbed.

Open weights apache-2.0 512 tokens transformers

Model · Sentence similarity

bm25

Qdrant

Repository with files to perform BM25 searches with FastEmbed. BM25 (Best Matching 25) is a ranking function used by search engines to estimate the relevance of documents to a given search query. This model is supposed to be used with Qdrant. Vectors have to be configured with Modifier.IDF. Here's an example of BM25 with FastEmbed.

Open weights apache-2.0 transformers

Model · Sentence similarity

Splade_PP_en_v1

Qdrant

ONNX port of prithivida/SpladePPenv1 for text classification and similarity searches. Here's an example of performing inference using the model with FastEmbed.

Open weights apache-2.0 512 tokens transformers

Model · Sentence similarity

embeddinggemma-300m

LiteRT Community (FKA TFLite)

This model card provides a few variants of the EmbeddingGemma model that are ready for deployment on Android and iOS using LiteRT, or on Android via the Google AI Edge RAG Library. Try out the demo example on GitHub. Try out the EmbeddingGemma model in the in the Google AI Edge RAG Library. You can find the SDK on GitHub or follow our Android guide to install directly from Maven. We have also published a sample app. Use the sentencepiece model as the tokenizer for the EmbeddingGemma model. Note that all benchmark stats are from a Samsung S25 Ultra. Mixed Precision refers to per-channel quantization with int4 for embeddings, feedforward, and projection layers, and int8 for attention…

Access requested at publisher gemma sentence-transformers