Views
No views yet
nkwbtb/SummaCoz1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
2
3tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-xxl")
4model = AutoModelForSeq2SeqLM.from_pretrained("nkwbtb/flan-t5-11b-SummaCoz",
5 torch_dtype="auto",
6 device_map="auto")
7pipe = pipeline("text2text-generation",
8 model=model,
9 tokenizer=tokenizer)
10
11PROMPT = """Is the hypothesis true based on the premise? Give your explanation afterwards.
12
13Premise:
14{article}
15
16Hypothesis:
17{summary}
18"""
19
20article = "Goldfish are being caught weighing up to 2kg and koi carp up to 8kg and one metre in length."
21summary = "Goldfish are being caught weighing up to 8kg and one metre in length."
22
23print(pipe(PROMPT.format(article=article, summary=summary),
24 do_sample=False,
25 max_new_tokens=512))
26"""[{'generated_text': '\
27No, the hypothesis is not true. \
28- The hypothesis states that goldfish are being caught weighing up to 8kg and one metre in length. \
29- However, the premise states that goldfish are being caught weighing up to 2kg and koi carp up to 8kg and one metre in length. \
30- The difference between the two is that the koi carp is weighing 8kg and the goldfish is weighing 2kg.'}]"""