Views
No views yet
1pip install unsloth
2
3alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
4
5### Instruction:
6{}
7
8### Input:
9{}
10
11### Response:
12{}"""
13
14FastLanguageModel.for_inference(model) # Enable native 2x faster inference
15inputs = tokenizer(
16[
17 alpaca_prompt.format(
18 "Generate a soft UI login form with a focus on tactile and gentle visual feedback.", # instruction
19 "", # input
20 "", # output - leave this blank for generation!
21 )
22], return_tensors = "pt").to("cuda")
23
24outputs = model.generate(**inputs, max_new_tokens = 4096, use_cache = True)
25tokenizer.batch_decode(outputs)
261from unsloth import FastLanguageModel
2 model, tokenizer = FastLanguageModel.from_pretrained(
3 model_name = "imranali291/UIGEN_Qwen2.5-Coder-7B-Instruct-bnb-4bit",
4 max_seq_length = max_seq_length,
5 dtype = dtype,
6 load_in_4bit = load_in_4bit,
7 )
8 FastLanguageModel.for_inference(model) # Enable native 2x faster inference
9
10# alpaca_prompt = You MUST copy from above!
11
12inputs = tokenizer(
13[
14 alpaca_prompt.format(
15 "What is a famous tall tower in Paris?", # instruction
16 "", # input
17 "", # output - leave this blank for generation!
18 )
19], return_tensors = "pt").to("cuda")
20
21from transformers import TextStreamer
22text_streamer = TextStreamer(tokenizer)
23_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)