Other
Transformers
Safetensors
English
Russian
t5
text2text-generation
text-to-graph
webnlg
bt5
text-generation-inference
Instructions to use Loria-MosAIk/bt5-webnlg-en-ru with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Loria-MosAIk/bt5-webnlg-en-ru with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Loria-MosAIk/bt5-webnlg-en-ru") model = AutoModelForSeq2SeqLM.from_pretrained("Loria-MosAIk/bt5-webnlg-en-ru", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Publish reproduced WebNLG checkpoint and model card
Browse files- README.md +42 -0
- added_tokens.json +5 -0
- config.json +34 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- special_tokens_map.json +23 -0
- spiece.model +3 -0
- tokenizer_config.json +63 -0
README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- ru
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text2text-generation
|
| 7 |
+
base_model: cointegrated/rut5-base-multitask
|
| 8 |
+
base_model_relation: finetune
|
| 9 |
+
tags:
|
| 10 |
+
- text-to-graph
|
| 11 |
+
- webnlg
|
| 12 |
+
- bt5
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# BT5 English–Russian Semantic Parsing
|
| 16 |
+
|
| 17 |
+
This model converts English or Russian text into subject–relation–object triples. It is our BT5 implementation based on [Agarwal et al. (2020)](https://aclanthology.org/2020.webnlg-1.13/), initialized from `cointegrated/rut5-base-multitask` and trained with six equally sampled parsing and translation tasks.
|
| 18 |
+
|
| 19 |
+
We used this checkpoint as a base text-to-data model in [XQDT](https://huggingface.co/papers/2608.29948). The [reproduction repository](https://github.com/guihuzhang/bt5-regen-reproduction) contains the code, saved predictions, and evaluation scripts.
|
| 20 |
+
|
| 21 |
+
The checkpoint is step 54,000. Its saved WebNLG 2020 test predictions give Exact F1 of 67.62 for English and 93.46 for Russian, using five-beam decoding.
|
| 22 |
+
|
| 23 |
+
## Usage
|
| 24 |
+
|
| 25 |
+
```python
|
| 26 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
| 27 |
+
|
| 28 |
+
model_path = "Loria-MosAIk/bt5-webnlg-en-ru"
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
|
| 30 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path).eval()
|
| 31 |
+
inputs = tokenizer("Parse English Paris is located in France.", return_tensors="pt")
|
| 32 |
+
outputs = model.generate(**inputs, num_beams=5, max_new_tokens=256)
|
| 33 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True, clean_up_tokenization_spaces=False))
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
Use `Parse Russian` for Russian input. Generated triples use `<S>`, `<P>`, and `<O>` markers. The accompanying reproduction code parses these markers and removes exact duplicate triples before evaluation.
|
| 37 |
+
|
| 38 |
+
The [base model](https://huggingface.co/cointegrated/rut5-base-multitask) is distributed under MIT. The WebNLG data used for fine-tuning are distributed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).
|
| 39 |
+
|
| 40 |
+
## Citation
|
| 41 |
+
|
| 42 |
+
Please cite Agarwal et al. (2020) for BT5 and Efimov-Zhang et al. (2026) for this reproduction. [BibTeX entries](https://github.com/guihuzhang/bt5-regen-reproduction#citation).
|
added_tokens.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"<O>": 30002,
|
| 3 |
+
"<P>": 30001,
|
| 4 |
+
"<S>": 30000
|
| 5 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "cointegrated/rut5-base-multitask",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"T5ForConditionalGeneration"
|
| 5 |
+
],
|
| 6 |
+
"classifier_dropout": 0.0,
|
| 7 |
+
"d_ff": 2048,
|
| 8 |
+
"d_kv": 64,
|
| 9 |
+
"d_model": 768,
|
| 10 |
+
"decoder_start_token_id": 0,
|
| 11 |
+
"dense_act_fn": "gelu_new",
|
| 12 |
+
"dropout_rate": 0.1,
|
| 13 |
+
"eos_token_id": 1,
|
| 14 |
+
"feed_forward_proj": "gated-gelu",
|
| 15 |
+
"gradient_checkpointing": false,
|
| 16 |
+
"initializer_factor": 1.0,
|
| 17 |
+
"is_encoder_decoder": true,
|
| 18 |
+
"is_gated_act": true,
|
| 19 |
+
"layer_norm_epsilon": 1e-06,
|
| 20 |
+
"model_type": "t5",
|
| 21 |
+
"num_decoder_layers": 12,
|
| 22 |
+
"num_heads": 12,
|
| 23 |
+
"num_layers": 12,
|
| 24 |
+
"output_past": true,
|
| 25 |
+
"pad_token_id": 0,
|
| 26 |
+
"relative_attention_max_distance": 128,
|
| 27 |
+
"relative_attention_num_buckets": 32,
|
| 28 |
+
"tie_word_embeddings": false,
|
| 29 |
+
"tokenizer_class": "T5Tokenizer",
|
| 30 |
+
"torch_dtype": "float32",
|
| 31 |
+
"transformers_version": "4.46.3",
|
| 32 |
+
"use_cache": true,
|
| 33 |
+
"vocab_size": 30003
|
| 34 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"decoder_start_token_id": 0,
|
| 4 |
+
"eos_token_id": 1,
|
| 5 |
+
"pad_token_id": 0,
|
| 6 |
+
"transformers_version": "4.46.3"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5389fc8a1a85e2072555fbe62a3943cd24b5f7aefd5101cf9e59324731e37ce8
|
| 3 |
+
size 977289064
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"eos_token": {
|
| 3 |
+
"content": "</s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"pad_token": {
|
| 10 |
+
"content": "<pad>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"unk_token": {
|
| 17 |
+
"content": "<unk>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
}
|
| 23 |
+
}
|
spiece.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:76927654c70c667e967c8caca165a3bb1311b415316b6aed8037ed5ede86b10e
|
| 3 |
+
size 827566
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": true,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"0": {
|
| 5 |
+
"content": "<pad>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": false,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"1": {
|
| 13 |
+
"content": "</s>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"2": {
|
| 21 |
+
"content": "<unk>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"30000": {
|
| 29 |
+
"content": "<S>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": true,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": false
|
| 35 |
+
},
|
| 36 |
+
"30001": {
|
| 37 |
+
"content": "<P>",
|
| 38 |
+
"lstrip": false,
|
| 39 |
+
"normalized": true,
|
| 40 |
+
"rstrip": false,
|
| 41 |
+
"single_word": false,
|
| 42 |
+
"special": false
|
| 43 |
+
},
|
| 44 |
+
"30002": {
|
| 45 |
+
"content": "<O>",
|
| 46 |
+
"lstrip": false,
|
| 47 |
+
"normalized": true,
|
| 48 |
+
"rstrip": false,
|
| 49 |
+
"single_word": false,
|
| 50 |
+
"special": false
|
| 51 |
+
}
|
| 52 |
+
},
|
| 53 |
+
"additional_special_tokens": [],
|
| 54 |
+
"clean_up_tokenization_spaces": false,
|
| 55 |
+
"eos_token": "</s>",
|
| 56 |
+
"extra_ids": 0,
|
| 57 |
+
"legacy": true,
|
| 58 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 59 |
+
"pad_token": "<pad>",
|
| 60 |
+
"sp_model_kwargs": {},
|
| 61 |
+
"tokenizer_class": "T5Tokenizer",
|
| 62 |
+
"unk_token": "<unk>"
|
| 63 |
+
}
|