Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
12
This is a sentence-transformers model finetuned from google/embeddinggemma-300m. 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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, '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()
)
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("yippyyipyip/embeddinggemma-300m-tripletloss")
# Run inference
queries = [
"A hard, brittle, heat-resistant material made from shaped and fired nonmetallic minerals, most commonly clay. Includes both glazed and unglazed forms such as porcelain and stoneware. Ceramic containers have a smooth surface and are used for decorative pots.",
]
documents = [
"Product Description: Bring a hint of the outdoors into your home with this elegant faux hydrangea arrangement. It's arranged in a decorative ceramic vase for a sophisticated touch. Lush with lifelike detail, this collection of blossoms brings a classic springtime vibe to your dining table or console. It easily complements any room's aesthetic, whether in your home or office. Made from a combination of plastic and polysilk, this artificial arrangement also has vibrant green leaves and stems to complete the look. Features: - Ideal for dining tables, hallway consoles, kitchen islands, and other surfaces - Great for all occasions, from weddings and parties to banquets and showers - Holiday: Easter, Mother's Day, birthday - Perfect for any season",
"Product Description: Add a lively pop of greenery to your space with this cheerful artificial grass and daisy arrangement. Set in a black pot, the 48'' tall design features long, wispy blades of green grass accented by bright white faux daisies for a sun-kissed, natural look. Made from durable plastic, the stems and petals offer realistic texture without the upkeep of live plants. This piece is perfect for brightening up a covered porch, sunny nook, or empty corner. We love that it brings fresh, seasonal charm to your décor year-round. Features: - Includes black plastic pot for instant display - Realistic grass and white daisies made from plastic - Stands 48'' tall to make a statement indoors or on covered patios",
'Product Description: This curio cabinet is a versatile addition to your home, perfect for showcasing your favorite decor or cherished collections. Crafted from engineered wood with a mirrored glass exterior, it features two hinged doors that open to reveal three shelves, including one adjustable, for all your display needs. The tempered glass panels in the doors provide a clear view of your items, while the lacquered finish adds a subtle sheen. Its compact 23” width makes it a smart choice for smaller spaces. Plus, it includes a wall anchor for added safety and stability.\n\nHand-curated by Kelly Clarkson.\n Features: - Ample Storage: Three shelves provide space for various items - Adjustable Shelf: One shelf offers three height placement options - Dust-Free Storage: Keeps items clean and organized - Display Tabletop: Surface suitable for picture frames, vases, and lamps',
]
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.9969, -0.9973, 0.9987]])
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
Indicates that the product does not have drawer glides, making this attribute irrelevant or not applicable. Select only when there are no drawer glides present in the product. |
Product Description: This console table highlights a sleek, modern silhouette and features mixed materials for your space. It has an open, airy frame with three legs that meet in the middle. Crafted from solid wood, this distressed frame comes in a rich brown hue for rustic charm and a well-worn look. The tabletop is oval-shaped and made of a concrete composite that's been wire-brushed in a rustic gray finish. At over 29" tall and 54" wide, this table fits nicely behind your living room sofa or is ready to greet guests in your entryway. Features: - Concrete composite tops - Built up edge - Soft shapes create contemporary feel - Interlocking shaped legs add soft appeal |
Product Description: The Chupp 47.3'' Solid Wood Top Console Table offers a perfect blend of understated elegance and practical design, making it an effortless addition to a variety of interior styles. Crafted from solid and engineered wood, this console table features a neutral finish that complements any room palette. Its rectangular shape and compact 13-inch depth make it an ideal choice for smaller spaces such as entryways or hallways, providing both style and function without overwhelming your decor. |
Indicates that the product does not have drawer glides, making this attribute irrelevant or not applicable. Select only when there are no drawer glides present in the product. |
Product Description: This console table is a sleek, stylish addition to your home, offering a perfect balance of charm and practicality. It's crafted from solid wood that's built to withstand spills while bringing a warm, natural feel to your space. Standing at 31.5'' tall, it's just the right height for displaying your favorite décor or catching keys as you walk through the door. There's not only a spacious surface but a low slatted shelf for baskets, bins, or potted plants. This table is the ideal accent in your entryway or living room. Features: - Solid wood construction for durability and easy maintenance - An open shelf for versatile storage - Available in a dynamic finish of your choice - Handcrafted with care |
Product Description: This console table combines natural touches with a modern mixed-material look for a casual, everyday vibe we love. It's made from solid oak wood with a brown finish that shows off the wood's natural grain color variation. Four shelves provide ample space to store or show off just about anything, while the 2 floating drawers with metal pulls offer additional out-of-sight storage we love. Our favorite detail is the Indian quartz tabletop, which adds a crisp contrast set against the rest of the table. Features: - Transitional design This console table embraces a mixed materials design that will blend right in with and enhance traditional, modern, and other décor styles - Stylish details: This natural wood console table is finished with a white quartz tabletop and metal pulls for a distinguished look and modern feel - Ample storage space: A broad tabletop, four open shelves, and two floating drawers provide ample room to display your favorite décor and store living ess... |
Indicates that the product does not have drawer glides, making this attribute irrelevant or not applicable. Select only when there are no drawer glides present in the product. |
Product Description: This console table elevates your space with a classic look that's ideal for a modern farmhouse aesthetic. It's crafted from engineered wood with a petite, rectangular silhouette. The design features two side supports with X-shaped accents that remind us of barn architecture. We love that the lower shelf is ideal for storage bins, baskets, or boxes, and the top is great for florals, picture frames, and decorative trays. Our favorite? It's scratch-resistant for holding up to everyday use in your hallway or living room. Features: - A modern farmhouse sofa table is a charming addition with a relaxed and inviting ambiance - The classic long, narrow silhouette works in an entry or living room - A full lower shelf is great for storage and display - X-cross accents add detail and character to the table - A stylish wood-toned finish adds casual appeal - Laminate surfaces resist scratches and are easy to clean |
Product Description: This console table offers functional storage and a vintage-inspired, boho look to complete your space. It's crafted from solid and engineered wood in a distressed brown finish that gives it the feel of a great flea market find. The design features a lower open shelf, great for stylish baskets, a top surface for the display of decor, and two drawers for tucking away smaller items like keys or charging cords. We love the classic turned legs and the scrollwork on the drawer fronts that complete the elegant yet laid-back vibe of this boho sideboard. Features: - Sturdy and durable - Designed with distressed brown and slight white finishes, retro-style bohemian pattern design on two drawers, adding a unique farmhouse charm to any space. - 2 convenient drawerss with iron slide rail allows for easy access to items stored inside and ensures smooth operation without getting stuck. |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16num_train_epochs: 4multi_dataset_batch_sampler: round_robindo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 4max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_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: Falsebf16_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: round_robinrouter_mapping: {}learning_rate_mapping: {}@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",
}
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Base model
google/embeddinggemma-300m