Views
No views yet
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 'query: If baby dey warm up but still dey shiver and cannot keep normal temperature, wetin next?',
8]
9documents = [
10 'passage: FINDING ON HISTORY FINDINGS ON CLINICAL JUDGMENT ACTION EXAMINATION Cold hands and feet -Temperature less than 36.5oC Moderate Condition 1.Ensure baby is dry and in -Cold Stress 36.0 – 36.4oC clean dry clothing -Moderate hypothermia 32.0 2.Place baby in skin to skin – 35.9oC contact in a pre-warmed Severe hypothermia <32.0oC blouse/shirt opening at the front with the baby in a nappy, hat and socks 3.Wrap baby in warm blanket 4.Ensure that the room is warm (at least 25oC) and is without drafts 5.If temperature is improving but baby cannot maintain normal temperature, put baby in Kangaroo Mother Care (KMC). 6.If temperature does not improve after one hour of re- warming, REFER immediately to hospital 2.Yellow hands and feet - Jaundice, No fever Moderate Condition REFER immediately to hospital where phototherapy is possible. Health Education 1.Continue skin to skin contact between mother and baby. 2.Teach mother about Kangaroo Mother Care -KMC). 3.Exclusive breastfeeding. 4.Counsel family members to support mother go through process.',
11 'passage: iv. Small baby •Weight is 2.5 kg or below Moderate condition 1.Encourage exclusive •Baby can suck breastfeeding. 2.Keep baby warm using Kangaroo Mother Care (KMC). 3.Review in 2 days. If improving, review weekly for 2 weeks. If no improvement, REFER. v. Birth marks •Small black or blue patches Moderate condition 1. Reassure mother or red or bluish red vi. Bleeding from circumcision • Bleeding with or without Moderate 1.Put pressure on side for 10 pallor minutes 2. Show mother how to maintain pressure 1-2 hours. 3. If bleeding does not stop, REFER appropriately. vii. Constipation Abdominal distention or no Mild/Moderate condition finding. 1.Encourage exclusive breastfeeding 2.Probe rectum to stimulate defecation If no improvement, REFER viii. Baby not feeding well, •No abnormality Mild condition 1.Examine mother’s breasts Crying always. •Baby is well Irritable and treat if necessary. Suspect maternal causes 2.Observe how mother feeds infant and correct if necessary. Counsel mother accordingly.',
12 "passage: MODERATE ACUTE MALNUTRITION: WFH/L greater than -3 to less than -2 z-scores OR MUAC 11.5 to 12.4cm. Treatment: If growth is faltering for 2 consecutive months, give Vitamin A, assess further or refer to hospital. Assess the child's feeding and counsel the mother on feeding recommendations. Give Albendazole if child is 1 year or older and has not had a dose in the previous 6 months. If feeding problems, follow up in 14 days. AT RISK OF ACUTE MALNUTRITION: Static weight or losing weight, -2 to less than -1 Z-Score. For age 6 months up to 59 months MUAC 12.5 to 13.5cm. Treatment: If child is less than 2 years old, and has growth faltering, assess feeding and counsel mother on feeding recommendations. Give Albendazole if child is 1 year or older and has not had a dose in the previous 6 months. Follow up in 14 days. If feeding problem, follow-up in 5 days. NO ACUTE MALNUTRITION: WFH/L greater than -1 z-scores OR MUAC greater than 13.5 cm.",
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 384] [3, 384]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.5057, 0.2280, 0.0387]])medichat-golden-evalInformationRetrievalEvaluator with these parameters:
1{
2 "query_prompt": "query: ",
3 "corpus_prompt": "passage: "
4}| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.5684 |
| cosine_accuracy@3 | 0.7053 |
| cosine_accuracy@5 | 0.7789 |
| cosine_accuracy@10 | 0.8632 |
| cosine_precision@1 | 0.5684 |
| cosine_precision@3 | 0.2351 |
| cosine_precision@5 | 0.1558 |
| cosine_precision@10 | 0.0863 |
| cosine_precision@20 | 0.0455 |
| cosine_recall@1 | 0.5684 |
| cosine_recall@3 | 0.7053 |
| cosine_recall@5 | 0.7789 |
| cosine_recall@10 | 0.8632 |
| cosine_recall@20 | 0.9105 |
| cosine_ndcg@1 | 0.5684 |
| cosine_ndcg@3 | 0.6486 |
| cosine_ndcg@5 | 0.6778 |
| cosine_ndcg@10 | 0.7055 |
| cosine_mrr@1 | 0.5684 |
| cosine_mrr@3 | 0.6289 |
| cosine_mrr@5 | 0.6445 |
| cosine_mrr@10 | 0.6562 |
| cosine_map@100 | 0.662 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
query: Madam, patient get chest pain with nausea and black stool. Pulse na 45. How I take am? | passage: I. Chest pain with any of the Pulse < 50/min Or > 100/min Severe condition REFER immediately to the following: BP > 180/110mmHg appropriate health facility. Nausea Difficult breathing Vomiting Pain radiates to neck, arm, shoulder and back II. Chest pain BP <90/60mmHg Temperature Severe condition 1. IV Normal saline 500ml, stop if 37.2°C breathing becomes worse 2. IV/IM Ceftriaxone 1g stat If no improvement, REFER appro- priately.. III. Chest pain becomes Severe pain Severe condition REFER immediately to the appro- worse on lying down or deep priate health facility. breathing IV. Severe chest pain and In pains Severe condition Low- Osmolarity ORS or known sickle cell disease IV Normal Saline 500ml 6hourly REFER if no improvement appro- priately. V. Central chest pain, radiates Central chest pain Severe condition (suspect REFER immediately to the to the neck, jaw and arm that angina) appropriate health facility. is : recurrent attack (joint pain) resulting from physical activity... | passage: 1.How long have you had this complaint? Is this the first time? 1. General appearance: Ill-looking 2.Have you had a good appetite? Any nausea or vomiting? 2. Temperature, pulse respiration, blood pressure: check and 3.Have you been urinating more frequently at night? Any pain on record micturition? 3. Face: Puffy 4.Any bleeding from nose? 4. Eyes:pallor jaundice * Vomiting or coughing blood? 5. Chest: crepitation, wheezes, decreased breath sounds * Blood in the urine or stool? Black stool? 6. Heart: rate, rhythm, 5.Any cough? Or breathlessness at night? 7. Abdomen: large tender liver, enlarged spleen 6.Do you sleep with extra pillow? 8. Limbs: a) legs 7.Have you ever been treated for jaundice? i) for oedema ii) does swelling pit on pressure (if not pitting, think of ele- phantiasis) b) hands for oedema 10. Urine: check for protein and sugar FINDING ON HISTORY FINDINGS ON CLINICAL ACTION EXAMINATION JUDGEMENT I. Swollen legs with large Swollen legs Severe condition REFER immedi... |
query: What is the correct Ribavir dose for a child weighing 3kg | passage: Hepatitis: Diffuse inflammation of the liver that can be caused by infective agents, drugs, alcohol, autoimmune and toxins. Clinical Features: Acute hepatitis (lasting for less than 6 months): Mild-to-moderate jaundice, Vague right upper quadrant discomfort, Fever, Hepatomegaly. Chronic hepatitis (lasting more than 6 months): General malaise/Fatigue, Re-occurence of jaundice. Complications: Liver failure, Bleeding tendencies, Cirrhosis/Liver cancer. Investigations: Liver Function Tests, Serologic markers of Hepatitis A, B, C, D and E, Viral load, Abdominal ultrasonography, Prothrombin time, HIV Screening. Treatment Goals: Provide supportive measures, Prevent progression to chronic phase. Non-drug Treatment: High carbohydrate and Normal protein diet, Discontinuation of hepatotoxic medication, Bed rest. Drug Treatment: Chronic Hepatitis B — Treatment is required in patients with viral load exceeding 2000 IU/ml for HBeAg negative or 20000 IU/ml for HBeAg positive status. Pegylate... | passage: Medicine doses in children are generally based on body weight in kilograms or age ranges: first one month (neonate), up to 1 year (infant), 1-5 years, and 6-12 years. Unless age is specified, the term child includes persons aged 12 years and below. Doses are calculated based on body weight or body surface area in square metres. Body Surface Area estimates are more accurate for calculation of paediatric doses as many physiological phenomena correlate better to BSA. For most medicines the adult maximum dose should not be exceeded. For example if the dose is stated as 4 mg/kg with max 180 mg, a child weighing 10 kg should receive 40 mg but a child weighing 50 kg should receive 180 mg not 200 mg. Young children may require higher doses per kilogram than adults because of their higher metabolic rate. Calculation by body weight in an overweight child may result in much higher doses than necessary so doses should be calculated based on ideal body weight in relation to height and age.... |
query: Aunty, girl dey bleed plenty during period with clots and she pale. Which care I go give for clinic? | passage: I. Abdominal pain with men- Lower abdominal tenderness, Moderate condition 1.Reassure the client/patient struation; Foul smelling High temperature Suspect infection 2. Counsel on personal hygiene discharge per vagina; Fever (use of sanitary pad) 3. Capsule Amoxicillin 250mg 8hourly for 5 days 4. Conduct RDT, if positive, treat for uncomplicated malaria 5. Review in 5 days, if no improvement REFER immediately to the appropriate health facility II. Heavy menstrual flow with May be pale Moderate condition 1.Reassure the client/patient clots, prolonged menstruation Blood clots per vagina Abnormal menstrual flow 2. Tablet Paracetamol 500mg 8hourly for 3 days III. Lower abdominal pain Lower abdominal Mild condition 1.Tablet Paracetamol 500 mg associated with menstruation tenderness, no fever, Suspect dysmenorrhea 8hourly for 3days No foul smelling Reassure and counsel discharge IV. Mucus or blood per vagina Normal mucus, no Mild condition 1. Counsel and reassure patient. smell Norma... | passage: 1.Have you used any contraceptive method before? General appearance: anxious thin, obese, ill, 2.What method were you using? Which Clinic did you attend? Skin: scars (signs of domestic violence) Why do you want to attend this particular clinic? Weight: weigh and record 3.Who referred you to this Clinic? Blood pressure: measure and record 4.How many children have you had? How many are alive? How Hair: hair loss especially in temporal region many dead? When did you have your last baby? Did you have a Face: swelling normal vaginal delivery or were you assisted (caesarean section, Eyes: pallor or jaundice forceps delivery or vacuum extraction). Neck: goitre, lymph nodes 5.Are you breastfeeding? Chest: shape, respiratory difficulty or rapid creps or wheeze 6.Are you menstruating now? When did you start? If not, when Heart: rate, rhythm, murmur was the last menstrual period? Breast: lump, dimpling of the skin, abnormal appearance of the 7.Do you normally have; nipples, retraction of... |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false,
5 "directions": [
6 "query_to_doc"
7 ],
8 "partition_mode": "joint",
9 "hardness_mode": null,
10 "hardness_strength": 0.0
11}per_device_train_batch_size: 32gradient_accumulation_steps: 2learning_rate: 2e-05num_train_epochs: 20warmup_steps: 0.1fp16: Trueload_best_model_at_end: Truegradient_checkpointing: Truebatch_sampler: no_duplicatesdo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 8gradient_accumulation_steps: 2eval_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: 20max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0.1log_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: Truebf16_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: Trueignore_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: Truegradient_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: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | medichat-golden-eval_cosine_ndcg@10 |
|---|---|---|---|
| 0.7407 | 10 | 3.8362 | - |
| 1.0 | 14 | - | 0.5792 |
| 1.4444 | 20 | 2.9571 | - |
| 2.0 | 28 | - | 0.5599 |
| 2.1481 | 30 | 1.8002 | - |
| 2.8889 | 40 | 1.2668 | - |
| 3.0 | 42 | - | 0.5853 |
| 3.5926 | 50 | 0.9162 | - |
| 4.0 | 56 | - | 0.6278 |
| 4.2963 | 60 | 0.8223 | - |
| 5.0 | 70 | 0.6656 | 0.6464 |
| 5.7407 | 80 | 0.6323 | - |
| 6.0 | 84 | - | 0.6671 |
| 6.4444 | 90 | 0.4876 | - |
| 7.0 | 98 | - | 0.6803 |
| 7.1481 | 100 | 0.5103 | - |
| 7.8889 | 110 | 0.4655 | - |
| 8.0 | 112 | - | 0.6981 |
| 8.5926 | 120 | 0.4001 | - |
| 9.0 | 126 | - | 0.6957 |
| 9.2963 | 130 | 0.3273 | - |
| 10.0 | 140 | 0.3571 | 0.6977 |
| 10.7407 | 150 | 0.3500 | - |
| 11.0 | 154 | - | 0.6991 |
| 11.4444 | 160 | 0.3185 | - |
| 12.0 | 168 | - | 0.7077 |
| 12.1481 | 170 | 0.2886 | - |
| 12.8889 | 180 | 0.2871 | - |
| 13.0 | 182 | - | 0.7087 |
| 13.5926 | 190 | 0.2392 | - |
| 14.0 | 196 | - | 0.7048 |
| 14.2963 | 200 | 0.2379 | - |
| 15.0 | 210 | 0.2381 | 0.7050 |
| 15.7407 | 220 | 0.2472 | - |
| 16.0 | 224 | - | 0.7078 |
| 16.4444 | 230 | 0.2206 | - |
| 17.0 | 238 | - | 0.7086 |
| 17.1481 | 240 | 0.2120 | - |
| 17.8889 | 250 | 0.2308 | - |
| 18.0 | 252 | - | 0.7055 |
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{oord2019representationlearningcontrastivepredictive,
2 title={Representation Learning with Contrastive Predictive Coding},
3 author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
4 year={2019},
5 eprint={1807.03748},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/1807.03748},
9}