ankitapasad / s3adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

s3adapter

hylee

Setting up

  1. directly clone this repo
  2. cd ./s3adapter/s3prl
pip install -e .
  1. pip install necessary packages
pip install huggingface-hub
pip install editdistance
pip install loralib
pip install tensorboardX
  1. You should be able to run s3prl with adapter version!

Starting adapter-based tuning

After modifying the three files, you can start adapter-based tuning with the following command line:

run_downstream.py --adapter houlsby -u hubert -d asr -m train -f -n hubert_asr_houlsby 

make sure the last sys.argv contains the name of adapter, and -f is set to True

The supported adapters includes

for example:

run_downstream.py --adapter houlsby -u hubert -d asr -m train -f -n hubert_asr_houlsby_cnn

means using houlsby and cnn adapters at the same time.

Simply tune the whole upstream model using the last hidden representation:

run_downstream.py  -u hubert -d asr -m train -f -l -1 -n hubert_asr_finetune

modified files

  1. s3prl/s3prl/run_downstream.py (add adapter option parser)
  2. s3prl/s3prl/upstream/wav2vec2/wav2vec2_model.py (add adapter to upstream modules)
  3. s3prl/s3prl/upstream/wav2vec2/expert.py (set load_state_dict strict=False to enable the model to load the pretrained checkpoint)
  4. s3prl/s3prl/downstream/runner.py (set require_grad = True for the adapter parameters, and freeze the remaining parameters )

About


Languages

Language:Python 90.6%Language:C 4.0%Language:Cython 2.9%Language:Shell 2.1%Language:Cuda 0.2%Language:C++ 0.2%Language:Lua 0.0%Language:Dockerfile 0.0%Language:Batchfile 0.0%Language:Makefile 0.0%Language:JavaScript 0.0%Language:CSS 0.0%