Views
No views yet
1from transformers import AutoTokenizer
2from gptqmodel import GPTQModel
3
4model_name = "ModelCloud/EXAONE-3.0-7.8B-Instruct-gptq-4bit"
5
6prompt = [
7 {"role": "system",
8 "content": "You are EXAONE model from LG AI Research, a helpful assistant."},
9 {"role": "user", "content": "I am in Shanghai, preparing to visit the natural history museum. Can you tell me the best way to"}
10]
11
12tokenizer = AutoTokenizer.from_pretrained(model_name)
13
14model = GPTQModel.from_quantized(model_name, trust_remote_code=True)
15
16input_tensor = tokenizer.apply_chat_template(prompt, add_generation_prompt=True, return_tensors="pt")
17outputs = model.generate(input_ids=input_tensor.to(model.device), max_new_tokens=100)
18result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
19
20print(result)