ASR project barebones
В do_everything.ipynb можно посмотреть на мои логи обучения и валидации.
В текст энкодере реализованы custom_ctc_beam_search
(написанный руками бим сёрч с семинара) и ctc_beam_search
(при помощи pyctcdecode).
Как запустить
- Запускаем докер.
docker build -t asr . docker run -it asr
- Скачиваем языковую модель.
pip install https://github.com/kpu/kenlm/archive/master.zip wget https://www.openslr.org/resources/11/3-gram.arpa.gz --no-check-certificate gzip -d 3-gram.arpa.gz
- Скачиваем чекпоинт модели.
wget https://downloader.disk.yandex.ru/disk/7a2747e39158f3e70bbb493407f3b1e0bc0f69e9d780cf19c4c7ec05f01db602/6376b7ff/8QS15owusqz-m1yNRn8_WS_okE79_hbaLxZm6TiDTjv1bV_hbzZmTIPnkE1aXuSNyg8NnWG9-6x-oxTaSLdxDA%3D%3D?uid=0&filename=model_best.pth&disposition=attachment&hash=ilgsfWA8OM84RYEizPtdxA%2BC3St4e5HXCV1FKmy6t4K7BBBjODfJC7b23vIzWYt/q/J6bpmRyOJonT3VoXnDag%3D%3D%3A&limit=0&content_type=application%2Fzip&owner_uid=1184656726&fsize=230184375&hid=579b5415d0a32fa41dd0cb2675e69544&media_type=compressed&tknv=v2
- Запускаем инференс.
python3 test.py \ --config hw_asr/configs/balrog_evaluation_test_other.json \ --resume model_best.pth \ --batch-size 64 \ --jobs 4 \ --beam-size 100 \ --output output_other.json python3 test.py \ --config hw_asr/configs/balrog_evaluation_test_clean.json \ --resume model_best.pth \ --batch-size 64 \ --jobs 4 \ --beam-size 100 \ --output output_clean.json
Обучение можно запустить командой
python3 train.py --config hw_asr/configs/balrog.json
Чтобы прогнать модель на тестах, запустите
python3 test.py \
-c hw_asr/configs/balrog_evaluation_test_other.json \
-r model_best.pth \
-t test_data \
-o test_result.json \
-b 5
Recommended implementation order
You might be a little intimidated by the number of folders and classes. Try to follow this steps to gradually undestand the workflow.
- Test
hw_asr/tests/test_dataset.py
andhw_asr/tests/test_config.py
and make sure everythin works for you - Implement missing functions to fix tests in
hw_asr\tests\test_text_encoder.py
- Implement missing functions to fix tests in
hw_asr\tests\test_dataloader.py
- Implement functions in
hw_asr\metric\utils.py
- Implement missing function to run
train.py
with a baseline model - Write your own model and try to overfit it on a single batch
- Implement ctc beam search and add metrics to calculate WER and CER over hypothesis obtained from beam search.
Pain and sufferingImplement your own models and train them. You've mastered this template when you can tune your experimental setup just by tuningconfigs.json
file and runningtrain.py
- Don't forget to write a report about your work
- Get hired by Google the next day
Before submitting
- Make sure your projects run on a new machine after complemeting the installation guide or by running it in docker container.
- Search project for
# TODO: your code here
and implement missing functionality - Make sure all tests work without errors
python -m unittest discover hw_asr/tests
- Make sure
test.py
works fine and works as expected. You should create filesdefault_test_config.json
and your installation guide should download your model checpoint and configs indefault_test_model/checkpoint.pth
anddefault_test_model/config.json
.python test.py \ -c default_test_config.json \ -r default_test_model/checkpoint.pth \ -t test_data \ -o test_result.json
- Use
train.py
for training
Credits
This repository is based on a heavily modified fork of pytorch-template repository.
Docker
You can use this project with docker. Quick start:
docker build -t my_hw_asr_image .
docker run \
--gpus '"device=0"' \
-it --rm \
-v /path/to/local/storage/dir:/repos/asr_project_template/data/datasets \
-e WANDB_API_KEY=<your_wandb_api_key> \
my_hw_asr_image python -m unittest
Notes:
-v /out/of/container/path:/inside/container/path
-- bind mount a path, so you wouldn't have to download datasets at the start of every docker run.-e WANDB_API_KEY=<your_wandb_api_key>
-- set envvar for wandb (if you want to use it). You can find your API key here: https://wandb.ai/authorize
TODO
These barebones can use more tests. We highly encourage students to create pull requests to add more tests / new functionality. Current demands:
- Tests for beam search
- README section to describe folders
- Notebook to show how to work with
ConfigParser
andconfig_parser.init_obj(...)