regen-webnlg-t2g-ce / README.md
guihu's picture
Streamline the usage notes around the examples
5401374 verified
|
Raw History Blame Contribute Delete
4.2 kB
---
language:
- en
library_name: transformers
pipeline_tag: other
base_model: google-t5/t5-large
base_model_relation: finetune
tags:
- text-to-graph
- webnlg
- regen
---
# ReGen T2G.CE for WebNLG
This T5-large model converts English text into subject–relation–object triples. It implements the WebNLG T2G.CE setting of [Dognin et al. (2021)](https://aclanthology.org/2021.emnlp-main.83/), using cross-entropy fine-tuning.
The first author of the [XQDT paper](https://huggingface.co/papers/2608.29948) reproduced ReGen T2G.CE for use as a base text-to-data model in that study. The [reproduction repository](https://github.com/guihuzhang/bt5-regen-text-to-graph) contains the code, saved predictions, and evaluation scripts.
The checkpoint is epoch 3 of the continuation run. Its saved predictions on 2,155 WebNLG 2020 English test examples give Exact precision 70.35, recall 72.18, and F1 71.07, using five-beam decoding. For CE on the same task, [Table 2 of the ReGen paper](https://aclanthology.org/2021.emnlp-main.83.pdf#page=7) reports 72.3 Exact F1, while the example run in the [IBM training guide](https://github.com/IBM/regen/blob/main/docs/train_t2g_webnlg.md#overview) scores 70.11.
## Usage
```python
import torch
from transformers import T5ForConditionalGeneration, T5Tokenizer
model_path = "Loria-MosAIk/regen-webnlg-t2g-ce"
tokenizer = T5Tokenizer.from_pretrained(model_path, legacy=True)
model = T5ForConditionalGeneration.from_pretrained(model_path).eval()
inputs = tokenizer("Text to Graph: Lina Dorado was born in Bogotá in 1975.", return_tensors="pt")
prefix = torch.full((1, 1), tokenizer.pad_token_id, dtype=inputs.input_ids.dtype)
input_ids = torch.cat((prefix, inputs.input_ids), dim=1)
attention_mask = torch.cat((torch.ones_like(prefix), inputs.attention_mask), dim=1)
outputs = model.generate(input_ids=input_ids, attention_mask=attention_mask, num_beams=5, max_length=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True, clean_up_tokenization_spaces=False))
```
Output:
```text
__subject__ Lina_Dorado __predicate__ birthPlace __object__ Bogotá __subject__ Lina_Dorado __predicate__ birthYear __object__ 1975
```
The example prepends a pad token to match ReGen's data loader.
The [base T5-large model](https://huggingface.co/google-t5/t5-large) is distributed under Apache-2.0. The WebNLG fine-tuning data are distributed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).
## Citation
Original ReGen model: [Dognin et al. (2021)](https://arxiv.org/abs/2108.12472).
```bibtex
@inproceedings{dognin-etal-2021-regen,
title = "{R}e{G}en: {R}einforcement Learning for Text and Knowledge Base Generation using Pretrained Language Models",
author = "Dognin, Pierre and
Padhi, Inkit and
Melnyk, Igor and
Das, Payel",
editor = "Moens, Marie-Francine and
Huang, Xuanjing and
Specia, Lucia and
Yih, Scott Wen-tau",
booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing",
month = nov,
year = "2021",
address = "Online and Punta Cana, Dominican Republic",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2021.emnlp-main.83/",
doi = "10.18653/v1/2021.emnlp-main.83",
pages = "1084--1099"
}
```
This checkpoint and reproduction code: [Efimov-Zhang et al. (2026)](https://aclanthology.org/2026.emnlp-main.397/).
```bibtex
@inproceedings{efimov-zhang-etal-2026-xqdt,
title = "{XQDT}: e{X}plainable and Quantitative Data-Text Alignment Metric with Feedback Signals",
author = "Efimov-Zhang, Kun and
Song, Yifei and
Gardent, Claire",
editor = "Lee, Hung-Yi and
Dev, Sunipa and
Li, Jessy and
Elliott, Desmond",
booktitle = "Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing",
month = oct,
year = "2026",
address = "Budapest, Hungary",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2026.emnlp-main.397/",
doi = "10.18653/2026.emnlp-main.397",
pages = "9121--9157",
ISBN = "979-8-89176-459-0"
}
```