# TypeError: \_\_init\_\_() missing 1 required positional argument: 'num\_labels'

**URL:** <https://discuss.huggingface.co/t/typeerror-init-missing-1-required-positional-argument-num-labels/12704>\
**Category:** 🤗Transformers\
**Created:** [December 10, 2021, 3:56pm UTC](https://discuss.huggingface.co/t/typeerror-init-missing-1-required-positional-argument-num-labels/12704 "2021-12-10T15:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmakelo](https://avatars.discourse-cdn.com/v4/letter/e/ea666f/32.png) [@emmakelo](https://discuss.huggingface.co/u/emmakelo)\
**Post date:** [December 10, 2021, 3:56pm UTC](https://discuss.huggingface.co/t/typeerror-init-missing-1-required-positional-argument-num-labels/12704/1 "2021-12-10T15:56:30Z")

</div>

I finetune Bert on multicalssification task. The best model during training was saved in a directory called “checkpoint\_10”.

Now I want to use it to get predictions on new data but I get this error ? why does it ask for a num\_labels

```auto
emb_feature = tokenizer(x, padding="max_length", truncation=True, max_length=512)

model ='./checkpoint_10'
model = XXXForSequenceClassification.from_pretrained(model, num_labels=3)
# Define test trainer
test_trainer = Trainer(model) 
	
# Make prediction
raw_pred, _, _ = test_trainer.predict(emb_feature) # list of dict with "input_id, attention_mask, token_input_ids"
print(raw_pred)

```

Error

```auto
File "/aitements/classifying.py", line 355, in <module>
    pred = predict(test, test_model)
  File "/aitements/classifying.py", line 219, in predict
    model =XXXForSequenceClassification.from_pretrained(model, num_labels=3)
  File "/uw/.conda/envs/bert/lib/python3.9/site-packages/transformers/modeling_utils.py", line 1179, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
TypeError: __init__ () missing 1 required positional argument: 'num_labels'

```

this is the beguinning of my sequenceclassification task :

```auto

class XXXForSequenceClassification(XXXModel):
	"""
	xxx Model for Classification Tasks.

	"""
	def __init__ (self, config, num_labels, freeze_encoder=False):

		"""
		@param XXXBert: a XXXBertModel object
		@param classifier: a torch.nn.Module classifier
		@param freeze_encoder (bool): Set `False` to fine-tune the XXXBERT model
		
		"""

		# instantiate the parent class XXXbertModel
		super(). __init__ (config)
		
		# Specify hidden size of FB hidden size of our classifier, and number of labels

		# instantiate num. of classes
		self.num_labels = num_labels
		
		# instantiate and load a pretrained XXXbertModel 
		self.encoder = XXXbertModel.from_pretrained(PRE_TRAINED_MODEL_NAME)

```
