Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ style = '''
|
|
23 |
'''
|
24 |
st.markdown(style, unsafe_allow_html=True)
|
25 |
|
26 |
-
st.markdown('<p style="font-family:sans-serif;font-size: 1.9rem;"> HertogAI
|
27 |
st.markdown("<p style='font-family:sans-serif;font-size: 0.9rem;'>Pre-trained TAPAS model runs on max 64 rows and 32 columns data. Make sure the file data doesn't exceed these dimensions.</p>", unsafe_allow_html=True)
|
28 |
|
29 |
# Initialize TAPAS pipeline
|
@@ -97,18 +97,15 @@ else:
|
|
97 |
coordinates = raw_answer.get('coordinates', [])
|
98 |
cells = raw_answer.get('cells', [])
|
99 |
|
100 |
-
#
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
base_sentence = f"The answer is: {answer}"
|
110 |
-
|
111 |
-
# Construct the full input for T5 model by including the original question
|
112 |
input_text = f"Given the question: '{question}', generate a more human-readable response: {base_sentence}"
|
113 |
|
114 |
# Tokenize the input and generate a fluent response using T5
|
|
|
23 |
'''
|
24 |
st.markdown(style, unsafe_allow_html=True)
|
25 |
|
26 |
+
st.markdown('<p style="font-family:sans-serif;font-size: 1.9rem;"> HertogAI Q&A using TAPAS and Model Language</p>', unsafe_allow_html=True)
|
27 |
st.markdown("<p style='font-family:sans-serif;font-size: 0.9rem;'>Pre-trained TAPAS model runs on max 64 rows and 32 columns data. Make sure the file data doesn't exceed these dimensions.</p>", unsafe_allow_html=True)
|
28 |
|
29 |
# Initialize TAPAS pipeline
|
|
|
97 |
coordinates = raw_answer.get('coordinates', [])
|
98 |
cells = raw_answer.get('cells', [])
|
99 |
|
100 |
+
# Construct a base sentence replacing 'SUM' with the query term
|
101 |
+
base_sentence = f"The {question.lower()} of the selected data is {answer}."
|
102 |
+
if coordinates and cells:
|
103 |
+
rows_info = [f"Row {coordinate[0] + 1}, Column '{df.columns[coordinate[1]]}' with value {cell}"
|
104 |
+
for coordinate, cell in zip(coordinates, cells)]
|
105 |
+
rows_description = " and ".join(rows_info)
|
106 |
+
base_sentence += f" This includes the following data: {rows_description}."
|
107 |
+
|
108 |
+
# Generate a fluent response using the T5 model, rephrasing the base sentence
|
|
|
|
|
|
|
109 |
input_text = f"Given the question: '{question}', generate a more human-readable response: {base_sentence}"
|
110 |
|
111 |
# Tokenize the input and generate a fluent response using T5
|