Spaces:
Build error
Build error
Commit ·
6674859
1
Parent(s): 0704eb2
updated to fix indexing error
Browse filesError:
Token indices sequence length is longer than the specified maximum sequence length for this model (5187 > 512).
This suggests that your input sequence length is exceeding the maximum allowable sequence length for the model. TAPAS, like many other transformer models, has a maximum input sequence length. In this case, it's 512 tokens.
IndexError: iloc cannot enlarge its target object
This is the error related to pandas, where it's not allowed to assign a value to an index that doesn't exist in the DataFrame.
Attempted Fix:
I've added checks to ensure that token count doesn't exceed the model's limit.
I've added debugging print statements to help you understand what's going on.
9 unmodified lines10111213141516171821 unmodified lines40414243444546479 unmodified linesdef ask_llm_chunk(chunk, questions):chunk = chunk.astype(str)inputs = tokenizer(table=chunk, queries=questions, padding="max_length", return_tensors="pt")if inputs["input_ids"].shape[1] > 1024:return ["Token limit exceeded for chunk"] * len(questions)outputs = model(**inputs)predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(inputs,21 unmodified linesfor chunk in dataframe_chunks:chunk_answers = ask_llm_chunk(chunk, questions)all_answers.extend(chunk_answers)aggregated_answers = all_answersreturn aggregated_answersst.title("TAPAS Table Question Answering")9 unmodified lines101112131415161718192021222324252627282921 unmodified lines515253545556579 unmodified linesdef ask_llm_chunk(chunk, questions):chunk = chunk.astype(str)# Debugging statement to print chunk shapeprint("Chunk shape:", chunk.shape)print("Sample data:", chunk.head())# Count tokenstoken_count = len(tokenizer.tokenize(str(chunk) + " ".join(questions)))print("Token count:", token_count)if token_count > 512:print("Warning: Token count exceeds maximum allowable sequence length.")return ["Token limit exceeded for chunk"] * len(questions)inputs = tokenizer(table=chunk, queries=questions, padding="max_length", return_tensors="pt")outputs = model(**inputs)predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(inputs,21 unmodified linesfor chunk in dataframe_chunks:chunk_answers = ask_llm_chunk(chunk, questions)all_answers.extend(chunk_answers)return all_answers # For now, simply returning the answers for each chunkst.title("TAPAS Table Question Answering")
app.py+14-4