# config.cfg for bert.ner.manual

**URL:** <https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970>\
**Category:** Uncategorized\
**Tags:** usage, ner, transformers\
**Created:** [September 23, 2022, 9:36pm UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970 "2022-09-23T21:36:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruiyeNLP](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ruiyenlp/32/2305_2.png) [@ruiyeNLP](https://support.prodi.gy/u/ruiyeNLP)\
**Post date:** [September 23, 2022, 9:36pm UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/1 "2022-09-23T21:36:16Z")

</div>

Hi, I annotated my file with the command

```python
prodigy bert.ner.manual data_5_trf ./input/data_5_ground_truth_1.0.jsonl --label RIGHTV,RIGHTN,ACCESSV,ACCESSN --tokenizer-vocab ./bert-base-uncased-vocab.txt --lowercase --hide-wp-prefix -F transformers_tokenizers.py

```

And i trained with this command

```python
prodigy train --ner data_5_trf ./tmp_model --eval-split 0.2 --config config.cfg --gpu-id 0 --label-stats

```

My question is: Should i change some lines in **config.cfg** file to match the `bert.ner.mannual` recipe? Especially set the **tokenizer-vocab** to be './bert-base-uncased-vocab.txt'?

BTW, when i try to set vocab\_data on config.cfg, there is an error.

> vocab\_data = './bert-base-uncased-vocab.txt'

 ![Screenshot 2022-09-23 at 23.33.59](https://us1.discourse-cdn.com/flex020/uploads/prodigy/original/2X/f/f95b2fed044d407959cd82d4dabe8c4f21a7a55c.png)

---

<div class="post-metadata">

**Author:** ![koaning](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/koaning/32/230_2.png) [@koaning](https://support.prodi.gy/u/koaning)\
**Post date:** [September 26, 2022, 10:06am UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/2 "2022-09-26T10:06:15Z")

</div>

Before diving deeper into this question I just want to make sure that I understand what your goal is. If you're trying to train a BERT model, you can also use spaCy without having to resort to [this custom recipe](https://github.com/explosion/prodigy-recipes/blob/master/other/transformers_tokenizers.py). To quote [the docs](https://prodi.gy/docs/named-entity-recognition/#transformers-tokenizers):

> **New in Prodigy v1.11 and spaCy v3**
> 
> spaCy v3 lets you train a transformer-based pipeline and will take care of all tokenization alignment under the hood, to ensure that the subword tokens match to the linguistic tokenization. You can use [` data-to-spacy`](https://prodi.gy/docs/recipes#data-to-spacy) to export your annotations and train with spaCy v3 and a [transformer-based config](https://spacy.io/usage/training) directly, or run [` train`](https://prodi.gy/docs/recipes#train) and provide the config via the `--config` argument.

So just to check, are you trying to train a BERT model using spaCy? If so, you might just want to follow the steps that I describe [here](https://support.prodi.gy/t/transform-annotations-to-match-tokenization-required-for-spanbert-bert/5923/4). If you're trying to generate data for another library, like Huggingface, that depends on the sentencepiece tokeniser ... then I can dive a bit deeper.

---

<div class="post-metadata">

**Author:** ![ruiyeNLP](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ruiyenlp/32/2305_2.png) [@ruiyeNLP](https://support.prodi.gy/u/ruiyeNLP)\
**Post date:** [September 26, 2022, 8:21pm UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/3 "2022-09-26T20:21:51Z")

</div>

Hey, thanks for your reply. I actually followed the tutorial [here](https://prodi.gy/docs/named-entity-recognition#transformers-tokenizers).

> If you’re creating training data for **fine-tuning a transformer** , you can use its tokenizer to preprocess your texts to make sure that the data you annotate is compatible with the **transformer tokenization**. It also makes annotation faster, because your selection can snap to token boundaries. The following recipe implementation uses Hugging Face’s easy-to-use [`tokenizers` library](https://github.com/huggingface/tokenizers) under the hood.

In this example, how do you think what should be changed the **config.cfg**?

---

<div class="post-metadata">

**Author:** ![koaning](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/koaning/32/230_2.png) [@koaning](https://support.prodi.gy/u/koaning)\
**Post date:** [September 28, 2022, 12:33pm UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/4 "2022-09-28T12:33:47Z")

</div>

As described [here](https://github.com/explosion/spaCy/discussions/10768), you can load any Huggingface model you want in spaCy and have spaCy train a model using its features, but that's not the same thing as being able to fine-tune it. For that, you'll probably want to use the Huggingface library itself.

---

<div class="post-metadata">

**Author:** ![ruiyeNLP](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ruiyenlp/32/2305_2.png) [@ruiyeNLP](https://support.prodi.gy/u/ruiyeNLP)\
**Post date:** [September 28, 2022, 8:00pm UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/5 "2022-09-28T20:00:00Z")

</div>

OK. But I am still confused. Do you know how to use **prodigy to train** the model after annotating following the prodigy example [here](https://prodi.gy/docs/named-entity-recognition#transformers-tokenizers)? What is the follow-up step after the BERT+NER annotation with Prodigy?

---

<div class="post-metadata">

**Author:** ![koaning](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/koaning/32/230_2.png) [@koaning](https://support.prodi.gy/u/koaning)\
**Post date:** [September 30, 2022, 8:33am UTC](https://support.prodi.gy/t/config-cfg-for-bert-ner-manual/5970/6 "2022-09-30T08:33:26Z")

</div>

For my understanding, what is your goal?

Do you wish to train and update a Huggingface BERT model without spaCy? If so, you'll need to use that library to train a component and you can use the data generated from [this recipe](https://prodi.gy/docs/named-entity-recognition#transformers-tokenizers). You'd need to take the extra effort here, because Huggingface might use a different tokeniser.

If you wish to use BERT as part of a spaCy pipeline, then you can use the normal `ner.manual` recipe for annotation and you don't need to worry about the tokens. You can just use `en_core_web_trf` as a model when running the [train](https://prodi.gy/docs/recipes#train) command from Prodigy. Assuming that you've annotated a dataset called `annotated_ner` then you train command would look something like:

```python
python -m prodigy train --ner annotated_ner --base_model en_core_web_trf

```
