Views
No views yet
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()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("shradharp/legal-ft-658ea1b1-1d08-4417-8a4e-4920ae593642")
5# Run inference
6sentences = [
7 '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?',
8 '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',
9 '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',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]InformationRetrievalEvaluator| 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 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
What is the population of Seattle as of 2023, and how does it rank in terms of population size among U.S. cities? | Seattle[object Object]dᶻidᶻəlal̕ič (Lushootseed)[object Object]City[object Object]Downtown Seattle skyline with Mount[object Object]Rainier in the background[object Object]Space Needle and Climate[object Object]Pledge Arena, with the[object Object]Olympic Mountains in the[object Object]background[object Object]Seattle Great[object Object]Wheel[object Object]Pike Place Market[object Object]Amazon Spheres[object Object]Flag[object Object]Seal[object Object]Wordmark[object Object]Nickname(s): The Emerald City, Jet City, Rain[object Object]City[object Object]Motto(s): The City of Flowers, The City of[object Object]Goodwill[object Object]Seattle[object Object]Seattle (/siˈætəl/ [object Object]ⓘ see-AT-əl) is the most populous city in[object Object]the U.S. state of Washington and in the Pacific Northwest[object Object]region of North America. With a population of 755,078 in[object Object]2023,[3] it is the 18th-most populous city in the United States.[object Object]The city is the county seat of King County, the most populous[object Object]county in Washington. The Seattle metropolitan area's[object Object]population is 4.02 million, making it the 15th-most populous[object Object]in the United States.[11] Its growth rate of 21.1% between 2010[object Object]and 2020 made it one of the country's fastest-growing large[object Object]cities.[12][object Object]Seattle is situated on an isthmus between Puget Sound, an[object Object]inlet of the Pacif... |
Who was Seattle named after, and what is the significance of this individual to the local Native American tribes? | Seattle[object Object]dᶻidᶻəlal̕ič (Lushootseed)[object Object]City[object Object]Downtown Seattle skyline with Mount[object Object]Rainier in the background[object Object]Space Needle and Climate[object Object]Pledge Arena, with the[object Object]Olympic Mountains in the[object Object]background[object Object]Seattle Great[object Object]Wheel[object Object]Pike Place Market[object Object]Amazon Spheres[object Object]Flag[object Object]Seal[object Object]Wordmark[object Object]Nickname(s): The Emerald City, Jet City, Rain[object Object]City[object Object]Motto(s): The City of Flowers, The City of[object Object]Goodwill[object Object]Seattle[object Object]Seattle (/siˈætəl/ [object Object]ⓘ see-AT-əl) is the most populous city in[object Object]the U.S. state of Washington and in the Pacific Northwest[object Object]region of North America. With a population of 755,078 in[object Object]2023,[3] it is the 18th-most populous city in the United States.[object Object]The city is the county seat of King County, the most populous[object Object]county in Washington. The Seattle metropolitan area's[object Object]population is 4.02 million, making it the 15th-most populous[object Object]in the United States.[11] Its growth rate of 21.1% between 2010[object Object]and 2020 made it one of the country's fastest-growing large[object Object]cities.[12][object Object]Seattle is situated on an isthmus between Puget Sound, an[object Object]inlet of the Pacif... |
Who was the city of Seattle named after and what tribes was he a leader of? | "Seattle" in honor of Chief Seattle, a prominent 19th-century[object Object]leader of the local Duwamish and Suquamish tribes. Seattle[object Object]currently has high populations of Native Americans alongside[object Object]Americans with strong Asian, African, European, and[object Object]Scandinavian ancestry, and, as of 2015, hosts the fifth-highest[object Object]percentage of residents who identify as LGBT in the U.S.[16][object Object]Logging was Seattle's first major industry, but by the late 19th[object Object]century the city had become a commercial and shipbuilding[object Object]center as a gateway to Alaska during the Klondike Gold Rush.[object Object]The city grew after World War II, partly due to the local[object Object]company Boeing, which established Seattle as a center for its[object Object]manufacturing of aircraft. Beginning in the 1980s, the Seattle[object Object]area [object Object]developed [object Object]into [object Object]a [object Object]technology [object Object]center; [object Object]Microsoft[object Object]established its headquarters in the region. Alaska Airlines is[object Object]based in SeaTac, Washington, serving Seattle–Tacoma[object Object]International Airport, Seattle's international airport. The[object Object]5/10/25, 9:32 PM[object Object]Seattle - Wikipedia[object Object]https... |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 768,
5 512,
6 256,
7 128,
8 64
9 ],
10 "matryoshka_weights": [
11 1,
12 1,
13 1,
14 1,
15 1
16 ],
17 "n_dims_per_step": -1
18}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 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 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},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 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},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}