luulinh90s
commited on
Commit
·
24cbc9a
1
Parent(s):
5d30bf1
update
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import random
|
|
4 |
import os
|
5 |
import string
|
6 |
import logging
|
|
|
7 |
|
8 |
# Set up logging
|
9 |
logging.basicConfig(level=logging.INFO,
|
@@ -158,9 +159,9 @@ def experiment(username):
|
|
158 |
|
159 |
# statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."
|
160 |
statement = """
|
161 |
-
|
162 |
-
You are given an explanation that describes the reasoning process of the Table
|
163 |
-
Please carefully analyze the explanation and determine you should Accept or Reject the AI prediction.
|
164 |
"""
|
165 |
|
166 |
return render_template('experiment.html',
|
@@ -195,6 +196,27 @@ def feedback():
|
|
195 |
# Save updated session data
|
196 |
save_session_data(username, session_data)
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
if session_data['current_index'] >= len(session_data['selected_samples']):
|
199 |
return redirect(url_for('completed', username=username))
|
200 |
|
@@ -217,7 +239,7 @@ def completed(username):
|
|
217 |
if method == "Chain-of-Table":
|
218 |
json_file = 'Tabular_LLMs_human_study_vis_6_COT.json'
|
219 |
else: # Default to Plan-of-SQLs
|
220 |
-
json_file = '
|
221 |
|
222 |
with open(json_file, 'r') as f:
|
223 |
ground_truth = json.load(f)
|
|
|
4 |
import os
|
5 |
import string
|
6 |
import logging
|
7 |
+
from datetime import datetime
|
8 |
|
9 |
# Set up logging
|
10 |
logging.basicConfig(level=logging.INFO,
|
|
|
159 |
|
160 |
# statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."
|
161 |
statement = """
|
162 |
+
A Table Question Answering model is working on Table Fact Verification task (TabFact dataset), verifying if a given Statement is TRUE or FALSE on a given input Table.
|
163 |
+
You are given an explanation that describes the reasoning process of the Table QA model.
|
164 |
+
Please carefully analyze the explanation and determine whether you should Accept or Reject the AI prediction.
|
165 |
"""
|
166 |
|
167 |
return render_template('experiment.html',
|
|
|
196 |
# Save updated session data
|
197 |
save_session_data(username, session_data)
|
198 |
|
199 |
+
# Write feedback to a separate JSON file
|
200 |
+
os.makedirs('session_data', exist_ok=True)
|
201 |
+
feedback_file = f'session_data/{username}_feedback.json'
|
202 |
+
|
203 |
+
if os.path.exists(feedback_file):
|
204 |
+
with open(feedback_file, 'r') as f:
|
205 |
+
feedback_data = json.load(f)
|
206 |
+
else:
|
207 |
+
feedback_data = []
|
208 |
+
|
209 |
+
feedback_data.append({
|
210 |
+
'sample_id': session_data['current_index'] - 1,
|
211 |
+
'feedback': feedback,
|
212 |
+
'timestamp': datetime.now().isoformat()
|
213 |
+
})
|
214 |
+
|
215 |
+
with open(feedback_file, 'w') as f:
|
216 |
+
json.dump(feedback_data, f, indent=4)
|
217 |
+
|
218 |
+
logger.info(f"Feedback saved for user {username}, sample {session_data['current_index'] - 1}")
|
219 |
+
|
220 |
if session_data['current_index'] >= len(session_data['selected_samples']):
|
221 |
return redirect(url_for('completed', username=username))
|
222 |
|
|
|
239 |
if method == "Chain-of-Table":
|
240 |
json_file = 'Tabular_LLMs_human_study_vis_6_COT.json'
|
241 |
else: # Default to Plan-of-SQLs
|
242 |
+
json_file = 'Tabular_LLMs_human_study_vis_6_POS.json'
|
243 |
|
244 |
with open(json_file, 'r') as f:
|
245 |
ground_truth = json.load(f)
|