---
base_model: BAAI/bge-base-en-v1.5
language:
- en
library_name: sentence-transformers
license: apache-2.0
metrics:
- cosine_accuracy@1
- cosine_accuracy@3
- cosine_accuracy@5
- cosine_accuracy@10
- cosine_precision@1
- cosine_precision@3
- cosine_precision@5
- cosine_precision@10
- cosine_recall@1
- cosine_recall@3
- cosine_recall@5
- cosine_recall@10
- cosine_ndcg@10
- cosine_mrr@10
- cosine_map@100
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:56355
- loss:MatryoshkaLoss
- loss:MultipleNegativesRankingLoss
widget:
- source_sentence: "\n Given the Column informations, generate an SQL query for\
\ the following question:\n Column: Finishing position | Points awarded (Platinum)\
\ | Points awarded (Gold) | Points awarded (Silver) | Points awarded (Satellite)\n\
\ Question: How many platinum points were awarded when 6 gold points were awarded?\n\
\ SQL Query: SELECT MAX Points awarded (Platinum) FROM table WHERE Points awarded\
\ (Gold) = 6\n "
sentences:
- How many platinum points were awarded when 6 gold points were awarded?
- Did any team score games that totaled up to 860.5?
- Who had the pole position at the German Grand Prix?
- source_sentence: "\n Given the Column informations, generate an SQL query for\
\ the following question:\n Column: Player | No. | Nationality | Position | Years\
\ in Toronto | School/Club Team\n Question: What's Dell Curry nationality?\n\
\ SQL Query: SELECT Nationality FROM table WHERE Player = Dell Curry\n "
sentences:
- What is the title when original air date is may15,2008?
- What's Dell Curry nationality?
- What's the minimum total attendance of the Premier League association football?
- source_sentence: "\n Given the Column informations, generate an SQL query for\
\ the following question:\n Column: Sepal length | Sepal width | Petal length\
\ | Petal width | Species\n Question: Name the species when petal width is 2.0\
\ and petal length is 4.9\n SQL Query: SELECT Species FROM table WHERE Petal\
\ width = 2.0 AND Petal length = 4.9\n "
sentences:
- What year was the championship in Wimbledon (2)?
- Who wrote Series 38?
- Name the species when petal width is 2.0 and petal length is 4.9
- source_sentence: "\n Given the Column informations, generate an SQL query for\
\ the following question:\n Column: No. in season | No. in series | Title | Directed\
\ by | Written by | Original air date | U.S. viewers (million)\n Question: How\
\ many millions of U.S. viewers watched the episode that first aired on March\
\ 31, 2013?\n SQL Query: SELECT U.S. viewers (million) FROM table WHERE Original\
\ air date = March 31, 2013\n "
sentences:
- How many millions of U.S. viewers watched the episode that first aired on March
31, 2013?
- How many viewers were there for the premier with 34
- What is Bruce Cerone overall?
- source_sentence: "\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 "
sentences:
- What was the film Falling up nominated for?
- Who wrote an episode watched by 19.01 million US viewers?
- What player is on the Montreal Alouettes CFl team?
model-index:
- name: BGE base SQL Matryoshka
results:
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 768
type: dim_768
metrics:
- type: cosine_accuracy@1
value: 0.4676281647562665
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.4697065121551833
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.4697065121551833
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.4697065121551833
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.4676281647562665
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.15656883738506108
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.09394130243103667
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.046970651215518334
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.4676281647562665
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.4697065121551833
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.4697065121551833
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.4697065121551833
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.46889822604232273
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.4686148549355503
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.4686406337350657
name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 512
type: dim_512
metrics:
- type: cosine_accuracy@1
value: 0.46775412520468573
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.4697065121551833
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.4697065121551833
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.4697065121551833
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.46775412520468573
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.15656883738506108
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.09394130243103667
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.046970651215518334
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.46775412520468573
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.4697065121551833
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.4697065121551833
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.4697065121551833
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.4689612062665323
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.46869882856782963
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.4687237988187482
name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 256
type: dim_256
metrics:
- type: cosine_accuracy@1
value: 0.46750220430784734
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.4697065121551833
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.4697065121551833
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.46976949237939286
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.46750220430784734
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.15656883738506108
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.09394130243103667
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.04697694923793929
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.46750220430784734
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.4697065121551833
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.4697065121551833
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.46976949237939286
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.4688906637675648
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.4685833648234455
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.468602927990512
name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 128
type: dim_128
metrics:
- type: cosine_accuracy@1
value: 0.46769114498047615
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.4696435319309737
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.46976949237939286
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.46976949237939286
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.46769114498047615
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.1565478439769912
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.09395389847587858
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.04697694923793929
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.46769114498047615
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.4696435319309737
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.46976949237939286
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.46976949237939286
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.4689469541953942
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.468661040433304
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.4686773555936371
name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: dim 64
type: dim_64
metrics:
- type: cosine_accuracy@1
value: 0.46775412520468573
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.4696435319309737
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.4696435319309737
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.4697065121551833
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.46775412520468573
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.1565478439769912
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.09392870638619474
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.046970651215518334
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.46775412520468573
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.4696435319309737
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.4696435319309737
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.4697065121551833
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.4689578301883334
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.468696204391821
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.46870770760703784
name: Cosine Map@100
---
# BGE base SQL Matryoshka
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [BAAI/bge-base-en-v1.5](https://huggingface.co/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](https://huggingface.co/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](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': 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:
```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("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` and `dim_64`
* Evaluated with [InformationRetrievalEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.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
and question
* Approximate statistics based on the first 1000 samples:
| | context | question |
|:--------|:------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string |
| details |
Given the Column informations, generate an SQL query for the following question:
Column: State/territory | Text/background colour | Format | Current slogan | Current series | Notes
Question: Tell me what the notes are for South Australia
SQL Query: SELECT Notes FROM table WHERE Current slogan = SOUTH AUSTRALIA
| Tell me what the notes are for South Australia
|
|
Given the Column informations, generate an SQL query for the following question:
Column: State/territory | Text/background colour | Format | Current slogan | Current series | Notes
Question: What is the current series where the new series began in June 2011?
SQL Query: SELECT Current series FROM table WHERE Notes = New series began in June 2011
| What is the current series where the new series began in June 2011?
|
|
Given the Column informations, generate an SQL query for the following question:
Column: State/territory | Text/background colour | Format | Current slogan | Current series | Notes
Question: What is the format for South Australia?
SQL Query: SELECT Format FROM table WHERE State/territory = South Australia
| What is the format for South Australia?
|
* Loss: [MatryoshkaLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#matryoshkaloss) with these parameters:
```json
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512
],
"matryoshka_weights": [
1,
1
],
"n_dims_per_step": -1
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: epoch
- `per_device_train_batch_size`: 16
- `gradient_accumulation_steps`: 8
- `learning_rate`: 2e-05
- `num_train_epochs`: 4
- `lr_scheduler_type`: cosine
- `warmup_ratio`: 0.1
- `fp16`: True
- `load_best_model_at_end`: True
- `optim`: adamw_torch_fused
- `batch_sampler`: no_duplicates
#### All Hyperparameters