luulinh90s commited on
Commit
86a95d5
1 Parent(s): f7f3eab
app.py CHANGED
@@ -175,7 +175,7 @@ def index():
175
  session_id = generate_session_id()
176
  session_data = {
177
  'username': username,
178
- 'seed': str(seed), # Store as string
179
  'method': method,
180
  'selected_samples': selected_samples,
181
  'current_index': 0,
@@ -184,12 +184,29 @@ def index():
184
  'session_id': session_id
185
  }
186
  save_session_data(session_id, session_data)
187
- return redirect(url_for('experiment', session_id=session_id))
188
  except Exception as e:
189
  logger.exception(f"Error in index route: {e}")
190
  return "An error occurred", 500
191
  return render_template('index.html')
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  @app.route('/experiment/<session_id>', methods=['GET', 'POST'])
194
  def experiment(session_id):
195
  try:
 
175
  session_id = generate_session_id()
176
  session_data = {
177
  'username': username,
178
+ 'seed': str(seed),
179
  'method': method,
180
  'selected_samples': selected_samples,
181
  'current_index': 0,
 
184
  'session_id': session_id
185
  }
186
  save_session_data(session_id, session_data)
187
+ return redirect(url_for('explanation', session_id=session_id))
188
  except Exception as e:
189
  logger.exception(f"Error in index route: {e}")
190
  return "An error occurred", 500
191
  return render_template('index.html')
192
 
193
+
194
+ @app.route('/explanation/<session_id>')
195
+ def explanation(session_id):
196
+ session_data = load_session_data(session_id)
197
+ if not session_data:
198
+ return redirect(url_for('index'))
199
+
200
+ method = session_data['method']
201
+ if method == 'Chain-of-Table':
202
+ return render_template('cot_intro.html', session_id=session_id)
203
+ elif method == 'Plan-of-SQLs':
204
+ return render_template('pos_intro.html', session_id=session_id)
205
+ elif method == 'Dater':
206
+ return render_template('dater_intro.html', session_id=session_id)
207
+ else: # No-XAI
208
+ return redirect(url_for('experiment', session_id=session_id))
209
+
210
  @app.route('/experiment/<session_id>', methods=['GET', 'POST'])
211
  def experiment(session_id):
212
  try:
templates/cot_intro.html ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Chain-of-Table Explanations in TableQA</title>
5
+ <style>
6
+ body {
7
+ font-family: 'Roboto', sans-serif;
8
+ background: url('/api/placeholder/1920/1080') no-repeat center center fixed;
9
+ background-size: cover;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ min-height: 100vh;
14
+ margin: 0;
15
+ padding: 20px;
16
+ }
17
+ .container {
18
+ text-align: center;
19
+ background-color: #ffffff;
20
+ padding: 40px;
21
+ border-radius: 10px;
22
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
23
+ width: 80%;
24
+ max-width: 1000px;
25
+ }
26
+ h1, h2 {
27
+ color: #333;
28
+ }
29
+ p, li {
30
+ font-size: 16px;
31
+ color: #333;
32
+ text-align: left;
33
+ }
34
+ .step {
35
+ background-color: #f9f9f9;
36
+ border: 1px solid #ddd;
37
+ border-radius: 5px;
38
+ margin-bottom: 20px;
39
+ padding: 15px;
40
+ }
41
+ .step-title {
42
+ font-weight: bold;
43
+ margin-bottom: 10px;
44
+ }
45
+ table {
46
+ width: 100%;
47
+ border-collapse: collapse;
48
+ margin-bottom: 20px;
49
+ }
50
+ th, td {
51
+ border: 1px solid #ddd;
52
+ padding: 8px;
53
+ text-align: left;
54
+ }
55
+ th {
56
+ background-color: #f2f2f2;
57
+ }
58
+ .highlighted-cell {
59
+ background-color: #ffffcc;
60
+ }
61
+ button {
62
+ background-color: #4CAF50;
63
+ color: white;
64
+ padding: 15px 30px;
65
+ border: none;
66
+ border-radius: 5px;
67
+ cursor: pointer;
68
+ font-size: 18px;
69
+ transition: background-color 0.3s ease;
70
+ margin-top: 20px;
71
+ }
72
+ button:hover {
73
+ background-color: #45a049;
74
+ }
75
+ iframe {
76
+ width: 100%;
77
+ height: 600px;
78
+ border: none;
79
+ margin-top: 20px;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <div class="container">
85
+ <h1>Understanding Chain-of-Table Explanations</h1>
86
+ <p>
87
+ Chain-of-Table is a TableQA method that breaks down the question-answering process into a series of intermediate tables. Each step in the chain represents a specific operation on the table, leading to the final answer.
88
+ </p>
89
+ <h2>Example: 1947 Kentucky Wildcats Football Team</h2>
90
+ <p>
91
+ Statement to verify: "The Wildcats kept the opposing team scoreless in 4 games."
92
+ </p>
93
+ <div class="step">
94
+ <div class="step-title">Step 1: f_select_row(row 1, row 2, row 3, row 4, row 8)</div>
95
+ <p>This step selects specific rows from the original table.</p>
96
+ </div>
97
+ <div class="step">
98
+ <div class="step-title">Step 2: f_select_column(game, wildcats points, opponents)</div>
99
+ <p>This step narrows down the table to only include the 'game', 'wildcats points', and 'opponents' columns.</p>
100
+ </div>
101
+ <div class="step">
102
+ <div class="step-title">Step 3: f_sort_column(opponents)</div>
103
+ <p>The table is then sorted based on the 'opponents' column, which puts the scoreless games (0 points) at the top.</p>
104
+ </div>
105
+ <div class="step">
106
+ <div class="step-title">Step 4: simple_query()</div>
107
+ <p>This step just inputs the Statement and the final simplified table to the model to ask for the verification.</p>
108
+ </div>
109
+ <h2>Chain-of-Table Example</h2>
110
+ <iframe src="htmls_COT/TP/test-0.html"></iframe>
111
+ <h2>Final Prediction: TRUE</h2>
112
+ <button onclick="location.href='{{ url_for('experiment') }}'">Proceed to Experiment</button>
113
+ </div>
114
+ </body>
115
+ </html>
templates/dater_intro.html ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dater Explanations in TableQA</title>
5
+ <style>
6
+ body {
7
+ font-family: 'Roboto', sans-serif;
8
+ background: url('/api/placeholder/1920/1080') no-repeat center center fixed;
9
+ background-size: cover;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ min-height: 100vh;
14
+ margin: 0;
15
+ padding: 20px;
16
+ }
17
+ .container {
18
+ text-align: center;
19
+ background-color: #ffffff;
20
+ padding: 40px;
21
+ border-radius: 10px;
22
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
23
+ width: 80%;
24
+ max-width: 1000px;
25
+ }
26
+ h1, h2 {
27
+ color: #333;
28
+ }
29
+ p, li {
30
+ font-size: 16px;
31
+ color: #333;
32
+ text-align: left;
33
+ }
34
+ .step {
35
+ background-color: #f9f9f9;
36
+ border: 1px solid #ddd;
37
+ border-radius: 5px;
38
+ margin-bottom: 20px;
39
+ padding: 15px;
40
+ }
41
+ .step-title {
42
+ font-weight: bold;
43
+ margin-bottom: 10px;
44
+ }
45
+ table {
46
+ width: 100%;
47
+ border-collapse: collapse;
48
+ margin-bottom: 20px;
49
+ }
50
+ th, td {
51
+ border: 1px solid #ddd;
52
+ padding: 8px;
53
+ text-align: left;
54
+ }
55
+ th {
56
+ background-color: #f2f2f2;
57
+ }
58
+ .highlighted-cell {
59
+ background-color: #ffffcc;
60
+ }
61
+ button {
62
+ background-color: #4CAF50;
63
+ color: white;
64
+ padding: 15px 30px;
65
+ border: none;
66
+ border-radius: 5px;
67
+ cursor: pointer;
68
+ font-size: 18px;
69
+ transition: background-color 0.3s ease;
70
+ margin-top: 20px;
71
+ }
72
+ button:hover {
73
+ background-color: #45a049;
74
+ }
75
+ iframe {
76
+ width: 100%;
77
+ height: 600px;
78
+ border: none;
79
+ margin-top: 20px;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ <div class="container">
85
+ <h1>Understanding Dater Explanations</h1>
86
+ <p>
87
+ Dater is a TableQA method that focuses on selecting relevant information from the input table and providing contextual information to support the statement verification process.
88
+ </p>
89
+ <h2>Example: 1947 Kentucky Wildcats Football Team</h2>
90
+ <p>
91
+ Statement to verify: "The Wildcats kept the opposing team scoreless in 4 games."
92
+ </p>
93
+ <div class="step">
94
+ <div class="step-title">Step 1: Sub-table Selection</div>
95
+ <p>Dater selects a sub-table from the original input Table that is relevant to the Statement. This step ensures that only the most relevant information is considered for verification.</p>
96
+ </div>
97
+ <div class="step">
98
+ <div class="step-title">Step 2: Contextual Information</div>
99
+ <p>Dater provides contextual information that is fact-checked against the Table. This information serves as support for the Statement being verified.</p>
100
+ </div>
101
+ <h2>Dater Example</h2>
102
+ <iframe src="htmls_DATER/TP/test-0.html"></iframe>
103
+ <h2>Final Prediction: TRUE</h2>
104
+ <button onclick="location.href='{{ url_for('experiment') }}'">Proceed to Experiment</button>
105
+ </div>
106
+ </body>
107
+ </html>
templates/index.html CHANGED
@@ -88,7 +88,7 @@
88
  50% { border-color: #000000; }
89
  100% { border-color: #000000; }
90
  }
91
- button[type="submit"] {
92
  background-color: #4CAF50;
93
  color: white;
94
  padding: 15px 30px;
@@ -99,7 +99,7 @@
99
  transition: background-color 0.3s ease;
100
  margin-top: 20px;
101
  }
102
- button[type="submit"]:hover {
103
  background-color: #45a049;
104
  }
105
  </style>
@@ -128,15 +128,18 @@
128
  }
129
  return true;
130
  }
 
 
 
 
 
 
131
  </script>
132
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
133
  </head>
134
  <body>
135
  <div class="container">
136
- <h1>Let's get started! Please input your name, a random number, and select one of the below explanation methods for your experiment.</h1>
137
- <!-- <div class="instruction">-->
138
- <!-- Let's get started! Please input your name, enter a random number as your seed, and select one of the explanation methods for your experiment.-->
139
- <!-- </div>-->
140
  <form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();">
141
  <label for="username">Hi there 👋👋👋 ! What is your name?</label>
142
  <input type="text" id="username" name="username" required>
@@ -160,7 +163,7 @@
160
  </div>
161
  </div>
162
 
163
- <button type="submit">Start</button>
164
  </form>
165
  </div>
166
  </body>
 
88
  50% { border-color: #000000; }
89
  100% { border-color: #000000; }
90
  }
91
+ button {
92
  background-color: #4CAF50;
93
  color: white;
94
  padding: 15px 30px;
 
99
  transition: background-color 0.3s ease;
100
  margin-top: 20px;
101
  }
102
+ button:hover {
103
  background-color: #45a049;
104
  }
105
  </style>
 
128
  }
129
  return true;
130
  }
131
+
132
+ function goToExplanation() {
133
+ if (validateForm()) {
134
+ document.getElementById('method-form').submit();
135
+ }
136
+ }
137
  </script>
138
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
139
  </head>
140
  <body>
141
  <div class="container">
142
+ <h1>Let's get started! Please input your name, a random number, and select one of the below explanation methods for your experiment. You will be assigned 10 samples to work on.</h1>
 
 
 
143
  <form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();">
144
  <label for="username">Hi there 👋👋👋 ! What is your name?</label>
145
  <input type="text" id="username" name="username" required>
 
163
  </div>
164
  </div>
165
 
166
+ <button type="button" onclick="goToExplanation()">Next</button>
167
  </form>
168
  </div>
169
  </body>
templates/pos_intro.html ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Plan-of-SQLs Explanations in TableQA</title>
5
+ <style>
6
+ body {
7
+ font-family: 'Roboto', sans-serif;
8
+ background: url('/api/placeholder/1920/1080') no-repeat center center fixed;
9
+ background-size: cover;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ min-height: 100vh;
14
+ margin: 0;
15
+ padding: 20px;
16
+ }
17
+ .container {
18
+ text-align: center;
19
+ background-color: #ffffff;
20
+ padding: 40px;
21
+ border-radius: 10px;
22
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
23
+ width: 80%;
24
+ max-width: 1000px;
25
+ }
26
+ h1, h2 {
27
+ color: #333;
28
+ }
29
+ p, li {
30
+ font-size: 16px;
31
+ color: #333;
32
+ text-align: left;
33
+ }
34
+ .step {
35
+ background-color: #f9f9f9;
36
+ border: 1px solid #ddd;
37
+ border-radius: 5px;
38
+ margin-bottom: 20px;
39
+ padding: 15px;
40
+ }
41
+ .highlighted-step {
42
+ background-color: #ffffd9;
43
+ border-left: 5px solid #ffeb3b;
44
+ padding-left: 15px;
45
+ }
46
+ .step-title {
47
+ font-weight: bold;
48
+ margin-bottom: 10px;
49
+ }
50
+ table {
51
+ width: 100%;
52
+ border-collapse: collapse;
53
+ margin-bottom: 20px;
54
+ }
55
+ th, td {
56
+ border: 1px solid #ddd;
57
+ padding: 8px;
58
+ text-align: left;
59
+ }
60
+ th {
61
+ background-color: #f2f2f2;
62
+ }
63
+ .highlighted-cell {
64
+ background-color: #ffffcc;
65
+ }
66
+ button {
67
+ background-color: #4CAF50;
68
+ color: white;
69
+ padding: 15px 30px;
70
+ border: none;
71
+ border-radius: 5px;
72
+ cursor: pointer;
73
+ font-size: 18px;
74
+ transition: background-color 0.3s ease;
75
+ margin-top: 20px;
76
+ }
77
+ button:hover {
78
+ background-color: #45a049;
79
+ }
80
+ iframe {
81
+ width: 100%;
82
+ height: 600px;
83
+ border: none;
84
+ margin-top: 20px;
85
+ }
86
+ </style>
87
+ </head>
88
+ <body>
89
+ <div class="container">
90
+ <h1>Understanding Plan-of-SQLs Explanations</h1>
91
+ <p>
92
+ Plan-of-SQLs is a TableQA method that breaks down the question-answering process into a series of SQL commands. Each step represents a specific operation on the table, leading to the final answer.
93
+ </p>
94
+ <h2>Example: 1947 Kentucky Wildcats Football Team</h2>
95
+ <p>
96
+ Statement to verify: "The Wildcats kept the opposing team scoreless in 4 games."
97
+ </p>
98
+ <div class="step">
99
+ <div class="step-title">Step 1: Order the table by 'opponents' in ascending order.</div>
100
+ <p>This step sorts the entire table based on the 'opponents' column, putting the scoreless games (0 points) at the top.</p>
101
+ </div>
102
+ <div class="step">
103
+ <div class="step-title">Step 2: Select rows where 'opponents' is 0.</div>
104
+ <p>This step filters the table to only include rows where the opposing team didn't score any points.</p>
105
+ </div>
106
+ <!-- <div class="step">-->
107
+ <div class="step highl ighted-step">
108
+ <div class="step-title">Step 3: Use a `CASE` statement to return TRUE if the number of rows is equal to 4, otherwise return FALSE.</div>
109
+ <p>This step checks if there are exactly 4 games where the opposing team was scoreless, as stated in the verification statement.</p>
110
+ <p>In the final intermediate, only count the rows with actual data. The top row, which contains the column headers (like titles or labels for the columns), is not part of the count. So, if you see only the header row with no data beneath it, the table has 0 rows. If you see one row beneath the header, the table has 1 row." </p>
111
+ </div>
112
+ <h2>Program-of-Sequence Example</h2>
113
+ <iframe src="htmls_PoS/TP/test-0.html"></iframe>
114
+ <h2>Final Prediction: TRUE</h2>
115
+ <button onclick="location.href='{{ url_for('experiment') }}'">Proceed to Experiment</button>
116
+ </div>
117
+ </body>
118
+ </html>