Views
No views yet
1# pip install -q transformers accelerate
2from transformers import pipeline, GenerationConfig
3
4model_name = "pszemraj/bart-base-instruct-dolly_hhrlhf"
5assistant = pipeline(
6 "text2text-generation",
7 model_name,
8 device_map="auto"
9)
10cfg = GenerationConfig.from_pretrained(model_name)
11
12# pass an 'instruction' as the prompt to the pipeline
13prompt = "Write a guide on how to become a ninja while working a 9-5 job."
14result = assistant(prompt, generation_config=cfg)[0]["generated_text"]
15print(result)using the generation config is optional, can subsitute with other generation params.