Text Generation
Transformers
Safetensors
English
t5
text2text-generation
fact-updating
wikipedia
text-generation-inference
Instructions to use gamemaker1/t5edit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gamemaker1/t5edit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="gamemaker1/t5edit")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("gamemaker1/t5edit") model = AutoModelForSeq2SeqLM.from_pretrained("gamemaker1/t5edit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gamemaker1/t5edit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gamemaker1/t5edit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gamemaker1/t5edit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/gamemaker1/t5edit
- SGLang
How to use gamemaker1/t5edit with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "gamemaker1/t5edit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gamemaker1/t5edit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "gamemaker1/t5edit" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gamemaker1/t5edit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use gamemaker1/t5edit with Docker Model Runner:
docker model run hf.co/gamemaker1/t5edit
add the card and the run config and metrics
Browse files- README.md +66 -0
- run_config.json +23 -0
- run_metrics.json +66 -0
README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model: google/flan-t5-large
|
| 6 |
+
tags:
|
| 7 |
+
- text2text-generation
|
| 8 |
+
- fact-updating
|
| 9 |
+
- wikipedia
|
| 10 |
+
library_name: transformers
|
| 11 |
+
pipeline_tag: text2text-generation
|
| 12 |
+
datasets:
|
| 13 |
+
- gamemaker1/wiki-wrong
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# DiffusEdit editor baseline
|
| 17 |
+
|
| 18 |
+
`google/flan-t5-large` (780M parameters) fine-tuned end to end to rewrite an
|
| 19 |
+
outdated article from evidence, in the style of EDIT5 (Iv et al., 2022).
|
| 20 |
+
It is the fine-tuned upper bound that DiffusEdit is compared against, and
|
| 21 |
+
every parameter was trained, unlike the DiffusEdit classifiers. The code is at
|
| 22 |
+
https://github.com/gamemaker1/diffusedit under
|
| 23 |
+
`code/pipeline/experiments/editor.py`.
|
| 24 |
+
|
| 25 |
+
## Input and output
|
| 26 |
+
|
| 27 |
+
```
|
| 28 |
+
input update: [0] <sentence 0> [1] <sentence 1> ... evidence: (0) <title>: <text> (1) ...
|
| 29 |
+
output [0] #1 <rewritten sentence 1> [2] ...
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
The output names each source sentence in order: `[j]` copies sentence j,
|
| 33 |
+
`#j text` replaces it, and a missing j deletes it. The input is cut at 1,024
|
| 34 |
+
tokens from the end and the output at 384 tokens.
|
| 35 |
+
|
| 36 |
+
## Training
|
| 37 |
+
|
| 38 |
+
Fit on the 12,180 train articles of `gamemaker1/wiki-wrong`, with
|
| 39 |
+
the validation loss after each epoch for early stopping (patience 1). Learning
|
| 40 |
+
rate 1e-4 with linear decay and 5% warm-up, 32 examples per optimiser step
|
| 41 |
+
(micro-batches of 4, 8 accumulated), gradient clipping at 1.0, bf16 autocast,
|
| 42 |
+
seed 42. The best epoch was the third of four, with validation loss 0.0439,
|
| 43 |
+
after 64 minutes on one A100 40GB.
|
| 44 |
+
|
| 45 |
+
## Test scores
|
| 46 |
+
|
| 47 |
+
On the 1,670 supported EDIT sentences of the test split, against the gold
|
| 48 |
+
rewrite: ROUGE-L 0.973, exact match 76.7%, new-value recall 88.7%, old-value
|
| 49 |
+
kept 10.0%. Copying the source scores ROUGE-L 0.875. Greedy decoding writes
|
| 50 |
+
an article in 0.35 seconds.
|
| 51 |
+
|
| 52 |
+
## Use
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 56 |
+
tok = AutoTokenizer.from_pretrained("gamemaker1/t5edit")
|
| 57 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("gamemaker1/t5edit")
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
`experiments.editor.input_text` builds the input from a dataset record and
|
| 61 |
+
`experiments.editor.parse` maps the output back to one sentence per source
|
| 62 |
+
sentence.
|
| 63 |
+
|
| 64 |
+
## Licence
|
| 65 |
+
|
| 66 |
+
Apache 2.0, as the base model.
|
run_config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"train": "/home/diffusedit/data/split/train.jsonl",
|
| 3 |
+
"val": "/home/diffusedit/data/split/val.jsonl",
|
| 4 |
+
"test": "/home/diffusedit/data/split/test.jsonl",
|
| 5 |
+
"out": "/home/diffusedit/full/runs/editor",
|
| 6 |
+
"model": "google/flan-t5-large",
|
| 7 |
+
"predict_only": false,
|
| 8 |
+
"max_input": 1024,
|
| 9 |
+
"max_new_tokens": 384,
|
| 10 |
+
"lr": 0.0001,
|
| 11 |
+
"batch": 4,
|
| 12 |
+
"accum": 8,
|
| 13 |
+
"epochs": 5,
|
| 14 |
+
"patience": 1,
|
| 15 |
+
"predict_batch": 8,
|
| 16 |
+
"gradient_checkpointing": true,
|
| 17 |
+
"log_every": 50,
|
| 18 |
+
"limit": null,
|
| 19 |
+
"seed": 42,
|
| 20 |
+
"n_train": 12180,
|
| 21 |
+
"n_val": 1564,
|
| 22 |
+
"n_test": 1602
|
| 23 |
+
}
|
run_metrics.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"train_lengths": {
|
| 3 |
+
"input": {
|
| 4 |
+
"p50": 193.0,
|
| 5 |
+
"p90": 338.0,
|
| 6 |
+
"p95": 389.0,
|
| 7 |
+
"p99": 507.2099999999991,
|
| 8 |
+
"mean": 213.64573070607554,
|
| 9 |
+
"max": 1520,
|
| 10 |
+
"over": 7
|
| 11 |
+
},
|
| 12 |
+
"target": {
|
| 13 |
+
"p50": 27.0,
|
| 14 |
+
"p90": 90.0,
|
| 15 |
+
"p95": 111.0,
|
| 16 |
+
"p99": 157.0,
|
| 17 |
+
"mean": 39.33522167487685,
|
| 18 |
+
"max": 970,
|
| 19 |
+
"over": 6
|
| 20 |
+
},
|
| 21 |
+
"evidence_cut": 4,
|
| 22 |
+
"article_cut": 3
|
| 23 |
+
},
|
| 24 |
+
"val_history": [
|
| 25 |
+
{
|
| 26 |
+
"epoch": 1,
|
| 27 |
+
"train_loss": 0.20339470065752346,
|
| 28 |
+
"val_loss": 0.059932903280978694
|
| 29 |
+
},
|
| 30 |
+
{
|
| 31 |
+
"epoch": 2,
|
| 32 |
+
"train_loss": 0.060603164612924705,
|
| 33 |
+
"val_loss": 0.04503743698826844
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"epoch": 3,
|
| 37 |
+
"train_loss": 0.0403840439127009,
|
| 38 |
+
"val_loss": 0.04387998025125058
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 4,
|
| 42 |
+
"train_loss": 0.029914886026241098,
|
| 43 |
+
"val_loss": 0.044346317642450714
|
| 44 |
+
}
|
| 45 |
+
],
|
| 46 |
+
"best_val_loss": 0.04387998025125058,
|
| 47 |
+
"epochs_run": 4,
|
| 48 |
+
"best_epoch": 3,
|
| 49 |
+
"train_seconds": 3814.4,
|
| 50 |
+
"articles": 1602,
|
| 51 |
+
"fallbacks": 3,
|
| 52 |
+
"fallback_reasons": {
|
| 53 |
+
"copy_text": 3
|
| 54 |
+
},
|
| 55 |
+
"articles_with_fallback": 3,
|
| 56 |
+
"restored_words": 109,
|
| 57 |
+
"sentences": {
|
| 58 |
+
"copied": 3565,
|
| 59 |
+
"rewritten": 1630,
|
| 60 |
+
"deleted": 417
|
| 61 |
+
},
|
| 62 |
+
"mean_output_words": 61.51622971285892,
|
| 63 |
+
"mean_output_sentences": 3.2428214731585516,
|
| 64 |
+
"mean_raw_chars": 136.54681647940075,
|
| 65 |
+
"seconds_per_article": 0.3500464130727837
|
| 66 |
+
}
|