A programming framework for agentic AI
fix NER roberta bug (#632)
Xueqing Liu8fb1c1a29ac0
diff --git a/flaml/model.py b/flaml/model.pyindex a2f192c42..721ac2e1d 100644--- a/flaml/model.py+++ b/flaml/model.py@@ -594,10 +594,7 @@ class TransformersEstimator(BaseEstimator):return AutoTokenizer.from_pretrained(self._training_args.model_path,use_fast=True,- add_prefix_space="roberta" in self._training_args.model_path- and not getattr(self, "_pred_flag", False),- # If roberta model and the call is from .fit instead of .predict (when the model_path is updated to the checkpoint name instead), must set add_prefix_space to True to avoid the assertion error at- # https://github.com/huggingface/transformers/blob/main/src/transformers/models/roberta/tokenization_roberta_fast.py#L249+ add_prefix_space=self._add_prefix_space,)@property@@ -644,6 +641,10 @@ class TransformersEstimator(BaseEstimator):self._X_train, self._y_train = X_train, y_trainself._set_training_args(**kwargs)+ self._add_prefix_space = (+ "roberta" in self._training_args.model_path+ ) # If using roberta model, must set add_prefix_space to True to avoid the assertion error at+ # https://github.com/huggingface/transformers/blob/main/src/transformers/models/roberta/tokenization_roberta_fast.py#L249train_dataset, self._X_train, self._y_train = self.preprocess_data(X_train, y_train@@ -822,7 +823,6 @@ class TransformersEstimator(BaseEstimator):Need to reinit training_args because of a bug in deepspeed: if not reinit, the deepspeed config will be inconsistentwith HF config https://github.com/huggingface/transformers/blob/main/src/transformers/training_args.py#L947"""- self._pred_flag = Truetraining_args = self._TrainingArguments(local_rank=-1, model_path=self._checkpoint_path, fp16=self.fp16)