# Pre-annotation does not work

**URL:** <https://support.prodi.gy/t/pre-annotation-does-not-work/4958>\
**Category:** Uncategorized\
**Tags:** solved, custom, ner, usage\
**Created:** [November 16, 2021, 2:50pm UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958 "2021-11-16T14:50:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aisha\_harbi](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@aisha\_harbi](https://support.prodi.gy/u/aisha_harbi)\
**Post date:** [November 16, 2021, 2:50pm UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/1 "2021-11-16T14:50:47Z")

</div>

I have implemented a custom recipe for my model, the text appears and labels on the UI except that the pre-annotations are not there, the text is not highlighted....

I used the pseudocode here : [https://prodi.gy/docs/named-entity-recognition#custom-model](https://prodi.gy/docs/named-entity-recognition#custom-model)  
I followed the same format.

---

<div class="post-metadata">

**Author:** ![ljvmiranda921](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ljvmiranda921/32/3197_2.png) [@ljvmiranda921](https://support.prodi.gy/u/ljvmiranda921)\
**Post date:** [November 17, 2021, 2:11am UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/2 "2021-11-17T02:11:59Z")

</div>

Hi @aisha_harbi ,

If the text appears but the labels on the UI aren't there, then the usual problem is that **the tokens and spans are not being aligned correctly**. To clarify:

- For a Token, the `start` and `end` are the character offsets
- For a Span, the `token_start` and `token_end` are the token indices, while the `start` and `end` are again, character offsets.

What you can do is first check the samples of your JSONL file, then work your way backwards in case there's some missing piece of logic (e.g. alignment, missing keys, etc.)

---

<div class="post-metadata">

**Author:** ![aisha\_harbi](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@aisha\_harbi](https://support.prodi.gy/u/aisha_harbi)\
**Post date:** [November 17, 2021, 7:50am UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/3 "2021-11-17T07:50:10Z")

</div>

isn't this the expected format?

```python
{
  "text": "Apple updates its analytics service with new metrics",
  "spans": [{"start": 0, "end": 5, "label": "ORG"}]
}

```

---

<div class="post-metadata">

**Author:** ![ljvmiranda921](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ljvmiranda921/32/3197_2.png) [@ljvmiranda921](https://support.prodi.gy/u/ljvmiranda921)\
**Post date:** [November 17, 2021, 7:58am UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/4 "2021-11-17T07:58:16Z")

</div>

You're missing `token_start` and `token_end` in the `spans`. You also need another key, `tokens` that should contain a list of this data structure:

```python
... "tokens": [{"text": str, "id": int, "start": int, "end": int},...]

```

A minimal structure looks like this:

```python
{
   "text":"Welcome to Prodigy!",
   "tokens":[
      {
         "text":"str",
         "start":"int",
         "end":"int",
         "id":"int"
      },
      {
         "text":"str",
         "start":"int",
         "end":"int",
         "id":"int"
      }
   ],
   "spans":[
      {
         "token_end":"int",
         "token_start":"int",
         "label":"str",
         "start":"int",
         "end":"int"
      }
   ],
   "meta":{
      "ids":[
         "str",
         "str"
      ],
      "start_indices":[
         "int",
         "int"
      ]
   }
}

```

---

<div class="post-metadata">

**Author:** ![aisha\_harbi](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@aisha\_harbi](https://support.prodi.gy/u/aisha_harbi)\
**Post date:** [November 17, 2021, 11:27am UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/5 "2021-11-17T11:27:31Z")

</div>

Do the keys within the list's dictionary have to be in order? and how do I create the meta and start\_indices lists? Because I have all the keys within the span and tokens and text lists..... Manual annotating works fine, it's just the pre-annotation that's not working. I think what I'm trying to ask is what does the pre annotation depend on, the spans, right?

Thanks so much,

---

<div class="post-metadata">

**Author:** ![aisha\_harbi](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@aisha\_harbi](https://support.prodi.gy/u/aisha_harbi)\
**Post date:** [November 17, 2021, 12:08pm UTC](https://support.prodi.gy/t/pre-annotation-does-not-work/4958/6 "2021-11-17T12:08:55Z")

</div>

Never mind it works, thanks again
