Feature Extraction
sentence-transformers
Safetensors
Vietnamese
English
bert
sentence-similarity
qdrant
vietnamese
tourist-notebook
text-embeddings-inference
Instructions to use lmtri0312/tramy-encoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lmtri0312/tramy-encoder with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("lmtri0312/tramy-encoder") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Update fine-tuned tramy-encoder
Browse files- 1_Pooling/config.json +2 -7
- README.md +37 -370
- config.json +11 -6
- config_sentence_transformers.json +6 -6
- eval/similarity_evaluation_e5-vietnamese-eval_results.csv +9 -0
- model.safetensors +2 -2
- modules.json +3 -3
- sentence_bert_config.json +8 -2
- tokenizer.json +0 -0
- tokenizer_config.json +14 -63
1_Pooling/config.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"pooling_mode_mean_tokens": true,
|
| 5 |
-
"pooling_mode_max_tokens": false,
|
| 6 |
-
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
-
"pooling_mode_weightedmean_tokens": false,
|
| 8 |
-
"pooling_mode_lasttoken": false,
|
| 9 |
"include_prompt": true
|
| 10 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"embedding_dimension": 384,
|
| 3 |
+
"pooling_mode": "mean",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"include_prompt": true
|
| 5 |
}
|
README.md
CHANGED
|
@@ -1,390 +1,57 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
- sentence-transformers
|
| 4 |
-
- sentence-similarity
|
| 5 |
- feature-extraction
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
widget:
|
| 12 |
-
- source_sentence: Phường Bến Thành thuộc Thành phố nào?
|
| 13 |
-
sentences:
|
| 14 |
-
- Phường Kỳ Sơn thuộc Tỉnh Phú Thọ
|
| 15 |
-
- Phường Phú Thọ thuộc Tỉnh Phú Thọ
|
| 16 |
-
- Xã Bà Điểm thuộc Thành phố Hồ Chí Minh
|
| 17 |
-
- source_sentence: Phường Bình Phú thuộc Thành phố nào?
|
| 18 |
-
sentences:
|
| 19 |
-
- Xã Xuân Lộc thuộc Tỉnh Đồng Nai
|
| 20 |
-
- Phường An Hội thuộc Tỉnh nào?
|
| 21 |
-
- '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
|
| 22 |
-
(thị xã Buôn Hồ) và Xã Cư Bao (thị xã Buôn Hồ) vào ngày 01/07/2025'
|
| 23 |
-
- source_sentence: Xã Đại Đồng thuộc Tỉnh nào?
|
| 24 |
-
sentences:
|
| 25 |
-
- Phường Tam Quan thuộc Tỉnh nào?
|
| 26 |
-
- Phường Tân Thành thuộc Tỉnh Cà Mau
|
| 27 |
-
- Xã Đại Đồng thuộc Tỉnh Nghệ An
|
| 28 |
-
- source_sentence: Xã Thái Mỹ thuộc Thành phố nào?
|
| 29 |
-
sentences:
|
| 30 |
-
- Xã Thái Mỹ thuộc Thành phố Hồ Chí Minh
|
| 31 |
-
- Phường Kiến Hưng được sáp nhập từ các Phường nào?
|
| 32 |
-
- Phường Hà Tiên được sáp nhập từ các Phường nào?
|
| 33 |
-
- source_sentence: Phường Nghĩa Lộ được sáp nhập từ các Phường nào?
|
| 34 |
-
sentences:
|
| 35 |
-
- '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
|
| 36 |
-
Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025'
|
| 37 |
-
- '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
|
| 38 |
-
Phù Cát) và Xã Cát Chánh (huyện Phù Cát) vào ngày 01/07/2025'
|
| 39 |
-
- Phường Cao Lãnh được sáp nhập từ các Phường nào?
|
| 40 |
-
pipeline_tag: sentence-similarity
|
| 41 |
-
library_name: sentence-transformers
|
| 42 |
-
metrics:
|
| 43 |
-
- pearson_cosine
|
| 44 |
-
- spearman_cosine
|
| 45 |
-
model-index:
|
| 46 |
-
- name: SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
|
| 47 |
-
results:
|
| 48 |
-
- task:
|
| 49 |
-
type: semantic-similarity
|
| 50 |
-
name: Semantic Similarity
|
| 51 |
-
dataset:
|
| 52 |
-
name: qa similarity eval
|
| 53 |
-
type: qa-similarity-eval
|
| 54 |
-
metrics:
|
| 55 |
-
- type: pearson_cosine
|
| 56 |
-
value: 0.898329291145673
|
| 57 |
-
name: Pearson Cosine
|
| 58 |
-
- type: spearman_cosine
|
| 59 |
-
value: 0.8699420206459687
|
| 60 |
-
name: Spearman Cosine
|
| 61 |
---
|
| 62 |
|
| 63 |
-
#
|
| 64 |
|
| 65 |
-
This is a
|
| 66 |
|
| 67 |
## Model Details
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
##
|
| 70 |
-
|
| 71 |
-
- **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision c9745ed1d9f207416be6d2e6f8de32d1f16199bf -->
|
| 72 |
-
- **Maximum Sequence Length:** 256 tokens
|
| 73 |
-
- **Output Dimensionality:** 384 dimensions
|
| 74 |
-
- **Similarity Function:** Cosine Similarity
|
| 75 |
-
<!-- - **Training Dataset:** Unknown -->
|
| 76 |
-
<!-- - **Language:** Unknown -->
|
| 77 |
-
<!-- - **License:** Unknown -->
|
| 78 |
-
|
| 79 |
-
### Model Sources
|
| 80 |
-
|
| 81 |
-
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 82 |
-
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
| 83 |
-
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
``
|
| 88 |
-
|
| 89 |
-
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
|
| 90 |
-
(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})
|
| 91 |
-
(2): Normalize()
|
| 92 |
-
)
|
| 93 |
-
```
|
| 94 |
|
| 95 |
-
## Usage
|
| 96 |
|
| 97 |
-
### Direct Usage (Sentence Transformers)
|
| 98 |
-
|
| 99 |
-
First install the Sentence Transformers library:
|
| 100 |
-
|
| 101 |
-
```bash
|
| 102 |
-
pip install -U sentence-transformers
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
Then you can load this model and run inference.
|
| 106 |
```python
|
| 107 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 108 |
|
| 109 |
-
#
|
| 110 |
-
model = SentenceTransformer(
|
| 111 |
-
# Run inference
|
| 112 |
-
sentences = [
|
| 113 |
-
'Phường Nghĩa Lộ được sáp nhập từ các Phường nào?',
|
| 114 |
-
'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',
|
| 115 |
-
'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',
|
| 116 |
-
]
|
| 117 |
-
embeddings = model.encode(sentences)
|
| 118 |
-
print(embeddings.shape)
|
| 119 |
-
# [3, 384]
|
| 120 |
-
|
| 121 |
-
# Get the similarity scores for the embeddings
|
| 122 |
-
similarities = model.similarity(embeddings, embeddings)
|
| 123 |
-
print(similarities)
|
| 124 |
-
# tensor([[1.0000, 0.3627, 0.3627],
|
| 125 |
-
# [0.3627, 1.0000, 1.0000],
|
| 126 |
-
# [0.3627, 1.0000, 1.0000]])
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
<!--
|
| 130 |
-
### Direct Usage (Transformers)
|
| 131 |
-
|
| 132 |
-
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 133 |
-
|
| 134 |
-
</details>
|
| 135 |
-
-->
|
| 136 |
-
|
| 137 |
-
<!--
|
| 138 |
-
### Downstream Usage (Sentence Transformers)
|
| 139 |
-
|
| 140 |
-
You can finetune this model on your own dataset.
|
| 141 |
-
|
| 142 |
-
<details><summary>Click to expand</summary>
|
| 143 |
-
|
| 144 |
-
</details>
|
| 145 |
-
-->
|
| 146 |
-
|
| 147 |
-
<!--
|
| 148 |
-
### Out-of-Scope Use
|
| 149 |
-
|
| 150 |
-
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 151 |
-
-->
|
| 152 |
-
|
| 153 |
-
## Evaluation
|
| 154 |
-
|
| 155 |
-
### Metrics
|
| 156 |
-
|
| 157 |
-
#### Semantic Similarity
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
| **spearman_cosine** | **0.8699** |
|
| 166 |
-
|
| 167 |
-
<!--
|
| 168 |
-
## Bias, Risks and Limitations
|
| 169 |
-
|
| 170 |
-
*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
|
| 171 |
-
-->
|
| 172 |
-
|
| 173 |
-
<!--
|
| 174 |
-
### Recommendations
|
| 175 |
-
|
| 176 |
-
*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
|
| 177 |
-
-->
|
| 178 |
-
|
| 179 |
-
## Training Details
|
| 180 |
-
|
| 181 |
-
### Training Dataset
|
| 182 |
-
|
| 183 |
-
#### Unnamed Dataset
|
| 184 |
-
|
| 185 |
-
* Size: 1,616 training samples
|
| 186 |
-
* Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
|
| 187 |
-
* Approximate statistics based on the first 1000 samples:
|
| 188 |
-
| | sentence_0 | sentence_1 | label |
|
| 189 |
-
|:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 190 |
-
| type | string | string | float |
|
| 191 |
-
| details | <ul><li>min: 5 tokens</li><li>mean: 19.64 tokens</li><li>max: 48 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 41.56 tokens</li><li>max: 224 tokens</li></ul> | <ul><li>min: 0.1</li><li>mean: 0.73</li><li>max: 1.0</li></ul> |
|
| 192 |
-
* Samples:
|
| 193 |
-
| sentence_0 | sentence_1 | label |
|
| 194 |
-
|:-------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------|
|
| 195 |
-
| <code>Phường Ayun Pa được sáp nhập từ các Phường nào?</code> | <code>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</code> | <code>0.1</code> |
|
| 196 |
-
| <code>Xã Bà Điểm được sáp nhập từ các Xã nào?</code> | <code>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</code> | <code>1.0</code> |
|
| 197 |
-
| <code>Phường An Biên được sáp nhập từ các Phường nào?</code> | <code>Xã Bình Mỹ được sáp nhập từ các Xã nào?</code> | <code>0.7</code> |
|
| 198 |
-
* Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
|
| 199 |
-
```json
|
| 200 |
-
{
|
| 201 |
-
"loss_fct": "torch.nn.modules.loss.MSELoss"
|
| 202 |
-
}
|
| 203 |
-
```
|
| 204 |
-
|
| 205 |
-
### Training Hyperparameters
|
| 206 |
-
#### Non-Default Hyperparameters
|
| 207 |
-
|
| 208 |
-
- `eval_strategy`: steps
|
| 209 |
-
- `num_train_epochs`: 4
|
| 210 |
-
- `multi_dataset_batch_sampler`: round_robin
|
| 211 |
-
|
| 212 |
-
#### All Hyperparameters
|
| 213 |
-
<details><summary>Click to expand</summary>
|
| 214 |
-
|
| 215 |
-
- `overwrite_output_dir`: False
|
| 216 |
-
- `do_predict`: False
|
| 217 |
-
- `eval_strategy`: steps
|
| 218 |
-
- `prediction_loss_only`: True
|
| 219 |
-
- `per_device_train_batch_size`: 8
|
| 220 |
-
- `per_device_eval_batch_size`: 8
|
| 221 |
-
- `per_gpu_train_batch_size`: None
|
| 222 |
-
- `per_gpu_eval_batch_size`: None
|
| 223 |
-
- `gradient_accumulation_steps`: 1
|
| 224 |
-
- `eval_accumulation_steps`: None
|
| 225 |
-
- `torch_empty_cache_steps`: None
|
| 226 |
-
- `learning_rate`: 5e-05
|
| 227 |
-
- `weight_decay`: 0.0
|
| 228 |
-
- `adam_beta1`: 0.9
|
| 229 |
-
- `adam_beta2`: 0.999
|
| 230 |
-
- `adam_epsilon`: 1e-08
|
| 231 |
-
- `max_grad_norm`: 1
|
| 232 |
-
- `num_train_epochs`: 4
|
| 233 |
-
- `max_steps`: -1
|
| 234 |
-
- `lr_scheduler_type`: linear
|
| 235 |
-
- `lr_scheduler_kwargs`: {}
|
| 236 |
-
- `warmup_ratio`: 0.0
|
| 237 |
-
- `warmup_steps`: 0
|
| 238 |
-
- `log_level`: passive
|
| 239 |
-
- `log_level_replica`: warning
|
| 240 |
-
- `log_on_each_node`: True
|
| 241 |
-
- `logging_nan_inf_filter`: True
|
| 242 |
-
- `save_safetensors`: True
|
| 243 |
-
- `save_on_each_node`: False
|
| 244 |
-
- `save_only_model`: False
|
| 245 |
-
- `restore_callback_states_from_checkpoint`: False
|
| 246 |
-
- `no_cuda`: False
|
| 247 |
-
- `use_cpu`: False
|
| 248 |
-
- `use_mps_device`: False
|
| 249 |
-
- `seed`: 42
|
| 250 |
-
- `data_seed`: None
|
| 251 |
-
- `jit_mode_eval`: False
|
| 252 |
-
- `use_ipex`: False
|
| 253 |
-
- `bf16`: False
|
| 254 |
-
- `fp16`: False
|
| 255 |
-
- `fp16_opt_level`: O1
|
| 256 |
-
- `half_precision_backend`: auto
|
| 257 |
-
- `bf16_full_eval`: False
|
| 258 |
-
- `fp16_full_eval`: False
|
| 259 |
-
- `tf32`: None
|
| 260 |
-
- `local_rank`: 0
|
| 261 |
-
- `ddp_backend`: None
|
| 262 |
-
- `tpu_num_cores`: None
|
| 263 |
-
- `tpu_metrics_debug`: False
|
| 264 |
-
- `debug`: []
|
| 265 |
-
- `dataloader_drop_last`: False
|
| 266 |
-
- `dataloader_num_workers`: 0
|
| 267 |
-
- `dataloader_prefetch_factor`: None
|
| 268 |
-
- `past_index`: -1
|
| 269 |
-
- `disable_tqdm`: False
|
| 270 |
-
- `remove_unused_columns`: True
|
| 271 |
-
- `label_names`: None
|
| 272 |
-
- `load_best_model_at_end`: False
|
| 273 |
-
- `ignore_data_skip`: False
|
| 274 |
-
- `fsdp`: []
|
| 275 |
-
- `fsdp_min_num_params`: 0
|
| 276 |
-
- `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
|
| 277 |
-
- `fsdp_transformer_layer_cls_to_wrap`: None
|
| 278 |
-
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
|
| 279 |
-
- `parallelism_config`: None
|
| 280 |
-
- `deepspeed`: None
|
| 281 |
-
- `label_smoothing_factor`: 0.0
|
| 282 |
-
- `optim`: adamw_torch_fused
|
| 283 |
-
- `optim_args`: None
|
| 284 |
-
- `adafactor`: False
|
| 285 |
-
- `group_by_length`: False
|
| 286 |
-
- `length_column_name`: length
|
| 287 |
-
- `ddp_find_unused_parameters`: None
|
| 288 |
-
- `ddp_bucket_cap_mb`: None
|
| 289 |
-
- `ddp_broadcast_buffers`: False
|
| 290 |
-
- `dataloader_pin_memory`: True
|
| 291 |
-
- `dataloader_persistent_workers`: False
|
| 292 |
-
- `skip_memory_metrics`: True
|
| 293 |
-
- `use_legacy_prediction_loop`: False
|
| 294 |
-
- `push_to_hub`: False
|
| 295 |
-
- `resume_from_checkpoint`: None
|
| 296 |
-
- `hub_model_id`: None
|
| 297 |
-
- `hub_strategy`: every_save
|
| 298 |
-
- `hub_private_repo`: None
|
| 299 |
-
- `hub_always_push`: False
|
| 300 |
-
- `hub_revision`: None
|
| 301 |
-
- `gradient_checkpointing`: False
|
| 302 |
-
- `gradient_checkpointing_kwargs`: None
|
| 303 |
-
- `include_inputs_for_metrics`: False
|
| 304 |
-
- `include_for_metrics`: []
|
| 305 |
-
- `eval_do_concat_batches`: True
|
| 306 |
-
- `fp16_backend`: auto
|
| 307 |
-
- `push_to_hub_model_id`: None
|
| 308 |
-
- `push_to_hub_organization`: None
|
| 309 |
-
- `mp_parameters`:
|
| 310 |
-
- `auto_find_batch_size`: False
|
| 311 |
-
- `full_determinism`: False
|
| 312 |
-
- `torchdynamo`: None
|
| 313 |
-
- `ray_scope`: last
|
| 314 |
-
- `ddp_timeout`: 1800
|
| 315 |
-
- `torch_compile`: False
|
| 316 |
-
- `torch_compile_backend`: None
|
| 317 |
-
- `torch_compile_mode`: None
|
| 318 |
-
- `include_tokens_per_second`: False
|
| 319 |
-
- `include_num_input_tokens_seen`: False
|
| 320 |
-
- `neftune_noise_alpha`: None
|
| 321 |
-
- `optim_target_modules`: None
|
| 322 |
-
- `batch_eval_metrics`: False
|
| 323 |
-
- `eval_on_start`: False
|
| 324 |
-
- `use_liger_kernel`: False
|
| 325 |
-
- `liger_kernel_config`: None
|
| 326 |
-
- `eval_use_gather_object`: False
|
| 327 |
-
- `average_tokens_across_devices`: False
|
| 328 |
-
- `prompts`: None
|
| 329 |
-
- `batch_sampler`: batch_sampler
|
| 330 |
-
- `multi_dataset_batch_sampler`: round_robin
|
| 331 |
-
- `router_mapping`: {}
|
| 332 |
-
- `learning_rate_mapping`: {}
|
| 333 |
-
|
| 334 |
-
</details>
|
| 335 |
-
|
| 336 |
-
### Training Logs
|
| 337 |
-
| Epoch | Step | Training Loss | qa-similarity-eval_spearman_cosine |
|
| 338 |
-
|:------:|:----:|:-------------:|:----------------------------------:|
|
| 339 |
-
| 0.4950 | 100 | - | 0.8485 |
|
| 340 |
-
| 0.9901 | 200 | - | 0.8517 |
|
| 341 |
-
| 1.0 | 202 | - | 0.8517 |
|
| 342 |
-
| 1.4851 | 300 | - | 0.8654 |
|
| 343 |
-
| 1.9802 | 400 | - | 0.8693 |
|
| 344 |
-
| 2.0 | 404 | - | 0.8691 |
|
| 345 |
-
| 2.4752 | 500 | 0.0429 | 0.8699 |
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
### Framework Versions
|
| 349 |
-
- Python: 3.12.11
|
| 350 |
-
- Sentence Transformers: 5.1.0
|
| 351 |
-
- Transformers: 4.56.1
|
| 352 |
-
- PyTorch: 2.8.0+cu126
|
| 353 |
-
- Accelerate: 1.10.1
|
| 354 |
-
- Datasets: 4.0.0
|
| 355 |
-
- Tokenizers: 0.22.0
|
| 356 |
-
|
| 357 |
-
## Citation
|
| 358 |
|
| 359 |
-
#
|
|
|
|
|
|
|
| 360 |
|
| 361 |
-
#
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
| 365 |
-
author = "Reimers, Nils and Gurevych, Iryna",
|
| 366 |
-
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
| 367 |
-
month = "11",
|
| 368 |
-
year = "2019",
|
| 369 |
-
publisher = "Association for Computational Linguistics",
|
| 370 |
-
url = "https://arxiv.org/abs/1908.10084",
|
| 371 |
-
}
|
| 372 |
```
|
| 373 |
-
|
| 374 |
-
<!--
|
| 375 |
-
## Glossary
|
| 376 |
-
|
| 377 |
-
*Clearly define terms in order to be accessible across audiences.*
|
| 378 |
-
-->
|
| 379 |
-
|
| 380 |
-
<!--
|
| 381 |
-
## Model Card Authors
|
| 382 |
-
|
| 383 |
-
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 384 |
-
-->
|
| 385 |
-
|
| 386 |
-
<!--
|
| 387 |
-
## Model Card Contact
|
| 388 |
-
|
| 389 |
-
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 390 |
-
-->
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- vi
|
| 4 |
+
- en
|
| 5 |
+
license: apache-2.0
|
| 6 |
tags:
|
| 7 |
- sentence-transformers
|
|
|
|
| 8 |
- feature-extraction
|
| 9 |
+
- sentence-similarity
|
| 10 |
+
- qdrant
|
| 11 |
+
- vietnamese
|
| 12 |
+
- tourist-notebook
|
| 13 |
+
pipeline_tag: feature-extraction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# tramy-encoder
|
| 17 |
|
| 18 |
+
This is a fine-tuned **alphaedge-ai/multilingual-e5-small-vie-32768** embedding model, specially optimized for **Vietnamese Tourist & Q&A Assistant Retrieval** with vector databases such as **Qdrant**.
|
| 19 |
|
| 20 |
## Model Details
|
| 21 |
+
- **Base model**: `alphaedge-ai/multilingual-e5-small-vie-32768` (Vietnamese-trimmed vocabulary 32,768 tokens, ~137MB)
|
| 22 |
+
- **Language**: Vietnamese (vi), English (en)
|
| 23 |
+
- **Embedding dimension**: 384
|
| 24 |
+
- **Primary use case**: Asymmetric retrieval (User search queries -> Stored Instructions/Documents/Passages)
|
| 25 |
|
| 26 |
+
## ⚠️ Important Prefix Usage (E5 Architecture)
|
| 27 |
+
Because this model uses the E5 architecture, you **must prepend prefixes**:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
- **When storing in Qdrant (Documents / Instructions / Answers)**: Prepend `passage: `
|
| 30 |
+
- Example: `passage: Thông tin tuyến xe buýt ở hồ chí minh`
|
| 31 |
+
- **When searching in Qdrant (User queries)**: Prepend `query: `
|
| 32 |
+
- Example: `query: tìm tuyến xe buýt ở hồ chí minh`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
## Usage with sentence-transformers
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```python
|
| 37 |
from sentence_transformers import SentenceTransformer
|
| 38 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 39 |
|
| 40 |
+
# Load model (384 dimensions)
|
| 41 |
+
model = SentenceTransformer('lmtri0312/tramy-encoder')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
# 1. Encoding documents to store in Qdrant
|
| 44 |
+
docs = [
|
| 45 |
+
"Thông tin tuyến xe buýt ở hồ chí minh",
|
| 46 |
+
"Lịch trình du lịch Đà Lạt 3 ngày 2 đêm"
|
| 47 |
+
]
|
| 48 |
+
doc_embeddings = model.encode([f"passage: {d}" for d in docs], normalize_embeddings=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
# 2. Encoding user search query
|
| 51 |
+
query = "tìm tuyến xe buýt ở hồ chí minh"
|
| 52 |
+
query_embedding = model.encode([f"query: {query}"], normalize_embeddings=True)
|
| 53 |
|
| 54 |
+
# 3. Calculate cosine similarity
|
| 55 |
+
similarity = cosine_similarity(query_embedding, doc_embeddings)
|
| 56 |
+
print("Similarity:", similarity)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
|
@@ -1,25 +1,30 @@
|
|
| 1 |
{
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"BertModel"
|
| 4 |
],
|
| 5 |
"attention_probs_dropout_prob": 0.1,
|
|
|
|
| 6 |
"classifier_dropout": null,
|
| 7 |
"dtype": "float32",
|
| 8 |
-
"
|
| 9 |
"hidden_act": "gelu",
|
| 10 |
"hidden_dropout_prob": 0.1,
|
| 11 |
"hidden_size": 384,
|
| 12 |
"initializer_range": 0.02,
|
| 13 |
"intermediate_size": 1536,
|
|
|
|
| 14 |
"layer_norm_eps": 1e-12,
|
| 15 |
"max_position_embeddings": 512,
|
| 16 |
"model_type": "bert",
|
| 17 |
"num_attention_heads": 12,
|
| 18 |
-
"num_hidden_layers":
|
| 19 |
-
"pad_token_id":
|
| 20 |
"position_embedding_type": "absolute",
|
| 21 |
-
"
|
|
|
|
|
|
|
| 22 |
"type_vocab_size": 2,
|
| 23 |
-
"use_cache":
|
| 24 |
-
"vocab_size":
|
| 25 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
"architectures": [
|
| 4 |
"BertModel"
|
| 5 |
],
|
| 6 |
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
"classifier_dropout": null,
|
| 9 |
"dtype": "float32",
|
| 10 |
+
"eos_token_id": 2,
|
| 11 |
"hidden_act": "gelu",
|
| 12 |
"hidden_dropout_prob": 0.1,
|
| 13 |
"hidden_size": 384,
|
| 14 |
"initializer_range": 0.02,
|
| 15 |
"intermediate_size": 1536,
|
| 16 |
+
"is_decoder": false,
|
| 17 |
"layer_norm_eps": 1e-12,
|
| 18 |
"max_position_embeddings": 512,
|
| 19 |
"model_type": "bert",
|
| 20 |
"num_attention_heads": 12,
|
| 21 |
+
"num_hidden_layers": 12,
|
| 22 |
+
"pad_token_id": 1,
|
| 23 |
"position_embedding_type": "absolute",
|
| 24 |
+
"tie_word_embeddings": true,
|
| 25 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
| 26 |
+
"transformers_version": "5.13.1",
|
| 27 |
"type_vocab_size": 2,
|
| 28 |
+
"use_cache": false,
|
| 29 |
+
"vocab_size": 32768
|
| 30 |
}
|
config_sentence_transformers.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
{
|
| 2 |
"__version__": {
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
},
|
|
|
|
| 7 |
"model_type": "SentenceTransformer",
|
| 8 |
"prompts": {
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
},
|
| 12 |
-
"default_prompt_name": null,
|
| 13 |
"similarity_fn_name": "cosine"
|
| 14 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"__version__": {
|
| 3 |
+
"pytorch": "2.11.0+cu128",
|
| 4 |
+
"sentence_transformers": "5.6.0",
|
| 5 |
+
"transformers": "5.13.1"
|
| 6 |
},
|
| 7 |
+
"default_prompt_name": null,
|
| 8 |
"model_type": "SentenceTransformer",
|
| 9 |
"prompts": {
|
| 10 |
+
"document": "",
|
| 11 |
+
"query": ""
|
| 12 |
},
|
|
|
|
| 13 |
"similarity_fn_name": "cosine"
|
| 14 |
}
|
eval/similarity_evaluation_e5-vietnamese-eval_results.csv
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
epoch,steps,cosine_pearson,cosine_spearman
|
| 2 |
+
1.0,3324,0.9602423552105073,0.2795829289673402
|
| 3 |
+
2.0,6648,0.9663303369405396,0.2795882717620926
|
| 4 |
+
3.0,9972,0.9719438552530223,0.2795965265730658
|
| 5 |
+
4.0,13296,0.9709707717460083,0.2795965268328552
|
| 6 |
+
1.0,3324,0.9716069995001885,0.2795950674475349
|
| 7 |
+
2.0,6648,0.9671237949811639,0.2795873006113885
|
| 8 |
+
3.0,9972,0.9642597483991596,0.2795853599057664
|
| 9 |
+
4.0,13296,0.9685522197371857,0.2795873018217958
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bca06e721075aaf44e05cb1830d686c2e2d4dd0b58079199aadadaa60feca4b6
|
| 3 |
+
size 136912008
|
modules.json
CHANGED
|
@@ -3,18 +3,18 @@
|
|
| 3 |
"idx": 0,
|
| 4 |
"name": "0",
|
| 5 |
"path": "",
|
| 6 |
-
"type": "sentence_transformers.
|
| 7 |
},
|
| 8 |
{
|
| 9 |
"idx": 1,
|
| 10 |
"name": "1",
|
| 11 |
"path": "1_Pooling",
|
| 12 |
-
"type": "sentence_transformers.
|
| 13 |
},
|
| 14 |
{
|
| 15 |
"idx": 2,
|
| 16 |
"name": "2",
|
| 17 |
"path": "2_Normalize",
|
| 18 |
-
"type": "sentence_transformers.
|
| 19 |
}
|
| 20 |
]
|
|
|
|
| 3 |
"idx": 0,
|
| 4 |
"name": "0",
|
| 5 |
"path": "",
|
| 6 |
+
"type": "sentence_transformers.base.modules.transformer.Transformer"
|
| 7 |
},
|
| 8 |
{
|
| 9 |
"idx": 1,
|
| 10 |
"name": "1",
|
| 11 |
"path": "1_Pooling",
|
| 12 |
+
"type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
|
| 13 |
},
|
| 14 |
{
|
| 15 |
"idx": 2,
|
| 16 |
"name": "2",
|
| 17 |
"path": "2_Normalize",
|
| 18 |
+
"type": "sentence_transformers.sentence_transformer.modules.normalize.Normalize"
|
| 19 |
}
|
| 20 |
]
|
sentence_bert_config.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"transformer_task": "feature-extraction",
|
| 3 |
+
"modality_config": {
|
| 4 |
+
"text": {
|
| 5 |
+
"method": "forward",
|
| 6 |
+
"method_output_name": "last_hidden_state"
|
| 7 |
+
}
|
| 8 |
+
},
|
| 9 |
+
"module_output_name": "token_embeddings"
|
| 10 |
}
|
tokenizer.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
CHANGED
|
@@ -1,65 +1,16 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
"single_word": false,
|
| 17 |
-
"special": true
|
| 18 |
-
},
|
| 19 |
-
"101": {
|
| 20 |
-
"content": "[CLS]",
|
| 21 |
-
"lstrip": false,
|
| 22 |
-
"normalized": false,
|
| 23 |
-
"rstrip": false,
|
| 24 |
-
"single_word": false,
|
| 25 |
-
"special": true
|
| 26 |
-
},
|
| 27 |
-
"102": {
|
| 28 |
-
"content": "[SEP]",
|
| 29 |
-
"lstrip": false,
|
| 30 |
-
"normalized": false,
|
| 31 |
-
"rstrip": false,
|
| 32 |
-
"single_word": false,
|
| 33 |
-
"special": true
|
| 34 |
-
},
|
| 35 |
-
"103": {
|
| 36 |
-
"content": "[MASK]",
|
| 37 |
-
"lstrip": false,
|
| 38 |
-
"normalized": false,
|
| 39 |
-
"rstrip": false,
|
| 40 |
-
"single_word": false,
|
| 41 |
-
"special": true
|
| 42 |
-
}
|
| 43 |
-
},
|
| 44 |
-
"clean_up_tokenization_spaces": false,
|
| 45 |
-
"cls_token": "[CLS]",
|
| 46 |
-
"do_basic_tokenize": true,
|
| 47 |
-
"do_lower_case": true,
|
| 48 |
-
"extra_special_tokens": {},
|
| 49 |
-
"mask_token": "[MASK]",
|
| 50 |
-
"max_length": 128,
|
| 51 |
-
"model_max_length": 256,
|
| 52 |
-
"never_split": null,
|
| 53 |
-
"pad_to_multiple_of": null,
|
| 54 |
-
"pad_token": "[PAD]",
|
| 55 |
-
"pad_token_type_id": 0,
|
| 56 |
-
"padding_side": "right",
|
| 57 |
-
"sep_token": "[SEP]",
|
| 58 |
-
"stride": 0,
|
| 59 |
-
"strip_accents": null,
|
| 60 |
-
"tokenize_chinese_chars": true,
|
| 61 |
-
"tokenizer_class": "BertTokenizer",
|
| 62 |
-
"truncation_side": "right",
|
| 63 |
-
"truncation_strategy": "longest_first",
|
| 64 |
-
"unk_token": "[UNK]"
|
| 65 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<s>",
|
| 4 |
+
"clean_up_tokenization_spaces": true,
|
| 5 |
+
"cls_token": "<s>",
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"is_local": false,
|
| 8 |
+
"local_files_only": false,
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"model_max_length": 512,
|
| 11 |
+
"pad_token": "<pad>",
|
| 12 |
+
"sep_token": "</s>",
|
| 13 |
+
"sp_model_kwargs": {},
|
| 14 |
+
"tokenizer_class": "TokenizersBackend",
|
| 15 |
+
"unk_token": "<unk>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|