Downloads · 30 days
7
7% of all-time downloads
shradharp/legal-ft-658ea1b1-1d08-4417-8a4e-4920ae593642
legal-ft-658ea1b1-1d08-4417-8a4e-4920ae593642 is a sentence similarity model from shradharp. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
This is a sentence-transformers model finetuned from Snowflake/snowflake-arctic-embed-m. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic…
Downloads · 30 days
7
7% of all-time downloads
All-time downloads
96
Public
Parameters
109M
436 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors436 MB · 100%
From the Hugging Face model README
This is a sentence-transformers model finetuned from Snowflake/snowflake-arctic-embed-m. 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': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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): 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("shradharp/legal-ft-658ea1b1-1d08-4417-8a4e-4920ae593642")
# Run inference
sentences = [
'What was the original meaning of the term "midway" in relation to fairs or carnivals, and how is it connected to the University of Chicago campus?',
'history.[65][66] The University of Chicago, formerly at another location, moved to the same South Side location in\n1892. The term "midway" for a fair or carnival referred originally to the Midway Plaisance, a strip of park land\nthat still runs through the University of Chicago campus and connects the Washington and Jackson Parks.[67][68]\nDuring World War I and the 1920s there was a major expansion in\nindustry. The availability of jobs attracted African Americans from the\nSouthern United States. Between 1910 and 1930, the African American\npopulation of Chicago increased dramatically, from 44,103 to 233,903.[69]\nThis Great Migration had an immense cultural impact, called the Chicago\nBlack Renaissance, part of the New Negro Movement, in art, literature,\nand music.[70] Continuing racial tensions and violence, such as the\nChicago race riot of 1919, also occurred.[71]\nThe ratification of the 18th amendment to the Constitution in 1919 made\nthe production and sale (including exportation) of alcoholic beverages\nillegal in the United States. This ushered in the beginning of what is\nknown as the gangster era, a time that roughly spans from 1919 until 1933 when Prohibition was repealed. The\n1920s saw gangsters, including Al Capone, Dion O\'Banion, Bugs Moran and Tony Accardo battle law enforcement\nand each other on the streets of Chicago during the Prohibition era.[72] Chicago was the location of the infamous\nSt. Valentine\'s Day Massacre in 1929, when Al Capone sent men to gun down members of a rival gang, North Side,\nled by Bugs Moran.[73]\nFrom 1920 to 1921, the city was affected by a series of tenant rent strikes, which lead to the formation of the\nChicago Tenants Protective association, passage of the Kessenger tenant laws, and of a heat ordinance that legally\nrequired flats to be kept above 68\xa0°F during winter months by landlords.[74][75][76][77][78][79]\n20th and 21st centuries\n1900 to 1939\n5/10/25, 9:32 PM\nChicago - Wikipedia\nhttps://en.wikipedia.org/wiki/Chicago\n5/57',
'Los Angeles\nCity\nSkyline of downtown Los Angeles\nHollywood Sign\nEcho Park\nCalle Olvera\nLos Angeles City Hall\nGriffith Observatory\nVenice Beach\nFlag\nSeal\nCoat of arms\nWordmark\nNicknames:\xa0L.A., City of Angels,[1] The\nEntertainment Capital of the World,[1] La-la-land,\nTinseltown[1]\nLos Angeles\nLos Angeles,[a] often referred to by its initials L.A., is the\ncommercial, financial, and cultural center of Southern\nCalifornia. With an estimated 3,820,914 residents within the\ncity limits as of 2023,[8] it is the most populous city in the\nU.S. state of California and the second-most populous in the\nUnited States, behind only New York City. Los Angeles has an\nethnically and culturally diverse population, and is the\nprincipal city of a metropolitan area of 12.9 million people\n(2024). Greater Los Angeles, a combined statistical area that\nincludes the Los Angeles and Riverside–San Bernardino\nmetropolitan areas, is a sprawling metropolis of over 18.5\nmillion residents.\nThe majority of the city proper lies in a basin in Southern\nCalifornia adjacent to the Pacific Ocean in the west and\nextending partly through the Santa Monica Mountains and\nnorth into the San Fernando Valley, with the city bordering\nthe San Gabriel Valley to its east. It covers about 469 square\nmiles (1,210\xa0 km2),[6] and is the county seat and most\npopulated city of Los Angeles County, which is the most\npopulous county in the United States with an estimated 9.86\nmillion residents as of 2022.[17] It is the third-most visited\ncity in the U.S. with over 2.7 million visitors as of 2023.[18]\nThe area that became Los Angeles was originally inhabited by\nthe indigenous Tongva people and later claimed by Juan\nRodríguez Cabrillo for Spain in 1542. The city was founded\non September 4, 1781, under Spanish governor Felipe de\nNeve, on the village of Yaanga.[19] It became a part of the\nFirst Mexican Empire in 1821 following the Mexican War of\nIndependence. In 1848, at the end of the Mexican–American',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
<!--
### 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.*
-->
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.8352 |
| cosine_accuracy@3 | 0.9773 |
| cosine_accuracy@5 | 0.9943 |
| cosine_accuracy@10 | 1.0 |
| cosine_precision@1 | 0.8352 |
| cosine_precision@3 | 0.3258 |
| cosine_precision@5 | 0.1989 |
| cosine_precision@10 | 0.1 |
| cosine_recall@1 | 0.8352 |
| cosine_recall@3 | 0.9773 |
| cosine_recall@5 | 0.9943 |
| cosine_recall@10 | 1.0 |
| cosine_ndcg@10 | 0.9283 |
| cosine_mrr@10 | 0.9039 |
| cosine_map@100 | 0.9039 |
| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 10 tokens</li><li>mean: 22.79 tokens</li><li>max: 40 tokens</li></ul> | <ul><li>min: 51 tokens</li><li>mean: 437.89 tokens</li><li>max: 512 tokens</li></ul> |
| sentence_0 | sentence_1 |
|---|---|
| <code>What is the population of Seattle as of 2023, and how does it rank in terms of population size among U.S. cities?</code> | <code>Seattle<br>dᶻidᶻəlal̕ič (Lushootseed)<br>City<br>Downtown Seattle skyline with Mount<br>Rainier in the background<br>Space Needle and Climate<br>Pledge Arena, with the<br>Olympic Mountains in the<br>background<br>Seattle Great<br>Wheel<br>Pike Place Market<br>Amazon Spheres<br>Flag<br>Seal<br>Wordmark<br>Nickname(s): The Emerald City, Jet City, Rain<br>City<br>Motto(s): The City of Flowers, The City of<br>Goodwill<br>Seattle<br>Seattle (/siˈætəl/ <br>ⓘ see-AT-əl) is the most populous city in<br>the U.S. state of Washington and in the Pacific Northwest<br>region of North America. With a population of 755,078 in<br>2023,[3] it is the 18th-most populous city in the United States.<br>The city is the county seat of King County, the most populous<br>county in Washington. The Seattle metropolitan area's<br>population is 4.02 million, making it the 15th-most populous<br>in the United States.[11] Its growth rate of 21.1% between 2010<br>and 2020 made it one of the country's fastest-growing large<br>cities.[12]<br>Seattle is situated on an isthmus between Puget Sound, an<br>inlet of the Pacif...</code> |
| <code>Who was Seattle named after, and what is the significance of this individual to the local Native American tribes?</code> | <code>Seattle<br>dᶻidᶻəlal̕ič (Lushootseed)<br>City<br>Downtown Seattle skyline with Mount<br>Rainier in the background<br>Space Needle and Climate<br>Pledge Arena, with the<br>Olympic Mountains in the<br>background<br>Seattle Great<br>Wheel<br>Pike Place Market<br>Amazon Spheres<br>Flag<br>Seal<br>Wordmark<br>Nickname(s): The Emerald City, Jet City, Rain<br>City<br>Motto(s): The City of Flowers, The City of<br>Goodwill<br>Seattle<br>Seattle (/siˈætəl/ <br>ⓘ see-AT-əl) is the most populous city in<br>the U.S. state of Washington and in the Pacific Northwest<br>region of North America. With a population of 755,078 in<br>2023,[3] it is the 18th-most populous city in the United States.<br>The city is the county seat of King County, the most populous<br>county in Washington. The Seattle metropolitan area's<br>population is 4.02 million, making it the 15th-most populous<br>in the United States.[11] Its growth rate of 21.1% between 2010<br>and 2020 made it one of the country's fastest-growing large<br>cities.[12]<br>Seattle is situated on an isthmus between Puget Sound, an<br>inlet of the Pacif...</code> |
| <code>Who was the city of Seattle named after and what tribes was he a leader of?</code> | <code>"Seattle" in honor of Chief Seattle, a prominent 19th-century<br>leader of the local Duwamish and Suquamish tribes. Seattle<br>currently has high populations of Native Americans alongside<br>Americans with strong Asian, African, European, and<br>Scandinavian ancestry, and, as of 2015, hosts the fifth-highest<br>percentage of residents who identify as LGBT in the U.S.[16]<br>Logging was Seattle's first major industry, but by the late 19th<br>century the city had become a commercial and shipbuilding<br>center as a gateway to Alaska during the Klondike Gold Rush.<br>The city grew after World War II, partly due to the local<br>company Boeing, which established Seattle as a center for its<br>manufacturing of aircraft. Beginning in the 1980s, the Seattle<br>area <br>developed <br>into <br>a <br>technology <br>center; <br>Microsoft<br>established its headquarters in the region. Alaska Airlines is<br>based in SeaTac, Washington, serving Seattle–Tacoma<br>International Airport, Seattle's international airport. The<br>5/10/25, 9:32 PM<br>Seattle - Wikipedia<br>https...</code> |
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
eval_strategy: stepsper_device_train_batch_size: 10per_device_eval_batch_size: 10num_train_epochs: 10multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 10per_device_eval_batch_size: 10per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_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: 10max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}tp_size: 0fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss | cosine_ndcg@10 |
|---|---|---|---|
| 0.3571 | 50 | - | 0.8540 |
| 0.7143 | 100 | - | 0.9098 |
| 1.0 | 140 | - | 0.9124 |
| 1.0714 | 150 | - | 0.9108 |
| 1.4286 | 200 | - | 0.9139 |
| 1.7857 | 250 | - | 0.9205 |
| 2.0 | 280 | - | 0.9239 |
| 2.1429 | 300 | - | 0.9159 |
| 2.5 | 350 | - | 0.9185 |
| 2.8571 | 400 | - | 0.9204 |
| 3.0 | 420 | - | 0.9187 |
| 3.2143 | 450 | - | 0.9160 |
| 3.5714 | 500 | 0.6931 | 0.9212 |
| 3.9286 | 550 | - | 0.9208 |
| 4.0 | 560 | - | 0.9208 |
| 4.2857 | 600 | - | 0.9244 |
| 4.6429 | 650 | - | 0.9241 |
| 5.0 | 700 | - | 0.9251 |
| 5.3571 | 750 | - | 0.9288 |
| 5.7143 | 800 | - | 0.9255 |
| 6.0 | 840 | - | 0.9241 |
| 6.0714 | 850 | - | 0.9262 |
| 6.4286 | 900 | - | 0.9246 |
| 6.7857 | 950 | - | 0.9252 |
| 7.0 | 980 | - | 0.9223 |
| 7.1429 | 1000 | 0.0978 | 0.9244 |
| 7.5 | 1050 | - | 0.9328 |
| 7.8571 | 1100 | - | 0.9296 |
| 8.0 | 1120 | - | 0.9255 |
| 8.2143 | 1150 | - | 0.9279 |
| 8.5714 | 1200 | - | 0.9287 |
| 8.9286 | 1250 | - | 0.9279 |
| 9.0 | 1260 | - | 0.9275 |
| 9.2857 | 1300 | - | 0.9279 |
| 9.6429 | 1350 | - | 0.9275 |
| 10.0 | 1400 | - | 0.9283 |
@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{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
<!--
## 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.*
-->