Introduction of DistilBERT_Authorship_Attribution_Model
Model Details of DistilBERT_Authorship_Attribution_Model
DistilBERT Fine-Tuned Model for Authorship Attribution on Blog Corpus
This repository hosts a fine-tuned DistilBERT model designed for the
authorship attribution
task on the Blog Authorship Corpus dataset. The model is optimized for identifying the author of a given blog post from a subset of top contributors.
Model Details
Model Architecture:
DistilBERT Base (distilbert-base-uncased)
Task:
Authorship Attribution
Dataset:
Blog Authorship Corpus (Top 10 authors selected)
Quantization:
Float16 (Post-training)
Fine-tuning Framework:
Hugging Face Transformers
Usage
Installation
pip install transformers torch
Loading the Model
from transformers import DistilBertForSequenceClassification, DistilBertTokenizerFast
import torch
# Load fine-tuned model
model_path = "fine-tuned-model"
model = DistilBertForSequenceClassification.from_pretrained(model_path)
tokenizer = DistilBertTokenizerFast.from_pretrained(model_path)
# Set model to evaluation and convert to half precision
device = "cuda"if torch.cuda.is_available() else"cpu"
model.to(device)
model.eval()
model.half()
# Example input
blog_post = "Today I went to the beach and had an amazing time with friends. The sunset was breathtaking!"# Tokenize input
inputs = tokenizer(blog_post, return_tensors="pt", padding=True, truncation=True, max_length=512).to(device)
inputs = {k: v.half() if v.dtype == torch.floatelse v for k, v in inputs.items()}
# Make predictionwith torch.no_grad():
outputs = model(**inputs)
predicted_class = torch.argmax(outputs.logits, dim=1).item()
# Label mapping (example)
label_mapping = {
0: "Author_A",
1: "Author_B",
2: "Author_C",
3: "Author_D",
4: "Author_E",
5: "Author_F",
6: "Author_G",
7: "Author_H",
8: "Author_I",
9: "Author_J"
}
predicted_author = label_mapping[predicted_class]
print(f"Predicted Author: {predicted_author}")
Performance Metrics
Accuracy:
~78% (on validation set of top 10 authors)
Precision/Recall/F1:
Vary per class, average F1 around 0.75
Fine-Tuning Details
Dataset
The model is trained on a subset of the
Blog Authorship Corpus
containing blogs from the top 10 most prolific authors. Each sample is a blog post with its corresponding author label.
Training
Epochs:
3
Batch size:
8
Evaluation strategy:
Per epoch
Learning rate:
2e-5
Quantization
Post-training dynamic quantization using PyTorch was applied to reduce model size and accelerate inference:
.
├── model/ # Contains the fine-tuned and quantized model files
├── tokenizer_config/ # Tokenizer configuration and vocabulary
├── model.safensors/ # Safetensors version of model weights
├── README.md # Documentation
Limitations
The model is limited to the top 10 authors used in fine-tuning.
May not generalize well to unseen authors or blogs outside the dataset distribution.
Quantization may slightly affect prediction precision.
Contributing
Contributions are welcome! If you find bugs or have suggestions for improvements, feel free to open an issue or submit a pull request.
Runs of AventIQ-AI DistilBERT_Authorship_Attribution_Model on huggingface.co
8
Total runs
-1
24-hour runs
-2
3-day runs
2
7-day runs
4
30-day runs
More Information About DistilBERT_Authorship_Attribution_Model huggingface.co Model
DistilBERT_Authorship_Attribution_Model huggingface.co is an AI model on huggingface.co that provides DistilBERT_Authorship_Attribution_Model's model effect (), which can be used instantly with this AventIQ-AI DistilBERT_Authorship_Attribution_Model model. huggingface.co supports a free trial of the DistilBERT_Authorship_Attribution_Model model, and also provides paid use of the DistilBERT_Authorship_Attribution_Model. Support call DistilBERT_Authorship_Attribution_Model model through api, including Node.js, Python, http.
DistilBERT_Authorship_Attribution_Model huggingface.co is an online trial and call api platform, which integrates DistilBERT_Authorship_Attribution_Model's modeling effects, including api services, and provides a free online trial of DistilBERT_Authorship_Attribution_Model, you can try DistilBERT_Authorship_Attribution_Model online for free by clicking the link below.
AventIQ-AI DistilBERT_Authorship_Attribution_Model online free url in huggingface.co:
DistilBERT_Authorship_Attribution_Model is an open source model from GitHub that offers a free installation service, and any user can find DistilBERT_Authorship_Attribution_Model on GitHub to install. At the same time, huggingface.co provides the effect of DistilBERT_Authorship_Attribution_Model install, users can directly use DistilBERT_Authorship_Attribution_Model installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
DistilBERT_Authorship_Attribution_Model install url in huggingface.co: