Upload BART-Base (Baseline) for sarcasm rewriting
Browse files- README.md +86 -0
- config.json +71 -0
- generation_config.json +40 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
base_model: facebook/bart-base
|
| 4 |
+
tags:
|
| 5 |
+
- text2text-generation
|
| 6 |
+
- style-transfer
|
| 7 |
+
- sarcasm
|
| 8 |
+
- bart
|
| 9 |
+
- seq2seq
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
pipeline_tag: text2text-generation
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# BART-Base (Baseline)
|
| 16 |
+
|
| 17 |
+
Baseline BART-base supervised fine-tuning on sarcastic->non-sarcastic headline pairs. No context enhancement, no RL.
|
| 18 |
+
|
| 19 |
+
Part of the **Project LLMao** sarcasm style transfer suite (CS4248 Team 14, NUS AY2025/26 S2).
|
| 20 |
+
This model rewrites sarcastic news headlines as neutral, factual equivalents while
|
| 21 |
+
preserving the underlying meaning.
|
| 22 |
+
|
| 23 |
+
## Task
|
| 24 |
+
|
| 25 |
+
**Input**: A sarcastic news headline
|
| 26 |
+
**Output**: A non-sarcastic rewrite
|
| 27 |
+
|
| 28 |
+
Example:
|
| 29 |
+
- In: *"Area Man Passionate Defender Of What He Imagines Constitution To Be"*
|
| 30 |
+
- Out: *"Man defends his interpretation of the Constitution."*
|
| 31 |
+
|
| 32 |
+
## Training
|
| 33 |
+
|
| 34 |
+
- **Base model**: [`facebook/bart-base`](https://huggingface.co/facebook/bart-base) (139M params)
|
| 35 |
+
- **Method**: Standard cross-entropy on (sarcastic, non-sarcastic) pairs derived from NHDSD.
|
| 36 |
+
- **Dataset**: 71,730 sarcastic / non-sarcastic headline pairs derived from NHDSD
|
| 37 |
+
(News Headlines Dataset for Sarcasm Detection), augmented with 6 sarcasm strategy
|
| 38 |
+
variants (sarcasm, irony, satire, overstatement, understatement, rhetorical question).
|
| 39 |
+
- **Input prefix**: `rewrite to non-sarcastic: ` is prepended to every input at inference time.
|
| 40 |
+
- **Generation**: beam search with `num_beams=4`, `max_length=128`.
|
| 41 |
+
|
| 42 |
+
## Usage
|
| 43 |
+
|
| 44 |
+
```python
|
| 45 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 46 |
+
|
| 47 |
+
model_id = "SeeYangZhi/BART-Base-Sarcasm-Rewriter"
|
| 48 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 49 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
| 50 |
+
|
| 51 |
+
headline = "Area Man Passionate Defender Of What He Imagines Constitution To Be"
|
| 52 |
+
prompt = "rewrite to non-sarcastic: " + headline
|
| 53 |
+
|
| 54 |
+
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=128)
|
| 55 |
+
outputs = model.generate(**inputs, max_length=128, num_beams=4)
|
| 56 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Evaluation
|
| 60 |
+
|
| 61 |
+
Evaluated on a 2,857-sample held-out test split alongside 13 other model variants
|
| 62 |
+
(BART, T5 baselines, LLaMA 3.2, ablation studies). Metrics include:
|
| 63 |
+
|
| 64 |
+
| Metric | Direction |
|
| 65 |
+
|---|---|
|
| 66 |
+
| Hard Flip Rate (% of samples where sarcasm was removed) | higher ↑ |
|
| 67 |
+
| Semantic Similarity (all-MiniLM-L6-v2 cosine) | higher ↑ |
|
| 68 |
+
| BLEU vs input (lower = more genuine rewriting) | lower ↓ |
|
| 69 |
+
| Perplexity (GPT-2) | lower ↓ |
|
| 70 |
+
| Normalized edit distance | higher ↑ |
|
| 71 |
+
| Paraphrase score (low = real rewriting) | lower ↓ |
|
| 72 |
+
|
| 73 |
+
Full per-variant numbers are published alongside the Project LLMao webapp.
|
| 74 |
+
|
| 75 |
+
## Related models
|
| 76 |
+
|
| 77 |
+
- [`SeeYangZhi/Llama-3.2-1B-Sarcasm-Rewriter`](https://huggingface.co/SeeYangZhi/Llama-3.2-1B-Sarcasm-Rewriter) — instruction-tuned LLaMA variant
|
| 78 |
+
- `SeeYangZhi/BART-Base-Sarcasm-Rewriter` — supervised baseline
|
| 79 |
+
- `SeeYangZhi/BART-Base-CE-Sarcasm-Rewriter` — context-enhanced SFT
|
| 80 |
+
- `SeeYangZhi/BART-Base-RL-Sarcasm-Rewriter` — REINFORCE on top of baseline
|
| 81 |
+
- `SeeYangZhi/BART-Base-CE-RL-Sarcasm-Rewriter` — CE + RL (best)
|
| 82 |
+
|
| 83 |
+
## License
|
| 84 |
+
|
| 85 |
+
MIT, inheriting from `facebook/bart-base`. The NHDSD dataset is used under its
|
| 86 |
+
original research-use terms.
|
config.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_dropout": 0.1,
|
| 3 |
+
"activation_function": "gelu",
|
| 4 |
+
"add_bias_logits": false,
|
| 5 |
+
"add_final_layer_norm": false,
|
| 6 |
+
"architectures": [
|
| 7 |
+
"BartForConditionalGeneration"
|
| 8 |
+
],
|
| 9 |
+
"attention_dropout": 0.1,
|
| 10 |
+
"bos_token_id": 0,
|
| 11 |
+
"classif_dropout": 0.1,
|
| 12 |
+
"classifier_dropout": 0.0,
|
| 13 |
+
"d_model": 768,
|
| 14 |
+
"decoder_attention_heads": 12,
|
| 15 |
+
"decoder_ffn_dim": 3072,
|
| 16 |
+
"decoder_layerdrop": 0.0,
|
| 17 |
+
"decoder_layers": 6,
|
| 18 |
+
"decoder_start_token_id": 2,
|
| 19 |
+
"dropout": 0.1,
|
| 20 |
+
"dtype": "float32",
|
| 21 |
+
"encoder_attention_heads": 12,
|
| 22 |
+
"encoder_ffn_dim": 3072,
|
| 23 |
+
"encoder_layerdrop": 0.0,
|
| 24 |
+
"encoder_layers": 6,
|
| 25 |
+
"eos_token_id": 2,
|
| 26 |
+
"gradient_checkpointing": false,
|
| 27 |
+
"id2label": {
|
| 28 |
+
"0": "LABEL_0",
|
| 29 |
+
"1": "LABEL_1",
|
| 30 |
+
"2": "LABEL_2"
|
| 31 |
+
},
|
| 32 |
+
"init_std": 0.02,
|
| 33 |
+
"is_decoder": false,
|
| 34 |
+
"is_encoder_decoder": true,
|
| 35 |
+
"label2id": {
|
| 36 |
+
"LABEL_0": 0,
|
| 37 |
+
"LABEL_1": 1,
|
| 38 |
+
"LABEL_2": 2
|
| 39 |
+
},
|
| 40 |
+
"max_position_embeddings": 1024,
|
| 41 |
+
"model_type": "bart",
|
| 42 |
+
"normalize_before": false,
|
| 43 |
+
"normalize_embedding": true,
|
| 44 |
+
"num_hidden_layers": 6,
|
| 45 |
+
"pad_token_id": 1,
|
| 46 |
+
"scale_embedding": false,
|
| 47 |
+
"task_specific_params": {
|
| 48 |
+
"summarization": {
|
| 49 |
+
"length_penalty": 1.0,
|
| 50 |
+
"max_length": 128,
|
| 51 |
+
"min_length": 12,
|
| 52 |
+
"num_beams": 4
|
| 53 |
+
},
|
| 54 |
+
"summarization_cnn": {
|
| 55 |
+
"length_penalty": 2.0,
|
| 56 |
+
"max_length": 142,
|
| 57 |
+
"min_length": 56,
|
| 58 |
+
"num_beams": 4
|
| 59 |
+
},
|
| 60 |
+
"summarization_xsum": {
|
| 61 |
+
"length_penalty": 1.0,
|
| 62 |
+
"max_length": 62,
|
| 63 |
+
"min_length": 11,
|
| 64 |
+
"num_beams": 6
|
| 65 |
+
}
|
| 66 |
+
},
|
| 67 |
+
"tie_word_embeddings": true,
|
| 68 |
+
"transformers_version": "5.0.0",
|
| 69 |
+
"use_cache": false,
|
| 70 |
+
"vocab_size": 50265
|
| 71 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": false,
|
| 3 |
+
"assistant_confidence_threshold": 0.4,
|
| 4 |
+
"assistant_lookbehind": 10,
|
| 5 |
+
"bos_token_id": 0,
|
| 6 |
+
"decoder_start_token_id": 2,
|
| 7 |
+
"diversity_penalty": 0.0,
|
| 8 |
+
"do_sample": false,
|
| 9 |
+
"early_stopping": true,
|
| 10 |
+
"encoder_no_repeat_ngram_size": 0,
|
| 11 |
+
"encoder_repetition_penalty": 1.0,
|
| 12 |
+
"eos_token_id": [
|
| 13 |
+
2
|
| 14 |
+
],
|
| 15 |
+
"epsilon_cutoff": 0.0,
|
| 16 |
+
"eta_cutoff": 0.0,
|
| 17 |
+
"forced_bos_token_id": 0,
|
| 18 |
+
"forced_eos_token_id": 2,
|
| 19 |
+
"length_penalty": 1.0,
|
| 20 |
+
"max_length": 20,
|
| 21 |
+
"min_length": 0,
|
| 22 |
+
"no_repeat_ngram_size": 3,
|
| 23 |
+
"num_assistant_tokens": 20,
|
| 24 |
+
"num_assistant_tokens_schedule": "constant",
|
| 25 |
+
"num_beam_groups": 1,
|
| 26 |
+
"num_beams": 4,
|
| 27 |
+
"num_return_sequences": 1,
|
| 28 |
+
"output_scores": false,
|
| 29 |
+
"pad_token_id": 1,
|
| 30 |
+
"remove_invalid_values": false,
|
| 31 |
+
"repetition_penalty": 1.0,
|
| 32 |
+
"return_dict_in_generate": false,
|
| 33 |
+
"target_lookbehind": 10,
|
| 34 |
+
"temperature": 1.0,
|
| 35 |
+
"top_k": 50,
|
| 36 |
+
"top_p": 1.0,
|
| 37 |
+
"transformers_version": "5.0.0",
|
| 38 |
+
"typical_p": 1.0,
|
| 39 |
+
"use_cache": true
|
| 40 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af4733e40a7fe8c9d7ec747f31cbbb0d455523b5009be6485fecad862fc82677
|
| 3 |
+
size 557912620
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"backend": "tokenizers",
|
| 4 |
+
"bos_token": "<s>",
|
| 5 |
+
"cls_token": "<s>",
|
| 6 |
+
"eos_token": "</s>",
|
| 7 |
+
"errors": "replace",
|
| 8 |
+
"is_local": false,
|
| 9 |
+
"mask_token": "<mask>",
|
| 10 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 11 |
+
"pad_token": "<pad>",
|
| 12 |
+
"sep_token": "</s>",
|
| 13 |
+
"tokenizer_class": "RobertaTokenizer",
|
| 14 |
+
"trim_offsets": true,
|
| 15 |
+
"unk_token": "<unk>"
|
| 16 |
+
}
|