DavidFM43 commited on
Commit
5bc7c1a
·
1 Parent(s): 178c5c2

Load PEFT model

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -1,7 +1,24 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
 
6
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
  import gradio as gr
2
+ import torch
3
+ from peft import PeftModel, PeftConfig
4
+ from transformers import AutoModelForCausalLM, AutoTokenizer
5
+
6
+ peft_model_id = "hackathon-somos-nlp-2023/bertin-gpt-j-6b-ner-es"
7
+ config = PeftConfig.from_pretrained(peft_model_id)
8
+ model = AutoModelForCausalLM.from_pretrained(
9
+ config.base_model_name_or_path,
10
+ return_dict=True,
11
+ load_in_8bit=True,
12
+ device_map="auto",
13
+ )
14
+ tokenizer = AutoTokenizer.from_pretrained(peft_model_id)
15
+ # Load the Lora model
16
+ model = PeftModel.from_pretrained(model, peft_model_id)
17
+
18
 
19
  def greet(name):
20
  return "Hello " + name + "!!"
21
 
22
+
23
  iface = gr.Interface(fn=greet, inputs="text", outputs="text")
24
+ iface.launch()