Views
No views yet
allenai/scibert_scivocab_uncasedtext_plain)label_int).transformers library1e-580.018XX.XX% (replace with your evaluation results)XX.XX% (replace with your evaluation results)1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3# Load the fine-tuned model and tokenizer
4model_name = "Geraldine/scibert-publications-classification" # Replace with your model name
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8# Example input
9text = "This paper explores the application of quantum computing in solving complex chemical problems."
10
11# Tokenize the input
12inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=512)
13
14# Get predictions
15outputs = model(**inputs)
16predictions = outputs.logits.argmax(dim=-1).item()
17print(f"Predicted category: {predictions}")| Label ID | Category |
|---|---|
| 0 | Medical Research |
| 1 | Biology (fond.) |
| 2 | Earth, Ecology, Energy and applied biology |
| 3 | Physical sciences and Astronomy |
| 4 | Social sciences |
| 5 | Mathematics |
| 6 | Humanities |
| 7 | Computer and information sciences |
| 8 | Chemistry |
| 9 | Engineering |
1from sklearn.metrics import classification_report, accuracy_score
2
3# Example: Ground truth labels and predicted labels
4y_true = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # Replace with actual labels
5y_pred = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # Replace with predictions
6
7# Accuracy
8acc = accuracy_score(y_true, y_pred)
9print(f"Accuracy: {acc}")
10
11# Classification report
12print(classification_report(y_true, y_pred, target_names=[
13 "Medical Research","Biology (fond.)","Earth, Ecology, Energy and applied biology",
14 "Physical sciences and Astronomy","Social sciences","Mathematics","Humanities",
15 "Computer and information sciences","Chemistry","Engineering"
16]))@article{your_citation_key,
title={Fine-tuned SciBERT for Multi-Class Classification of Publications Metadata},
author={Your Name(s)},
year={2024},
publisher={Hugging Face}
}