Downloads · 30 days
7
0% of all-time downloads
bew/t5_sentence_to_triplet_xl
t5_sentence_to_triplet_xl is a text generation model from bew. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This is a version of flan-t5-xl fine-tuned on the KELM Corpus to take in sentences and output triplets of the form subject-relation-object to be used for knowledge graph generation.
Downloads · 30 days
7
0% of all-time downloads
All-time downloads
3.2K
Public
Repo size
37.9 MB
Likes
4
Public
Click a slice to open those files.
.bin37.9 MB · 100%
From the Hugging Face model README
This is a version of flan-t5-xl fine-tuned on the KELM Corpus to take in sentences and output triplets of the form subject-relation-object to be used for knowledge graph generation.
The model uses custom tokens to delimit triplets:
special_tokens = ['<triplet>', '</triplet>', '<relation>', '<object>']
tokenizer.add_tokens(special_tokens)
You can use it like this:
model = model.to(device)
model.eval()
new_input = "Hugging Face, Inc. is an American company that develops tools for building applications using machine learning.",
inputs = tokenizer(new_input, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(input_ids=inputs["input_ids"].to("cuda"))
print(tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=False)[0])
Output: <pad><triplet> Hugging Face <relation> instance of <object> Business </triplet></s>
This model still isn't perfect, and may make mistakes! I'm working on fine-tuning it for longer and on a more diverse set of data.