A fine-tuned DeBERTa-v3-small model for classifying character plot arc types in narrative text.
1from transformers import DebertaV2Tokenizer, DebertaV2ForSequenceClassification
2import torch
3
4# Load model and tokenizer
5model_name = "plot-arc-classifier-deberta-small"
6tokenizer = DebertaV2Tokenizer.from_pretrained(model_name)
7model = DebertaV2ForSequenceClassification.from_pretrained(model_name)
8
9# Example text
10text = "Sir Galahad embarks on a perilous quest to retrieve the stolen Crown of Ages."
11
12# Tokenize and predict
13inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
14with torch.no_grad():
15 outputs = model(**inputs)
16 probabilities = torch.softmax(outputs.logits, dim=-1)
17 predicted_class = torch.argmax(probabilities, dim=-1)
18
19# Class mapping
20class_names = ['NONE', 'INTERNAL', 'EXTERNAL', 'BOTH']
21prediction = class_names[predicted_class.item()]
22confidence = probabilities[0][predicted_class].item()
23
24print(f"Predicted class: {prediction} (confidence: {confidence:.3f})")
1from transformers import pipeline
2
3classifier = pipeline(
4 "text-classification",
5 model="plot-arc-classifier-deberta-small",
6 return_all_scores=True
7)
8
9result = classifier("Captain Torres must infiltrate enemy lines while battling his own cowardice.")
10print(result)
1@model{plot_arc_classifier_2025,
2 title={Plot Arc Classifier - DeBERTa Small},
3 author={Claude Code Assistant},
4 year={2025},
5 url={https://github.com/your-org/plot-arc-classifier},
6 note={Fine-tuned DeBERTa-v3-small for character plot arc classification}
7}
For questions about this model, please open an issue in the repository or contact the maintainers.