Conversation
Qiaochu-Song
commented
Mar 17, 2022
- Add an estimator for TextPredictor.
- Add a test for TextPredictor estimator.
liususan091219
left a comment
There was a problem hiding this comment.
Why is the training data passed through kwargs? It’s supposed to be passed from X_train
liususan091219
left a comment
There was a problem hiding this comment.
Rename your estimator to MultiModalEstimator
flaml/ml.py
Outdated
| ARIMA, | ||
| SARIMAX, | ||
| TransformersEstimator, | ||
| AGTextPredictorEstimator, |
There was a problem hiding this comment.
| AGTextPredictorEstimator, | |
| MultiModalEstimator, | |
There was a problem hiding this comment.
Please update all occurrences
There was a problem hiding this comment.
Please update the commit.
flaml/model.py
Outdated
| from autogluon.text import TextPredictor | ||
|
|
||
| super().__init__(task, **params) | ||
| self.estimator_class = TextPredictor |
There was a problem hiding this comment.
I can remove this and initialize the model with TextPredictor instead. Is that better?
flaml/model.py
Outdated
| } | ||
| return search_space_dict | ||
|
|
||
| def _init_fix_args(self, automl_fit_kwargs: dict=None): |
There was a problem hiding this comment.
Why do we need this function? Can we simply remove it?
There was a problem hiding this comment.
If we have AGArgs dataclass in utils, and just use the default settings, we can remove this function, and just have self.ag_args=AGArgs() in MultimodalEstimator.fit(). Does it make sense?
There was a problem hiding this comment.
Yes, you can implement this, and define a similar init_hf_args if you need to check user input validity.
test/nlp/test_agtextpredictor.py
Outdated
| score = automl.model.estimator.evaluate(test_dataset) | ||
| print(f"Inference on test set complete, {metric}: {score}") | ||
| del automl | ||
| gc.collect() No newline at end of file |
There was a problem hiding this comment.
add a breakline to the end
test/nlp/test_agtextpredictor.py
Outdated
| "gpu_per_trial": 0, | ||
| "max_iter": 2, | ||
| "time_budget": 50, | ||
| "task": "mm_multi", |
There was a problem hiding this comment.
rename mm_multi -> multimodal-classification
flaml/model.py
Outdated
| # train_data = self._kwargs["train_data"] | ||
| import pandas as pd | ||
| train_data = pd.concat([X_train, y_train], axis=1) | ||
| tuning_data = pd.concat([X_train, y_train], axis=1) |
There was a problem hiding this comment.
You mean X_val, y_val?
There was a problem hiding this comment.
I will remove this line since the tuning data is not necessary anymore.
flaml/model.py
Outdated
|
|
||
| self.fix_args = fix_args | ||
|
|
||
| def _init_hp_config(self, text_backbone: str, multimodal_fusion_strategy: str): |
There was a problem hiding this comment.
Please define cfg by defining a function inside of flaml/nlp/utils.py:class AGArgs, the remove this function.
There was a problem hiding this comment.
This _init_hp_config is to use the AGArgs and the self.params to get the hyperparametersdiction for the TextPredictor. If removed, still need to assemble this diction inside the MultimodalEstimator.fit(). Do you think it is better without this function and have this part inside the .fit()?
There was a problem hiding this comment.
Move this function to a function inside of AGArgs because AGArgs is for managing the config for AG.
flaml/data.py
Outdated
| ) | ||
| SEQREGRESSION = "seq-regression" | ||
| REGRESSION = ("regression", SEQREGRESSION) | ||
| REGRESSION = ("regression", "mm_regression", SEQREGRESSION) |
There was a problem hiding this comment.
Rename "mm_regression" -> "multimodal-regression", define a static variable for it
flaml/data.py
Outdated
| SEQCLASSIFICATION, | ||
| MULTICHOICECLASSIFICATION, | ||
| TOKENCLASSIFICATION, | ||
| "mm_multi", |
There was a problem hiding this comment.
can you automatically detect "mm_multi" and "mm_binary" so we don't need these two values anymore?
flaml/model.py
Outdated
|
|
||
| # train_data = self._kwargs["train_data"] | ||
| import pandas as pd | ||
| train_data = pd.concat([X_train, y_train], axis=1) |
There was a problem hiding this comment.
please use estimator._join method. See TransformersEstimator._join
flaml/ml.py
Outdated
| ARIMA, | ||
| SARIMAX, | ||
| TransformersEstimator, | ||
| AGTextPredictorEstimator, |
There was a problem hiding this comment.
Please update the commit.
flaml/model.py
Outdated
| from autogluon.text import TextPredictor | ||
|
|
||
| super().__init__(task, **params) | ||
| self.estimator_class = TextPredictor |
flaml/model.py
Outdated
| } | ||
| return search_space_dict | ||
|
|
||
| def _init_fix_args(self, automl_fit_kwargs: dict=None): |
There was a problem hiding this comment.
Yes, you can implement this, and define a similar init_hf_args if you need to check user input validity.
flaml/model.py
Outdated
|
|
||
| self.fix_args = fix_args | ||
|
|
||
| def _init_hp_config(self, text_backbone: str, multimodal_fusion_strategy: str): |
There was a problem hiding this comment.
Move this function to a function inside of AGArgs because AGArgs is for managing the config for AG.
flaml/model.py
Outdated
| save_dir = self.fix_args["output_dir"] | ||
| label_column = self.fix_args["label_column"] | ||
| dataset_name = self.fix_args["dataset_name"] | ||
| ag_model_save_dir = os.path.join(save_dir, f"{dataset_name}_ag_text_multimodal_{text_backbone}\ |
There was a problem hiding this comment.
ok. Can you use the original directory save_dir instead of the modified directory ag_model_save_dir so users know where to find the saved model?