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
Add verified text-to-graph input and output examples
Browse files
README.md
CHANGED
|
@@ -28,12 +28,25 @@ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
| 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
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|
|
|
|
| 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 Lina Dorado was born in Bogotá in 1975.", 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 |
+
Output:
|
| 37 |
+
|
| 38 |
+
```text
|
| 39 |
+
<S> Lina Dorado <P> birth year <O> 1975 <S> Lina Dorado <P> birth place <O> Bogotá
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
For a Russian sentence, use the `Parse Russian` prefix:
|
| 43 |
+
|
| 44 |
+
```text
|
| 45 |
+
Input: Parse Russian Валюта Индии - Индийская рупия.
|
| 46 |
+
Output: <S> India <P> currency <O> Indian rupee
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
The markers `<S>`, `<P>`, and `<O>` identify the subject, relation, and object of each triple. The reproduction code removes exact duplicate triples before evaluation.
|
| 50 |
|
| 51 |
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/).
|
| 52 |
|