Views
No views yet
1def format_test(x):
2
3 if x['input']:
4 formatted_text = f"""Below is an instruction that describes a task. \
5 Write a response that appropriately completes the request.
6
7 ### Instruction:
8 {x['instruction']}
9
10 ### Input:
11 {x['input']}
12
13 ### Response:
14 """
15
16 else:
17 formatted_text = f"""Below is an instruction that describes a task. \
18 Write a response that appropriately completes the request.
19
20 ### Instruction:
21 {x['instruction']}
22
23 ### Response:
24 """
25
26 return formatted_text
27
28# using code_instructions_122k_alpaca dataset
29Prompt = format_test(data[155])
30print(Prompt)
311from transformers import TextStreamer
2
3FastLanguageModel.for_inference(model) # Enable native 2x faster inference
4inputs = tokenizer(
5[
6 Prompt
7], return_tensors = "pt").to("cuda")
8
9text_streamer = TextStreamer(tokenizer)
10_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 512)1from unsloth import FastLanguageModel
2
3model, tokenizer = FastLanguageModel.from_pretrained(
4 model_name = "EpistemeAI/Athena-codegemma-2-9b-v1", # YOUR MODEL YOU USED FOR TRAINING
5 max_seq_length = max_seq_length,
6 dtype = dtype,
7 load_in_4bit = load_in_4bit,
8)
9FastLanguageModel.for_inference(model) # Enable native 2x faster inference
10
11# alpaca_prompt = You MUST copy from above!
12
13inputs = tokenizer(
14[
15 alpaca_prompt.format(
16 "Create a function to calculate the sum of a sequence of integers.", # instruction
17 "", # input
18 "", # output - leave this blank for generation!
19 )
20], return_tensors = "pt").to("cuda")
21
22outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
23tokenizer.batch_decode(outputs)1@article{gemma_2024,
2 title={Gemma},
3 url={https://www.kaggle.com/m/3301},
4 DOI={10.34740/KAGGLE/M/3301},
5 publisher={Kaggle},
6 author={Gemma Team},
7 year={2024}
8}