Sentence Similarity
PEFT
Safetensors
sentence-transformers
English
medical
cardiology
embeddings
domain-adaptation
lora
Run this model with HF Jobs
Run richardyoung/CardioEmbed-BioLinkBERT 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-BioLinkBERT. 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-BioLinkBERT 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-BioLinkBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use richardyoung/CardioEmbed-BioLinkBERT with PEFT:
from peft import PeftModel from transformers import AutoModel base_model = AutoModel.from_pretrained("michiyasunaga/BioLinkBERT-large") model = PeftModel.from_pretrained(base_model, "richardyoung/CardioEmbed-BioLinkBERT") - sentence-transformers
How to use richardyoung/CardioEmbed-BioLinkBERT with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("richardyoung/CardioEmbed-BioLinkBERT") 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
Initial upload: Best performing cardiology embedding model (separation: 0.510)
Browse filesFiles changed (8)
- README.mdAdded+72
- adapter_config.jsonAdded+42
- adapter_model.safetensorsAdded+3
- special_tokens_map.jsonAdded+37
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+58
- training_config.jsonAdded+18
- vocab.txtAdded
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172---library_name: peftbase_model: michiyasunaga/BioLinkBERT-largetags:- medical- cardiology- embeddings- domain-adaptation- lora- sentence-transformers- sentence-similaritylanguage:- enlicense: apache-2.0---
# CardioEmbed-BioLinkBERT
**Domain-specialized cardiology text embeddings using LoRA-adapted BioLinkBERT-large**
This is the **best performing model** from our comparative study of 10 embedding architectures for clinical cardiology.
## Performance
| Metric | Score ||--------|-------|| Separation Score | **0.510** || Similar Pair Avg | 0.811 || Different Pair Avg | 0.301 || Throughput | 143.5 emb/sec || Memory | 1.51 GB |
## Usage
```pythonfrom transformers import AutoModel, AutoTokenizerfrom peft import PeftModel
# Load base modelbase_model = AutoModel.from_pretrained("michiyasunaga/BioLinkBERT-large")tokenizer = AutoTokenizer.from_pretrained("michiyasunaga/BioLinkBERT-large")
# Load LoRA adaptermodel = PeftModel.from_pretrained(base_model, "richardyoung/CardioEmbed-BioLinkBERT")
# Generate embeddingstext = "Atrial fibrillation with rapid ventricular response"inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)outputs = model(**inputs)embeddings = outputs.last_hidden_state.mean(dim=1)```
## 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}}```
## Related Models
This is part of the CardioEmbed model family. See [richardyoung/CardioEmbed](https://huggingface.co/richardyoung/CardioEmbed) for more models.123456789101112131415161718192021222324252627282930313233343536373839404142{ "alora_invocation_tokens": null, "alpha_pattern": {}, "arrow_config": null, "auto_mapping": null, "base_model_name_or_path": "michiyasunaga/BioLinkBERT-large", "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": [ "value", "key", "query" ], "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:93a2689f97321200ced08a2389c4fcf79337df643456168667469041de7faddfsize 945690412345678910111213141516171819202122232425262728293031323334353637{ "cls_token": { "content": "[CLS]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "mask_token": { "content": "[MASK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "[PAD]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "sep_token": { "content": "[SEP]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758{ "added_tokens_decoder": { "0": { "content": "[PAD]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "[CLS]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "[SEP]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "4": { "content": "[MASK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "clean_up_tokenization_spaces": false, "cls_token": "[CLS]", "do_basic_tokenize": true, "do_lower_case": true, "extra_special_tokens": {}, "mask_token": "[MASK]", "model_max_length": 1000000000000000019884624838656, "never_split": null, "pad_token": "[PAD]", "sep_token": "[SEP]", "strip_accents": null, "tokenize_chinese_chars": true, "tokenizer_class": "BertTokenizer", "unk_token": "[UNK]"}123456789101112131415161718{ "name": "BioLinkBERT-large", "model_id": "michiyasunaga/BioLinkBERT-large", "batch_size": 64, "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": [ "query", "key", "value" ], "output_dir": "biolinkbert_cardiology"}README.mdAdded+72
adapter_config.jsonAdded+42
adapter_model.safetensorsAdded+3
special_tokens_map.jsonAdded+37
tokenizer.jsonAdded
tokenizer_config.jsonAdded+58
training_config.jsonAdded+18
vocab.txtAdded