This is an encoder-decoder model that was trained on various information extraction tasks, including text classification, named entity recognition, relation extraction and entity linking.
How to use:
First of all, initialize the model:
from transformers import T5Tokenizer, T5ForConditionalGeneration
import torch
device = torch.device("cuda") if torch.cuda.is_available() else torch.device('cpu')
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
model = T5ForConditionalGeneration.from_pretrained("knowledgator/t5-for-ie").to(device)
You need to set a prompt and put it with text to the model, below are examples of how to use it for different tasks:
named entity recognition
input_text = "Extract entity types from the text: <e1>Kyiv</e1> is the capital of <e2>Ukraine</e2>."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
text classification
input_text = "Classify the following text into the most relevant categories: Kyiv is the capital of Ukraine"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
relation extraction
input_text = "Extract relations between entities in the text: <e1>Kyiv</e1> is the capital of <e2>Ukraine</e2>."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to(device)
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
Unlimited-classifier
With our
unlimited-classifier
you can use
t5-for-ie
to classify text into millions of categories. It applies generation with contraints that is super helful when structured and deterministic outputs are needed.
To install it, run the following command:
pip install -U unlimited-classifier
Right now you can try it with the following example:
from unlimited_classifier import TextClassifier
labels=[
"e1 - capital of Ukraine",
"e1 - capital of Poland",
"e1 - European city",
"e1 - Asian city",
"e1 - small country"
]
classifier = TextClassifier(
labels=['default'],
model=model,
tokenizer=tokenizer,
device=device #if cuda
)
classifier.initialize_labels_trie(labels)
text = "<e1>Kyiv</e1> is the capital <e2>Ukraine</e2>."
output = classifier.invoke(text)
print(output)
Turbo T5
We recommend to use this model on GPU with our
TurboT5 package
, it uses custom CUDA kernels that accelerate computations and allows much longer sequences.
First of all, you need to install the package
pip install turbot5 -U
Then you can import different heads for various purposes; we released more encoder heads for tasks such as token classification, question-answering or text classification and, of course, encoder-decoder heads for conditional generation:
from turbot5 import T5ForConditionalGeneration
from turbot5 import T5Config
from transformers import T5Tokenizer
import torch
tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-large")
model = T5ForConditionalGeneration.from_pretrained("knowledgator/t5-for-ie",
attention_type = 'flash', #put attention type you want to use
use_triton=True).to('cuda')
Feedback
We value your input! Share your feedback and suggestions to help us improve our models.
Fill out the feedback
form
Join Our Discord
Connect with our community on Discord for news, support, and discussion about our models.
Join
Discord
Runs of knowledgator t5-for-ie on huggingface.co
17
Total runs
0
24-hour runs
1
3-day runs
4
7-day runs
8
30-day runs
More Information About t5-for-ie huggingface.co Model
t5-for-ie huggingface.co is an AI model on huggingface.co that provides t5-for-ie's model effect (), which can be used instantly with this knowledgator t5-for-ie model. huggingface.co supports a free trial of the t5-for-ie model, and also provides paid use of the t5-for-ie. Support call t5-for-ie model through api, including Node.js, Python, http.
t5-for-ie huggingface.co is an online trial and call api platform, which integrates t5-for-ie's modeling effects, including api services, and provides a free online trial of t5-for-ie, you can try t5-for-ie online for free by clicking the link below.
knowledgator t5-for-ie online free url in huggingface.co:
t5-for-ie is an open source model from GitHub that offers a free installation service, and any user can find t5-for-ie on GitHub to install. At the same time, huggingface.co provides the effect of t5-for-ie install, users can directly use t5-for-ie installed effect in huggingface.co for debugging and trial. It also supports api for free installation.