# Python nlp transformers library understanding the methods/functions/properties

**URL:** <https://discuss.huggingface.co/t/python-nlp-transformers-library-understanding-the-methods-functions-properties/13219>\
**Category:** Beginners\
**Created:** [December 29, 2021, 11:10pm UTC](https://discuss.huggingface.co/t/python-nlp-transformers-library-understanding-the-methods-functions-properties/13219 "2021-12-29T23:10:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitempe](https://avatars.discourse-cdn.com/v4/letter/n/54ee81/32.png) [@nitempe](https://discuss.huggingface.co/u/nitempe)\
**Post date:** [December 29, 2021, 11:10pm UTC](https://discuss.huggingface.co/t/python-nlp-transformers-library-understanding-the-methods-functions-properties/13219/1 "2021-12-29T23:10:15Z")

</div>

I am learning huggingface transformer model and looked at this [Fine-tuning a pretrained model - Hugging Face Course](https://huggingface.co/course/chapter3/2?fw=tf).

I saw some code samples as below and did some additional google search and realized things like below could be done. I decided to explore the documentation and the google search after searching `TFAutoModelForSequenceClassification` returned this [Auto Classes](https://huggingface.co/docs/transformers/model_doc/auto)

but that page doesn’t explain methods/functions/properties such as `model.summary()` or `model2.layers[0].trainable`. It doesn’t even mention that there is a parameter `num_labels` in the `TFAutoModelForSequenceClassification.from_pretrained`. I realized these thing because my other google searches returned those

Is there any better documentation where I could understand such things? I am finding it incredibly difficult to understand what are the different things that I could do

```auto
 !pip install datasets transformers[sentencepiece]
    
    checkpoint = "bert-base-uncased"
    from transformers import TFAutoModelForSequenceClassification
    
    model = TFAutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
    
    model.summary()

```

this returns

```auto
    All model checkpoint layers were used when initializing TFBertForSequenceClassification.
    
    Some layers of TFBertForSequenceClassification were not initialized from the model checkpoint at bert-base-uncased and are newly initialized: ['classifier']
    You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
    Model: "tf_bert_for_sequence_classification_1"
    _________________________________________________________________
     Layer (type) Output Shape Param #   
    =================================================================
     bert (TFBertMainLayer) multiple 109482240 
                                                                     
     dropout_75 (Dropout) multiple 0         
                                                                     
     classifier (Dense) multiple 1538      
                                                                     
    =================================================================
    Total params: 109,483,778
    Trainable params: 109,483,778
    Non-trainable params: 0
    _________________________________________________________________

```

Then

```auto
    # (optional) freeze bert layer
    model2=model
    model2.layers[0].trainable = False
    model2.summary()

```

returns

```auto
    Model: "tf_bert_for_sequence_classification_1"
    _________________________________________________________________
     Layer (type) Output Shape Param #   
    =================================================================
     bert (TFBertMainLayer) multiple 109482240 
                                                                     
     dropout_75 (Dropout) multiple 0         
                                                                     
     classifier (Dense) multiple 1538      
                                                                     
    =================================================================
    Total params: 109,483,778
    Trainable params: 1,538
    Non-trainable params: 109,482,240
    _________________________________________________________________

```
