Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
2import torch
3
4tokenizer = AutoTokenizer.from_pretrained("satyajitghana/mistral-7b-v0.1-alpaca-chat")
5model = AutoModelForCausalLM.from_pretrained(
6 "satyajitghana/mistral-7b-v0.1-alpaca-chat",
7 torch_dtype=torch.bfloat16,
8 device_map="auto"
9)
10
11pipe = pipeline(
12 "text-generation",
13 model=model,
14 tokenizer=tokenizer,
15)
16
17INPUT = """
18### Instruction:
19List 3 historical events related to the following country
20
21### Input:
22India
23
24### Response:
25"""
26
27out = pipe(
28 INPUT,
29 max_new_tokens=200
30)
31
32print(out[0]['generated_text'])