# BERT Model Selector - Import SavedModel Error

**URL:** <https://forum.knime.com/t/bert-model-selector-import-savedmodel-error/76234>\
**Category:** Partner Extensions\
**Tags:** other-partner-extensions\
**Created:** [December 25, 2023, 7:01am UTC](https://forum.knime.com/t/bert-model-selector-import-savedmodel-error/76234 "2023-12-25T07:01:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sommer\_sun](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@sommer\_sun](https://forum.knime.com/u/sommer_sun)\
**Post date:** [December 25, 2023, 7:01am UTC](https://forum.knime.com/t/bert-model-selector-import-savedmodel-error/76234/1 "2023-12-25T07:01:31Z")

</div>

Hi,

I downloaded “BERT for patents” from [here](https://github.com/google/patents-public-data/blob/master/models/BERT%20for%20Patents.md) to a local directory. Trying to load this model from local directory with BERT Model Selector I get the following error message:

> ValueError: Importing a SavedModel with `tf.saved_model.load` requires a `tags=` argument if there is more than one MetaGraph. Got `tags=None`, but there are 2 MetaGraphs in the SavedModel with tag sets: [[‘serve’], [‘serve’, ‘tpu’]]. Pass a `tags=` argument to load this SavedModel.

Is there any solution for this problem?

---

<div class="post-metadata">

**Author:** ![roberto\_cadili](https://forum-cdn.knime.com/user_avatar/forum.knime.com/roberto_cadili/32/62735_2.png) [@roberto\_cadili](https://forum.knime.com/u/roberto_cadili)\
**Post date:** [December 29, 2023, 8:50am UTC](https://forum.knime.com/t/bert-model-selector-import-savedmodel-error/76234/2 "2023-12-29T08:50:10Z")

</div>

Hi @sommer_sun,

I’ve never encountered this issue before but from a quick Google search, it looks like it might be connected to [this](https://github.com/tensorflow/tensorflow/issues/37068).

At the same time, mind that the [documentation of the node](https://hub.knime.com/redfield/extensions/se.redfield.bert.feature/latest/se.redfield.bert.nodes.selector.BertModelSelectorNodeFactory/) reports the following:

> **SETTINGS tab**
> 
> - **Remote URL**  
> An arbitrary link to a model. Use with caution since there is no guarantee that the model will be compatible with the node. **Only active when Advanced tab checkbox is active. This feature is experimental, use with discretion.**
> - **Local folder**  
> A path to the local model that was downloaded not by this node. **Only active when Advanced tab checkbox is active. This feature is experimental, use with discretion.**
> 
> **ADVANCED tab**
> 
> - **Enable Remote URL and Local path selection modes**  
> Enable Remote URL and Local path selection modes - an experimental feature that makes it possible to pick any model from a remote or local source. **There is no guarantee that the models will be compatible with the BERT extension.**

Being still experimental, I guess this feature causes the problem (at least when reading models locally).

Depending on what you need the model for, an option is to access the model from Hugging Face model repository using Python in the Python Script node. I think I’ve found the same model you’re interested here: [anferico/bert-for-patents · Hugging Face](https://huggingface.co/anferico/bert-for-patents). On Hugging Face, the task this model is enabled for is “[fill-mask](https://huggingface.co/tasks/fill-mask)”. Find below the essential code to use the mask-filler:

```auto
from transformers import pipeline

pipe = pipeline("fill-mask", model="anferico/bert-for-patents")

predict_mask = pipe("Paris is the capital city of [MASK].")

```

Find more info on fill-mask pipelines here: [Pipelines](https://huggingface.co/docs/transformers/v4.36.1/en/main_classes/pipelines#transformers.FillMaskPipeline).

However, if you’re interested in using it for classification, this option from Hugging Face won’t work well, as the the task the model is associated with is “fill-mask” instead of “zero-shot-classification” or “text-classification”. You can force the task to do classification but results most likely are going to be poor.

Hope this helps!

Roberto

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [March 28, 2024, 8:50am UTC](https://forum.knime.com/t/bert-model-selector-import-savedmodel-error/76234/3 "2024-03-28T08:50:33Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
