# Predicting On New Text With Fine-Tuned Multi-Label Model

**URL:** <https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046>\
**Category:** Beginners\
**Created:** [December 22, 2021, 3:36pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046 "2021-12-22T15:36:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TardisPilot](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tardispilot/32/3509_2.png) [@TardisPilot](https://discuss.huggingface.co/u/TardisPilot)\
**Post date:** [December 22, 2021, 3:36pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046/1 "2021-12-22T15:36:02Z")

</div>

This is very much a beginner question. I am trying to load a fine tuned model for multi-label text classification. Fine-tuned on 11 labels, bert-base-uncased.

I just want to feed new text to the model and get the labels predicted to be associated with the text.

I have looked everywhere and cannot find an example of how to actually load and use a fine-tuned model on new data after fine tuning is complete.

I have the model saved via:

`model.save_pretrained("fine_tuned_model")`

I can load the model back with:

`model = AutoModelForSequenceClassification.from_pretrained("fine_tuned_model", from_tf=False, config=config)`

From here I am stuck. I have been told to use `model.predict("text")` but when I do I get the following error:

`'BertForSequenceClassification' object has no attribute 'predict'`

I hope this makes sense and any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![merve](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/merve/32/49809_2.png) [@merve](https://discuss.huggingface.co/u/merve)\
**Post date:** [December 22, 2021, 7:32pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046/2 "2021-12-22T19:32:37Z")

</div>

Hello and welcome to our Forum 👋🤗  
I’d suggest you to use the [Text Classification pipeline](https://huggingface.co/docs/transformers/v4.15.0/en/main_classes/pipelines#transformers.TextClassificationPipeline) instead.

```auto
from transformers import pipeline
clf = pipeline("text-classification", fine_tuned_model)
answer = clf("text)

```

---

<div class="post-metadata">

**Author:** ![TardisPilot](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tardispilot/32/3509_2.png) [@TardisPilot](https://discuss.huggingface.co/u/TardisPilot)\
**Post date:** [December 23, 2021, 1:17pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046/3 "2021-12-23T13:17:37Z")

</div>

Hey @merve, thank you so much for the suggestion and assistance! The code you provided works but only returns one of my 11 labels per text entered:

`#Output: [{'label': 'LABEL_7', 'score': 0.9935219883918762}]`

Is there a way to get the scores for all labels (I have 11) and have the label values mapped to their respective labels? So the output would include 11 returns with scores?

For instance, instead of ‘LABEL\_7’ it would say ‘Technology’ and so on and so forth.

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [December 23, 2021, 2:33pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046/4 "2021-12-23T14:33:49Z")

</div>

To get all scores, `pipeline` has a parameter

`clf("text", return_all_scores=True)`

For the label being LABEL\_7, you need to check out the `config.json` in your repo. See for example `id2label` and `label2id` in [config.json · distilbert-base-uncased-finetuned-sst-2-english at main](https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/blob/main/config.json).

---

<div class="post-metadata">

**Author:** ![TardisPilot](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tardispilot/32/3509_2.png) [@TardisPilot](https://discuss.huggingface.co/u/TardisPilot)\
**Post date:** [December 23, 2021, 3:15pm UTC](https://discuss.huggingface.co/t/predicting-on-new-text-with-fine-tuned-multi-label-model/13046/5 "2021-12-23T15:15:31Z")

</div>

Hey @osanseviero , thank you so much! I really appreciate the kind response!
