I am using the SQuaD dataset for answer span selection. After using the BertTokenizer to tokenize the passages, for some samples, the start and end indices of the answer don't match the real answer span position in the passage tokens anymore. How to solve this problem? One way is to modify the answer indices (also the training targets) accordingly? But how to do it?
How to map token indices from the SQuAD data to tokens from BERT tokenizer?
4.1k Views Asked by KoalaJ At
1
There are 1 best solutions below
Related Questions in BERT-LANGUAGE-MODEL
- Are special tokens [CLS] [SEP] absolutely necessary while fine tuning BERT?
- BERT NER Python
- Fine tuning of Bert word embeddings
- how to predict a masked word in a given sentence
- Batch size keeps on changin, throwing `Pytorch Value Error Expected: input batch size does not match target batch size`
- Huggingface BERT SequenceClassification - ValueError: too many values to unpack (expected 2)
- How do I train word embeddings within a large block of custom text using BERT?
- what's the difference between "self-attention mechanism" and "full-connection" layer?
- Convert dtype('<U13309') to string in python
- Can I add a layer of meta data in a text classification model?
- My checkpoint albert files does not change when training
- BERT zero layer fixed word embeddings
- Tensorflow input for a series of (1, 512) tensors
- Microsoft LayoutLM model error with huggingface
- BERT model classification with many classes
Related Questions in TRANSFORMER-MODEL
- Using parseincludes in Laravel5 Fractal
- how to transform result to map in hibernate5.2
- Cognos Framework manager alternatives on Linux only
- Modifying python AST while preserving comments
- Java Hibernate Transformer AliasToBeanNestedResultTransformer
- How to change color and stroke of one type of edges
- ibm cognos transformer multiple fact table not supported by dimension
- java standard lib produce wrong xml 1.1
- Mule returning a MessageCollection from component
- XLM-RoBERTa token - id relationship
- what's the difference between "self-attention mechanism" and "full-connection" layer?
- Transformer Image captioning model produces just padding rather than a caption
- Using Transformer's decoder to extract sentences
- Is there any way to self create Transformer to run on Coral board?
- Use Asus Transformer Prime as USB Debugger
Related Questions in NLP-QUESTION-ANSWERING
- How to validate free answers from exam
- Build a model that answers question from dataset using GPT3
- Evaluation metrics for multiple correct answers in QA problem system
- Is there any NLP question answering dataset with multiple answers?
- My checkpoint albert files does not change when training
- how to get short natural answers from internet?
- I am trying to make a product which will reformat the answer using the question and Sql_answer as data
- How to evaluate Retriever in Haystack python using retriever.eval() method
- Simple Transformer Question Answer model error showing input should be list of examples
- Retrieve page from the PDF in PDF-chatbot using Langchain
- LLM Question answer models for yes or no answers
- Map_Reduce prompt with RetrievalQA Chain
- Langchain map_reduce can't load gpt2 tokenizer error
- How to implement Knowledge graph
- What Is this C# Code doing in algorithms?
Related Questions in HUGGINGFACE-TOKENIZERS
- Loading saved NER back into HuggingFace pipeline?
- How to download the pretrained dataset of huggingface RagRetriever to a custom directory
- Iterating through Huggingface tokenizer with remainder
- BERT zero layer fixed word embeddings
- DistilBert tokenization does not add pounds (##) at the start of in-word tokens after increasing vocabulary
- Can I use lora to just reduce the size and run inference?
- Identifying most useful domain-specific tokens for adding to the existing tokenizer in huggingface transformers
- Fine-tuning pretrained LLM using HuggingFace transformers throws "index out of range in self"
- NameError: name 'tokenize_and_split_data' is not defined in Python code
- .tokenize() behaviour difference in Tokenizer using various pre-trained models in HuggingFace on Chinese sentences
- Preserving formatting in a BERT-tokenized string
- Huggingface Steraming Inference without TGI
- Offline using cached models from huggingface pretrained
- Incremental training of a large language model
- Features have excessive nesting error when trying to use my own vocab_file
Related Questions in SQUAD
- Cannot reproduce the performance of deepset/roberta-base-squad2 on squad2 due to no-answer questions
- Fine Tuning a T5 Model on Squad
- Running BERT SQUAD model on GPU
- Fail to run trainer.train() with huggingface transformer
- fine tuning with hugging face trainer when adding layer on eletra model
- KeyError: 'answers' error when using BioASQ dataset using Huggingface Transformers
- How can I build a custom context based Question answering model SQuAD using deeppavlov
- deeppavlov model train no module found
- Implementing channels in haskell -- Tackling the awkward squad
- Understanding the Hugging face transformers
- How to fine tune BERT on Squad2.0
- Multiple answer spans in context, BERT question answering
- How to map token indices from the SQuAD data to tokens from BERT tokenizer?
- How to save-freeze-generate a .pb or .ckpt file for transformers and squad dataset?
- What does BERT's special characters appearance in SQuAD's QA answers mean?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The tokenization in the original dataset is different from how BERT tokenizes the input. In BERT, less frequent words get split into subword units. You can easily find out the character offsets of the tokens in the original dataset.
In the newer versions of Transformers, the tokenizers have the option of
return_offsets_mapping. If this is set toTrue, it returns the character offset (a tuple(char_start, char_end)). If you have the character offsets in the original text, you can map them with the output of the tokenizer.The output:
The
(0, 0)spans correspond to technical tokens, in the case of BERT[CLS]and[SEP].When you have the offsets using both the original tokenization and BERT tokenization, you can find out what are the indices in the re-tokenized string.