Views
No views yet
1from transformers import pipeline
2
3def generate_by_pipeline(instruction, inputs=""):
4 if inputs == "":
5 prompt = f"### Instruction:\n{instruction}\n\n### Response:"
6 else:
7 prompt = f"### Instruction:\n{instruction}\n\n### Input:\n{inputs}\n\n### Response:"
8 return generator(prompt)[0]['generated_text']
9
10print(generate_by_pipeline("What is the capital of China?"))