isimorfizam commited on
Commit
79927bb
1 Parent(s): 87a237f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -1,11 +1,25 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- pipeline = pipeline(task="feedback-distilbert", model="isimorfizam/distilbert-base-cased-distilled-squad-feedback")
 
 
 
 
 
 
 
 
 
 
5
 
6
  def predict(question):
7
- question_answerer = pipeline("question-answering", model=MODEL_CHECKPOINT)
8
- return question_answerer(question=question,context=context)
 
 
 
 
 
9
 
10
 
11
  gradio_app = gr.Interface(
 
1
  import gradio as gr
 
2
 
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+ from peft import PeftModel, PeftConfig
5
+
6
+ base_model = "google/gemma-2b-it"
7
+ adapter_model = "isimorfizam/logs"
8
+
9
+ model = AutoModelForCausalLM.from_pretrained(base_model)
10
+ model = PeftModel.from_pretrained(model, adapter_model)
11
+ tokenizer = AutoTokenizer.from_pretrained(base_model)
12
+
13
+ model = model.to("cuda")
14
 
15
  def predict(question):
16
+
17
+ #input_pretext = 'Answer the following question for me.'
18
+ input_text = question
19
+ input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
20
+
21
+ outputs = model.generate(**input_ids, max_length = 100)
22
+ return tokenizer.decode(outputs[0])
23
 
24
 
25
  gradio_app = gr.Interface(