WorkInTheDark/FairytaleQA
Viewer • Updated • 10.6k • 425 • 15
How to use curious008/BertForStorySkillClassification with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="curious008/BertForStorySkillClassification", trust_remote_code=True) # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("curious008/BertForStorySkillClassification", trust_remote_code=True)
model = AutoModelForSequenceClassification.from_pretrained("curious008/BertForStorySkillClassification", trust_remote_code=True)BertForStorySkillClassification is a BERT-based text classification model designed to categorize story-related questions into one of the following 7 classes:
This model is suitable for applications in education, literary analysis, and story comprehension.
bert-base-uncasedEnsure you have the transformers library installed:
pip install transformers
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("curious008/BertForStorySkillClassification")
tokenizer = AutoTokenizer.from_pretrained("curious008/BertForStorySkillClassification")
# Single text prediction
result = model.predict(
texts="Where does this story take place?",
tokenizer=tokenizer,
return_probabilities=True
)
print(result)
# Output: [{'text': 'Where does this story take place?', 'label': 'setting', 'score': 0.93178}]
# Batch prediction
results = model.predict(
texts=["Why is the character sad?", "How does the story end?","why could n't alice get a doll as a child ? <SEP> because her family was very poor "],
tokenizer=tokenizer,
batch_size=16,
device="cuda"
)
print(results)
"""
output:
[{'text': 'Why is the character sad?', 'label': 'causal relationship'},
{'text': 'How does the story end?', 'label': 'action'},
{'text': "why could n't alice get a doll as a child ? <SEP> because her family was very poor ",
'label': 'causal relationship'}]
"""
Source: FairytaleQAData
Learning Rate: 2e-5 Batch Size: 32 Epochs: 3 Optimizer: AdamW
Accuracy: 97.3%
Recall: 96.59%
F1 Score: 96.96%
If you use this model, please cite the following:
@misc{BertForStorySkillClassification,
author = {curious},
title = {BertForStorySkillClassification: A BERT-based Model for Story Question Classification},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/curious008/BertForStorySkillClassification}}
}
This model is open-sourced under the Apache 2.0 License. For more details, see the LICENSE file.
Base model
google-bert/bert-base-uncased