Spaces:
Paused
Paused
truongghieu
commited on
Commit
•
fe849b6
1
Parent(s):
a918eee
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,3 @@
|
|
1 |
-
|
2 |
-
import torch
|
3 |
-
from time import perf_counter
|
4 |
-
from transformers import GenerationConfig
|
5 |
-
from peft import PeftConfig,PeftModel
|
6 |
-
import gradio as gr
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
model_id = "truongghieu/deci-finetuned"
|
11 |
-
|
12 |
-
peft_model_config = PeftConfig(model_id)
|
13 |
-
config = PeftConfig.from_pretrained(model_id)
|
14 |
-
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path,return_dict = True,load_in_8bit = False,device_map="auto", torch_dtype=torch.float16)
|
15 |
-
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
16 |
-
|
17 |
-
my_model = PeftModel.from_pretrained(model,model_id)
|
18 |
-
|
19 |
-
def text_gen(input):
|
20 |
-
inputs = tokenizer("\n###Instruction: "+str(input)+"\".\n###Response:", return_tensors="pt").to("cuda")
|
21 |
-
|
22 |
-
outputs = my_model.generate(**inputs)
|
23 |
-
return outputs
|
24 |
-
|
25 |
-
gr.Interface(fn=text_gen,input=gr.Textbox(label="Message "),outputs=gr.Textbox(label="text"),title="Text Generation with GPT-3",
|
26 |
-
description="Enter a prompt to generate text using the GPT-3 model.",
|
27 |
-
live=True,).launch()
|
28 |
|
|
|
|
1 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
gr.Interface.load("truongghieu/spaceTest").launch()
|