Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,13 @@
|
|
|
|
|
| 1 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
import os
|
| 6 |
-
import time
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
if len(sys.argv) < 3:
|
| 14 |
-
print(
|
| 15 |
-
"Too few arguments. You should provide: \n1. dataset_filename" +
|
| 16 |
-
"\n2. output_data_filename"
|
| 17 |
-
)
|
| 18 |
-
sys.exit()
|
| 19 |
-
|
| 20 |
-
start = time.perf_counter()
|
| 21 |
-
dataset_filename_ = sys.argv[1]
|
| 22 |
-
output_data_filename_ = sys.argv[2]
|
| 23 |
-
|
| 24 |
-
headers_pairs = get_headers_pairs_list(dataset_filename_, verbose=True)
|
| 25 |
-
|
| 26 |
-
dist_matrix, max_dist = get_distance_matrix(
|
| 27 |
-
list(map(lambda x: x[1], headers_pairs)),
|
| 28 |
-
verbose=True
|
| 29 |
)
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
end = time.perf_counter()
|
| 34 |
-
"""
|
| 35 |
-
|
| 36 |
-
tokenizer = AutoTokenizer.from_pretrained('JetBrains/Mellum-4b-base')
|
| 37 |
-
model = AutoModelForCausalLM.from_pretrained('JetBrains/Mellum-4b-base')
|
| 38 |
-
encoded_input = tokenizer(example, return_tensors='pt', return_token_type_ids=False)
|
| 39 |
-
input_len = len(encoded_input["input_ids"][0])
|
| 40 |
-
out = model.generate(
|
| 41 |
-
**encoded_input,
|
| 42 |
-
max_new_tokens=100,
|
| 43 |
-
)
|
| 44 |
-
print("### Context")
|
| 45 |
-
print(tokenizer.decode(out[0][:input_len]))
|
| 46 |
-
print("### Prediction")
|
| 47 |
-
print(tokenizer.decode(out[0][input_len:]))
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
|
| 4 |
+
def run(input):
|
| 5 |
+
return "Rofl: " + name
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
app = gr.Interface(
|
| 8 |
+
fn=run,
|
| 9 |
+
inputs=["text"],
|
| 10 |
+
outputs=["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
)
|
| 12 |
|
| 13 |
+
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|