Views
No views yet
1import torch
2from transformers import AutoTokenizer , AutoModelForCausalLM
3
4quant_path = "aiplanet/effi-7b-gptq"
5
6model = AutoModelForCausalLM.from_pretrained(quant_path , device_map='cuda')
7tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True , safetensors=True , fuse_layers=True)
8
9
10tst = """
11
12### INSTRUCTION:
13Virgin Australia, the trading name of Virgin Australia Airlines Pty Ltd, is an Australian-based airline. It is the largest airline by fleet size to use the Virgin brand. It commenced services on 31 August 2000 as Virgin Blue, with two aircraft on a single route. It suddenly found itself as a major airline in Australia's domestic market after the collapse of Ansett Australia in September 2001. The airline has since grown to directly serve 32 cities in Australia, from hubs in Brisbane, Melbourne and Sydney.Is Virgin Australia and Virgin Blue the same airlines?
14
15"""
16
17system_message = "Given your chain of thought reasoning, provide a rationale for the context in the source."
18
19template=f"""
20 Context: {system_message}
21 Human: {tst}
22"""
23
24# Tokenize the input
25input_ids = tokenizer(template, return_tensors="pt", truncation=True).input_ids.cuda()
26# Run the model to infere an output
27outputs = model.generate(input_ids=input_ids, max_new_tokens=512, top_p=0.9,temperature=0.1 , top_k=1, repetition_penalty=1.1)
28
29
30# Print the result
31
32print(f"{tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True)[0][len(template):]}")
33@misc {bhavyaaiplanet,
author = { {Bhavya Bhola} },
title = { Quantized version of effi-7b by AI Planet},
year = 2024,
url = { https://huggingface.co/aiplanet/effi-7b-gptq },
publisher = { Hugging Face }
}