BGE base SQL Matryoshka
This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5 on the json dataset. It maps sentences & paragraphs to a 768-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: BAAI/bge-base-en-v1.5
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- json
- Language: en
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("dat-ai/bge-base-for_text2sql")
# Run inference
sentences = [
'\n Given the Column informations, generate an SQL query for the following question:\n Column: Nomination | Actors Name | Film Name | Director | Country\n Question: What was the film Falling up nominated for?\n SQL Query: SELECT Nomination FROM table WHERE Film Name = Falling Up\n ',
'What was the film Falling up nominated for?',
'Who wrote an episode watched by 19.01 million US viewers?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Information Retrieval
- Datasets:
dim_768
,dim_512
,dim_256
,dim_128
anddim_64
- Evaluated with
InformationRetrievalEvaluator
Metric | dim_768 | dim_512 | dim_256 | dim_128 | dim_64 |
---|---|---|---|---|---|
cosine_accuracy@1 | 0.4676 | 0.4678 | 0.4675 | 0.4677 | 0.4678 |
cosine_accuracy@3 | 0.4697 | 0.4697 | 0.4697 | 0.4696 | 0.4696 |
cosine_accuracy@5 | 0.4697 | 0.4697 | 0.4697 | 0.4698 | 0.4696 |
cosine_accuracy@10 | 0.4697 | 0.4697 | 0.4698 | 0.4698 | 0.4697 |
cosine_precision@1 | 0.4676 | 0.4678 | 0.4675 | 0.4677 | 0.4678 |
cosine_precision@3 | 0.1566 | 0.1566 | 0.1566 | 0.1565 | 0.1565 |
cosine_precision@5 | 0.0939 | 0.0939 | 0.0939 | 0.094 | 0.0939 |
cosine_precision@10 | 0.047 | 0.047 | 0.047 | 0.047 | 0.047 |
cosine_recall@1 | 0.4676 | 0.4678 | 0.4675 | 0.4677 | 0.4678 |
cosine_recall@3 | 0.4697 | 0.4697 | 0.4697 | 0.4696 | 0.4696 |
cosine_recall@5 | 0.4697 | 0.4697 | 0.4697 | 0.4698 | 0.4696 |
cosine_recall@10 | 0.4697 | 0.4697 | 0.4698 | 0.4698 | 0.4697 |
cosine_ndcg@10 | 0.4689 | 0.469 | 0.4689 | 0.4689 | 0.469 |
cosine_mrr@10 | 0.4686 | 0.4687 | 0.4686 | 0.4687 | 0.4687 |
cosine_map@100 | 0.4686 | 0.4687 | 0.4686 | 0.4687 | 0.4687 |
Training Details
Training Dataset
json
- Dataset: json
- Size: 56,355 training samples
- Columns:
context
andquestion
- Approximate statistics based on the first 1000 samples:
context question type string string details - min: 45 tokens
- mean: 72.61 tokens
- max: 196 tokens
- min: 7 tokens
- mean: 15.41 tokens
- max: 36 tokens
- Samples:
context question
Given the Column informations, generate an SQL query for the following question:
Column: State/territoryText/background colour
Given the Column informations, generate an SQL query for the following question:
Column: State/territoryText/background colour
Given the Column informations, generate an SQL query for the following question:
Column: State/territoryText/background colour - Loss:
MatryoshkaLoss
with these parameters:{ "loss": "MultipleNegativesRankingLoss", "matryoshka_dims": [ 768, 512 ], "matryoshka_weights": [ 1, 1 ], "n_dims_per_step": -1 }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: epochper_device_train_batch_size
: 16gradient_accumulation_steps
: 8learning_rate
: 2e-05num_train_epochs
: 4lr_scheduler_type
: cosinewarmup_ratio
: 0.1fp16
: Trueload_best_model_at_end
: Trueoptim
: adamw_torch_fusedbatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: epochprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 8per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 8eval_accumulation_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 4max_steps
: -1lr_scheduler_type
: cosinelr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 42data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Falsefp16
: Truefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 0dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Trueignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torch_fusedoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Falsehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseeval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Nonedispatch_batches
: Nonesplit_batches
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseprompts
: Nonebatch_sampler
: no_duplicatesmulti_dataset_batch_sampler
: proportional
Training Logs
Click to expand
Epoch | Step | Training Loss | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
---|---|---|---|---|---|---|---|
0.0227 | 10 | 1.773 | - | - | - | - | - |
0.0454 | 20 | 1.3231 | - | - | - | - | - |
0.0681 | 30 | 0.713 | - | - | - | - | - |
0.0908 | 40 | 0.286 | - | - | - | - | - |
0.1135 | 50 | 0.1013 | - | - | - | - | - |
0.1362 | 60 | 0.0635 | - | - | - | - | - |
0.1590 | 70 | 0.0453 | - | - | - | - | - |
0.1817 | 80 | 0.041 | - | - | - | - | - |
0.2044 | 90 | 0.039 | - | - | - | - | - |
0.2271 | 100 | 0.027 | - | - | - | - | - |
0.2498 | 110 | 0.0193 | - | - | - | - | - |
0.2725 | 120 | 0.0167 | - | - | - | - | - |
0.2952 | 130 | 0.016 | - | - | - | - | - |
0.3179 | 140 | 0.0197 | - | - | - | - | - |
0.3406 | 150 | 0.0217 | - | - | - | - | - |
0.3633 | 160 | 0.0162 | - | - | - | - | - |
0.3860 | 170 | 0.012 | - | - | - | - | - |
0.4087 | 180 | 0.013 | - | - | - | - | - |
0.4315 | 190 | 0.0255 | - | - | - | - | - |
0.4542 | 200 | 0.0229 | - | - | - | - | - |
0.4769 | 210 | 0.0181 | - | - | - | - | - |
0.4996 | 220 | 0.0195 | - | - | - | - | - |
0.5223 | 230 | 0.0199 | - | - | - | - | - |
0.5450 | 240 | 0.0144 | - | - | - | - | - |
0.5677 | 250 | 0.0102 | - | - | - | - | - |
0.5904 | 260 | 0.0101 | - | - | - | - | - |
0.6131 | 270 | 0.0095 | - | - | - | - | - |
0.6358 | 280 | 0.0173 | - | - | - | - | - |
0.6585 | 290 | 0.01 | - | - | - | - | - |
0.6812 | 300 | 0.0129 | - | - | - | - | - |
0.7039 | 310 | 0.0177 | - | - | - | - | - |
0.7267 | 320 | 0.0106 | - | - | - | - | - |
0.7494 | 330 | 0.0146 | - | - | - | - | - |
0.7721 | 340 | 0.0185 | - | - | - | - | - |
0.7948 | 350 | 0.0203 | - | - | - | - | - |
0.8175 | 360 | 0.0146 | - | - | - | - | - |
0.8402 | 370 | 0.0072 | - | - | - | - | - |
0.8629 | 380 | 0.0102 | - | - | - | - | - |
0.8856 | 390 | 0.0075 | - | - | - | - | - |
0.9083 | 400 | 0.0064 | - | - | - | - | - |
0.9310 | 410 | 0.0163 | - | - | - | - | - |
0.9537 | 420 | 0.0069 | - | - | - | - | - |
0.9764 | 430 | 0.0072 | - | - | - | - | - |
0.9991 | 440 | 0.0147 | 0.4688 | 0.4689 | 0.4688 | 0.4689 | 0.4689 |
1.0219 | 450 | 0.0151 | - | - | - | - | - |
1.0446 | 460 | 0.0135 | - | - | - | - | - |
1.0673 | 470 | 0.0189 | - | - | - | - | - |
1.0900 | 480 | 0.0121 | - | - | - | - | - |
1.1127 | 490 | 0.0064 | - | - | - | - | - |
1.1354 | 500 | 0.0111 | - | - | - | - | - |
1.1581 | 510 | 0.0103 | - | - | - | - | - |
1.1808 | 520 | 0.0144 | - | - | - | - | - |
1.2035 | 530 | 0.0151 | - | - | - | - | - |
1.2262 | 540 | 0.0062 | - | - | - | - | - |
1.2489 | 550 | 0.0104 | - | - | - | - | - |
1.2716 | 560 | 0.0046 | - | - | - | - | - |
1.2944 | 570 | 0.0056 | - | - | - | - | - |
1.3171 | 580 | 0.0073 | - | - | - | - | - |
1.3398 | 590 | 0.007 | - | - | - | - | - |
1.3625 | 600 | 0.0074 | - | - | - | - | - |
1.3852 | 610 | 0.0057 | - | - | - | - | - |
1.4079 | 620 | 0.0052 | - | - | - | - | - |
1.4306 | 630 | 0.0114 | - | - | - | - | - |
1.4533 | 640 | 0.0075 | - | - | - | - | - |
1.4760 | 650 | 0.0116 | - | - | - | - | - |
1.4987 | 660 | 0.0092 | - | - | - | - | - |
1.5214 | 670 | 0.0137 | - | - | - | - | - |
1.5441 | 680 | 0.0066 | - | - | - | - | - |
1.5668 | 690 | 0.0042 | - | - | - | - | - |
1.5896 | 700 | 0.0036 | - | - | - | - | - |
1.6123 | 710 | 0.0039 | - | - | - | - | - |
1.6350 | 720 | 0.0065 | - | - | - | - | - |
1.6577 | 730 | 0.0051 | - | - | - | - | - |
1.6804 | 740 | 0.0054 | - | - | - | - | - |
1.7031 | 750 | 0.0086 | - | - | - | - | - |
1.7258 | 760 | 0.0062 | - | - | - | - | - |
1.7485 | 770 | 0.0071 | - | - | - | - | - |
1.7712 | 780 | 0.0108 | - | - | - | - | - |
1.7939 | 790 | 0.009 | - | - | - | - | - |
1.8166 | 800 | 0.0075 | - | - | - | - | - |
1.8393 | 810 | 0.0039 | - | - | - | - | - |
1.8620 | 820 | 0.0047 | - | - | - | - | - |
1.8848 | 830 | 0.0037 | - | - | - | - | - |
1.9075 | 840 | 0.0037 | - | - | - | - | - |
1.9302 | 850 | 0.0064 | - | - | - | - | - |
1.9529 | 860 | 0.0047 | - | - | - | - | - |
1.9756 | 870 | 0.0034 | - | - | - | - | - |
1.9983 | 880 | 0.0061 | 0.4689 | 0.4689 | 0.4689 | 0.4690 | 0.4690 |
2.0210 | 890 | 0.0096 | - | - | - | - | - |
2.0437 | 900 | 0.0071 | - | - | - | - | - |
2.0664 | 910 | 0.0101 | - | - | - | - | - |
2.0891 | 920 | 0.0054 | - | - | - | - | - |
2.1118 | 930 | 0.0039 | - | - | - | - | - |
2.1345 | 940 | 0.0074 | - | - | - | - | - |
2.1573 | 950 | 0.0044 | - | - | - | - | - |
2.1800 | 960 | 0.0088 | - | - | - | - | - |
2.2027 | 970 | 0.0096 | - | - | - | - | - |
2.2254 | 980 | 0.0057 | - | - | - | - | - |
2.2481 | 990 | 0.0063 | - | - | - | - | - |
2.2708 | 1000 | 0.0026 | - | - | - | - | - |
2.2935 | 1010 | 0.0032 | - | - | - | - | - |
2.3162 | 1020 | 0.0027 | - | - | - | - | - |
2.3389 | 1030 | 0.0041 | - | - | - | - | - |
2.3616 | 1040 | 0.0052 | - | - | - | - | - |
2.3843 | 1050 | 0.0035 | - | - | - | - | - |
2.4070 | 1060 | 0.0025 | - | - | - | - | - |
2.4297 | 1070 | 0.0059 | - | - | - | - | - |
2.4525 | 1080 | 0.0048 | - | - | - | - | - |
2.4752 | 1090 | 0.0064 | - | - | - | - | - |
2.4979 | 1100 | 0.0066 | - | - | - | - | - |
2.5206 | 1110 | 0.0078 | - | - | - | - | - |
2.5433 | 1120 | 0.0057 | - | - | - | - | - |
2.5660 | 1130 | 0.0026 | - | - | - | - | - |
2.5887 | 1140 | 0.0021 | - | - | - | - | - |
2.6114 | 1150 | 0.0021 | - | - | - | - | - |
2.6341 | 1160 | 0.0047 | - | - | - | - | - |
2.6568 | 1170 | 0.0034 | - | - | - | - | - |
2.6795 | 1180 | 0.0044 | - | - | - | - | - |
2.7022 | 1190 | 0.0058 | - | - | - | - | - |
2.7250 | 1200 | 0.0043 | - | - | - | - | - |
2.7477 | 1210 | 0.0056 | - | - | - | - | - |
2.7704 | 1220 | 0.0076 | - | - | - | - | - |
2.7931 | 1230 | 0.0063 | - | - | - | - | - |
2.8158 | 1240 | 0.0033 | - | - | - | - | - |
2.8385 | 1250 | 0.0025 | - | - | - | - | - |
2.8612 | 1260 | 0.0019 | - | - | - | - | - |
2.8839 | 1270 | 0.0052 | - | - | - | - | - |
2.9066 | 1280 | 0.0021 | - | - | - | - | - |
2.9293 | 1290 | 0.0041 | - | - | - | - | - |
2.9520 | 1300 | 0.0035 | - | - | - | - | - |
2.9747 | 1310 | 0.0044 | - | - | - | - | - |
2.9974 | 1320 | 0.0035 | - | - | - | - | - |
2.9997 | 1321 | - | 0.469 | 0.469 | 0.469 | 0.469 | 0.469 |
3.0202 | 1330 | 0.0062 | - | - | - | - | - |
3.0429 | 1340 | 0.0047 | - | - | - | - | - |
3.0656 | 1350 | 0.008 | - | - | - | - | - |
3.0883 | 1360 | 0.0033 | - | - | - | - | - |
3.1110 | 1370 | 0.0025 | - | - | - | - | - |
3.1337 | 1380 | 0.0069 | - | - | - | - | - |
3.1564 | 1390 | 0.0035 | - | - | - | - | - |
3.1791 | 1400 | 0.0085 | - | - | - | - | - |
3.2018 | 1410 | 0.007 | - | - | - | - | - |
3.2245 | 1420 | 0.007 | - | - | - | - | - |
3.2472 | 1430 | 0.0052 | - | - | - | - | - |
3.2699 | 1440 | 0.0019 | - | - | - | - | - |
3.2926 | 1450 | 0.0022 | - | - | - | - | - |
3.3154 | 1460 | 0.0019 | - | - | - | - | - |
3.3381 | 1470 | 0.0028 | - | - | - | - | - |
3.3608 | 1480 | 0.0042 | - | - | - | - | - |
3.3835 | 1490 | 0.0023 | - | - | - | - | - |
3.4062 | 1500 | 0.0024 | - | - | - | - | - |
3.4289 | 1510 | 0.0036 | - | - | - | - | - |
3.4516 | 1520 | 0.0038 | - | - | - | - | - |
3.4743 | 1530 | 0.0063 | - | - | - | - | - |
3.4970 | 1540 | 0.0044 | - | - | - | - | - |
3.5197 | 1550 | 0.0064 | - | - | - | - | - |
3.5424 | 1560 | 0.0053 | - | - | - | - | - |
3.5651 | 1570 | 0.0019 | - | - | - | - | - |
3.5879 | 1580 | 0.0019 | - | - | - | - | - |
3.6106 | 1590 | 0.0017 | - | - | - | - | - |
3.6333 | 1600 | 0.004 | - | - | - | - | - |
3.6560 | 1610 | 0.0026 | - | - | - | - | - |
3.6787 | 1620 | 0.0031 | - | - | - | - | - |
3.7014 | 1630 | 0.0043 | - | - | - | - | - |
3.7241 | 1640 | 0.0032 | - | - | - | - | - |
3.7468 | 1650 | 0.0041 | - | - | - | - | - |
3.7695 | 1660 | 0.0069 | - | - | - | - | - |
3.7922 | 1670 | 0.0063 | - | - | - | - | - |
3.8149 | 1680 | 0.0038 | - | - | - | - | - |
3.8376 | 1690 | 0.0024 | - | - | - | - | - |
3.8603 | 1700 | 0.0018 | - | - | - | - | - |
3.8831 | 1710 | 0.0034 | - | - | - | - | - |
3.9058 | 1720 | 0.0016 | - | - | - | - | - |
3.9285 | 1730 | 0.0026 | - | - | - | - | - |
3.9512 | 1740 | 0.0037 | - | - | - | - | - |
3.9739 | 1750 | 0.0024 | - | - | - | - | - |
3.9966 | 1760 | 0.0027 | 0.4689 | 0.4690 | 0.4689 | 0.4689 | 0.4690 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.10.14
- Sentence Transformers: 3.3.0
- Transformers: 4.41.2
- PyTorch: 2.1.2+cu121
- Accelerate: 0.34.2
- Datasets: 2.19.1
- Tokenizers: 0.19.1
Citation
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
- Downloads last month
- 6
Inference Providers
NEW
This model is not currently available via any of the supported Inference Providers.
Model tree for dat-ai/bge-base-for_text2sql
Base model
BAAI/bge-base-en-v1.5Evaluation results
- Cosine Accuracy@1 on dim 768self-reported0.468
- Cosine Accuracy@3 on dim 768self-reported0.470
- Cosine Accuracy@5 on dim 768self-reported0.470
- Cosine Accuracy@10 on dim 768self-reported0.470
- Cosine Precision@1 on dim 768self-reported0.468
- Cosine Precision@3 on dim 768self-reported0.157
- Cosine Precision@5 on dim 768self-reported0.094
- Cosine Precision@10 on dim 768self-reported0.047
- Cosine Recall@1 on dim 768self-reported0.468
- Cosine Recall@3 on dim 768self-reported0.470