benjamintli commited on
Commit
45f3287
·
verified ·
1 Parent(s): 9824e69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -1,7 +1,29 @@
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
1
  import gradio as gr
2
 
3
+ from unsloth import FastLanguageModel
4
+ model, tokenizer = FastLanguageModel.from_pretrained(
5
+ model_name = "benjamintli/llama3.2_abc_fine_tune", # YOUR MODEL YOU USED FOR TRAINING
6
+ max_seq_length = 2048,
7
+ dtype = None,
8
+ load_in_4bit = True,
9
+ )
10
+
11
+ def greet(input):
12
+ messages = [
13
+ {"role": "system", "content": "you are a helpful assistant that generates ABC notation music"},
14
+ {"role": "user", "content": f"{input}"},
15
+ ]
16
+ inputs = tokenizer.apply_chat_template(
17
+ messages,
18
+ tokenize = True,
19
+ add_generation_prompt = True, # Must add for generation
20
+ return_tensors = "pt",
21
+ )
22
+
23
+ outputs = model.generate(input_ids = inputs, max_new_tokens = 128, use_cache = True,
24
+ temperature = 1.5, min_p = 0.1)
25
+ response = tokenizer.batch_decode(outputs)
26
+ return response
27
 
28
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
29
  demo.launch()