-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RodionfromHSE/finetune
Finetune
- Loading branch information
Showing
37 changed files
with
3,838 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,4 @@ target/ | |
# Mypy cache | ||
.mypy_cache/ | ||
/data | ||
/models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defaults: | ||
- _self_ | ||
- dataset: null | ||
- model: null | ||
- params: null | ||
- setup: null | ||
|
||
|
||
root: /Users/user010/Desktop/Programming/ML/En2RuTranslator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
path: ${root}/data/processed/model_eval_results.csv | ||
|
||
cols: # cols to be used when calculating BLEU | ||
reference: target | ||
candidates: | ||
- transformer-en-ru | ||
- nnlb-1.3B-distilled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
path: ${root}/data/processed/model_eval.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
path: "waleko/unarXive-en2ru" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
path: ${root}/models/embs/cc.en.100.bin | ||
type: fasttext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
path: ${root}/models/embs/cc.ru.100.bin | ||
type: fasttext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: nnlb-1.3B-distilled | ||
model_and_tokenizer_name: facebook/nllb-200-distilled-1.3B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: opus-distilled-en-ru | ||
model_and_tokenizer_name: "under-tree/transformer-en-ru" | ||
output_dir: ${root}/models/${.name}/finetuned | ||
type: seq2seq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: opus-en-ru | ||
model_and_tokenizer_name: Helsinki-NLP/opus-mt-en-ru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
type: "random" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root: ??? | ||
|
||
nnlb_model: | ||
name: nnlb-1.3B-distilled | ||
model_and_tokenizer_name: facebook/nllb-200-distilled-1.3B | ||
|
||
mt_model: | ||
name: transformer-en-ru | ||
model_and_tokenizer_name: Helsinki-NLP/opus-mt-en-ru | ||
|
||
inference_dataset_path: ${root}/data/processed/model_eval.csv | ||
results_path: ${root}/data/processed/model_eval_results.csv | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root: ??? | ||
load_dataset_params: | ||
path: 'turkic_xwmt' | ||
name: 'ru-en' | ||
split: 'test' | ||
save_path: '${root}/data/processed/model_eval.csv' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
batch_size: 16 | ||
max_length: 512 | ||
train_args: | ||
evaluation_strategy: epoch | ||
learning_rate: 2e-5 | ||
per_device_train_batch_size: ${..batch_size} | ||
per_device_eval_batch_size: ${..batch_size} | ||
weight_decay: 0.01 | ||
save_total_limit: 3 | ||
num_train_epochs: 4 | ||
predict_with_generate: true | ||
|
||
wandb_args: | ||
report_to: wandb | ||
run_name: finetune |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- /model@model1: opus_en_ru | ||
- /model@model2: opus_distilled_en_ru | ||
- override /dataset: unarxive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- /model@pretrained: opus_en_ru | ||
- /model@finetuned: opus_distilled_en_ru | ||
- override /dataset: unarxive | ||
- override /params: finetune |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- /model@opus_model: opus_en_ru | ||
- /model@nnlb_model: nnlb_1.3B | ||
- /dataset@inference_dataset: model_eval_raw | ||
- /dataset@result_dataset: model_eval |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- /model@dest_synonym_searcher: fasttext_ru | ||
- /model@src_synonym_searcher: fasttext_en | ||
- /model@translator: opus_distilled_en_ru | ||
- /model@attention_extractor: random_attention_extractor | ||
- override /params: finetune |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from omegaconf import OmegaConf | ||
import json | ||
import typing as tp | ||
import os | ||
from hydra import initialize_config_dir, compose | ||
|
||
__ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) | ||
__CONFIG_DIR = os.path.join(__ROOT_DIR, "conf") | ||
|
||
def read_config(config_dir: str = __CONFIG_DIR, overrides: tp.Optional[tp.List[str]] = None) -> OmegaConf: | ||
""" | ||
:@param config_dir: path to config directory | ||
:@param overrides: list of overrides (e.g. ["dataset=model_eval"]) | ||
:@param set_to_none_empty_with_warn: if True, set empty values to None and print warning | ||
:@return: OmegaConf object | ||
""" | ||
config_dir = os.path.abspath(config_dir) | ||
with initialize_config_dir(config_dir=config_dir, version_base=None): | ||
cfg = compose(config_name="config", overrides=overrides) | ||
cfg = OmegaConf.create(OmegaConf.to_yaml(cfg, resolve=True)) | ||
return cfg | ||
|
||
def pprint_config(cfg: OmegaConf) -> None: | ||
"Pretty print config" | ||
print(json.dumps(OmegaConf.to_container(cfg), indent=2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
outs: | ||
- md5: 255799c6a8913d73679631d546a9dd88.dir | ||
nfiles: 13 | ||
- md5: a04b7051c1e5067e29c68137c321dae1.dir | ||
nfiles: 15 | ||
hash: md5 | ||
path: data | ||
size: 19936558 | ||
size: 21297660 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
outs: | ||
- md5: c32a6fc3220dba5ae7628692d397c852.dir | ||
size: 4892930090 | ||
nfiles: 2 | ||
hash: md5 | ||
path: models |
Oops, something went wrong.