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
title the card DiffusEdit T5edit and call the model the upper bound
Browse files
README.md
CHANGED
|
@@ -13,54 +13,74 @@ datasets:
|
|
| 13 |
- gamemaker1/wiki-wrong
|
| 14 |
---
|
| 15 |
|
| 16 |
-
# DiffusEdit
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
## Input and output
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
```
|
| 28 |
-
|
| 29 |
-
output [0] #1 <rewritten sentence 1> [2] ...
|
| 30 |
```
|
| 31 |
|
| 32 |
-
The output names each source sentence in order
|
| 33 |
-
`#j text`
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
the
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
after 64 minutes on one A100 40GB.
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
kept
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
`
|
| 61 |
-
`
|
| 62 |
-
sentence.
|
|
|
|
|
|
|
| 63 |
|
| 64 |
## Licence
|
| 65 |
|
| 66 |
-
Apache 2.0,
|
|
|
|
| 13 |
- gamemaker1/wiki-wrong
|
| 14 |
---
|
| 15 |
|
| 16 |
+
# DiffusEdit T5edit
|
| 17 |
|
| 18 |
+
t5edit is [google/flan-t5-large](https://huggingface.co/google/flan-t5-large),
|
| 19 |
+
a sequence-to-sequence model with 780M parameters, fine-tuned to rewrite an
|
| 20 |
+
outdated article from evidence. It follows the design of EDIT5 from the
|
| 21 |
+
FRUIT paper by Iv et al. (2022), in which the model writes the updated
|
| 22 |
+
article but copies an unchanged sentence through a short marker instead of
|
| 23 |
+
spelling it out again.
|
| 24 |
+
|
| 25 |
+
The model was trained as the upper bound for DiffusEdit, a system that keeps a
|
| 26 |
+
frozen diffusion language model and trains only small classifiers over its
|
| 27 |
+
hidden states. The classifiers are at
|
| 28 |
+
[gamemaker1/diffusedit](https://huggingface.co/gamemaker1/diffusedit) and
|
| 29 |
+
the data at [gamemaker1/wiki-wrong](https://huggingface.co/datasets/gamemaker1/wiki-wrong).
|
| 30 |
+
Every parameter of t5edit was trained, so it bounds what a fully trained
|
| 31 |
+
generator reaches on the same data. The training script is
|
| 32 |
+
`code/pipeline/experiments/editor.py` in
|
| 33 |
+
[github.com/gamemaker1/diffusedit](https://github.com/gamemaker1/diffusedit).
|
| 34 |
|
| 35 |
## Input and output
|
| 36 |
|
| 37 |
+
The input names each sentence of the outdated article with an index and
|
| 38 |
+
appends the evidence passages.
|
| 39 |
+
|
| 40 |
```
|
| 41 |
+
update: [0] <sentence 0> [1] <sentence 1> ... evidence: (0) <title>: <text> (1) <title>: <text> ...
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
+
The output names each source sentence in order. `[j]` means that sentence j
|
| 45 |
+
is copied unchanged, `#j <text>` means that sentence j is replaced by the
|
| 46 |
+
text, and a sentence whose index is absent is deleted.
|
| 47 |
|
| 48 |
+
```
|
| 49 |
+
[0] #1 <the rewritten sentence 1> [2]
|
| 50 |
+
```
|
| 51 |
|
| 52 |
+
The input is cut to 1,024 tokens from the end, so the evidence is shortened
|
| 53 |
+
before the article, and the output is cut at 384 tokens. The T5 vocabulary
|
| 54 |
+
cannot write some letters, such as the ø in a Norwegian name, so after
|
| 55 |
+
decoding, a word of the output that equals a word of the input with its
|
| 56 |
+
missing letters removed is replaced by that input word.
|
|
|
|
| 57 |
|
| 58 |
+
## Training
|
| 59 |
|
| 60 |
+
The model was fit on the train split of wiki-wrong. The validation loss was
|
| 61 |
+
computed after each epoch, the checkpoint with the lowest validation loss
|
| 62 |
+
was kept, and training stopped after one epoch without improvement. The
|
| 63 |
+
learning rate was 1e-4 with a linear decay and a warm-up over the first 5%
|
| 64 |
+
of the steps. Each optimiser step used 32 examples, as eight accumulated
|
| 65 |
+
micro-batches of four, with gradient clipping at 1.0, bfloat16 autocast and
|
| 66 |
+
seed 42, on one A100 with 40 GB of memory. The validation loss per epoch
|
| 67 |
+
and the time taken are in `run_metrics.json`.
|
| 68 |
|
| 69 |
## Use
|
| 70 |
|
| 71 |
```python
|
| 72 |
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 73 |
+
|
| 74 |
tok = AutoTokenizer.from_pretrained("gamemaker1/t5edit")
|
| 75 |
model = AutoModelForSeq2SeqLM.from_pretrained("gamemaker1/t5edit")
|
| 76 |
```
|
| 77 |
|
| 78 |
+
In the training script, `input_text` builds the input string from a
|
| 79 |
+
wiki-wrong record and `parse` maps the generated text back to one output
|
| 80 |
+
sentence per source sentence. `run_config.json` and `run_metrics.json` in
|
| 81 |
+
this repository are the configuration and the metrics that the training run
|
| 82 |
+
wrote.
|
| 83 |
|
| 84 |
## Licence
|
| 85 |
|
| 86 |
+
Apache 2.0, the licence of the base model.
|