-
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.
- Loading branch information
1 parent
63153fa
commit 954731b
Showing
57 changed files
with
1,440 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,122 @@ | ||
default_language_version: | ||
python: python3 | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
# list of supported hooks: https://pre-commit.com/hooks.html | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-docstring-first | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- id: check-executables-have-shebangs | ||
- id: check-toml | ||
- id: check-case-conflict | ||
- id: check-added-large-files | ||
|
||
# python code formatting | ||
- repo: https://github.com/psf/black | ||
rev: 22.6.0 | ||
hooks: | ||
- id: black | ||
args: [--line-length, "99"] | ||
|
||
# python import sorting | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files"] | ||
|
||
# python upgrading syntax to newer version | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.32.1 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py38-plus] | ||
|
||
# python docstring formatting | ||
- repo: https://github.com/myint/docformatter | ||
rev: v1.4 | ||
hooks: | ||
- id: docformatter | ||
args: [--in-place, --wrap-summaries=99, --wrap-descriptions=99] | ||
|
||
# python check (PEP8), programming errors and code complexity | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
[ | ||
"--extend-ignore", | ||
"E203,E402,E501,F401,F841", | ||
"--exclude", | ||
"logs/*,data/*", | ||
] | ||
|
||
# python security linter | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: "1.7.1" | ||
hooks: | ||
- id: bandit | ||
args: ["-s", "B101"] | ||
|
||
# yaml formatting | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v2.7.1 | ||
hooks: | ||
- id: prettier | ||
types: [yaml] | ||
|
||
# shell scripts linter | ||
- repo: https://github.com/shellcheck-py/shellcheck-py | ||
rev: v0.8.0.4 | ||
hooks: | ||
- id: shellcheck | ||
|
||
# md formatting | ||
- repo: https://github.com/executablebooks/mdformat | ||
rev: 0.7.14 | ||
hooks: | ||
- id: mdformat | ||
args: ["--number"] | ||
additional_dependencies: | ||
- mdformat-gfm | ||
- mdformat-tables | ||
- mdformat_frontmatter | ||
# - mdformat-toc | ||
# - mdformat-black | ||
|
||
# word spelling linter | ||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.1.0 | ||
hooks: | ||
- id: codespell | ||
args: | ||
- --skip=logs/**,data/**,*.ipynb | ||
# - --ignore-words-list=abc,def | ||
|
||
# jupyter notebook cell output clearing | ||
- repo: https://github.com/kynan/nbstripout | ||
rev: 0.5.0 | ||
hooks: | ||
- id: nbstripout | ||
|
||
# jupyter notebook linting | ||
- repo: https://github.com/nbQA-dev/nbQA | ||
rev: 1.4.0 | ||
hooks: | ||
- id: nbqa-black | ||
args: ["--line-length=99"] | ||
- id: nbqa-isort | ||
args: ["--profile=black"] | ||
- id: nbqa-flake8 | ||
args: | ||
[ | ||
"--extend-ignore=E203,E402,E501,F401,F841", | ||
"--exclude=logs/*,data/*", | ||
] |
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,27 @@ | ||
|
||
help: ## Show help | ||
@grep -E '^[.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
clean: ## Clean autogenerated files | ||
rm -rf dist | ||
find . -type f -name "*.DS_Store" -ls -delete | ||
find . | grep -E "(__pycache__|\.pyc|\.pyo)" | xargs rm -rf | ||
find . | grep -E ".pytest_cache" | xargs rm -rf | ||
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf | ||
rm -f .coverage | ||
|
||
clean-logs: ## Clean logs | ||
rm -r logs/** | ||
|
||
style: ## Run pre-commit hooks | ||
pre-commit run -a | ||
|
||
sync: ## Merge changes from develop branch to your current branch | ||
git fetch --all | ||
git merge develop | ||
|
||
test: ## Run not slow tests | ||
pytest -k "not slow" | ||
|
||
test-full: ## Run all tests | ||
pytest |
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,2 +1,58 @@ | ||
<div align="center"> | ||
|
||
# reliability-score | ||
NLP tool for wide-range model evaluations | ||
|
||
<a href="https://pytorch.org/get-started/locally/"><img alt="PyTorch" src="https://img.shields.io/badge/PyTorch-ee4c2c?logo=pytorch&logoColor=white"></a> | ||
<a href="https://pytorchlightning.ai/"><img alt="Lightning" src="https://img.shields.io/badge/-Lightning-792ee5?logo=pytorchlightning&logoColor=white"></a> | ||
<a href="https://hydra.cc/"><img alt="Config: Hydra" src="https://img.shields.io/badge/Config-Hydra-89b8cd"></a> | ||
<a href="https://github.com/ashleve/lightning-hydra-template"><img alt="Template" src="https://img.shields.io/badge/-Lightning--Hydra--Template-017F2F?style=flat&logo=github&labelColor=gray"></a><br> | ||
[](https://www.nature.com/articles/nature14539) | ||
[](https://papers.nips.cc/paper/2020) | ||
|
||
</div> | ||
|
||
## Description | ||
|
||
What it does | ||
|
||
## How to run | ||
|
||
Install dependencies | ||
|
||
```bash | ||
# clone project | ||
git clone https://github.com/YourGithubName/your-repo-name | ||
cd your-repo-name | ||
|
||
# [OPTIONAL] create conda environment | ||
conda create -n myenv python=3.8 | ||
conda activate myenv | ||
|
||
# install pytorch according to instructions | ||
# https://pytorch.org/get-started/ | ||
|
||
# install requirements | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Train model with default configuration | ||
|
||
```bash | ||
# train on CPU | ||
python src/test.py trainer=cpu | ||
|
||
# train on GPU | ||
python src/test.py trainer=gpu | ||
``` | ||
|
||
Train model with chosen experiment configuration from [configs/experiment/](configs/experiment/) | ||
|
||
```bash | ||
python src/test.py experiment=experiment_name.yaml | ||
``` | ||
|
||
You can override any parameter from command line like this | ||
|
||
```bash | ||
python src/test.py datamodule.batch_size=64 | ||
``` |
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,3 @@ | ||
accuracy_callback: | ||
_target_: src.callbacks.evals.discriminative.AccuracyMetric | ||
monitor: "all" |
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 @@ | ||
defaults: | ||
- rich_progress_bar.yaml | ||
- _self_ | ||
|
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 @@ | ||
defaults: | ||
- default.yaml | ||
- acc.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,6 @@ | ||
# https://pytorch-lightning.readthedocs.io/en/latest/api/pytorch_lightning.callbacks.RichProgressBar.html | ||
|
||
# Create a progress bar with rich text formatting. | ||
# Look at the above link for more detailed information. | ||
rich_progress_bar: | ||
_target_: pytorch_lightning.callbacks.RichProgressBar |
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,5 @@ | ||
model_name: "ishan/bert-base-uncased-mnli" | ||
tokenizer: | ||
model_name: "ishan/bert-base-uncased-mnli" | ||
args: | ||
truncation: true |
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 @@ | ||
_target_: src.datamodules.mnli_datamodule.MNLIDataModule | ||
data_dir: ${paths.data_dir} | ||
batch_size: 1 | ||
num_workers: 0 | ||
pin_memory: False | ||
tokenizer_data: ${custom_model.tokenizer} |
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,19 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- _self_ | ||
- callbacks: default.yaml | ||
- datamodule: mnli.yaml # choose datamodule with `test_dataloader()` for evaluation | ||
- model: inference.yaml | ||
- logger: null | ||
- trainer: default.yaml | ||
- paths: default.yaml | ||
- extras: default.yaml | ||
- hydra: default.yaml | ||
- custom_model: bert_base_uncased.yaml | ||
|
||
- experiment: null | ||
|
||
task_name: "eval" | ||
|
||
tags: ["dev"] |
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,18 @@ | ||
# @package _global_ | ||
|
||
# to execute this experiment run: | ||
# python train.py experiment=example | ||
|
||
defaults: | ||
- override /datamodule: mnli.yaml | ||
- override /model: inference.yaml | ||
- override /callbacks: mnli.yaml | ||
- override /trainer: default.yaml | ||
- override /custom_model: bert_base_uncased.yaml | ||
|
||
# all parameters below will be merged with parameters from default configurations set above | ||
# this allows you to overwrite only specified parameters | ||
|
||
tags: ["mnli", "test"] | ||
|
||
seed: 42 |
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 @@ | ||
# disable python warnings if they annoy you | ||
ignore_warnings: False | ||
|
||
# ask user for tags if none are provided in the config | ||
enforce_tags: True | ||
|
||
# pretty print config tree at the start of the run using Rich library | ||
print_config: True |
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 @@ | ||
# https://hydra.cc/docs/configure_hydra/intro/ | ||
|
||
# enable color logging | ||
defaults: | ||
- override hydra_logging: colorlog | ||
- override job_logging: colorlog | ||
|
||
# output directory, generated dynamically on each run | ||
run: | ||
dir: ${paths.log_dir}/${task_name}/runs/${now:%Y-%m-%d}_${now:%H-%M-%S} | ||
sweep: | ||
dir: ${paths.log_dir}/${task_name}/multiruns/${now:%Y-%m-%d}_${now:%H-%M-%S} | ||
subdir: ${hydra.job.num} |
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,12 @@ | ||
# https://www.comet.ml | ||
|
||
comet: | ||
_target_: pytorch_lightning.loggers.comet.CometLogger | ||
api_key: ${oc.env:COMET_API_TOKEN} # api key is loaded from environment variable | ||
save_dir: "${paths.output_dir}" | ||
project_name: "lightning-hydra-template" | ||
rest_api_key: null | ||
# experiment_name: "" | ||
experiment_key: null # set to resume experiment | ||
offline: False | ||
prefix: "" |
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 @@ | ||
# csv logger built in lightning | ||
|
||
csv: | ||
_target_: pytorch_lightning.loggers.csv_logs.CSVLogger | ||
save_dir: "${paths.output_dir}" | ||
name: "csv/" | ||
prefix: "" |
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 @@ | ||
# train with many loggers at once | ||
|
||
defaults: | ||
# - comet.yaml | ||
- csv.yaml | ||
# - mlflow.yaml | ||
# - neptune.yaml | ||
- tensorboard.yaml | ||
- wandb.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,12 @@ | ||
# https://mlflow.org | ||
|
||
mlflow: | ||
_target_: pytorch_lightning.loggers.mlflow.MLFlowLogger | ||
# experiment_name: "" | ||
# run_name: "" | ||
tracking_uri: ${paths.log_dir}/mlflow/mlruns # run `mlflow ui` command inside the `logs/mlflow/` dir to open the UI | ||
tags: null | ||
# save_dir: "./mlruns" | ||
prefix: "" | ||
artifact_location: null | ||
# run_id: "" |
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 @@ | ||
# https://neptune.ai | ||
|
||
neptune: | ||
_target_: pytorch_lightning.loggers.neptune.NeptuneLogger | ||
api_key: ${oc.env:NEPTUNE_API_TOKEN} # api key is loaded from environment variable | ||
project: username/lightning-hydra-template | ||
# name: "" | ||
log_model_checkpoints: True | ||
prefix: "" |
Oops, something went wrong.