Views
No views yet
1import torch
2from transformers import AutoTokenizer
3from gptqmodel import GPTQModel
4
5device = torch.device("cuda:0")
6
7model_name = "ModelCloud/Meta-Llama-3.1-8B-gptq-4bit"
8
9prompt = "I am in Shanghai, preparing to visit the natural history museum. Can you tell me the best way to"
10
11tokenizer = AutoTokenizer.from_pretrained(model_name)
12
13model = GPTQModel.from_quantized(model_name)
14
15inputs = tokenizer(prompt, return_tensors="pt").to(device)
16res = model.generate(**inputs, num_beams=1, min_new_tokens=1, max_new_tokens=512)
17print(tokenizer.decode(res[0]))