Facebook-Bart-Qna / README.md
Mr-Vicky-01's picture
Update README.md
07a5af3 verified
|
raw
history blame
1.09 kB
metadata
license: mit
datasets:
  - databricks/databricks-dolly-15k
language:
  - en
metrics:
  - rouge
widget:
  - text: A room without books is like a body without a soul.
library_name: transformers

Uploaded model

Inference

# Load model directly
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("Mr-Vicky-01/Facebook-Bart-Qna")
model = AutoModelForSeq2SeqLM.from_pretrained("Mr-Vicky-01/Facebook-Bart-Qna")

def generate_answer(text):
    inputs = tokenizer([text], return_tensors='pt', truncation=True)
    summary_ids = model.generate(inputs['input_ids'], max_length=512)
    summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
    return summary

text_to_summarize = """Please answer this question: What is Artifical Intelligence?"""
summary = generate_answer(text_to_summarize)
print(summary)