Spaces:
Sleeping
Sleeping
Amitontheweb
commited on
Commit
•
ab113d6
1
Parent(s):
c9bc8d4
Update app.py
Browse files
app.py
CHANGED
@@ -8,20 +8,12 @@ import os
|
|
8 |
|
9 |
token = os.environ.get("HF_TOKEN")
|
10 |
|
11 |
-
# Load default model as GPT2
|
12 |
|
13 |
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
#tokenizer_gpt2 = AutoTokenizer.from_pretrained("openai-community/gpt2")
|
18 |
-
#model_gpt2 = AutoModelForCausalLM.from_pretrained("openai-community/gpt2")
|
19 |
-
|
20 |
-
#tokenizer_gemma = AutoTokenizer.from_pretrained("google/gemma-2b")
|
21 |
-
#model_gemma = AutoModelForCausalLM.from_pretrained("google/gemma-2b", token=token)
|
22 |
-
|
23 |
-
#tokenizer_qwen = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B")
|
24 |
-
#model_qwen = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-0.5B")
|
25 |
|
26 |
# Define functions
|
27 |
|
@@ -139,30 +131,12 @@ def generate(input_text, number_steps, number_beams, number_beam_groups, diversi
|
|
139 |
|
140 |
#--------ON SELECTING MODEL------------------------
|
141 |
|
142 |
-
def select_model(model_selected):
|
143 |
-
|
144 |
-
global model_name
|
145 |
-
|
146 |
-
if model_selected == "GPT2":
|
147 |
-
model_name = "openai-community/gpt2"
|
148 |
-
#tokenizer = tokenizer_gpt2
|
149 |
-
#model = model_gpt2
|
150 |
-
#print (model_selected + " loaded")
|
151 |
-
|
152 |
-
#if model_selected == "Gemma 2":
|
153 |
-
#tokenizer = tokenizer_gemma
|
154 |
-
#model = model_gemma
|
155 |
-
|
156 |
-
if model_selected == "Qwen2":
|
157 |
-
model_name = "Qwen/Qwen2-0.5B"
|
158 |
-
#tokenizer = tokenizer_qwen
|
159 |
-
#model = model_qwen
|
160 |
|
161 |
# On clicking load button
|
162 |
|
163 |
def load_model (name):
|
164 |
|
165 |
-
global model_name
|
166 |
global tokenizer
|
167 |
global model
|
168 |
|
|
|
8 |
|
9 |
token = os.environ.get("HF_TOKEN")
|
10 |
|
11 |
+
# Load default model as GPT2
|
12 |
|
13 |
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained("openai-community/gpt2")
|
15 |
+
model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Define functions
|
19 |
|
|
|
131 |
|
132 |
#--------ON SELECTING MODEL------------------------
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
# On clicking load button
|
136 |
|
137 |
def load_model (name):
|
138 |
|
139 |
+
#global model_name
|
140 |
global tokenizer
|
141 |
global model
|
142 |
|