dinushiTJ/nz_research_commons_embedding_triplets_5k
Viewer • Updated • 8.32k • 16
How to use dinushiTJ/nz-research-commons-embedding-gemma with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("dinushiTJ/nz-research-commons-embedding-gemma")
sentences = [
"maori_origin",
"title: Mutations of p53 gene and SV40 sequences in asbestos associated and non- asbestos-associated mesotheliomas\n\nauthors: Mayall, Frederick G.\n\nsubjects: mesothelioma\n\nabstract: AIM: To examine mesotheliomas for a possible relation between p53 immunostaining, p53 gene mutation, simian virus 40 (SV40), and asbestos exposure. METHODS: Paraffin sections from 11 mesotheliomas were used for p53 immunostaining and also to extract DNA. This was analysed for the presence of mutations in exons 5 to 8 of the p53 gene using a \"cold\" single strand conformational polymorphism method, together with sequencing. The DNA from the paraffin sections was also used to search for SV40 sequences. A 105 base pair segment at the 3' of the SV40 large T antigen (Tag) was targeted and any PCR amplification products were sequenced to confirm that they were of SV40 origin. EDAX electron microscopic differential mineral fibre counts were performed on dried lung tissue at a specialist referral centre. RESULTS: The fibre counts showed that seven of the mesotheliomas were associated with abnormally high asbestos exposure. Of these, two showed p53 immunostaining, none showed p53 gene mutation, and five showed SV40. Of the four other mesotheliomas, three showed p53 immunostaining, one showed a (silent) p53 mutation, and none showed SV40. The difference in frequency of SV40 detection was significant at the p < 0.05 level. CONCLUSIONS: Immunostaining for the p53 gene was relatively common but p53 mutations were rare in this series. SV40 virus sequence was detected in five of seven asbestos associated mesotheliomas but in none of the non-asbestos-associated mesotheliomas. This suggests there may be a synergistic interaction between asbestos and SV40 in human mesotheliomas. A study with a larger number of cases is needed to investigate these observations further.\n\ntext: Mutations of p53 gene and SV40 sequences in asbestos associated and non- asbestos-associated mesotheliomas AIM: To examine mesotheliomas for a possible relation between p53 immunostaining, p53 gene mutation, simian virus 40 (SV40), and asbestos exposure. METHODS: Paraffin sections from 11 mesotheliomas were used for p53 immunostaining and also to extract DNA. This was analysed for the presence of mutations in exons 5 to 8 of the p53 gene using a \"cold\" single strand conformational polymorphism method, together with sequencing. The DNA from the paraffin sections was also used to search for SV40 sequences. A 105 base pair segment at the 3' of the SV40 large T antigen (Tag) was targeted and any PCR amplification products were sequenced to confirm that they were of SV40 origin. EDAX electron microscopic differential mineral fibre counts were performed on dried lung tissue at a specialist referral centre. RESULTS: The fibre counts showed that seven of the mesotheliomas were associated with abnormally high asbestos exposure. Of these, two showed p53 immunostaining, none showed p53 gene mutation, and five showed SV40. Of the four other mesotheliomas, three showed p53 immunostaining, one showed a (silent) p53 mutation, and none showed SV40. The difference in frequency of SV40 detection was significant at the p < 0.05 level. CONCLUSIONS: Immunostaining for the p53 gene was relatively common but p53 mutations were rare in this series. SV40 virus sequence was detected in five of seven asbestos associated mesotheliomas but in none of the non-asbestos-associated mesotheliomas. This suggests there may be a synergistic interaction between asbestos and SV40 in human mesotheliomas. A study with a larger number of cases is needed to investigate these observations further.\n\nyear: 2013",
"title: Te Karauna Hou: the senior Ngati Rahiri rangatira\n\nauthors: Hart, Philip\n\nabstract: Te Karauna Hou, the principal Ngati Rahiri rangatira living at Te Aroha in 1880, had a distinguished whakapapa linking him to several hapu. Before settling permanently at Te Aroha in the 1870s he lived in several places, especially at Kaitawa, on the southern outskirts of Thames. One of the principal rangatira in Hauraki, he was loyal to the Crown during the Waikato War, and later assisted Pakeha settlement. To emphasize his mana and that of his hapu, he held big festivities at Kaitawa and at Omahu pa at Te Aroha. \r\nIn 1871, when Ngati Haua won a (temporary) victory in the land court over the ownership of the Aroha Block, Karauna took control of it on behalf of the Marutuahu confederation, and subsequently kept Ngati Haua at bay. For a time he opposed road-making on this block, but later agreed to it, for financial reasons. Like all rangatira, he sought to maximize his ownership of as many blocks of land as possible, sometimes having his lies exposed through his contradicting his earlier evidence. He also denied receiving money for land when his denials were easily disproved. Despite leasing and selling land, selling timber and gum, and opening his land to miners, he often struggled financially. \r\nKarauna claimed to have found gold in Hauraki in 1852, and was willing to open his land at Thames to miners, but did not invest in any claims before the Te Aroha rush, when he attempted to extract a bonus of £1,000 from the government for opening the field. After his death in 1885, Pakeha remembered with gratitude his friendly attitude to them, but they also remembered his drunkenness, which meant he lost the respect of both Maori and Pakeha in his latter years.\n\ntext: Te Karauna Hou: the senior Ngati Rahiri rangatira Te Karauna Hou, the principal Ngati Rahiri rangatira living at Te Aroha in 1880, had a distinguished whakapapa linking him to several hapu. Before settling permanently at Te Aroha in the 1870s he lived in several places, especially at Kaitawa, on the southern outskirts of Thames. One of the principal rangatira in Hauraki, he was loyal to the Crown during the Waikato War, and later assisted Pakeha settlement. To emphasize his mana and that of his hapu, he held big festivities at Kaitawa and at Omahu pa at Te Aroha. \r\nIn 1871, when Ngati Haua won a (temporary) victory in the land court over the ownership of the Aroha Block, Karauna took control of it on behalf of the Marutuahu confederation, and subsequently kept Ngati Haua at bay. For a time he opposed road-making on this block, but later agreed to it, for financial reasons. Like all rangatira, he sought to maximize his ownership of as many blocks of land as possible, sometimes having his lies exposed through his contradicting his earlier evidence. He also denied receiving money for land when his denials were easily disproved. Despite leasing and selling land, selling timber and gum, and opening his land to miners, he often struggled financially. \r\nKarauna claimed to have found gold in Hauraki in 1852, and was willing to open his land at Thames to miners, but did not invest in any claims before the Te Aroha rush, when he attempted to extract a bonus of £1,000 from the government for opening the field. After his death in 1885, Pakeha remembered with gratitude his friendly attitude to them, but they also remembered his drunkenness, which meant he lost the respect of both Maori and Pakeha in his latter years.\n\nyear: 2016",
"title: Mental health and wellbeing for young people from intersectional identity groups: Inequity for Māori, Pacific, Rainbow young people, and those with a disabling condition\n\nauthors: Roy, Rituparna\n\nsubjects: Māori\n\nabstract: ‘Intersectionality’ describes the converging effects of ethnicity, gender, sexuality, disability, and other social group characteristics that influence life experiences. We draw on a representative study of year 9-13 students in Tai Tokerau, Tāmaki Makaurau, and Waikato (Youth19) to explore differences in mental health and wellbeing outcomes for young people from a selection of intersectional identities (Māori, Pasifika, Rainbow, and young people with a Disabling Condition). We found a pervasive pattern of inequity for young people who have intersectional identities compared to those from the majority groups (i.e. Pākehā, non-disabled, cis-heterosexual youth). Intersectional youth had higher levels of inequity and faced a greater array of inequities. There was evidence of an additive effect for some indicators. Thematic analysis of open-text survey responses found the need for positive inclusive environments, and support for all young people, including those at the intersections of identity. Drawing on the findings, we offered several systemslevel policy recommendations, including strategies to improve inclusiveness and reduce discrimination.\n\ntext: Mental health and wellbeing for young people from intersectional identity groups: Inequity for Māori, Pacific, Rainbow young people, and those with a disabling condition ‘Intersectionality’ describes the converging effects of ethnicity, gender, sexuality, disability, and other social group characteristics that influence life experiences. We draw on a representative study of year 9-13 students in Tai Tokerau, Tāmaki Makaurau, and Waikato (Youth19) to explore differences in mental health and wellbeing outcomes for young people from a selection of intersectional identities (Māori, Pasifika, Rainbow, and young people with a Disabling Condition). We found a pervasive pattern of inequity for young people who have intersectional identities compared to those from the majority groups (i.e. Pākehā, non-disabled, cis-heterosexual youth). Intersectional youth had higher levels of inequity and faced a greater array of inequities. There was evidence of an additive effect for some indicators. Thematic analysis of open-text survey responses found the need for positive inclusive environments, and support for all young people, including those at the intersections of identity. Drawing on the findings, we offered several systemslevel policy recommendations, including strategies to improve inclusiveness and reduce discrimination.\n\nyear: 2023"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model trained on the nz_research_commons_embedding_triplets_5k dataset. 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': 'Gemma3TextModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
(3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
(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("dinushiTJ/nz-research-commons-embedding-gemma")
# Run inference
queries = [
'non_maori_origin',
]
documents = [
'title: Urban narrative: Computational linguistic interpretation of large format public participation for urban infrastructure\n\nauthors: Dyer, Mark\n\nabstract: Urban Narrative works at the interface between public participation and participatory design to support collaboration processes for urban planning and design. It applies computational linguistics to interpret large format public consultation by identifying shared interests and desired qualities for urban infrastructure services and utilities. As a proof of concept, data was used from the Christchurch public engagement initiative called ‘Share an Idea,’ where public thoughts, ideas, and opinions were expressed about the future redevelopment of Christchurch after the 2011 earthquakes. The data set was analysed to identify shared interests and desired connections between institutional, communal, or personal infrastructures with the physical urban infrastructures in terms of buildings, public places, and utilities. The data has been visualised using chord charts from the D3 JavaScript open source library to illustrate the existence of connections between soft and hard urban infrastructures along with individual contributions or stories. Lastly, the analysis was used to create an infographic design brief that compares and contrasts qualitative information from public consultation with quantitative municipal statistical data on well-being.\n\ntext: Urban narrative: Computational linguistic interpretation of large format public participation for urban infrastructure Urban Narrative works at the interface between public participation and participatory design to support collaboration processes for urban planning and design. It applies computational linguistics to interpret large format public consultation by identifying shared interests and desired qualities for urban infrastructure services and utilities. As a proof of concept, data was used from the Christchurch public engagement initiative called ‘Share an Idea,’ where public thoughts, ideas, and opinions were expressed about the future redevelopment of Christchurch after the 2011 earthquakes. The data set was analysed to identify shared interests and desired connections between institutional, communal, or personal infrastructures with the physical urban infrastructures in terms of buildings, public places, and utilities. The data has been visualised using chord charts from the D3 JavaScript open source library to illustrate the existence of connections between soft and hard urban infrastructures along with individual contributions or stories. Lastly, the analysis was used to create an infographic design brief that compares and contrasts qualitative information from public consultation with quantitative municipal statistical data on well-being.\n\nyear: 2020',
'title: A report to iwi on the kaupapa Māori environmental outcomes and indicators kete\n\nauthors: Jefferies, Richard\n\nsubjects: New Zealand\n\nabstract: Tangata whenua in Aotearoa have been largely excluded from participation in local government planning since colonisation, but tikanga and Māori values have for the past two decades been acknowledged in resource management and local government legislation, especially the Resource Management Act, 1991 (RMA) and Local Government Act, 2002 (LGA). For example, the RMA has provisions in over 30 sections for councils to give effect to Māori interests.\r\n\r\nIn practice, however, there is widespread concern that despite these provisions, Māori are largely excluded from local government resource management processes and their values subordinated to those of the wider community, particularly western scientific values.\r\n\r\nThis report describes research that resulted in a kaupapa Māori outcomes and indicators framework, and associated methods, that can be used by iwi to assess the quality of statutory plans and the environmental performance of councils in their rohe.\n\ntext: A report to iwi on the kaupapa Māori environmental outcomes and indicators kete Tangata whenua in Aotearoa have been largely excluded from participation in local government planning since colonisation, but tikanga and Māori values have for the past two decades been acknowledged in resource management and local government legislation, especially the Resource Management Act, 1991 (RMA) and Local Government Act, 2002 (LGA). For example, the RMA has provisions in over 30 sections for councils to give effect to Māori interests.\r\n\r\nIn practice, however, there is widespread concern that despite these provisions, Māori are largely excluded from local government resource management processes and their values subordinated to those of the wider community, particularly western scientific values.\r\n\r\nThis report describes research that resulted in a kaupapa Māori outcomes and indicators framework, and associated methods, that can be used by iwi to assess the quality of statutory plans and the environmental performance of councils in their rohe.\n\nyear: 2009-06-30',
'title: The issues of the criminal justice system and of resources in Aotearoa/New Zealand\n\nauthors: Toki, Valmaine\n\nabstract: Within the seven regions, recognized by the United Nations, various jurisdictions have acknowledged Indigenous rights within their respective constitutions. Although not explicit, some constitutional provisions, such as those included in the Norwegian Constitution, when read together with other articles, provide tentative opportunities for the implementation of an Indigenous legal system and an Indigenous court. Some Constitutions, such as that of Ecuador, are more explicit in providing constitutional recognition of an Indigenous legal system as well as rights to nature and, the interim Constitution of Nepal, courts for Indigenous Peoples.\n\ntext: The issues of the criminal justice system and of resources in Aotearoa/New Zealand Within the seven regions, recognized by the United Nations, various jurisdictions have acknowledged Indigenous rights within their respective constitutions. Although not explicit, some constitutional provisions, such as those included in the Norwegian Constitution, when read together with other articles, provide tentative opportunities for the implementation of an Indigenous legal system and an Indigenous court. Some Constitutions, such as that of Ecuador, are more explicit in providing constitutional recognition of an Indigenous legal system as well as rights to nature and, the interim Constitution of Nepal, courts for Indigenous Peoples.\n\nyear: 2014',
]
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.7187, -0.9579, -0.3887]])
rc-triplet-evalTripletEvaluator| Metric | Value |
|---|---|
| cosine_accuracy | 0.984 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
maori_origin |
title: KAUMĀTUATANGA Supporting School Leaders To Develop Cultural Values While Resisting The Dominance of Colonialism |
title: Studies of New Zealand Marine Organisms |
maori_origin |
title: Taku Ara, Taku Mahara: Pākehā Family Experiences of Kaupapa Māori and Bilingual Education |
title: What is creative to whom and why? Perceptions in advertising agencies |
maori_origin |
title: Te whakahuatanga i te reo Māori: Kua ahatia e tātou i roto i ngā tau 100 kua hipa nei? (The pronunciation of Māori: What have we done to it in the last 100 Years?) |
title: A contrast-sensitive, redundancy reduction mechanism acting on MT neurons can explain global motion direction biases without the need for Bayesian priors |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.COSINE",
"triplet_margin": 0.3
}
per_device_train_batch_size: 1learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1load_best_model_at_end: Truepush_to_hub: Truehub_model_id: dinushiTJ/nz-research-commons-embedding-gemmahub_strategy: checkpointhub_private_repo: Falseeval_on_start: Trueprompts: task: classification | query:overwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 1per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_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: {}warmup_ratio: 0.1warmup_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: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_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: Trueresume_from_checkpoint: Nonehub_model_id: dinushiTJ/nz-research-commons-embedding-gemmahub_strategy: checkpointhub_private_repo: Falsehub_always_push: Falsehub_revision: Nonegradient_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: Trueuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: task: classification | query: batch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | rc-triplet-eval_cosine_accuracy |
|---|---|---|
| 1.0 | 5000 | 0.9840 |
@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}
}