Matryoshka Representation Learning
Paper • 2205.13147 • Published • 27
How to use josegg5/ModernBERT-projects-retriever with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("josegg5/ModernBERT-projects-retriever")
sentences = [
"Tromso Dynasonde atmospheric gravity wave ionospheric disturbances correlation geomagnetic activity",
"The production of chemicals, plastics, solvents, etc., contributes to 20 % of the Gross Value Added in the EU, where sales have doubled over the last 20 years. Despite this dynamism, the chemical industry is energy intensive and 95 % of organic chemicals derive from fossil oil and natural gas. To sustain the growth of this industry, the replacement of fossil feedstocks with renewable carbon, phosphorus and silicon sources should be encouraged. Nonetheless, such a sourcing shift represents a paradigm shift: while the development of petrochemistry has relied on the selective oxidation of hydrocarbons, the conversion of renewable feedstocks (e.g. CO2, phosphates, silicates or biomass) requires efficient reduction methods and catalysts to overcome their oxidized nature.Today, no reduction method meets the criteria for a versatile and energy efficient reduction of oxidized feedstocks and the aim of the ReNewHydrides project is to design novel reductants and catalytic reactions to achieve this important aim. At the crossroads of main group element chemistry, organometallic chemistry, electrochemistry and homogenous catalysis, I propose to develop innovative and recyclable reductants based on silicon and boron compounds, and to utilize them to tackle catalytic challenges in the reduction of C–O, P–O and Si–O bonds. The overarching principle is to build a balanced synthetic cycle, where the electrochemical reduction of functionalized and oxidized substrates is ensured by silicon and boron based hydride donors, with a high energy efficiency and selectivity.This project will foster innovative routes in the utilization of renewable carbon, phosphorus and silicon feedstocks. It is therefore of high risk, but ultimately extremely rewarding. The results will also also open-up new horizons in silicon and boron chemistry and they will finally serve the scientific community involved in the fields of organic and inorganic chemistry, sustainable chemistry and energy storage.",
"This project will study a class of atmospheric waves (known as atmospheric gravity waves) and associated travelling ionospheric disturbances at high latitudes, along with the possible connections between this wave activity and geomagnetic activity. The project will use data obtained using the Tromso Dynasonde (electron density and ionospheric tilts) between January 2014 and December 2016. The project will fully investigate the spectral characteristics of the data, along with the statistical distribution of the propagation parameters, and their altitude and temporal variability. The final goal is to identify possible correlations between these parameters and indicators of the level of geomagnetic activity. The project is submitted by a researcher with substantial experience in the subject areas, originally gained in during his PhD studies at the University of Colorado. The applicant is seeking the fellowship to aid in his reintegration at the Institute of Space Science in Romania.",
"The SEADE project provides fundamental and tangible support services to the Research and Innovation (R&I) ecosystems of Europe (EU) and Sub-Saharan Africa (SSA), undertaking human-centred research, programme development/delivery, and pilot actions in four SSA target regions to support increased cooperation. These actions will focus on two key areas identified as challenges for this ecosystem: digital transformation and international collaboration. Alongside the programme development, integration of legacy elements from current or newly closed initiatives working in the EU-SSA R&I, such as the ICT-58 projects funded under Horizon 2020, will provide the R&I in Digital (R&IID) actors across both continents with a comprehensive resource toolkit, made available within the legacy platform of the ENRICH in Africa (EiA) project. With this approach SEADE aims to provide a seamless ‘Route-to-Market’ pathway for the R&I actors in transferring research knowledge into market success, thus supporting the development of economic growth, and facilitate job market boosting.By founding the actions of SEADE in a human-centred approach, the activities can be developed through user-, as well as market-driven research, ensuring the services developed are relevant and required by the target users, and therefore more likely to be successful. The delivery of these new services within 4 pilot regions (Ghana, Kenya, Senegal, South Africa), will enable the SEADE consortium to set measurable criteria for the assessment of such actions within different cultural, political, and financial ecosystems. This data will enable SEADE to produce key policy positioning papers and reports, which can support the development of further R&IID targeted actions in other African regions.The EU and SSA actors of SEADE will be engaged via the wealth of networks available within the consortium partnership, enabling a strong dissemination and communication strategy for the project to be undertaken from the start."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from joe32140/ModernBERT-base-msmarco. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'ModernBertModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)
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 = [
'home renovation energy savings platform',
'Leveraging on the business operations of consortium partners (4000 integrated building renovations conducted to date), TURNKEY RETROFIT will develop and replicate an integrated home renovation service which will be initially operated in 3 EU countries - France, Ireland and Spain - with an expected 335M€ investment pipeline for home renovation within the first 5 years (approximately 14 700 dwellings renovated, leading to 96,6 GWh/year Primary energy savings triggered) beyond the end of the project. The project will point to further replication across Europe and Internationally in particular via the Green Building Council network.The TURNKEY RETROFIT service will be developed as a home-owner-centric renovation journey, which will transform the complex and fragmented renovation process into a simple, straightforward and attractive process for the home-owner. It will include the initial technical and behavioural diagnosis, technical offer, contract development and agreement, structuring and provision of financial support, as well as the on-site coordination of works and quality assurance. It will be a service-oriented model where the home-owner is offered tailor-made solutions through the whole customer journey.The service will be accessible through a user-friendly digital platform and it will address drivers of building renovation that go beyond a desire to reduce energy bills and increase asset value, such as home improvement, increased comfort, enhanced health & quality of life.',
'BLAZE aims at developing Low cost, Advanced and Zero Emission first-of-a-kind small-to-medium Biomass CHP. This aim is reached by developing bubbling fluidised bed technology integrating high temperature cleaning & conditioning system (IBFBG, that can convert heterogeneous feedstocks in a syngas with zero particulate matter and ultra-low tar and contaminants content), an integrated high temperature gas cleaning approach for HCl and H2S removal and an innovative key component for thermal and chemical integration of solid oxide fuel cell (efficient gas recirculation of the fuel cell anode exhaust to the gasification process via a steam-driven high speed micro-compressor using gas bearing technology). The technology is developed for a CHP capacity range from small (25-100 kWe) to medium (0.1-5 MWe) scale and is characterised by the widest fuel spectrum applicable (forest, agricultural, industrial and municipal waste also with high moisture, ash and contaminants content), high efficiencies (50% electrical versus the actual 20%), low investment (< 4 k€/kWe) and operation (≈ 0.05 €/kWh) costs as well as almost zero gaseous and PM emissions, projecting electricity production cost below 0.10 €/kWh . Gasification, gas cleaning & conditioning and fuel cells will be tested at lab scale and 25 kWe SOFC will be thermally and chemically integrated in 100 kWth IBFBG demonstrating the achievement of new milestones, increasing competitiveness of European industry, energy system reliability and flexibility and biomass plants social acceptance. Process simulations, computer aided design, tests, performance evaluation, risk and safety analysis as well as a technology assessment part covering techno-economic, environmental and overall impact assessments and market studies will be carried out together with a clear dissemination, exploitation and communication plan, that can count on the involvement of the main gasifier, gas conditioning and SOFC European companies and research centres.',
]
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.7217, 0.0099],
# [ 0.7217, 1.0000, -0.0355],
# [ 0.0099, -0.0355, 1.0000]])
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
identify neural markers of partner action prediction in joint turn-taking tasks |
The ability to perform joint (multi-person) actions such as ensemble music performance confers numerous benefits, from generating unique aesthetic experiences to enhancing affiliation with one’s co-actors. Co-actors must be able to accurately predict when one another’s actions will occur so that they can time their own actions accordingly. One question facing the field of social neuroscience is how co-actors learn to make accurate predictions about one another’s actions. The current project, JAL, launches one of the first systematic investigations of joint action learning to address this question on the levels of both brain and behaviour. The project will implement a series of empirical studies in which partners learn novel joint turn-taking tasks while electroencephalography (EEG) is simultaneously measured from both partners: Turn-taking tasks are optimal for measuring prediction processes because partners must be able to accurately predict when one another’s turns will end so that ... |
measure intergalactic magnetic field strength topology with Jansky VLA observations |
There is a pressing need to chart the origin, evolution, and impact of magnetic fields over the full 13.7 billion year history of the Universe, with implications for particle physics, cosmology, and astrophysics. Key to this endeavour is a detailed physical understanding of how galaxies have become magnetised and what role intergalactic magnetic fields play in shaping the Universe. To make progress, we need to observationally characterize properties such as the strengths and topologies of galactic and intergalactic magnetic fields. I propose a portfolio of ground-breaking research projects that will capitalise on the recently upgraded Jansky VLA radio telescope to provide new observational measurements of interstellar and intergalactic magnetic fields and elucidate their roles in shaping the Universe. A Marie Skłodowska-Curie Actions Research Fellowship will facilitate movement from my current position as an Assistant Scientist at the National Radio Astronomy Observatory in the USA to ... |
identify mechanisms for building cross-cultural peace in frontier societies after European expansion |
This research project investigates the historical roots of cross-cultural peacebuilding. European expansion during the sixteenth century was characterised by a high degree of violence, which was fuelled by cultural differences and religious radicalisms. The meeting of different cultures created new forms of violence, but, at the same time, generated new forms of cross-cultural encounters that were driven to construct a lasting peace. This project explains the transition from the violent conflicts of the first encounters between Europeans and non-European peoples, to their peaceful coexistence. Rather than focusing on cross-cultural diplomacy or treaty-making, this research project explains how peace was constructed “on the ground”. In order to do so, it focuses on three different frontiers of the first global empires. Through a comparative survey that includes cases from the Mediterranean, the Americas and Asia, this project shows that frontier societies resulting from European expansi... |
MatryoshkaLoss with these parameters:{
"loss": "CachedMultipleNegativesRankingLoss",
"matryoshka_dims": [
768,
512,
384,
128
],
"matryoshka_weights": [
1,
1,
1,
1
],
"n_dims_per_step": -1
}
per_device_train_batch_size: 128warmup_steps: 0.1bf16: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 128num_train_epochs: 3max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torchoptim_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: 1.0label_smoothing_factor: 0.0bf16: Truefp16: Falsebf16_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: trackioeval_strategy: noper_device_eval_batch_size: 8prediction_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: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.05 | 10 | 3.2163 |
| 0.1 | 20 | 1.7746 |
| 0.15 | 30 | 1.4810 |
| 0.2 | 40 | 1.3188 |
| 0.25 | 50 | 1.2752 |
| 0.3 | 60 | 1.0782 |
| 0.35 | 70 | 1.3100 |
| 0.4 | 80 | 1.1656 |
| 0.45 | 90 | 1.2851 |
| 0.5 | 100 | 0.8679 |
| 0.55 | 110 | 1.0867 |
| 0.6 | 120 | 0.9813 |
| 0.65 | 130 | 1.1205 |
| 0.7 | 140 | 1.0515 |
| 0.75 | 150 | 1.1204 |
| 0.8 | 160 | 1.0693 |
| 0.85 | 170 | 1.2327 |
| 0.9 | 180 | 1.0022 |
| 0.95 | 190 | 0.9105 |
| 1.0 | 200 | 0.9762 |
| 1.05 | 210 | 0.8044 |
| 1.1 | 220 | 0.6001 |
| 1.15 | 230 | 0.7198 |
| 1.2 | 240 | 0.7558 |
| 1.25 | 250 | 0.6640 |
| 1.3 | 260 | 0.7734 |
| 1.35 | 270 | 0.5751 |
| 1.4 | 280 | 0.6581 |
| 1.45 | 290 | 0.8340 |
| 1.5 | 300 | 0.7724 |
| 1.55 | 310 | 0.7067 |
| 1.6 | 320 | 0.8881 |
| 1.65 | 330 | 0.7336 |
| 1.7 | 340 | 0.8310 |
| 1.75 | 350 | 0.6577 |
| 1.8 | 360 | 0.7495 |
| 1.85 | 370 | 0.6583 |
| 1.9 | 380 | 0.6538 |
| 1.95 | 390 | 0.6584 |
| 2.0 | 400 | 0.7172 |
| 2.05 | 410 | 0.4208 |
| 2.1 | 420 | 0.6484 |
| 2.15 | 430 | 0.5394 |
| 2.2 | 440 | 0.6239 |
| 2.25 | 450 | 0.5398 |
| 2.3 | 460 | 0.5325 |
| 2.35 | 470 | 0.6015 |
| 2.4 | 480 | 0.5501 |
| 2.45 | 490 | 0.5694 |
| 2.5 | 500 | 0.5466 |
| 2.55 | 510 | 0.5243 |
| 2.6 | 520 | 0.5384 |
| 2.65 | 530 | 0.6373 |
| 2.7 | 540 | 0.4570 |
| 2.75 | 550 | 0.4945 |
| 2.8 | 560 | 0.4487 |
| 2.85 | 570 | 0.5663 |
| 2.9 | 580 | 0.6261 |
| 2.95 | 590 | 0.4750 |
| 3.0 | 600 | 0.3843 |
@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{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
Base model
answerdotai/ModernBERT-base