This repository contains code for an exploration of using Mistral open-source models inferenced locally using vLLM for QA on Spreadsheets.
It consists of three parts:
app.py- Script that runs the app.model_interaction.py- Logic for OpenAI wrapper, RefineChain processing using Langchain and local tokenization.html_imaging_functions.py- All the logic for processing spreadsheets in HTML and extracting data from them.
If you want to have a go at running the app, please follow these steps:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.shchmod +x ~/miniconda.sh
~/miniconda.sh
mkdir -p ~/miniconda3
bash ~/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda.sh~/miniconda3/bin/conda init
source ~/.bashrcconda create --name spreadsheets-qa python=3.11
conda activate spreadsheets-qa
pip install -r requirements.txttmux new -s "inference-server"conda activate spreadsheets-qahuggingface-cli login --token $HF_TOKENvllm serve mistralai/Mistral-Nemo-Instruct-2407 \
--tokenizer_mode mistral \
--config_format mistral \
--load_format mistralCtrl + B + D
python app.py- Titanic https://www.kaggle.com/c/titanic/data (train.csv)
- Wine Quality https://archive.ics.uci.edu/dataset/186/wine+quality?ref=hackernoon.com (winequality-red.csv)
- Amazon Bestsellers data https://www.kaggle.com/datasets/sootersaalu/amazon-top-50-bestselling-books-2009-2019/ (bestsellers with categories.csv)
The spreadsheet parser only works with .html spreadsheets downloaded from Google Sheets. To prepare your data in that way, please import your custom spreadsheet to Google Sheets. Then go to: File -> Download -> Web page (.html)
The size of spreadsheet is limited (approx 450-500 rows max. because of the context window limitations) and the model tries to answer questions based on the whole spreadsheet. Faster and less factually precise.
No limitation on the size of the spreadsheet. Uses refine-chain approach to feed itself a spreadsheet splitted into chunks of N rows (feel free to experiment with different chunk sizes) and with each new discovered chunk decides whether to alter the answer or stick to the current one.