Table-based Question Answering Application
This project implements a table-based question answering application using the Tapas model and Streamlit library. Users can upload a CSV file, view the data in a table, and enter queries to get answers based on the table data.
Category:
Sub-category:
Natural Language Processing (NLP)
Subcategory
Overview:
This code implements a table-based question answering application. It allows users to upload a CSV file, view the data in the table, and enter queries to get answers based on the table data. The code utilizes the Tapas model for question answering and the Streamlit library for building the user interface.
Description:
The model used for question answering is TAPAS, which is loaded from the Hugging Face model repository using the Tapas class. The TapasTokenizer is also instantiated from the same model.
The Streamlit library is used to create a user interface for the application. The code presents a title and header for the application, prompts the user to upload a CSV file, and displays the uploaded file's data if requested.
The user can then enter queries separated by commas in a text input field. When the "Predict Answers" button is clicked, the code uses the Tapas model to predict answers for the provided queries. The table data is preprocessed using the tokenizer, and the model's outputs are obtained by passing the preprocessed inputs to the model. The predicted answer coordinates and aggregation indices are extracted from the model outputs.
The code then retrieves the answers from the table based on the predicted coordinates. If the answer corresponds to a single cell, it is directly retrieved from the table. If the answer spans multiple cells, the values from those cells are combined into a comma-separated string.
Programming Language:
Python
Libraries:
Pytorch, Streamlit, Numpy, Transformers, Tensorflow