Update README.md
Browse files
README.md
CHANGED
|
@@ -5,4 +5,28 @@ language:
|
|
| 5 |
tags:
|
| 6 |
- NLP
|
| 7 |
pipeline_tag: feature-extraction
|
| 8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
- NLP
|
| 7 |
pipeline_tag: feature-extraction
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Usage
|
| 11 |
+
from transformers import AutoTokenizer
|
| 12 |
+
from model import (
|
| 13 |
+
BERTContrastiveLearning_simcse,
|
| 14 |
+
BERTContrastiveLearning_simcse_w,
|
| 15 |
+
BERTContrastiveLearning_samp,
|
| 16 |
+
BERTContrastiveLearning_samp_w,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
str_list = data["string"].tolist() # Your list of strings here
|
| 20 |
+
tokenizer = AutoTokenizer.from_pretrained("emilyalsentzer/Bio_ClinicalBERT")
|
| 21 |
+
tokenized_inputs = tokenizer(
|
| 22 |
+
str_list, padding=True, max_length=50, truncation=True, return_tensors="pt"
|
| 23 |
+
)
|
| 24 |
+
input_ids = tokenized_inputs["input_ids"]
|
| 25 |
+
attention_mask = tokenized_inputs["attention_mask"]
|
| 26 |
+
|
| 27 |
+
model1 = BERTContrastiveLearning_simcse.load_from_checkpoint(ckpt1).eval()
|
| 28 |
+
model2 = BERTContrastiveLearning_simcse_w.load_from_checkpoint(ckpt2).eval()
|
| 29 |
+
model3 = BERTContrastiveLearning_samp.load_from_checkpoint(ckpt3).eval()
|
| 30 |
+
model4 = BERTContrastiveLearning_samp_w.load_from_checkpoint(ckpt4).eval()
|
| 31 |
+
|
| 32 |
+
cls, _ = model(input_ids, attention_mask) # embeddings
|