Instructions to use emilyalsentzer/Bio_ClinicalBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use emilyalsentzer/Bio_ClinicalBERT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="emilyalsentzer/Bio_ClinicalBERT")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("emilyalsentzer/Bio_ClinicalBERT", dtype="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
How can I use it in locally on CPU
#8
by Jahanzaib006201 - opened
Hi,
kindly guide me how can i use this model locally on CPU. I want to explore this model if anyone knows about it kindly share the way to use it. Thank you!
Here's how to use emilyalsentzer/Bio_ClinicalBERT with Hugging Face's transformers library:
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
model = AutoModel.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
Encode Text:
text = "The patient was prescribed 5mg of Coumadin."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
outputs = model(**inputs)
# Extract embeddings
last_hidden_state = outputs.last_hidden_state # shape: (1, seq_len, hidden_dim)
cls_embedding = last_hidden_state[:, 0, :] # [CLS] token embedding