SentenceTransformer based on intfloat/multilingual-e5-base
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-base. It maps inputs 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/multilingual-e5-base
- Maximum Sequence Length: 384 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': 'XLMRobertaModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
)
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: makanan apa yang bisa dibuat dari 1 dash The Truth Old Time Aromatic Bitters or Angostura bitters, 1 sugar cube, 6" twist from a lemon, 5 ounces chilled Champagne?',
'passage: Title: The Champagne Cocktail. Ingredients: 1 dash The Truth Old Time Aromatic Bitters or Angostura bitters, 1 sugar cube, 6" twist from a lemon, 5 ounces chilled Champagne. Instructions: Drop 1 dash The Truth Old Time Aromatic Bitters or Angostura bitters onto a sugar cube and place in a Champagne flute. Using a channel or paring knife, cut a 6" twist from a lemon and arrange inside glass. Gently pour 5 ounces chilled Champagne into glass.',
'passage: Title: Balsamic Truffles. Ingredients: bittersweet chocolate truffle base, 1 tablespoon plus 1/4 teaspoon aged balsamic vinegar, Chopped toasted salted hazelnuts. Instructions: Follow recipe for bittersweet chocolate truffle base , stirring aged balsamic vinegar into lukewarm cream. Mix in melted chocolate. Chill truffle base and form truffles. Drop each freshly coated truffle (or just–formed, uncoated truffle) into bowl of hazelnuts; turn to coat.',
]
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.8373, 0.1429],
# [0.8373, 1.0000, 0.1506],
# [0.1429, 0.1506, 1.0000]])
Training Details
Training Dataset
Unnamed Dataset
- Size: 4,000 training samples
- Columns: anchor, positive, and negative
- Approximate statistics based on the first 100 samples:
anchor positive negative type string string string modality text text text details min: 10 tokensmean: 33.53 tokensmax: 108 tokens min: 79 tokensmean: 328.21 tokensmax: 384 tokens min: 78 tokensmean: 327.38 tokensmax: 384 tokens - Samples:
anchor positive negative query: rekomendasikan resep dengan bahan 2 cups bittersweet chocolate chips, 2 tablespoons canola oil, Assorted toppings for coating bananas (such as crushed chocolate sandwich cookies, toffee bits, chopped Butterfinger candy bars, chopped salted peanuts, or toasted shredded sweetened coconut), 3 ripe bananas passage: Title: Chocolate-Dipped Frozen Banana Bites. Ingredients: 2 cups bittersweet chocolate chips, 2 tablespoons canola oil, Assorted toppings for coating bananas (such as crushed chocolate sandwich cookies, toffee bits, chopped Butterfinger candy bars, chopped salted peanuts, or toasted shredded sweetened coconut), 3 ripe bananas, peeled, cut into 1/2-inch-thick slices. Instructions: Stir chocolate and oil in heavy small saucepan over low heat just until smooth. Let stand 15 minutes to cool. Place each topping in separate shallow dish. Line baking sheet with foil. Arrange banana slices on foil. Using fingers, dip 1 banana slice in chocolate, coating completely. Shake off excess chocolate. Drop dipped banana in 1 topping. Using clean hand, sprinkle more topping over banana to coat; transfer to foil-lined sheet. Repeat with remaining bananas, chocolate, and toppings. Freeze until firm, about 3 hours, then serve. passage: Title: Shrimp Un-Fried Rice. Ingredients: 1 tablespoon oil, 4 large eggs, whisked, 1 red bell pepper, diced, 1/2 cup shelled edamame, 1 garlic clove, minced, 1/2 pound shrimp, peeled and deveined, 1/2 teaspoon salt, 4 cups cooked brown rice, 2 tablespoons low sodium soy sauce, 1 tablespoon sesame seeds, 1 tablespoon diced scallions. Instructions: 1. Heat 1 teaspoon of the oil in a skillet over medium heat. Add the whisked eggs and cook for 1 minute stirring to make scrambled eggs, then remove to a plate. 2. Heat the remaining 2 teaspoons oil, add the red bell peppers and cook 3–4 minutes, until soft. Add the edamame and garlic and cook 1 more minute. 3. Add the shrimp and salt and cook 3 minutes, until they are bright pink. 4. Add the cooked eggs, rice, soy sauce and sesame seeds and cook 2 minutes, just until heated through. 5. Top with the scallions and serve. query: makanan apa yang bisa dibuat dari 12 ounces carrots (preferably assorted colors), peeled, julienned (about 4 cups), 2 tablespoons vegetable oil or grapeseed oil, 1 tablespoons fresh lime juice, 1 1/2 teaspoons sugar? passage: Title: Carrot, Cilantro, and Chile Slaw. Ingredients: 12 ounces carrots (preferably assorted colors), peeled, julienned (about 4 cups), 2 tablespoons vegetable oil or grapeseed oil, 1 tablespoons fresh lime juice, 1 1/2 teaspoons sugar, 1/2 teaspoons kosher salt plus more for seasoning, 2 jalapeños, stemmed, seeded, minced, 1/2 cup (loosely packed) fresh cilantro leaves, 3/4 teaspoon ground coriander, Freshly ground black pepper. Instructions: Toss carrots, oil, lime juice, sugar, 1/2 teaspoon salt, and jalapeños in a large bowl. Let marinate for 15 minutes, tossing occasionally. Add cilantro and coriander; toss to evenly incorporate. Season to taste with salt and pepper. passage: Title: Basic Nut Milk. Ingredients: 1 cup raw almonds, hazelnuts, pistachios, pecans, walnuts, cashews, or peanuts, 4 teaspoons agave syrup (nectar), 1/8 teaspoon kosher or sea salt. Instructions: Place nuts in a large bowl and add water to cover by 2". Let stand at least 12 hours (this is key for silky, nongritty results; the longer the nuts soak, the smoother the milk will be). Drain nuts; discard soaking liquid. Purée nuts, agave, salt, and 4 cups very hot water (but not boiling; hot water yields creamier milk) in a blender on high speed until very smooth, about 2 minutes. Strain through a fine-mesh sieve into a medium bowl, pressing down on solids; discard nut pulp. Thin nut milk with water as necessary to reach desired consistency. Transfer to airtight container and chill until cold. DO AHEAD: Nuts can be soaked 2 days ahead; cover. Nut milk can be made 3 days ahead; keep chilled. query: rekomendasikan resep dengan bahan 12 to 16 (1/2-inch-thick) baguette slices, 3 tablespoons extra-virgin olive oil, 1 garlic clove, halved, 1 (1- to 1 1/4 -lb) live lobster passage: Title: Bouillabaisse. Ingredients: 12 to 16 (1/2-inch-thick) baguette slices, 3 tablespoons extra-virgin olive oil, 1 garlic clove, halved, 1 (1- to 1 1/4 -lb) live lobster, 2 large tomatoes, peeled and coarsely chopped, 1 large onion, chopped, 4 garlic cloves, chopped, 1/2 cup extra-virgin olive oil, 1 lb boiling potatoes, 1/3 cup finely chopped fennel fronds (sometimes called anise), 1 Turkish or 1/2 California bay leaf, 1/4 teaspoon crumbled saffron threads, 1 1/2 tablespoons coarse sea salt, 1/2 teaspoon black pepper, 9 cups white fish stock (or store-bought), 3 pounds white fish fillets (such as monkfish, turbot, red snapper, striped bass, porgy, grouper, and/or cod), cut into 2-inch pieces, 1/2 pound cockles or small hard-shelled clams, scrubbed, 1/2 pound cultivated mussels, scrubbed and any beards removed, 1/2 pound large shrimp in shells, Rouille. Instructions: Put oven rack in middle position and preheat oven to 250°F. Arrange bread slices in 1 layer in a shallow bak... passage: Title: Roasted Butternut Squash with Spicy Onions. Ingredients: 2 tablespoons olive oil, 1 medium red onion, sliced, 1 teaspoon crushed red pepper flakes, 1 teaspoon finely grated lime zest, 1/4 cup fresh lime juice, 2 teaspoons honey, 1 cup blanched hazelnuts, 2 large butternut squash (about 4 pounds), peeled, seeded, sliced 1/4" thick, 1/4 cup plus 2 tablespoons olive oil, Kosher salt, freshly ground pepper, 1/2 cup chopped fresh flat-leaf parsley, 1/2 cup chopped fresh mint, 2 tablespoons chopped fresh marjoram, 4 ounces fresh goat cheese, crumbled. Instructions: Heat oil in a large skillet over medium-high heat. Cook onion, stirring often, until lightly charred and softened but not falling apart, 5–7 minutes. Add red pepper flakes and toss to combine. Remove pan from heat and mix in lime juice and honey. Let cool, then mix in lime zest. DO AHEAD: Spicy onions can be made 3 days ahead. Cover and chill. Preheat oven to 350°F. Toast hazelnuts on a small rimmed baking sheet, s... - Loss: MultipleNegativesRankingLoss with these parameters:
{ "scale": 20.0, "similarity_fct": "cos_sim", "gather_across_devices": false, "directions": [ "query_to_doc" ], "partition_mode": "joint", "hardness_mode": null, "hardness_strength": 0.0 }
Training Hyperparameters
Non-Default Hyperparameters
learning_rate: 2e-05num_train_epochs: 1warmup_steps: 0.1fp16: True
All Hyperparameters
do_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0.1log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.2 | 50 | 0.7584 |
| 0.4 | 100 | 0.0130 |
| 0.6 | 150 | 0.0101 |
| 0.8 | 200 | 0.0160 |
| 1.0 | 250 | 0.0048 |
Training Time
- Training: 7.2 minutes
Framework Versions
- Python: 3.12.13
- Sentence Transformers: 6.1.0
- Transformers: 5.0.0
- PyTorch: 2.10.0+cu128
- Accelerate: 1.15.0
- Datasets: 5.0.1
- Tokenizers: 0.22.2
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",
}
MultipleNegativesRankingLoss
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}