huggingface / huggingface/transformers.js
[Feature request] Return offset mapping using tokenizer
- Dominant language
- JavaScript
- Stars
- 16.3k
- Forks
- 1.2k
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 6
Description
**Return offset mapping using tokenizer**
Hi guys, awesome work with this project, it is helping us a lot! Is it possible to add the parameter "return_offset_mapping" to the Tokenizer class, just like in the Transformers python library?
**Reason for request**
The returned offsets are crucial for our project in Named Entity Recognition, as we need to associate the predicted tags with the original sentence (prior to tokenization). Currently we can only associate the predicted tags with the list of subtokens, as they are a 1-to-1 association, and we know that the list of subtokens ignore some elements, such as whitespaces, which are present in the original sentence.
**Additional context**
Reference for "return_offset_mapping" on Transformers python library: https://huggingface.co/docs/transformers/v4.35.2/en/main_classes/tokenizer#transformers.PreTrainedTokenizerFast.__call__.return_offsets_mapping
Contributor guide
Assessment
This issue has not been assessed yet.