This repository is exclusively for the Large Language Models course from RUG (WBAI068-05, 2024-2025), which will be a informal-to-formal style transfer task
Create a python package manager (python environment) by typing
python -m venv <directory>
in your terminal, where directory is the name of the folder you want to give to your package manager. A popular option is to call it "venv".
To activate, type
source <directory>/bin/activate
if in linux or macOS or
# In cmd.exe
venv\Scripts\activate.bat
# In PowerShell
venv\Scripts\Activate.ps1if in windows.
To install all the requirements type
pip install -r requirements.txt.
However, for the usage of LoRA you will need to install the package from the source. To do so, type
!pip install -q git+https://github.com/huggingface/peftTo run the tokenisation
!python src/data_processing/loading_tokenization.pyThis will output three files in the data/processed folder:
test.pkl, train.pkl, and tune.pkl.
Besides, we will also save the tokeniser in models/tokeniser/tokeniser.pkl.
To run the non-parameter efficient finetuning
!python src/models/finetuning.pyThis will create a folder in src/models:
fulldataset_FT_model, containing the files needed to load in the model and tokeniser.
To run the parameter efficient finetuning, run all cells in this notebook
!python src/models/LoRA_peft_finetuning.ipynbThis will create three folders in src/models:
lora_trained, base_model and trained_tokenizer containing the files needed to load in the base model, the finetuned model and tokeniser.
To run the streamlit demo
streamlit run streamlit_demo.pyThis will open a local server containing the streamlit demo. For more info visit the streamlit forums on https://docs.streamlit.io/
To tun the Formality Classifier
!python src/utils/Formality_Classification.pyThis will import the USE embeddings and then run a cross validation with grid search for the Formality Classifier, while saving the hyper-parameters of the best model
To tun the evaluation
!python src/tests/eval_model.py