PhantHive commited on
Commit
e16e02a
·
1 Parent(s): 061a67c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -26
app.py CHANGED
@@ -1,27 +1,4 @@
1
- import gradio as gr
2
- import peft
3
- from peft import PeftModel, PeftConfig
4
- from transformers import AutoModelForCausalLM, AutoTokenizer
5
- import torch
6
 
7
- # Load the model and config when the script starts
8
- config = PeftConfig.from_pretrained("PhantHive/bigbrain")
9
- model = AutoModelForCausalLM.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
10
- model = PeftModel.from_pretrained(model, "PhantHive/bigbrain")
11
-
12
- # Load the tokenizer
13
- tokenizer = AutoTokenizer.from_pretrained("NousResearch/Llama-2-7b-chat-hf")
14
-
15
-
16
- def greet(text):
17
- batch = tokenizer(f"'{text}' ->: ", return_tensors='pt')
18
-
19
- # Use torch.no_grad to disable gradient calculation
20
- with torch.no_grad():
21
- output_tokens = model.generate(**batch, do_sample=True, max_new_tokens=50)
22
-
23
- return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
24
-
25
-
26
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
27
- iface.launch()
 
1
+ # Use a pipeline as a high-level helper
2
+ from transformers import pipeline
 
 
 
3
 
4
+ pipe = pipeline("text-generation", model="PhantHive/bigbrain")