I am working with classification. I added into the output additional param. Prediction and evaluate work well.
"out": [
"x",
"y_pred_ids",
"y_pred_labels",
"y_pred_probas"
]
Full config:
{
"dataset_reader": {
"class_name": "basic_classification_reader",
"x": "Comment",
"y": "Class",
"data_path": "{PROJECT_PATH}/data/"
},
"dataset_iterator": {
"class_name": "basic_classification_iterator",
"seed": 42
},
"chainer": {
"in": [
"x"
],
"in_y": [
"y"
],
"pipe": [
{
"class_name": "torch_transformers_preprocessor",
"vocab_file": "{TRANSFORMER}",
"do_lower_case": true,
"max_seq_length": 64,
"in": [
"x"
],
"out": [
"bert_features"
]
},
{
"id": "classes_vocab",
"class_name": "simple_vocab",
"fit_on": [
"y"
],
"save_path": "{MODEL_PATH}/classes.dict",
"load_path": "{MODEL_PATH}/classes.dict",
"in": [
"y"
],
"out": [
"y_ids"
]
},
{
"in": [
"y_ids"
],
"out": [
"y_onehot"
],
"class_name": "one_hotter",
"depth": "#classes_vocab.len",
"single_vector": true
},
{
"class_name": "torch_transformers_classifier",
"n_classes": "#classes_vocab.len",
"return_probas": true,
"pretrained_bert": "{TRANSFORMER}",
"save_path": "{MODEL_PATH}/model",
"load_path": "{MODEL_PATH}/model",
"optimizer": "AdamW",
"optimizer_parameters": {
"lr": 1e-05
},
"learning_rate_drop_patience": 5,
"learning_rate_drop_div": 2.0,
"in": [
"bert_features"
],
"in_y": [
"y_ids"
],
"out": [
"y_pred_probas"
]
},
{
"in": [
"y_pred_probas"
],
"out": [
"y_pred_ids"
],
"class_name": "proba2labels",
"max_proba": true
},
{
"in": [
"y_pred_ids"
],
"out": [
"y_pred_labels"
],
"ref": "classes_vocab"
}
],
"out": [
"x",
"y_pred_ids",
"y_pred_labels",
"y_pred_probas"
]
},
"train": {
"device": "gpu",
"epochs": 100,
"batch_size": 64,
"metrics": [
{
"name": "roc_auc",
"inputs": [
"y_onehot",
"y_pred_probas"
]
},
"accuracy",
"f1_macro"
],
"validation_patience": 5,
"val_every_n_epochs": 1,
"log_every_n_epochs": 1,
"show_examples": false,
"evaluation_targets": [
"train",
"valid",
"test"
],
"class_name": "torch_trainer"
},
"metadata": {
"NAME": "Russian Language Toxic Comments",
"variables": {
"ROOT_PATH": "./data",
"PROJECT_PATH": "{ROOT_PATH}/rlt",
"MODELS_PATH": "{PROJECT_PATH}/models",
"MODEL_PATH": "{MODELS_PATH}/classifiers",
"TRANSFORMER": "bert-base-uncased",
"LOGS_PATH": "{PROJECT_PATH}/logs"
}
}
}
But if I try to train or evaluate I get the error:
2024-08-01 22:32:47.833 WARNING in 'deeppavlov.core.trainers.fit_trainer'['fit_trainer'] at line 66: TorchTrainer got additional init parameters ['device'] that will be ignored:
Some weights of BertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: ['classifier.bias', 'classifier.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
2024-08-01 22:32:49.892 WARNING in 'deeppavlov.core.models.torch_model'['torch_model'] at line 96: Unable to place component TorchTransformersClassifierModel on GPU, since no CUDA GPUs are available. Using CPU.
76it [01:16, 1.01s/it]
Traceback (most recent call last):
File "cli.py", line 47, in <module>
switch(args.action)
File "cli.py", line 44, in switch
cases.get(case, lambda: print("Incorrect action."))()
File "cli.py", line 33, in evaluate
EvaluateHandler().evaluate(args.config, args.lang)
File "applicaion/handler/evaluate_handler.py", line 20, in evaluate
evaluate_model(config)
File "venv/lib/python3.9/site-packages/deeppavlov/__init__.py", line 37, in evaluate_model
return train_evaluate_model_from_config(config, to_train=False, install=install,
File "venv/lib/python3.9/site-packages/deeppavlov/core/commands/train.py", line 123, in train_evaluate_model_from_config
res = trainer.evaluate(iterator, evaluation_targets)
File "venv/lib/python3.9/site-packages/deeppavlov/core/trainers/fit_trainer.py", line 230, in evaluate
report = self.test(data_gen)
File "venv/lib/python3.9/site-packages/deeppavlov/core/trainers/torch_trainer.py", line 34, in test
report = super(TorchTrainer, self).test(data=data, metrics=metrics, start_time=start_time,
File "venv/lib/python3.9/site-packages/deeppavlov/core/trainers/fit_trainer.py", line 187, in test
value = metric.fn(*[outputs[i] for i in metric.inputs])
TypeError: accuracy() takes 2 positional arguments but 5 were given
How does it need to be configured correctly with additional output data?