Views
No views yet
dmis-lab/biobert-base-cased-v1.1pip install transformers torch1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4# Load the model and tokenizer
5model_name = "debjit20504/miRNA-biobert"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9# Move model to GPU or MPS (for Mac)
10device = torch.device("mps") if torch.backends.mps.is_available() else torch.device("cuda" if torch.cuda.is_available() else "cpu")
11model.to(device)
12model.eval()
13
14def classify_text(text):
15 inputs = tokenizer(text, return_tensors="pt").to(device)
16 with torch.no_grad():
17 output = model(**inputs)
18 label = torch.argmax(output.logits, dim=1).item()
19 return "functional" if label == 1 else "Non-functional"
20
21# Example Test
22sample_text = "The results showed that miR-223-3p decreased in glioblastoma tissue but NLRP3 increased."
23print(f"Classification: {classify_text(sample_text)}")