Upload folder using huggingface_hub
Browse files- README.md +177 -0
- added_tokens.json +3 -0
- config.json +43 -0
- model.safetensors +3 -0
- special_tokens_map.json +15 -0
- spm.model +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +59 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- text-classification
|
| 7 |
+
- character-analysis
|
| 8 |
+
- plot-arc
|
| 9 |
+
- narrative-analysis
|
| 10 |
+
- deberta-v3
|
| 11 |
+
- binary-classification
|
| 12 |
+
datasets:
|
| 13 |
+
- custom
|
| 14 |
+
metrics:
|
| 15 |
+
- accuracy
|
| 16 |
+
- f1
|
| 17 |
+
model-index:
|
| 18 |
+
- name: plot-arc-classifier
|
| 19 |
+
results:
|
| 20 |
+
- task:
|
| 21 |
+
type: text-classification
|
| 22 |
+
name: Character Plot Arc Classification
|
| 23 |
+
dataset:
|
| 24 |
+
type: custom
|
| 25 |
+
name: Character Arc Dataset
|
| 26 |
+
metrics:
|
| 27 |
+
- type: accuracy
|
| 28 |
+
value: 0.796
|
| 29 |
+
name: Accuracy
|
| 30 |
+
- type: f1
|
| 31 |
+
value: 0.796
|
| 32 |
+
name: F1 Score (Strong Class)
|
| 33 |
+
- type: precision
|
| 34 |
+
value: 0.777
|
| 35 |
+
name: Precision (Strong Class)
|
| 36 |
+
- type: recall
|
| 37 |
+
value: 0.816
|
| 38 |
+
name: Recall (Strong Class)
|
| 39 |
+
base_model: microsoft/deberta-v3-xsmall
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
# Plot Arc Character Classifier
|
| 43 |
+
|
| 44 |
+
A DeBERTa-v3-XSmall model fine-tuned to classify fictional characters based on their plot arc potential.
|
| 45 |
+
|
| 46 |
+
## Model Description
|
| 47 |
+
|
| 48 |
+
This model classifies character descriptions into two categories:
|
| 49 |
+
- **STRONG** (label 1): Characters with both internal conflict and external responsibilities/events
|
| 50 |
+
- **WEAK** (label 0): Characters with no plot arc, pure internal conflict only, or pure external events only
|
| 51 |
+
|
| 52 |
+
The model fixes critical bias issues where simple background characters (shopkeepers, guards) were incorrectly classified as plot-significant.
|
| 53 |
+
|
| 54 |
+
## Training Data
|
| 55 |
+
|
| 56 |
+
- **Dataset Size**: 11,888 balanced examples (50/50 split)
|
| 57 |
+
- **Training Examples**: 9,510
|
| 58 |
+
- **Validation Examples**: 2,378
|
| 59 |
+
- **Source**: Custom 4-way classified character descriptions from literature
|
| 60 |
+
|
| 61 |
+
### Label Mapping
|
| 62 |
+
- **STRONG (1)**: Characters classified as "BOTH" (internal conflict + external events)
|
| 63 |
+
- **WEAK (0)**: Characters classified as "NONE", "INTERNAL", or "EXTERNAL"
|
| 64 |
+
|
| 65 |
+
## Training Details
|
| 66 |
+
|
| 67 |
+
- **Base Model**: microsoft/deberta-v3-xsmall (22M parameters)
|
| 68 |
+
- **Training Time**: ~15 minutes
|
| 69 |
+
- **Batch Size**: 8 (with gradient accumulation = 2)
|
| 70 |
+
- **Max Sequence Length**: 384 tokens
|
| 71 |
+
- **Learning Rate**: 5e-5 with warmup
|
| 72 |
+
- **Early Stopping**: Yes (stopped at 3.7/5 epochs)
|
| 73 |
+
|
| 74 |
+
## Performance
|
| 75 |
+
|
| 76 |
+
### Validation Metrics
|
| 77 |
+
| Metric | Score |
|
| 78 |
+
|--------|-------|
|
| 79 |
+
| Accuracy | 79.6% |
|
| 80 |
+
| F1 (Strong) | 79.6% |
|
| 81 |
+
| Precision (Strong) | 77.7% |
|
| 82 |
+
| Recall (Strong) | 81.6% |
|
| 83 |
+
|
| 84 |
+
### Synthetic Test Results
|
| 85 |
+
**100% accuracy** on diverse test cases including previously problematic examples:
|
| 86 |
+
|
| 87 |
+
| Character Type | Example | Prediction | Confidence |
|
| 88 |
+
|----------------|---------|------------|------------|
|
| 89 |
+
| Background (NONE) | Baker, Guard | WEAK ✅ | 98.9%, 98.5% |
|
| 90 |
+
| Pure Internal | Haunted Artist | WEAK ✅ | 93.9% |
|
| 91 |
+
| Pure External | Military Commander | WEAK ✅ | 94.5% |
|
| 92 |
+
| Both (Internal+External) | Conflicted King | STRONG ✅ | 95.1% |
|
| 93 |
+
| Both (Trauma+Mission) | PTSD Captain | STRONG ✅ | 95.5% |
|
| 94 |
+
| Both (Doubt+Quest) | Uncertain Prophet | STRONG ✅ | 96.0% |
|
| 95 |
+
|
| 96 |
+
**Key Achievement**: Fixed critical bias where simple background characters were incorrectly classified as plot-significant.
|
| 97 |
+
|
| 98 |
+
## Usage
|
| 99 |
+
|
| 100 |
+
```python
|
| 101 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 102 |
+
import torch
|
| 103 |
+
|
| 104 |
+
# Load model and tokenizer
|
| 105 |
+
tokenizer = AutoTokenizer.from_pretrained("plot-arc-classifier")
|
| 106 |
+
model = AutoModelForSequenceClassification.from_pretrained("plot-arc-classifier")
|
| 107 |
+
|
| 108 |
+
# Example usage
|
| 109 |
+
def classify_character(description):
|
| 110 |
+
inputs = tokenizer(description, return_tensors="pt", truncation=True, max_length=384)
|
| 111 |
+
|
| 112 |
+
with torch.no_grad():
|
| 113 |
+
outputs = model(**inputs)
|
| 114 |
+
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 115 |
+
predicted_class = torch.argmax(probabilities, dim=-1).item()
|
| 116 |
+
|
| 117 |
+
labels = {0: "WEAK", 1: "STRONG"}
|
| 118 |
+
confidence = probabilities[0][predicted_class].item()
|
| 119 |
+
|
| 120 |
+
return labels[predicted_class], confidence
|
| 121 |
+
|
| 122 |
+
# Test examples
|
| 123 |
+
examples = [
|
| 124 |
+
"A baker who makes fresh bread daily and serves customers with a smile.",
|
| 125 |
+
"A warrior haunted by past failures who must lead a desperate battle to save his homeland while confronting his inner demons.",
|
| 126 |
+
]
|
| 127 |
+
|
| 128 |
+
for desc in examples:
|
| 129 |
+
label, conf = classify_character(desc)
|
| 130 |
+
print(f"'{desc[:50]}...': {label} ({conf:.3f})")
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
## Model Improvements
|
| 134 |
+
|
| 135 |
+
This model addresses critical issues from previous versions:
|
| 136 |
+
|
| 137 |
+
1. **Fixed Bias**: No longer classifies simple background characters as STRONG
|
| 138 |
+
2. **Proper Discrimination**: Requires both internal and external elements for STRONG classification
|
| 139 |
+
3. **Balanced Training**: 50/50 split prevents class imbalance issues
|
| 140 |
+
4. **Clean Taxonomy**: Based on proper 4-way character analysis
|
| 141 |
+
|
| 142 |
+
## Limitations
|
| 143 |
+
|
| 144 |
+
- Trained on English literary character descriptions
|
| 145 |
+
- May not generalize well to other domains (screenwriting, gaming, etc.)
|
| 146 |
+
- Performance may degrade on very short or very long descriptions
|
| 147 |
+
- Cultural bias toward Western narrative structures
|
| 148 |
+
|
| 149 |
+
## Ethical Considerations
|
| 150 |
+
|
| 151 |
+
This model is designed for narrative analysis and creative writing assistance. It should not be used to make judgments about real people or for any discriminatory purposes.
|
| 152 |
+
|
| 153 |
+
## Citation
|
| 154 |
+
|
| 155 |
+
If you use this model, please cite:
|
| 156 |
+
|
| 157 |
+
```bibtex
|
| 158 |
+
@misc{plot-arc-classifier-2024,
|
| 159 |
+
title={Plot Arc Character Classifier},
|
| 160 |
+
author={Generated with Claude Code},
|
| 161 |
+
year={2024},
|
| 162 |
+
url={https://huggingface.co/plot-arc-classifier}
|
| 163 |
+
}
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
+
## Training Infrastructure
|
| 167 |
+
|
| 168 |
+
- **Framework**: 🤗 Transformers
|
| 169 |
+
- **Hardware**: Apple Silicon (MPS)
|
| 170 |
+
- **Optimization**: Memory-optimized for MPS training
|
| 171 |
+
- **Early Stopping**: Enabled to prevent overfitting
|
| 172 |
+
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
🤖 Generated with [Claude Code](https://claude.ai/code)
|
| 176 |
+
|
| 177 |
+
Co-Authored-By: Claude <[email protected]>
|
added_tokens.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"[MASK]": 128000
|
| 3 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"DebertaV2ForSequenceClassification"
|
| 4 |
+
],
|
| 5 |
+
"attention_probs_dropout_prob": 0.1,
|
| 6 |
+
"hidden_act": "gelu",
|
| 7 |
+
"hidden_dropout_prob": 0.1,
|
| 8 |
+
"hidden_size": 384,
|
| 9 |
+
"id2label": {
|
| 10 |
+
"0": "WEAK",
|
| 11 |
+
"1": "STRONG"
|
| 12 |
+
},
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 1536,
|
| 15 |
+
"label2id": {
|
| 16 |
+
"STRONG": 1,
|
| 17 |
+
"WEAK": 0
|
| 18 |
+
},
|
| 19 |
+
"layer_norm_eps": 1e-07,
|
| 20 |
+
"legacy": true,
|
| 21 |
+
"max_position_embeddings": 512,
|
| 22 |
+
"max_relative_positions": -1,
|
| 23 |
+
"model_type": "deberta-v2",
|
| 24 |
+
"norm_rel_ebd": "layer_norm",
|
| 25 |
+
"num_attention_heads": 6,
|
| 26 |
+
"num_hidden_layers": 12,
|
| 27 |
+
"pad_token_id": 0,
|
| 28 |
+
"pooler_dropout": 0,
|
| 29 |
+
"pooler_hidden_act": "gelu",
|
| 30 |
+
"pooler_hidden_size": 384,
|
| 31 |
+
"pos_att_type": [
|
| 32 |
+
"p2c",
|
| 33 |
+
"c2p"
|
| 34 |
+
],
|
| 35 |
+
"position_biased_input": false,
|
| 36 |
+
"position_buckets": 256,
|
| 37 |
+
"relative_attention": true,
|
| 38 |
+
"share_att_key": true,
|
| 39 |
+
"torch_dtype": "float32",
|
| 40 |
+
"transformers_version": "4.55.4",
|
| 41 |
+
"type_vocab_size": 0,
|
| 42 |
+
"vocab_size": 128100
|
| 43 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6ce91fabf1a7eb0bff15a40318d19b56965648198c98e39be216583bd8b4969
|
| 3 |
+
size 283347432
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "[CLS]",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"eos_token": "[SEP]",
|
| 5 |
+
"mask_token": "[MASK]",
|
| 6 |
+
"pad_token": "[PAD]",
|
| 7 |
+
"sep_token": "[SEP]",
|
| 8 |
+
"unk_token": {
|
| 9 |
+
"content": "[UNK]",
|
| 10 |
+
"lstrip": false,
|
| 11 |
+
"normalized": true,
|
| 12 |
+
"rstrip": false,
|
| 13 |
+
"single_word": false
|
| 14 |
+
}
|
| 15 |
+
}
|
spm.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
|
| 3 |
+
size 2464616
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"added_tokens_decoder": {
|
| 3 |
+
"0": {
|
| 4 |
+
"content": "[PAD]",
|
| 5 |
+
"lstrip": false,
|
| 6 |
+
"normalized": false,
|
| 7 |
+
"rstrip": false,
|
| 8 |
+
"single_word": false,
|
| 9 |
+
"special": true
|
| 10 |
+
},
|
| 11 |
+
"1": {
|
| 12 |
+
"content": "[CLS]",
|
| 13 |
+
"lstrip": false,
|
| 14 |
+
"normalized": false,
|
| 15 |
+
"rstrip": false,
|
| 16 |
+
"single_word": false,
|
| 17 |
+
"special": true
|
| 18 |
+
},
|
| 19 |
+
"2": {
|
| 20 |
+
"content": "[SEP]",
|
| 21 |
+
"lstrip": false,
|
| 22 |
+
"normalized": false,
|
| 23 |
+
"rstrip": false,
|
| 24 |
+
"single_word": false,
|
| 25 |
+
"special": true
|
| 26 |
+
},
|
| 27 |
+
"3": {
|
| 28 |
+
"content": "[UNK]",
|
| 29 |
+
"lstrip": false,
|
| 30 |
+
"normalized": true,
|
| 31 |
+
"rstrip": false,
|
| 32 |
+
"single_word": false,
|
| 33 |
+
"special": true
|
| 34 |
+
},
|
| 35 |
+
"128000": {
|
| 36 |
+
"content": "[MASK]",
|
| 37 |
+
"lstrip": false,
|
| 38 |
+
"normalized": false,
|
| 39 |
+
"rstrip": false,
|
| 40 |
+
"single_word": false,
|
| 41 |
+
"special": true
|
| 42 |
+
}
|
| 43 |
+
},
|
| 44 |
+
"bos_token": "[CLS]",
|
| 45 |
+
"clean_up_tokenization_spaces": false,
|
| 46 |
+
"cls_token": "[CLS]",
|
| 47 |
+
"do_lower_case": false,
|
| 48 |
+
"eos_token": "[SEP]",
|
| 49 |
+
"extra_special_tokens": {},
|
| 50 |
+
"mask_token": "[MASK]",
|
| 51 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 52 |
+
"pad_token": "[PAD]",
|
| 53 |
+
"sep_token": "[SEP]",
|
| 54 |
+
"sp_model_kwargs": {},
|
| 55 |
+
"split_by_punct": false,
|
| 56 |
+
"tokenizer_class": "DebertaV2Tokenizer",
|
| 57 |
+
"unk_token": "[UNK]",
|
| 58 |
+
"vocab_type": "spm"
|
| 59 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3947b09074cc74a0341a06416cf1b03fb6cc4401933e052557f006ccc8f0c9e3
|
| 3 |
+
size 5777
|