Views
No views yet
1!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
2
3from unsloth import FastLanguageModel
4import torch
5max_seq_length = 2048
6dtype = None
7load_in_4bit = False
8model, tokenizer = FastLanguageModel.from_pretrained(
9 model_name = "waadarsh/llama3-8b-nissan-magnite-16bit",
10 max_seq_length = max_seq_length,
11 dtype = dtype,
12 load_in_4bit = load_in_4bit,
13)
14
15prompt_template_1 = """
16You are a helpful assistant for customers of nissan magnite. You are given the following input. Please complete the response in a clear and comprehensive way.
17## Question:
18{}
19
20## Response:
21{}"""1
2FastLanguageModel.for_inference(model)
3inputs = tokenizer(
4[
5 prompt_template_1.format(
6 "Tell me about different variants of nissan magnite", #input
7 "" # response
8 )
9], return_tensors = "pt").to("cuda")
10
11with torch.autocast(device_type="cuda"):
12 outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.5, repetition_penalty=1.2, use_cache=False)
13
14# Decode the outputs
15tokenizer.batch_decode(outputs)
161Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.
2['\nYou are a helpful assistant for customers of nissan magnite. You are given the following input. Please complete the response in a clear and comprehensive way.\n## Question:\nTell me about different variants of nissan magnite\n\n## Response:\nThe Nissan Magnite comes in multiple variants: XE, XL, XV and XV Premium. Each variant has unique features and specifications suited for different needs.<|end_of_text|>']1
2inputs = tokenizer(
3[
4 prompt_template_1.format(
5 "What type of infotainment system is available in the Nissan Magnite?", #input
6 "" # response
7 )
8], return_tensors = "pt").to("cuda")
9
10from transformers import TextStreamer
11text_streamer = TextStreamer(tokenizer)
12_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)
131Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.
2
3You are a helpful assistant for customers of nissan magnite. You are given the following input. Please complete the response in a clear and comprehensive way.
4## Question:
5What type of infotainment system is available in the Nissan Magnite?
6
7## Response:
8The Nissan Magnite features an 8-inch touchscreen infotainment system with Android Auto and Apple CarPlay compatibility. It is designed with a user-friendly interface and provides both entertainment and navigation solutions.<|end_of_text|>