---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
- generated_from_trainer
- dataset_size:1616
- loss:CosineSimilarityLoss
base_model: sentence-transformers/all-MiniLM-L6-v2
widget:
- source_sentence: Phường Bến Thành thuộc Thành phố nào?
sentences:
- Phường Kỳ Sơn thuộc Tỉnh Phú Thọ
- Phường Phú Thọ thuộc Tỉnh Phú Thọ
- Xã Bà Điểm thuộc Thành phố Hồ Chí Minh
- source_sentence: Phường Bình Phú thuộc Thành phố nào?
sentences:
- Xã Xuân Lộc thuộc Tỉnh Đồng Nai
- Phường An Hội thuộc Tỉnh nào?
- 'Phường Cư Bao được sáp nhập từ: Phường Bình Tân (thị xã Buôn Hồ), Xã Bình Thuận
(thị xã Buôn Hồ) và Xã Cư Bao (thị xã Buôn Hồ) vào ngày 01/07/2025'
- source_sentence: Xã Đại Đồng thuộc Tỉnh nào?
sentences:
- Phường Tam Quan thuộc Tỉnh nào?
- Phường Tân Thành thuộc Tỉnh Cà Mau
- Xã Đại Đồng thuộc Tỉnh Nghệ An
- source_sentence: Xã Thái Mỹ thuộc Thành phố nào?
sentences:
- Xã Thái Mỹ thuộc Thành phố Hồ Chí Minh
- Phường Kiến Hưng được sáp nhập từ các Phường nào?
- Phường Hà Tiên được sáp nhập từ các Phường nào?
- source_sentence: Phường Nghĩa Lộ được sáp nhập từ các Phường nào?
sentences:
- 'Xã Ngô Mây được sáp nhập từ: Xã Cát Hưng (huyện Phù Cát), Xã Cát Thắng (huyện
Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025'
- 'Xã Ngô Mây được sáp nhập từ: Xã Cát Hưng (huyện Phù Cát), Xã Cát Thắng (huyện
Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025'
- Phường Cao Lãnh được sáp nhập từ các Phường nào?
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
model-index:
- name: SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: qa similarity eval
type: qa-similarity-eval
metrics:
- type: pearson_cosine
value: 0.898329291145673
name: Pearson Cosine
- type: spearman_cosine
value: 0.8699420206459687
name: Spearman Cosine
---
# SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
## Model Details
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)
- **Maximum Sequence Length:** 256 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Normalize()
)
```
## Usage
### Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
```bash
pip install -U sentence-transformers
```
Then you can load this model and run inference.
```python
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("lmtri0312/tramy-encoder")
# Run inference
sentences = [
'Phường Nghĩa Lộ được sáp nhập từ các Phường nào?',
'Xã Ngô Mây được sáp nhập từ: Xã Cát Hưng (huyện Phù Cát), Xã Cát Thắng (huyện Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025',
'Xã Ngô Mây được sáp nhập từ: Xã Cát Hưng (huyện Phù Cát), Xã Cát Thắng (huyện Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.3627, 0.3627],
# [0.3627, 1.0000, 1.0000],
# [0.3627, 1.0000, 1.0000]])
```
## Evaluation
### Metrics
#### Semantic Similarity
* Dataset: `qa-similarity-eval`
* Evaluated with [EmbeddingSimilarityEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.8983 |
| **spearman_cosine** | **0.8699** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 1,616 training samples
* Columns: sentence_0, sentence_1, and label
* Approximate statistics based on the first 1000 samples:
| | sentence_0 | sentence_1 | label |
|:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------|
| type | string | string | float |
| details |
Phường Ayun Pa được sáp nhập từ các Phường nào? | Bão số 5 (Kajiki) diễn ra từ 00:00 24-08-2025 đến 23:59 27-08-2025, ở Thành phố Đà Nẵng | 0.1 |
| Xã Bà Điểm được sáp nhập từ các Xã nào? | Xã Bà Điểm được sáp nhập từ: Xã Xuân Thới Thượng (huyện Hóc Môn), Xã Trung Chánh (huyện Hóc Môn) và Xã Bà Điểm (huyện Hóc Môn) vào ngày 01/07/2025 | 1.0 |
| Phường An Biên được sáp nhập từ các Phường nào? | Xã Bình Mỹ được sáp nhập từ các Xã nào? | 0.7 |
* Loss: [CosineSimilarityLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
```json
{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `num_train_epochs`: 4
- `multi_dataset_batch_sampler`: round_robin
#### All Hyperparameters