---
language:
- en
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
- generated_from_trainer
- dataset_size:2699
- loss:CachedMultipleNegativesRankingLoss
base_model: google/embeddinggemma-300m
widget:
- source_sentence: For a conventional conforming loan, what are the common down payment
amounts?
sentences:
- fannie_mae_selling_guide_chunk_001
- fannie_mae_selling_guide
- Standard down payment options for a conventional conforming loan range from 3
to 20 of the purchase price.
- source_sentence: How is the cash required for mortgage reserves confirmed by a lender?
sentences:
- freddie_mac_guide
- Lenders verify assets by requiring two months of consecutive statements for all
checking, savings, and investment accounts.
- freddie_mac_guide_chunk_017
- source_sentence: What are the different types of mortgage rate locks available to
borrowers?
sentences:
- freddie_mac_guide
- Common rate locks include a 30-day lock, a 45-day lock, and a 60-day lock, with
longer locks sometimes incurring a small fee.
- freddie_mac_guide_chunk_014
- source_sentence: How do lenders verify a borrowers assets for reserves?
sentences:
- va_chapter2_eligibility_chunk_001
- Lenders verify assets by obtaining the two most recent monthly statements for
all checking, savings, and investment accounts, ensuring the funds have been sourced
and seasoned.
- va_chapter2_eligibility
- source_sentence: When is a borrower eligible for a streamline refinance?
sentences:
- A borrower is eligible for a streamline refinance if they have made at least six
consecutive on-time payments on their current mortgage.
- fha_handbook_4000_1
- fha_handbook_4000_1_chunk_007
datasets:
- sugiv/mortgage-qa-dataset
pipeline_tag: sentence-similarity
library_name: sentence-transformers
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
model-index:
- name: SentenceTransformer based on google/embeddinggemma-300m
results:
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: mortgage eval
type: mortgage-eval
metrics:
- type: cosine_accuracy@1
value: 0.34421364985163205
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.6468842729970327
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.7863501483679525
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.9317507418397626
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.34421364985163205
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.21562809099901084
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.1572700296735905
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.09317507418397623
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.34421364985163205
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.6468842729970327
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.7863501483679525
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.9317507418397626
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.620931422633939
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.5233208515849467
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.5285370057494337
name: Cosine Map@100
- task:
type: information-retrieval
name: Information Retrieval
dataset:
name: mortgage test
type: mortgage-test
metrics:
- type: cosine_accuracy@1
value: 0.2781065088757396
name: Cosine Accuracy@1
- type: cosine_accuracy@3
value: 0.5621301775147929
name: Cosine Accuracy@3
- type: cosine_accuracy@5
value: 0.7100591715976331
name: Cosine Accuracy@5
- type: cosine_accuracy@10
value: 0.8727810650887574
name: Cosine Accuracy@10
- type: cosine_precision@1
value: 0.2781065088757396
name: Cosine Precision@1
- type: cosine_precision@3
value: 0.18737672583826429
name: Cosine Precision@3
- type: cosine_precision@5
value: 0.14201183431952663
name: Cosine Precision@5
- type: cosine_precision@10
value: 0.08727810650887573
name: Cosine Precision@10
- type: cosine_recall@1
value: 0.2781065088757396
name: Cosine Recall@1
- type: cosine_recall@3
value: 0.5621301775147929
name: Cosine Recall@3
- type: cosine_recall@5
value: 0.7100591715976331
name: Cosine Recall@5
- type: cosine_recall@10
value: 0.8727810650887574
name: Cosine Recall@10
- type: cosine_ndcg@10
value: 0.553056381202397
name: Cosine Ndcg@10
- type: cosine_mrr@10
value: 0.4530313703390625
name: Cosine Mrr@10
- type: cosine_map@100
value: 0.46216201514766103
name: Cosine Map@100
---
# SentenceTransformer based on google/embeddinggemma-300m
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [google/embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m) on the [mortgage-qa-dataset](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset) 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:** [google/embeddinggemma-300m](https://huggingface.co/google/embeddinggemma-300m)
- **Maximum Sequence Length:** 2048 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- [mortgage-qa-dataset](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset)
- **Language:** en
### 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': 2048, 'do_lower_case': False, 'architecture': 'Gemma3TextModel'})
(1): Pooling({'word_embedding_dimension': 768, '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): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(4): 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("sugiv/embeddinggemma-300m-mortgage")
# Run inference
queries = [
"When is a borrower eligible for a streamline refinance?",
]
documents = [
'A borrower is eligible for a streamline refinance if they have made at least six consecutive on-time payments on their current mortgage.',
'fha_handbook_4000_1',
'fha_handbook_4000_1_chunk_007',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[ 0.8276, -0.0791, -0.0792]])
```
## Evaluation
### Metrics
#### Information Retrieval
* Datasets: `mortgage-eval` and `mortgage-test`
* Evaluated with [InformationRetrievalEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator)
| Metric | mortgage-eval | mortgage-test |
|:--------------------|:--------------|:--------------|
| cosine_accuracy@1 | 0.3442 | 0.2781 |
| cosine_accuracy@3 | 0.6469 | 0.5621 |
| cosine_accuracy@5 | 0.7864 | 0.7101 |
| cosine_accuracy@10 | 0.9318 | 0.8728 |
| cosine_precision@1 | 0.3442 | 0.2781 |
| cosine_precision@3 | 0.2156 | 0.1874 |
| cosine_precision@5 | 0.1573 | 0.142 |
| cosine_precision@10 | 0.0932 | 0.0873 |
| cosine_recall@1 | 0.3442 | 0.2781 |
| cosine_recall@3 | 0.6469 | 0.5621 |
| cosine_recall@5 | 0.7864 | 0.7101 |
| cosine_recall@10 | 0.9318 | 0.8728 |
| **cosine_ndcg@10** | **0.6209** | **0.5531** |
| cosine_mrr@10 | 0.5233 | 0.453 |
| cosine_map@100 | 0.5285 | 0.4622 |
## Training Details
### Training Dataset
#### mortgage-qa-dataset
* Dataset: [mortgage-qa-dataset](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset) at [de29792](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset/tree/de297929404e24bbfaa5909430b0d325e76419cf)
* Size: 2,699 training samples
* Columns: question, answer, source_document, and source_chunk
* Approximate statistics based on the first 1000 samples:
| | question | answer | source_document | source_chunk |
|:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
| type | string | string | string | string |
| details |
When is a full appraisal required for a mortgage application? | A full appraisal is required for most transactions, but it can be waived for certain streamlined refinance programs if the Loan-to-Value LTV ratio is 90 or less. | fha_handbook_4000_1 | fha_handbook_4000_1_chunk_005 |
| When getting a mortgage, who orders the title insurance for the lender? | While often coordinated by the settlement agent, the lender typically requires and is the ultimate recipient of the lenders title insurance policy to protect their financial interest. | va_chapter4_underwriting | va_chapter4_underwriting_chunk_012 |
| What components of a loan application does an underwriter assess? | Underwriters analyze the four Cs of credit: Capacity income and DTI, Capital assets and reserves, Collateral property value, and Credit credit history and score. | va_chapter5_processing | va_chapter5_processing_chunk_005 |
* Loss: [CachedMultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cachedmultiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false
}
```
### Evaluation Dataset
#### mortgage-qa-dataset
* Dataset: [mortgage-qa-dataset](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset) at [de29792](https://huggingface.co/datasets/sugiv/mortgage-qa-dataset/tree/de297929404e24bbfaa5909430b0d325e76419cf)
* Size: 337 evaluation samples
* Columns: question, answer, source_document, and source_chunk
* Approximate statistics based on the first 337 samples:
| | question | answer | source_document | source_chunk |
|:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
| type | string | string | string | string |
| details | What financial metrics are crucial for an AUS to issue an approval? | Key AUS factors include credit score, loan-to-value ratio, debt-to-income ratio, and the overall strength and stability of the borrowers financial profile. | va_chapter4_underwriting | va_chapter4_underwriting_chunk_017 |
| Can you explain how an LTV ratio is figured out? | The LTV ratio is calculated by dividing the mortgage loan amount by the appraised value or purchase price of the property, whichever is lower. | fannie_mae_servicing_guide | fannie_mae_servicing_guide_chunk_002 |
| How do lenders verify a borrowers employment history? | Lenders verify employment by contacting employers directly and typically require a two-year history, which may be confirmed via recent pay stubs and W-2 forms. | freddie_mac_guide | freddie_mac_guide_chunk_002 |
* Loss: [CachedMultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cachedmultiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"mini_batch_size": 32,
"gather_across_devices": false
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `learning_rate`: 3e-06
- `num_train_epochs`: 4
- `warmup_steps`: 100
- `fp16`: True
- `load_best_model_at_end`: True
- `batch_sampler`: no_duplicates
#### All Hyperparameters