-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
52 lines (41 loc) · 2.32 KB
/
run.py
File metadata and controls
52 lines (41 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
from src.evaluate.run_evaluation import evaluate
from src.evaluate.mapping_best_classifiers import consolidate_models_info
from src.fine_tuning.run_fine_tuning import run_fine_tuning
from src.preprocessing.run_preprocessing import datasets_preprocessing
from src.utils.utils import check_best_models_info_exists, load_config
from src.zero_shot.run_zero_shot import masked_zero_shot
def main():
config = load_config()
parser = argparse.ArgumentParser(description='Fake news classifiers.')
parser.add_argument('--task', choices=[
"preprocessing", "masked_zero_shot", "fine_tuning", "evaluation"],
required=True, help='Tipo de operação.')
parser.add_argument('--model',
choices=["bertimbau", "mt5", "command", "sabia-3", "cohere-embeddings"],
help='Modelo a ser utilizado.')
parser.add_argument('--data', choices=config["data_lower_short_names"], help='Nome do dataset selecionado.')
parser.add_argument('--mode', choices=["zero_shot", "in_data", "cross_data"], help='Tipo de experimento.')
run_args = parser.parse_args()
if run_args.preprocessing:
datasets_preprocessing()
# Execução de experimentos zero-shot com os modelos 'bertimbau' e 'mT5'.
# Nota: Experimentos zero-shot com os modelos 'sabia-3' e 'command' estão
# disponíveis em src/zero_shot.
if run_args.masked_zero_shot:
masked_zero_shot(config, run_args.model)
# Tarefa de aperfeiçoamento dos modelos pré-treinados 'bertimbau' e 'mT5'
# Nota: O fine-tuning do modelo 'cohere-embeddings' está disponível em src/zero_shot.
if run_args.fine_tuning:
run_fine_tuning(config, run_args.model, run_args.data)
# Consolidação de resultados de experimentos e geração de métricas de avaliação
if run_args.evaluation:
if run_args.model in ["bertimbau", "mt5"] and run_args.mode != "zero_shot":
if check_best_models_info_exists(config):
print("Encontrado mapeamento de melhores modelos treinados com 5 folds.")
else:
print("Buscando os melhores modelos da validação cruzada...")
consolidate_models_info()
evaluate(config, run_args.model, run_args.mode)
if __name__ == "__main__":
main()