SentenceTransformer based on intfloat/e5-base-v2
This is a sentence-transformers model finetuned from intfloat/e5-base-v2. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: intfloat/e5-base-v2
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', '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("sentence_transformers_model_id")
# Run inference
sentences = [
'query: yakitori restaurant',
'passage: - **Definition**: Non-commercial organizations serving community, membership, social-welfare, or civic purposes, including charities, associations, clubs, and community centers.\n - **Key Concepts & Modalities**: Charitable nonprofits, membership associations, community centers, social service organizations, civic clubs, advocacy and mutual-aid groups.\n - **Representative Keywords**: non profit organization, charity, community center, association, foundation, social services organization, youth organization, civic club, volunteer organization, NGO, membership organization, welfare organization, fraternal organization, community group, mutual aid.\n - **Boundary Disambiguation**: Excludes government departments and places of worship whose primary identity is religious practice rather than secular community nonprofit activity. Community centers, civic centers, youth centers, veterans centers, senior citizen centers, and homeless shelters operated by nonprofit organizations belong here; those directly operated as government departments belong in Government & Public Services. The key distinction is nonprofit organizational structure versus government agency.',
'passage: - **Definition**: Providers of essential utility infrastructure and energy services, including electricity, gas, water, waste, and related energy production or distribution facilities.\n - **Key Concepts & Modalities**: Electric and gas utilities, water and wastewater services, waste management, energy generation, utility infrastructure services.\n - **Representative Keywords**: electric utility, gas company, water utility, waste management service, power plant, solar energy company, wind farm, recycling center, sewage treatment, energy supplier, utility contractor, propane supplier, garbage collection, district heating, energy provider.\n - **Boundary Disambiguation**: Excludes retail electronics or appliance stores and excludes general construction contractors who are not utility or energy operators. These are utility SERVICE providers delivering electricity, gas, or water directly to end customers. NOT factories or manufacturers. NOT construction contractors. The primary business is operating infrastructure and billing customers for consumption.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, -0.0123, -0.0051],
# [-0.0123, 1.0000, -0.0121],
# [-0.0051, -0.0121, 1.0000]])
Training Details
Training Dataset
Unnamed Dataset
- Size: 48,425 training samples
- Columns: sentence_0, sentence_1, and label
- Approximate statistics based on the first 100 samples:
sentence_0 sentence_1 label type string string float modality text text details min: 5 tokensmean: 6.93 tokensmax: 11 tokens min: 144 tokensmean: 184.91 tokensmax: 248 tokens min: 0.0mean: 0.07max: 1.0 - Samples:
sentence_0 sentence_1 label query: concrete product supplier passage: - Definition: Businesses that provide lodging, travel arrangement, tourism experiences, and visitor hospitality services for travelers. - Key Concepts & Modalities: Hotels and lodging, travel agencies, tour operators, guest accommodation, visitor hospitality services. - Representative Keywords: hotel, motel, hostel, bed and breakfast, travel agency, tour operator, resort hotel, guest house, vacation rental, tourist information center, lodge, inn, campground, booking agency, hospitality service, resort, rv park, airbnb. - Boundary Disambiguation: Excludes restaurants unless lodging is primary, and excludes passenger carriers such as airlines or bus companies that operate transport rather than tourism lodging or travel planning. 0.0 query: photography class passage: - Definition: Establishments that produce, fabricate, process, or assemble physical goods at industrial scale, including factories, plants, mills, and industrial production services. - Key Concepts & Modalities: Product manufacturing, industrial processing, fabrication and machining, plant and mill operations, industrial engineering support for production. - Representative Keywords: manufacturer, factory, industrial plant, machine shop, assembly plant, mill, foundry, chemical plant, electronics manufacturer, food manufacturer, textile mill, fabrication shop, production facility, cannery, printing plant. - Boundary Disambiguation: Excludes retail storefronts, wholesale-only distributors without production, and construction contractors who build on-site rather than manufacture products. Large-scale food manufacturers (canneries, frozen food manufacturers, food factories) belong here; breweries, distilleries, and wineries that serve or sell... 0.0 query: museum of space history passage: - Definition: Primary-sector operations involving farming, livestock, aquaculture, forestry, fishing, and extraction or stewardship of natural resources. - Key Concepts & Modalities: Crop and livestock farming, aquaculture and fishing, orchards and vineyards as production, agribusiness services, natural resource operations. - Representative Keywords: farm, ranch, orchard, vineyard, dairy farm, poultry farm, fishery, aquaculture farm, agricultural production, greenhouse, nursery grower, forestry service, livestock breeder, crop grower, agricultural cooperative. - Boundary Disambiguation: Excludes food restaurants and grocery retail, and excludes agricultural equipment manufacturers unless the site itself is a producing farm or resource operation. Vineyards, orchards, fish farms, and dairy farms as producers belong here; wineries that primarily serve wine to consumers on-premises belong in Food & Drink. Farm shops and farmstay businesses t... 0.0 - Loss: CosineSimilarityLoss with these parameters:
{ "loss_fct": "torch.nn.modules.loss.MSELoss", "cos_score_transformation": "torch.nn.modules.linear.Identity" }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 6fp16: Trueper_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robin
All Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 6max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 32prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Nonedataloader_multiprocessing_context: Nonedataloader_in_order: Trueremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}warmup_ratio: None
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.3303 | 500 | 0.0483 |
| 0.6605 | 1000 | 0.0143 |
| 0.9908 | 1500 | 0.0113 |
| 1.3210 | 2000 | 0.0049 |
| 1.6513 | 2500 | 0.0047 |
| 1.9815 | 3000 | 0.0032 |
| 2.3118 | 3500 | 0.0013 |
| 2.6420 | 4000 | 0.0012 |
| 2.9723 | 4500 | 0.0009 |
| 3.3025 | 5000 | 0.0006 |
| 3.6328 | 5500 | 0.0006 |
| 3.9630 | 6000 | 0.0004 |
| 4.2933 | 6500 | 0.0006 |
| 4.6235 | 7000 | 0.0002 |
| 4.9538 | 7500 | 0.0003 |
| 5.2840 | 8000 | 0.0002 |
| 5.6143 | 8500 | 0.0003 |
| 5.9445 | 9000 | 0.0003 |
Training Time
- Training: 1.1 hours
Framework Versions
- Python: 3.13.15
- Sentence Transformers: 5.7.0
- Transformers: 5.16.1
- PyTorch: 2.11.0+cu128
- Accelerate: 1.14.0
- Datasets: 4.8.5
- Tokenizers: 0.23.1
Additional Resources
- Training and Finetuning Embedding Models with Sentence Transformers: the end-to-end guide for training or finetuning Sentence Transformer models.
- Introduction to Matryoshka Embedding Models: variable-size embeddings that can be truncated with minimal quality loss.
- Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval: post-training compression of embedding vectors.
- Multimodal Embedding & Reranker Models with Sentence Transformers: use text, image, audio, and video models through the same API.
- Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers: train multimodal embedding models, with a Visual Document Retrieval walkthrough.
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",
}