huggingface / huggingface/transformers.js
[Bug] token-classification return start=null and end=null instead of index in original text
- Dominant language
- JavaScript
- Stars
- 16.3k
- Forks
- 1.2k
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 6
Description
**Describe the bug**
*A clear and concise description of what the bug is.*
**How to reproduce**
*Steps or a minimal working example to reproduce the behavior*
```js
let classifier = await pipeline('token-classification', 'Xenova/bert-base-NER');
let output = await classifier('My name is Sarah and I live in London');
[
{
"entity": "B-PER",
"score": 0.9980159401893616,
"index": 4,
"word": "Sarah",
"start": null,
"end": null
},
{
"entity": "B-LOC",
"score": 0.9994593262672424,
"index": 9,
"word": "London",
"start": null,
"end": null
}
]
```
**Expected behavior**
I expected "start" and "end" to point to the start and end in the original text.
**Environment**
- Transformers.js version: https://cdn.jsdelivr.net/npm/@xenova/transformers@2.6.2
- Browser (if applicable): Chrome
- Operating system (if applicable): MacOS
- Other:
**Additional context**
The documentation for the python version gives back proper start and end points.
https://huggingface.co/docs/transformers/main_classes/pipelines#transformers.TokenClassificationPipeline.example
Contributor guide
Assessment
This issue has not been assessed yet.