Spaces:
Build error
Build error
Commit
·
66f9f66
1
Parent(s):
072f6c1
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,9 @@ def ask_llm_chunk(chunk, questions):
|
|
| 16 |
st.write(f"An error occurred: {e}")
|
| 17 |
return ["Error occurred while tokenizing"] * len(questions)
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
outputs = model(**inputs)
|
| 23 |
predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(
|
|
@@ -28,42 +29,28 @@ def ask_llm_chunk(chunk, questions):
|
|
| 28 |
|
| 29 |
answers = []
|
| 30 |
for coordinates in predicted_answer_coordinates:
|
| 31 |
-
|
| 32 |
-
row, col =
|
| 33 |
try:
|
| 34 |
-
st.write(f"DataFrame shape: {chunk.shape}") # Debugging line
|
| 35 |
-
st.write(f"DataFrame columns: {chunk.columns}") # Debugging line
|
| 36 |
st.write(f"Trying to access row {row}, col {col}") # Debugging line
|
| 37 |
value = chunk.iloc[row, col]
|
| 38 |
-
st.write(f"Value accessed: {value}") #
|
| 39 |
if isinstance(value, pd.Series):
|
| 40 |
answers.append(value.values)
|
| 41 |
else:
|
| 42 |
answers.append(value.item() if hasattr(value, 'item') else value)
|
| 43 |
except Exception as e:
|
| 44 |
-
st.write(f"
|
| 45 |
-
st.write(f"
|
| 46 |
-
st.write(f"
|
| 47 |
-
|
| 48 |
-
cell_values = []
|
| 49 |
-
for coordinate in coordinates:
|
| 50 |
-
row, col = coordinate
|
| 51 |
-
try:
|
| 52 |
-
value = chunk.iloc[row, col]
|
| 53 |
-
if isinstance(value, pd.Series):
|
| 54 |
-
cell_values.append(value.values)
|
| 55 |
-
else:
|
| 56 |
-
cell_values.append(value.item() if hasattr(value, 'item') else value)
|
| 57 |
-
except Exception as e:
|
| 58 |
-
st.write(f"An error occurred: {e}")
|
| 59 |
-
cell_values.append("Error")
|
| 60 |
-
answers.append(", ".join(map(str, cell_values)))
|
| 61 |
|
| 62 |
return answers
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
|
|
|
| 67 |
MAX_ROWS_PER_CHUNK = 200
|
| 68 |
|
| 69 |
def summarize_map_reduce(data, questions):
|
|
|
|
| 16 |
st.write(f"An error occurred: {e}")
|
| 17 |
return ["Error occurred while tokenizing"] * len(questions)
|
| 18 |
|
| 19 |
+
if inputs["input_ids"].shape[1] > 512:
|
| 20 |
+
st.warning("Token limit exceeded for chunk")
|
| 21 |
+
return ["Token limit exceeded for chunk"] * len(questions)
|
| 22 |
|
| 23 |
outputs = model(**inputs)
|
| 24 |
predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(
|
|
|
|
| 29 |
|
| 30 |
answers = []
|
| 31 |
for coordinates in predicted_answer_coordinates:
|
| 32 |
+
for coordinate in coordinates:
|
| 33 |
+
row, col = coordinate
|
| 34 |
try:
|
|
|
|
|
|
|
| 35 |
st.write(f"Trying to access row {row}, col {col}") # Debugging line
|
| 36 |
value = chunk.iloc[row, col]
|
| 37 |
+
st.write(f"Value accessed: {value}") # Debugging line
|
| 38 |
if isinstance(value, pd.Series):
|
| 39 |
answers.append(value.values)
|
| 40 |
else:
|
| 41 |
answers.append(value.item() if hasattr(value, 'item') else value)
|
| 42 |
except Exception as e:
|
| 43 |
+
st.write(f"An error occurred: {e}")
|
| 44 |
+
st.write(f"Type of error: {type(e)}")
|
| 45 |
+
st.write(f"Arguments of error: {e.args}")
|
| 46 |
+
answers.append(", ".join(map(str, [chunk.iloc[coordinate].values for coordinate in coordinates])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
return answers
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
+
|
| 54 |
MAX_ROWS_PER_CHUNK = 200
|
| 55 |
|
| 56 |
def summarize_map_reduce(data, questions):
|