Spaces:
Sleeping
Sleeping
smhavens
commited on
Commit
·
2c3c9f7
1
Parent(s):
7a2e05d
Testing tab added to gradio
Browse files
app.py
CHANGED
@@ -37,6 +37,7 @@ def compute_metrics(eval_pred):
|
|
37 |
|
38 |
|
39 |
def training():
|
|
|
40 |
dataset = load_dataset("glue", "cola")
|
41 |
dataset = dataset["train"]
|
42 |
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
@@ -50,7 +51,9 @@ def training():
|
|
50 |
|
51 |
|
52 |
|
53 |
-
finetune(small_train_dataset, small_eval_dataset)
|
|
|
|
|
54 |
|
55 |
|
56 |
def finetune(train, eval):
|
@@ -106,6 +109,7 @@ def finetune(train, eval):
|
|
106 |
|
107 |
print("Sentence embeddings:")
|
108 |
print(sentence_embeddings)
|
|
|
109 |
|
110 |
|
111 |
|
@@ -134,6 +138,8 @@ def main():
|
|
134 |
answer = "Moon"
|
135 |
global guesses
|
136 |
|
|
|
|
|
137 |
prompt = f"{word1} is to {word2} as {word3} is to ____"
|
138 |
with gr.Blocks() as iface:
|
139 |
gr.Markdown(prompt)
|
@@ -143,11 +149,15 @@ def main():
|
|
143 |
text_button = gr.Button("Submit")
|
144 |
with gr.Accordion("Open for previous guesses"):
|
145 |
text_guesses = gr.Textbox()
|
|
|
|
|
|
|
|
|
146 |
text_button.click(check_answer, inputs=[text_input], outputs=[text_output, text_guesses])
|
147 |
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
148 |
iface.launch()
|
149 |
|
150 |
-
|
151 |
|
152 |
|
153 |
|
|
|
37 |
|
38 |
|
39 |
def training():
|
40 |
+
dataset_id = "glue-cola"
|
41 |
dataset = load_dataset("glue", "cola")
|
42 |
dataset = dataset["train"]
|
43 |
tokenized_datasets = dataset.map(tokenize_function, batched=True)
|
|
|
51 |
|
52 |
|
53 |
|
54 |
+
embeddings = finetune(small_train_dataset, small_eval_dataset)
|
55 |
+
|
56 |
+
return (dataset['train'].num_rows, type(dataset['train'][0]), type(dataset['train'][0]['set']), dataset['train'][0], embeddings)
|
57 |
|
58 |
|
59 |
def finetune(train, eval):
|
|
|
109 |
|
110 |
print("Sentence embeddings:")
|
111 |
print(sentence_embeddings)
|
112 |
+
return sentence_embeddings
|
113 |
|
114 |
|
115 |
|
|
|
138 |
answer = "Moon"
|
139 |
global guesses
|
140 |
|
141 |
+
num_rows, data_type, value, example, embeddings = training()
|
142 |
+
|
143 |
prompt = f"{word1} is to {word2} as {word3} is to ____"
|
144 |
with gr.Blocks() as iface:
|
145 |
gr.Markdown(prompt)
|
|
|
149 |
text_button = gr.Button("Submit")
|
150 |
with gr.Accordion("Open for previous guesses"):
|
151 |
text_guesses = gr.Textbox()
|
152 |
+
with gr.Tab("Testing"):
|
153 |
+
gr.Markdown(f"""Number of rows in dataset is {num_rows}, with each having type {data_type} and value {value}.
|
154 |
+
An example is {example}.
|
155 |
+
The Embeddings are {embeddings}.""")
|
156 |
text_button.click(check_answer, inputs=[text_input], outputs=[text_output, text_guesses])
|
157 |
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
158 |
iface.launch()
|
159 |
|
160 |
+
|
161 |
|
162 |
|
163 |
|