Views
No views yet
CohereForAI/aya-expanse-8b model using the GPTQ method in 4-bit precision.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Set up device
5device = torch.device('cuda:1') # Remember to use the correct device here
6
7# Load model and tokenizer
8model_name = "kevinbazira/aya-expanse-8b-gptq-4bit"
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10model = AutoModelForCausalLM.from_pretrained(
11 model_name,
12 device_map={"": device.index}
13)
14
15# Prepare input
16# https://huggingface.co/docs/transformers/en/pad_truncation
17input_text = "Add your prompt here."
18inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding="max_length", max_length=64)
19inputs = {key: value.to(device) for key, value in inputs.items()}
20
21# Perform text generation
22# https://huggingface.co/docs/transformers/en/main_classes/text_generation
23outputs = model.generate(
24 **inputs,
25 num_return_sequences=1,
26 min_new_tokens=64,
27 max_new_tokens=64,
28 do_sample=False,
29 use_cache=True,
30 num_beams=1
31)
32
33# Decode and print the output
34print(tokenizer.decode(outputs[0], skip_special_tokens=True))

contact@kevinbazira.com. I'll be happy to help!