Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import re
|
3 |
-
import time
|
4 |
-
import streamlit as st
|
5 |
-
from transformers import pipeline, Conversation, AutoTokenizer
|
6 |
-
#"meta-llama/Llama-2-13b-chat-hf"
|
7 |
-
my_config = {'model_name': "BramVanroy/Llama-2-13b-chat-dutch", 'do_sample': True, 'temperature': 0.1, 'repetition_penalty': 1.1, 'max_new_tokens': 500}
|
8 |
-
|
9 |
-
print(f"Loading the model: {my_config['model_name']}....")
|
10 |
-
time_load_model_start = time.time()
|
11 |
-
|
12 |
-
print(time_load_model_start)
|
13 |
-
|
14 |
-
# Load the model and tokenizer outside of the functions
|
15 |
-
llm = pipeline("text-generation",
|
16 |
-
model=my_config['model_name'],
|
17 |
-
tokenizer=AutoTokenizer.from_pretrained(my_config['model_name']),
|
18 |
-
do_sample=my_config['do_sample'],
|
19 |
-
temperature=my_config['temperature'],
|
20 |
-
repetition_penalty=my_config['repetition_penalty'],
|
21 |
-
max_new_tokens=my_config['max_new_tokens']
|
22 |
-
)
|
23 |
-
time_load_model_end = time.time()
|
24 |
-
elapsed_time = time_load_model_end - time_load_model_start
|
25 |
-
print(f"Elapsed time to load the model: {elapsed_time:.2f} sec")
|
26 |
-
|
27 |
-
def get_answer(chatbot, input_text):
|
28 |
-
start_time = time.time()
|
29 |
-
print(f"Processing the input\n {input_text}\n")
|
30 |
-
print('Processing the answer....')
|
31 |
-
conversation = Conversation(input_text)
|
32 |
-
print(f"Conversation(input_text): {conversation}")
|
33 |
-
output = (chatbot(conversation))[1]['content']
|
34 |
-
elapsed_time = time.time() - start_time
|
35 |
-
#Add the last print statement to the output variable
|
36 |
-
output += f"\nAnswered in {elapsed_time:.1f} seconds, Nr generated words: {count_words(output)}"
|
37 |
-
|
38 |
-
return output
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
#gr.ChatInterface(get_answer(llm, text)).launch()
|
43 |
-
demo = gr.Interface(fn=get_answer, inputs="text", outputs="text")
|
44 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|