CoolFace
Modelpublic

sugiv/embeddinggemma-300m-mortgage

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes71downloads
Model Card

SentenceTransformer based on google/embeddinggemma-300m

This is a sentence-transformers model finetuned from google/embeddinggemma-300m on the 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 <!-- at revision 64614b0b8b64f0c6c1e52b07e4e9a4e8fe4d2da2 -->
  • Maximum Sequence Length: 2048 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity
  • Training Dataset:
  • mortgage-qa-dataset
  • Language: en <!-- - License: Unknown -->

Model Sources

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]])

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
Metricmortgage-evalmortgage-test
cosine_accuracy@10.34420.2781
cosine_accuracy@30.64690.5621
cosine_accuracy@50.78640.7101
cosine_accuracy@100.93180.8728
cosine_precision@10.34420.2781
cosine_precision@30.21560.1874
cosine_precision@50.15730.142
cosine_precision@100.09320.0873
cosine_recall@10.34420.2781
cosine_recall@30.64690.5621
cosine_recall@50.78640.7101
cosine_recall@100.93180.8728
cosine_ndcg@100.62090.5531
cosine_mrr@100.52330.453
cosine_map@1000.52850.4622

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

mortgage-qa-dataset
  • Dataset: mortgage-qa-dataset at de29792
  • Size: 2,699 training samples
  • Columns: <code>question</code>, <code>answer</code>, <code>sourcedocument</code>, and <code>sourcechunk</code>
  • Approximate statistics based on the first 1000 samples: | | question | answer | sourcedocument | sourcechunk | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | string | string | | details | <ul><li>min: 9 tokens</li><li>mean: 16.15 tokens</li><li>max: 27 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 31.67 tokens</li><li>max: 62 tokens</li></ul> | <ul><li>min: 8 tokens</li><li>mean: 9.99 tokens</li><li>max: 14 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 15.99 tokens</li><li>max: 20 tokens</li></ul> |
  • Samples: | question | answer | sourcedocument | sourcechunk | |:-------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------|:------------------------------------------------| | <code>When is a full appraisal required for a mortgage application?</code> | <code>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.</code> | <code>fhahandbook40001</code> | <code>fhahandbook40001chunk005</code> | | <code>When getting a mortgage, who orders the title insurance for the lender?</code> | <code>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.</code> | <code>vachapter4underwriting</code> | <code>vachapter4underwritingchunk012</code> | | <code>What components of a loan application does an underwriter assess?</code> | <code>Underwriters analyze the four Cs of credit: Capacity income and DTI, Capital assets and reserves, Collateral property value, and Credit credit history and score.</code> | <code>vachapter5processing</code> | <code>vachapter5processingchunk005</code> |
  • Loss: <code>CachedMultipleNegativesRankingLoss</code> 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 at de29792
  • Size: 337 evaluation samples
  • Columns: <code>question</code>, <code>answer</code>, <code>sourcedocument</code>, and <code>sourcechunk</code>
  • Approximate statistics based on the first 337 samples: | | question | answer | sourcedocument | sourcechunk | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | string | string | | details | <ul><li>min: 9 tokens</li><li>mean: 16.44 tokens</li><li>max: 28 tokens</li></ul> | <ul><li>min: 17 tokens</li><li>mean: 32.28 tokens</li><li>max: 62 tokens</li></ul> | <ul><li>min: 8 tokens</li><li>mean: 10.14 tokens</li><li>max: 14 tokens</li></ul> | <ul><li>min: 14 tokens</li><li>mean: 16.14 tokens</li><li>max: 20 tokens</li></ul> |
  • Samples: | question | answer | sourcedocument | sourcechunk | |:---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------|:--------------------------------------------------| | <code>What financial metrics are crucial for an AUS to issue an approval?</code> | <code>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.</code> | <code>vachapter4underwriting</code> | <code>vachapter4underwritingchunk017</code> | | <code>Can you explain how an LTV ratio is figured out?</code> | <code>The LTV ratio is calculated by dividing the mortgage loan amount by the appraised value or purchase price of the property, whichever is lower.</code> | <code>fanniemaeservicingguide</code> | <code>fanniemaeservicingguidechunk002</code> | | <code>How do lenders verify a borrowers employment history?</code> | <code>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.</code> | <code>freddiemacguide</code> | <code>freddiemacguidechunk002</code> |
  • Loss: <code>CachedMultipleNegativesRankingLoss</code> 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

<details><summary>Click to expand</summary>

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 3e-06
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 4
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 100
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: True
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamwtorchfused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining LossValidation Lossmortgage-eval_cosine_ndcg@10mortgage-test_cosine_ndcg@10
-1-1--0.5803-
0.1479250.1574---
0.2959500.10530.07220.5993-
0.4438750.0969---
0.59171000.07650.07730.6085-
0.73961250.079---
0.88761500.08020.08580.6056-
1.03551750.021---
1.18342000.07280.05490.6093-
1.33142250.0857---
1.47932500.0710.06590.6145-
1.62722750.0633---
1.77513000.18440.06870.6209-
1.92313250.0545---
2.07103500.04740.06460.6025-
2.21893750.0702---
2.36694000.08310.06990.6026-
2.51484250.0635---
2.66274500.1030.06740.6031-
2.81074750.097---
2.95865000.0770.06860.6032-
3.10655250.0713---
3.25445500.16170.06680.6087-
3.40245750.1084---
3.55036000.07910.06580.6038-
3.69826250.0477---
3.84626500.09560.06590.6073-
3.99416750.0587---
-1-1--0.62090.5531
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.11
  • Sentence Transformers: 5.1.0
  • Transformers: 4.57.0.dev0
  • PyTorch: 2.8.0.dev20250319+cu128
  • Accelerate: 1.10.1
  • Datasets: 4.0.0
  • Tokenizers: 0.22.0

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
CachedMultipleNegativesRankingLoss
bibtex
@misc{gao2021scaling,
    title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
    author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
    year={2021},
    eprint={2101.06983},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->