mwitiderrick's picture
Create README.md
63bcbad verified
|
raw
history blame
1.31 kB
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
prompt = "How to make banana bread?"
formatted_prompt = f"<s> [|User|]\n{prompt}</s>[|Assistant|]\n"
model_id = "/home/mwiti/mwitiderrick/output_oneshot"
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.float16)
tokenizer = AutoTokenizer.from_pretrained(model_id)
inputs = tokenizer(formatted_prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.batch_decode(outputs)[0])
"""
<s><s> [|User|]
How to make banana bread?</s>[|Assistant|]
To make banana bread, follow these steps:
1. Start by preparing the ingredients. You will need banana bread mix, flour, water, and salt.
2. Mix the ingredients together and mix the mixture thoroughly.
3. Pour the mixture into a pan to cook.
4. Cook the mixture until it is cooked.
5. Once the bread is cooked, you can use it as a base for making banana bread.
6. Add the banana bread mix to the pan and mix it thoroughly.
7. Pour the mixture into a pan to cook.
8. Cook the mixture until it is cooked.
9. Once the bread is cooked, you can use it as a base for making banana bread.
10. Add the banana bread mix to the pan and mix it thoroughly.
11. Pour the mixture into a pan to cook.
12.
"""
```