Code Monkey home page Code Monkey logo

dennismstfc / comparison-finetuning-against-adapter-tuning Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 883 KB

This repository contains code for implementing the LexGLUE benchmark using two different versions of the BERT architecture. The original BERT model is compared to a modified version that includes bottleneck adapter modules.

Python 100.00%
adapter bottleneck-adapter adapter-tuning bert-adapter-tuning lexglue finetuning-vs-adapter-tuning

comparison-finetuning-against-adapter-tuning's Introduction

Experimental setup to examine the impact of adapter tuning of the BERT architecture with LexGLUE

In my bachelor thesis I investigated the effects of adding adapter modules to the BERT architecture. As part of this work, I conducted an empirical study comparing different training methods and analyzing the resulting differences. This repository contains the source code that implements the training of the BERT architecture using finetuning and adapter tuning. Adapter modules with a bottleneck architecture were used for adapter tuning.

Methodology behind this experimental setup

Due to the different loss values produced by the two training methods, in addition to using early-stopping to determine the model, a user-defined callback was developed to allow for timed training. Early-stopping determines the optimal model state by comparing training and evaluation loss. However, this creates challenges because different loss magnitudes are generated depending on the model variant resulting from the selected training method. This can lead to ambiguities in model comparison. Therefore, time-dependent training was introduced, where models are trained with both training methods over a period of 24 hours, for example, and then compared. This minimizes the variability in the comparisons. Nevertheless, the models determined by early-stopping are also stored, since these are of great importance in practical applications and a comparison is therefore essential.

Installation & Usage

Linux/macOS

  1. Open a terminal and navigate to the directory where you want to create your Python environment.
  2. Use the command python3 -m venv .env to create a virtual Python environment named ".env".
  3. Activate the virtual Python environment with the command source .env/bin/activate. You should now see an arrow (e.g. "(.env)") in front of the prompt in your terminal, indicating that the virtual environment is activated.
  4. Use the command pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 to install pytorch. Make sure that you select the cuda version. Look here to see the documentation
  5. Use the command pip install -r requirements.txt to install the remaining dependencies.
  6. Use the command cd src to enter the source folder.
  7. Use the command python -m run_experiment to run the script.

Windows

  1. Open a command prompt window and navigate to the directory where you want to create your Python environment.
  2. Use the command python -m venv .env to create a virtual Python environment named ".env".
  3. Activate the virtual Python environment with the command .env\Scripts\activate.bat. You should now see an arrow (e.g. "(.env)") in front of the prompt in your command prompt window, indicating that the virtual environment is activated.
  4. Use the command pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 to install pytorch. Make sure that you select the cuda version. Look here to see the documentation
  5. Use the command pip install -r requirements.txt to install the remaining dependencies.
  6. Use the command cd src to enter the source folder.
  7. Use the command python -m run_experiment to run the script.

Credits

Please check out the LexGLUE-Repository, that provided scripts of the data preprocessing.

Contact

Dennis Mustafic - [email protected]

comparison-finetuning-against-adapter-tuning's People

Contributors

dennismstfc avatar

Stargazers

 Manibharathi Murugesan avatar  avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.