Spaces:
Build error
Still getting tokenization and chunking errors
Browse filesErrors:
The error Token indices sequence length is longer than the specified maximum sequence length for this model (5183 > 512) clearly indicates that the tokenized sequence length is exceeding the model's limit, which is 512 tokens for TAPAS.
The exception ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length. suggests that you should enable truncation to cut the token sequence down to a manageable size.
Fix:
Enable truncation in the tokenizer.
Possibly reduce the chunk size if the above step doesn't resolve the issue.
Notice the truncation=True argument in the tokenizer method. This will truncate the token sequence to fit the model's maximum input size. Also, I've included a try-except block to capture any exceptions that may occur during tokenization.
9 unmodified lines1011121314151617 unmodified lines3435363738399 unmodified linesdef ask_llm_chunk(chunk, questions):chunk = chunk.astype(str)inputs = tokenizer(table=chunk, queries=questions, padding="max_length", return_tensors="pt")# Check for token limitif inputs["input_ids"].shape[1] > 512:17 unmodified linesanswers.append(", ".join(cell_values))return answersMAX_ROWS_PER_CHUNK = 200def summarize_map_reduce(data, questions):9 unmodified lines101112131415161718192017 unmodified lines383940414243449 unmodified linesdef ask_llm_chunk(chunk, questions):chunk = chunk.astype(str)try:inputs = tokenizer(table=chunk, queries=questions, padding="max_length", truncation=True, return_tensors="pt")except Exception as e:st.write(f"An error occurred: {e}")return ["Error occurred while tokenizing"] * len(questions)# Check for token limitif inputs["input_ids"].shape[1] > 512:17 unmodified linesanswers.append(", ".join(cell_values))return answersMAX_ROWS_PER_CHUNK = 200def summarize_map_reduce(data, questions):