Welcome to the QGAR Project - a note-processing and flashcard generation application.
If you want to run the application, please read the Prerequisites section.
To get access to our models and datasets you must be a part of our organization, The Coorporation, on Huggingface Hub.
Moreover, when training the QG model, the training process will be uploaded to wandb.
In order for the QGAR to do the above, you must be authorized via access tokens.
Therefore you must create a .local directory in the root directory and create the following files containing your tokens:
hg_token.txt- contains your access token to Huggingfacewandb_token.txt- contains your access token to Weight and Biases
QGAR uses 3rd party libraries which are specified in requirements.txt.
To install them either use the command make install or:
pip install -r requirements.txtNB: Make sure you install the libraries in a Virtual Environment!
You run QGAR by running main.py via:
python main.py <args>The application can take arguments to specify what to do:
main.py -t- starts a training session for theQGmodel.main.py -qg <context>- runs theQGmodel on the input text and generates questions from the given context.main.py -d- downloads and preprocesses our modifiedSQuADdatasetmain.py -n <path>- the path to a note filemain.py -s <filename>.json- use the specified settings file. Defaults tosettings.jsonmain.py -h- shows instructions on how to run the programmain.py -o- used in combination with-n; specifies whether to output questions and answers as json (debug) or csv. Defaults to csv.
The following sections describe the setup process to use Hugging Face and PyTorch locally on your device running in a Virtual Environment.
The steps have been tested to run without errors on Linux 22.04 (LTS).
Table of Contents:
- 3.1 Setup Miniconda
- 3.2 Install PyTorch with NVIDIA GPU
- 3.3 Install HuggingFace Transformers
- 3.4 Configure VS Code to use Virtual Environment
- 3.5 Setup on MAC M1
-
Install Miniconda
Miniconda will be in charge of managing our virtual Python environment and will download and install needed packages.
To install it, run the commands:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh
-
Create Virtual Environment
To isolate our development environment from the main Python installation on your system, we will create a virtual environment.
In this, we will install all the needed Python packages, which will only be available through the environment.
Run the following command, where
<name>is the name of your local environment:conda create --name <name> python=3.10.9
-
Activate the Virtual Environment
Now we must activate our created environment, so all install commands targets the virtual environment and not your main installation.
Run the following command, where
<name>is the name of the virtual environment you created in step 2.conda activate <name>
In the terminal you should now see the name of your local environment. This way you always know if it is activated.
-
Activate your Virtual Environment
First, make sure you have activated your virtual environment.
You can activate it with the following command, where
<name>is the name of the environment:conda activate <name>
-
Install PyTorch
Run the following command:
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
-
Verify the installation
Run the following command:
python3 -c "import torch; print(torch.cuda.is_available())"It should return
Truein the console!
-
Activate your Virtual Environment
First, make sure you have activated your virtual environment.
You can activate it with the following command, where
<name>is the name of the environment:conda activate <name>
-
Install Transformers
Run the following command:
conda install -c huggingface transformers
-
Verify installation
Run the following command:
python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"It should output something similar to the following:
[{'label': 'POSITIVE', 'score': 0.9998704791069031}]
-
Open example.py to activate the VS Code Python Extension.
-
Press the
F1key on your keyboard -
Write the following:
> Python: Select Interpreter
-
Select the interpreter with the name of your local environment (listed as
conda). -
The libraries you have installed are now imported correctly.
Follow instructions here link
to run, remember to use
python3 [file].pyAnd not just "python"
To install packages, use
python3 -m pip install [package]