Spaces:
Paused
Paused
- HF_inference.py +4 -0
- __pycache__/HF_inference.cpython-39.pyc +0 -0
- __pycache__/app5.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/academic_list.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/app5_selectbox_func.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/class_tbl.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/database_con.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/evaluation.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/evaluation_analysis.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/evaluation_fac.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/g4f_prompt.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/instructor.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/naive_bayes_cl.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/program.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/student.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/subj_inst.cpython-39.pyc +0 -0
- app5_selectbox/__pycache__/subject.cpython-39.pyc +0 -0
- app5_selectbox/evaluation.py +2 -2
- app5_selectbox/evaluation_analysis.py +11 -11
- app5_selectbox/evaluation_fac.py +2 -2
HF_inference.py
CHANGED
|
@@ -72,18 +72,22 @@ RETRY_INTERVAL = 1 # in seconds
|
|
| 72 |
@st.cache_resource(experimental_allow_widgets=True, show_spinner=False)
|
| 73 |
def query(payload, selected_model):
|
| 74 |
# st.write(selected_model)
|
|
|
|
| 75 |
API_URL = MODEL_URLS.get(selected_model, MODEL_URLS[selected_model]) # Get API URL based on selected model
|
| 76 |
|
| 77 |
for retry in range(MAX_RETRIES):
|
|
|
|
| 78 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 79 |
if response.status_code == 200:
|
| 80 |
return response.json()
|
| 81 |
else:
|
|
|
|
| 82 |
time.sleep(RETRY_INTERVAL)
|
| 83 |
|
| 84 |
return None
|
| 85 |
|
| 86 |
def analyze_sintement(text, selected_model):
|
|
|
|
| 87 |
output = query({"inputs": text}, selected_model)
|
| 88 |
if output:
|
| 89 |
return output[0][0]['label'], output[0][0]['score']
|
|
|
|
| 72 |
@st.cache_resource(experimental_allow_widgets=True, show_spinner=False)
|
| 73 |
def query(payload, selected_model):
|
| 74 |
# st.write(selected_model)
|
| 75 |
+
|
| 76 |
API_URL = MODEL_URLS.get(selected_model, MODEL_URLS[selected_model]) # Get API URL based on selected model
|
| 77 |
|
| 78 |
for retry in range(MAX_RETRIES):
|
| 79 |
+
|
| 80 |
response = requests.post(API_URL, headers=headers, json=payload)
|
| 81 |
if response.status_code == 200:
|
| 82 |
return response.json()
|
| 83 |
else:
|
| 84 |
+
st.info("loadings")
|
| 85 |
time.sleep(RETRY_INTERVAL)
|
| 86 |
|
| 87 |
return None
|
| 88 |
|
| 89 |
def analyze_sintement(text, selected_model):
|
| 90 |
+
# print(headers)
|
| 91 |
output = query({"inputs": text}, selected_model)
|
| 92 |
if output:
|
| 93 |
return output[0][0]['label'], output[0][0]['score']
|
__pycache__/HF_inference.cpython-39.pyc
ADDED
|
Binary file (1.38 kB). View file
|
|
|
__pycache__/app5.cpython-39.pyc
ADDED
|
Binary file (6.73 kB). View file
|
|
|
app5_selectbox/__pycache__/academic_list.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/academic_list.cpython-39.pyc and b/app5_selectbox/__pycache__/academic_list.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/app5_selectbox_func.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/app5_selectbox_func.cpython-39.pyc and b/app5_selectbox/__pycache__/app5_selectbox_func.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/class_tbl.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/class_tbl.cpython-39.pyc and b/app5_selectbox/__pycache__/class_tbl.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/database_con.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/database_con.cpython-39.pyc and b/app5_selectbox/__pycache__/database_con.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/evaluation.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/evaluation.cpython-39.pyc and b/app5_selectbox/__pycache__/evaluation.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/evaluation_analysis.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/evaluation_analysis.cpython-39.pyc and b/app5_selectbox/__pycache__/evaluation_analysis.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/evaluation_fac.cpython-39.pyc
ADDED
|
Binary file (11.6 kB). View file
|
|
|
app5_selectbox/__pycache__/g4f_prompt.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/g4f_prompt.cpython-39.pyc and b/app5_selectbox/__pycache__/g4f_prompt.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/instructor.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/instructor.cpython-39.pyc and b/app5_selectbox/__pycache__/instructor.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/naive_bayes_cl.cpython-39.pyc
ADDED
|
Binary file (2.16 kB). View file
|
|
|
app5_selectbox/__pycache__/program.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/program.cpython-39.pyc and b/app5_selectbox/__pycache__/program.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/student.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/student.cpython-39.pyc and b/app5_selectbox/__pycache__/student.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/subj_inst.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/subj_inst.cpython-39.pyc and b/app5_selectbox/__pycache__/subj_inst.cpython-39.pyc differ
|
|
|
app5_selectbox/__pycache__/subject.cpython-39.pyc
CHANGED
|
Binary files a/app5_selectbox/__pycache__/subject.cpython-39.pyc and b/app5_selectbox/__pycache__/subject.cpython-39.pyc differ
|
|
|
app5_selectbox/evaluation.py
CHANGED
|
@@ -168,7 +168,7 @@ def analyze_instructors(evaluation_df):
|
|
| 168 |
try:
|
| 169 |
with st.spinner("Analyzing... "):
|
| 170 |
# st.write(llm_chain.run(prompt))
|
| 171 |
-
st.write(g4f_prompt(results_to_prompt)) #############################
|
| 172 |
st.success("Analyzing Complete!")
|
| 173 |
break
|
| 174 |
|
|
@@ -381,7 +381,7 @@ def analyze_instructors(evaluation_df):
|
|
| 381 |
while True:
|
| 382 |
with st.spinner("Generating Recommendation"):
|
| 383 |
try:
|
| 384 |
-
st.write(g4f_prompt(prompt)) #############################
|
| 385 |
# pass
|
| 386 |
# break
|
| 387 |
break
|
|
|
|
| 168 |
try:
|
| 169 |
with st.spinner("Analyzing... "):
|
| 170 |
# st.write(llm_chain.run(prompt))
|
| 171 |
+
# st.write(g4f_prompt(results_to_prompt)) #############################
|
| 172 |
st.success("Analyzing Complete!")
|
| 173 |
break
|
| 174 |
|
|
|
|
| 381 |
while True:
|
| 382 |
with st.spinner("Generating Recommendation"):
|
| 383 |
try:
|
| 384 |
+
# st.write(g4f_prompt(prompt)) #############################
|
| 385 |
# pass
|
| 386 |
# break
|
| 387 |
break
|
app5_selectbox/evaluation_analysis.py
CHANGED
|
@@ -97,10 +97,9 @@ def classify_sentiments(text_samples, model):
|
|
| 97 |
|
| 98 |
# text = ["i love this", "nice one!", "happy!"]
|
| 99 |
selected_model = model
|
|
|
|
| 100 |
results = [analyze_sintement(t, selected_model) for t in text_samples]
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
for idx, result in enumerate(results):
|
| 105 |
# st.text(result[0])
|
| 106 |
# predicted_class, probabilities = analyze_sintement(text_sample, model)
|
|
@@ -129,16 +128,17 @@ def calculate_average_scores(probability_list):
|
|
| 129 |
|
| 130 |
def eval_analysis(instructor, instructor_comment, criteria_results, selected_model):
|
| 131 |
if selected_model < 3:
|
| 132 |
-
|
|
|
|
| 133 |
# model_tokenizer = model_tokenizer_list[selected_model]
|
| 134 |
-
model_tokenizer = model_list[selected_model]
|
| 135 |
-
loaded_model = AutoModelForSequenceClassification.from_pretrained(model)
|
| 136 |
-
tokenizer = AutoTokenizer.from_pretrained(model_tokenizer)
|
| 137 |
-
|
| 138 |
clean_instructor_comment = clean_text(instructor_comment)
|
| 139 |
|
| 140 |
-
|
| 141 |
-
# predicted_sentiments_transformer = classify_sentiments(clean_instructor_comment,
|
|
|
|
| 142 |
|
| 143 |
predicted_sentiments = predicted_sentiments_transformer[1]
|
| 144 |
scores = predicted_sentiments_transformer[2]
|
|
@@ -316,7 +316,7 @@ def eval_analysis(instructor, instructor_comment, criteria_results, selected_mod
|
|
| 316 |
while True:
|
| 317 |
try:
|
| 318 |
with st.spinner("Generating...."):
|
| 319 |
-
if not llama2_g4f: st.write(g4f_prompt(prompt)) #################
|
| 320 |
# else: st.write(llama_prompt(prompt)) #################
|
| 321 |
st.success("Generation Complete!")
|
| 322 |
break
|
|
@@ -340,7 +340,7 @@ def eval_analysis(instructor, instructor_comment, criteria_results, selected_mod
|
|
| 340 |
while True:
|
| 341 |
try:
|
| 342 |
with st.spinner("Generating...."):
|
| 343 |
-
if not llama2_g4f: st.write(g4f_prompt(prompt)) #################
|
| 344 |
# else: st.write(llama_prompt(prompt)) #################
|
| 345 |
st.success("Generation Complete!")
|
| 346 |
break
|
|
|
|
| 97 |
|
| 98 |
# text = ["i love this", "nice one!", "happy!"]
|
| 99 |
selected_model = model
|
| 100 |
+
|
| 101 |
results = [analyze_sintement(t, selected_model) for t in text_samples]
|
| 102 |
|
|
|
|
|
|
|
| 103 |
for idx, result in enumerate(results):
|
| 104 |
# st.text(result[0])
|
| 105 |
# predicted_class, probabilities = analyze_sintement(text_sample, model)
|
|
|
|
| 128 |
|
| 129 |
def eval_analysis(instructor, instructor_comment, criteria_results, selected_model):
|
| 130 |
if selected_model < 3:
|
| 131 |
+
## local model
|
| 132 |
+
# model = model_list[selected_model]
|
| 133 |
# model_tokenizer = model_tokenizer_list[selected_model]
|
| 134 |
+
# model_tokenizer = model_list[selected_model]
|
| 135 |
+
# loaded_model = AutoModelForSequenceClassification.from_pretrained(model)
|
| 136 |
+
# tokenizer = AutoTokenizer.from_pretrained(model_tokenizer)
|
|
|
|
| 137 |
clean_instructor_comment = clean_text(instructor_comment)
|
| 138 |
|
| 139 |
+
# print(models[selected_model])
|
| 140 |
+
# predicted_sentiments_transformer = classify_sentiments(clean_instructor_comment, tokenizer, loaded_model) # local model
|
| 141 |
+
predicted_sentiments_transformer = classify_sentiments(clean_instructor_comment, models[selected_model]) # inference
|
| 142 |
|
| 143 |
predicted_sentiments = predicted_sentiments_transformer[1]
|
| 144 |
scores = predicted_sentiments_transformer[2]
|
|
|
|
| 316 |
while True:
|
| 317 |
try:
|
| 318 |
with st.spinner("Generating...."):
|
| 319 |
+
# if not llama2_g4f: st.write(g4f_prompt(prompt)) #################
|
| 320 |
# else: st.write(llama_prompt(prompt)) #################
|
| 321 |
st.success("Generation Complete!")
|
| 322 |
break
|
|
|
|
| 340 |
while True:
|
| 341 |
try:
|
| 342 |
with st.spinner("Generating...."):
|
| 343 |
+
# if not llama2_g4f: st.write(g4f_prompt(prompt)) #################
|
| 344 |
# else: st.write(llama_prompt(prompt)) #################
|
| 345 |
st.success("Generation Complete!")
|
| 346 |
break
|
app5_selectbox/evaluation_fac.py
CHANGED
|
@@ -391,7 +391,7 @@ def analyze_instructors(evaluation_df):
|
|
| 391 |
with st.spinner("Analyzing... "):
|
| 392 |
# st.write(llm_chain.run(prompt))
|
| 393 |
if enable_llm_analyze_sintement and sentiment_model:
|
| 394 |
-
st.write(g4f_prompt(results_to_prompt)) #############################
|
| 395 |
st.success("Analyzing Complete!")
|
| 396 |
break
|
| 397 |
|
|
@@ -487,7 +487,7 @@ def analyze_instructors(evaluation_df):
|
|
| 487 |
while True:
|
| 488 |
with st.spinner("Generating Recommendation"):
|
| 489 |
try:
|
| 490 |
-
if enable_llm_analyze_sintement and sentiment_model: st.write(g4f_prompt(prompt)) #############################
|
| 491 |
# pass
|
| 492 |
# break
|
| 493 |
break
|
|
|
|
| 391 |
with st.spinner("Analyzing... "):
|
| 392 |
# st.write(llm_chain.run(prompt))
|
| 393 |
if enable_llm_analyze_sintement and sentiment_model:
|
| 394 |
+
# st.write(g4f_prompt(results_to_prompt)) #############################
|
| 395 |
st.success("Analyzing Complete!")
|
| 396 |
break
|
| 397 |
|
|
|
|
| 487 |
while True:
|
| 488 |
with st.spinner("Generating Recommendation"):
|
| 489 |
try:
|
| 490 |
+
# if enable_llm_analyze_sintement and sentiment_model: st.write(g4f_prompt(prompt)) #############################
|
| 491 |
# pass
|
| 492 |
# break
|
| 493 |
break
|