Sentence Similarity
PEFT
Safetensors
sentence-transformers
English
medical
cardiology
embeddings
domain-adaptation
lora
Run this model with HF Jobs
Run richardyoung/CardioEmbed-MPNet-base on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/richardyoung/CardioEmbed-MPNet-base. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/richardyoung/CardioEmbed-MPNet-base on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use richardyoung/CardioEmbed-MPNet-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use richardyoung/CardioEmbed-MPNet-base with PEFT:
from peft import PeftModel from transformers import AutoModel base_model = AutoModel.from_pretrained("sentence-transformers/all-mpnet-base-v2") model = PeftModel.from_pretrained(base_model, "richardyoung/CardioEmbed-MPNet-base") - sentence-transformers
How to use richardyoung/CardioEmbed-MPNet-base with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("richardyoung/CardioEmbed-MPNet-base") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Cardiology embedding model (separation: 0.386)
Browse filesFiles changed (8)
- README.mdAdded+55
- adapter_config.jsonAdded+42
- adapter_model.safetensorsAdded+3
- special_tokens_map.jsonAdded+51
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+73
- training_config.jsonAdded+18
- vocab.txtAdded
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455---library_name: peftbase_model: sentence-transformers/all-mpnet-base-v2tags:- medical- cardiology- embeddings- domain-adaptation- lora- sentence-transformers- sentence-similaritylanguage:- enlicense: apache-2.0---
# CardioEmbed-MPNet-base
**Domain-specialized cardiology text embeddings using LoRA-adapted MPNet-base**
Part of a comparative study of 10 embedding architectures for clinical cardiology.
## Performance
| Metric | Score ||--------|-------|| Separation Score | **0.386** |
## Usage
```pythonfrom transformers import AutoModel, AutoTokenizerfrom peft import PeftModel
base_model = AutoModel.from_pretrained("sentence-transformers/all-mpnet-base-v2")tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-mpnet-base-v2")model = PeftModel.from_pretrained(base_model, "richardyoung/CardioEmbed-MPNet-base")```
## Training
- **Training Data**: 106,535 cardiology text pairs from medical textbooks- **Method**: LoRA fine-tuning (r=16, alpha=32)- **Loss**: Multiple Negatives Ranking Loss (InfoNCE)
## Citation
```bibtex@article{young2024comparative, title={Comparative Analysis of LoRA-Adapted Embedding Models for Clinical Cardiology Text Representation}, author={Young, Richard J and Matthews, Alice M}, journal={arXiv preprint}, year={2024}}```123456789101112131415161718192021222324252627282930313233343536373839404142{ "alora_invocation_tokens": null, "alpha_pattern": {}, "arrow_config": null, "auto_mapping": null, "base_model_name_or_path": "sentence-transformers/all-mpnet-base-v2", "bias": "none", "corda_config": null, "ensure_weight_tying": false, "eva_config": null, "exclude_modules": null, "fan_in_fan_out": false, "inference_mode": true, "init_lora_weights": true, "layer_replication": null, "layers_pattern": null, "layers_to_transform": null, "loftq_config": {}, "lora_alpha": 32, "lora_bias": false, "lora_dropout": 0.1, "megatron_config": null, "megatron_core": "megatron.core", "modules_to_save": null, "peft_type": "LORA", "peft_version": "0.18.0", "qalora_group_size": 16, "r": 16, "rank_pattern": {}, "revision": null, "target_modules": [ "q", "k", "v" ], "target_parameters": null, "task_type": "FEATURE_EXTRACTION", "trainable_token_indices": null, "use_dora": false, "use_qalora": false, "use_rslora": false}123version https://git-lfs.github.com/spec/v1oid sha256:17e57ad9066d90adbb68c5825309a133eebbe50b8a61bd8acf53c7be187cd4fbsize 3548456123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051{ "bos_token": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "cls_token": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "eos_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "mask_token": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<pad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "sep_token": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273{ "added_tokens_decoder": { "0": { "content": "<s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "<pad>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "</s>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "<unk>", "lstrip": false, "normalized": true, "rstrip": false, "single_word": false, "special": true }, "104": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "30526": { "content": "<mask>", "lstrip": true, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "bos_token": "<s>", "clean_up_tokenization_spaces": false, "cls_token": "<s>", "do_lower_case": true, "eos_token": "</s>", "extra_special_tokens": {}, "mask_token": "<mask>", "max_length": 128, "model_max_length": 512, "pad_to_multiple_of": null, "pad_token": "<pad>", "pad_token_type_id": 0, "padding_side": "right", "sep_token": "</s>", "stride": 0, "strip_accents": null, "tokenize_chinese_chars": true, "tokenizer_class": "MPNetTokenizer", "truncation_side": "right", "truncation_strategy": "longest_first", "unk_token": "[UNK]"}123456789101112131415161718{ "name": "all-mpnet-base-v2", "model_id": "sentence-transformers/all-mpnet-base-v2", "batch_size": 48, "gradient_accumulation_steps": 1, "learning_rate": 2e-05, "epochs": 3, "max_seq_length": 512, "lora_r": 16, "lora_alpha": 32, "use_8bit": false, "target_modules": [ "q", "k", "v" ], "output_dir": "mpnet_base_cardiology"}README.mdAdded+55
adapter_config.jsonAdded+42
adapter_model.safetensorsAdded+3
special_tokens_map.jsonAdded+51
tokenizer.jsonAdded
tokenizer_config.jsonAdded+73
training_config.jsonAdded+18
vocab.txtAdded