Embedding models fail possibly on scientific characters no matter how the pdf is parsed A developer using LlamaIndex reports that embedding models such as BAAI/bge-small-en-v1.5 fail on scientific papers containing special characters, throwing a TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]], regardless of whether the PDFs are parsed with LlamaParse or PyMuPDF. The issue occurs during semantic chunking with SemanticSplitterNodeParser, while simple texts and individual documents work, suggesting the embedding process struggles with certain scientific notation. I am trying to create a RAG pipline using Llamaindex. Anytime I try to use an embedding model on these papers fpr semantic chunking or anything, it does not follow through, which is I think is possibly due to the presence of scientific characters. I’m working with large amount of papers so it’s not possible to audit each separately. Are there any options other than removing the chunks/papers that are problematic? The documents have been parsed in Llamaparse and saved in markdown all with SimpleDirectoryReader - same issue arose in the past when I parsed with PyMuPDF and SimpleDirectoryReader, so my thoughts go towards the embedding process as the main issue. The parsed data itself has been properly preserved in the .pkl file so I don’t think any issues with reading that. It works on simple texts, or docs 0 when tested individually but the entire process fails together. python from llama index.core import SimpleDirectoryReader from llama parse import LlamaParse import nest asyncio import os nest asyncio.apply from dotenv import load dotenv load dotenv first api = os.getenv "LLAMA CLOUD API KEY" parser = LlamaParse api key = first api ,result type="markdown", user prompt="Make sure the structure of all info is preserved", extract charts=True,auto mode trigger on table in page=True, auto mode trigger on image in page=True, documents = SimpleDirectoryReader input dir="./docs", file extractor={"pdf": parser} .load data print "docs ingested" print documents 0 .text :100 import pickle with open "mds ", 'wb' as f: pickle.dump documents, f changed the file extension to mds.pkl afterwards python from llama index.core.node parser import SemanticSplitterNodeParser, SentenceSplitter import pickle from llama index.embeddings.huggingface import HuggingFaceEmbedding import nest asyncio nest asyncio.apply from dotenv import load dotenv import os load dotenv embed model = HuggingFaceEmbedding model name="BAAI/bge-small-en-v1.5" with open "/Users/rifah/Desktop/p/species/mds.pkl", "rb" as f: docs = pickle.load f splitter = SemanticSplitterNodeParser buffer size=1, embed model=embed model,include metadata=True nodes = splitter.get nodes from documents docs 2026-07-24 16:27:07.093685: I tensorflow/core/platform/cpu feature guard.cc:210 This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. /opt/anaconda3/lib/python3.12/site-packages/keras/src/export/tf2onnx lib.py:8: FutureWarning: In the future np.object will be defined as the corresponding NumPy scalar. if not hasattr np, "object" : Embedding attempt failed: TextEncodeInput must be Union TextInputSequence, Tuple InputSequence, InputSequence Embedding attempt failed: TextEncodeInput must be Union TextInputSequence, Tuple InputSequence, InputSequence Embedding attempt failed: TextEncodeInput must be Union TextInputSequence, Tuple InputSequence, InputSequence --------------------------------------------------------------------------- TypeError Traceback most recent call last File /opt/anaconda3/lib/python3.12/site-packages/sentence transformers/base/model.py:557, in BaseModel.preprocess self, inputs, prompt, kwargs 556 try: -- 557 preprocessed = self 0 .preprocess inputs, prompt=prompt, kwargs 558 except TypeError: File /opt/anaconda3/lib/python3.12/site-packages/sentence transformers/base/modules/transformer.py:988, in Transformer.preprocess self, inputs, prompt, processing kwargs, kwargs 987 with suggest extra on exception : -- 988 processor output = self. call processor 989 modality, 990 processor inputs, 991 modality kwargs, 992 common kwargs, 993 chat template kwargs=chat template kwargs, 994 996 if num images per sample is not None and "image grid thw" in processor output: File /opt/anaconda3/lib/python3.12/site-packages/sentence transformers/base/modules/transformer.py:1241, in Transformer. call processor self, modality, processor inputs, modality kwargs, common kwargs, chat template kwargs 1239 return self. call multimodal processor modality, processor inputs, modality kwargs, common kwargs - 1241 return self. call single modality processor modality, processor inputs, modality kwargs, common kwargs File /opt/anaconda3/lib/python3.12/site-packages/sentence transformers/base/modules/transformer.py:1302, in Transformer. call single modality processor self, modality, processor inputs, modality kwargs, common kwargs 1301 primary input = processor inputs.pop modality type - 1302 return self.processor primary input, processor inputs, call kwargs 1303 return self.processor processor inputs, call kwargs File /opt/anaconda3/lib/python3.12/site-packages/transformers/tokenization utils base.py:3078, in PreTrainedTokenizerBase. call self, text, text pair, text target, text pair target, add special tokens, padding, truncation, max length, stride, is split into words, pad to multiple of, padding side, return tensors, return token type ids, return attention mask, return overflowing tokens, return special tokens mask, return offsets mapping, return length, verbose, kwargs 3077 self. switch to input mode - 3078 encodings = self. call one text=text, text pair=text pair, all kwargs 3079 if text target is not None: File /opt/anaconda3/lib/python3.12/site-packages/transformers/tokenization utils base.py:3166, in PreTrainedTokenizerBase. call one self, text, text pair, add special tokens, padding, truncation, max length, stride, is split into words, pad to multiple of, padding side, return tensors, return token type ids, return attention mask, return overflowing tokens, return special tokens mask, return offsets mapping, return length, verbose, split special tokens, kwargs 3165 batch text or text pairs = list zip text, text pair if text pair is not None else text - 3166 return self.batch encode plus 3167 batch text or text pairs=batch text or text pairs, 3168 add special tokens=add special tokens, 3169 padding=padding, 3170 truncation=truncation, 3171 max length=max length, 3172 stride=stride, 3173 is split into words=is split into words, 3174 pad to multiple of=pad to multiple of, 3175 padding side=padding side, 3176 return tensors=return tensors, 3177 return token type ids=return token type ids, 3178 return attention mask=return attention mask, 3179 return overflowing tokens=return overflowing tokens, 3180 return special tokens mask=return special tokens mask, 3181 return offsets mapping=return offsets mapping, 3182 return length=return length, 3183 verbose=verbose, 3184 split special tokens=split special tokens, 3185 kwargs, 3186 3187 else: File /opt/anaconda3/lib/python3.12/site-packages/transformers/tokenization utils base.py:3367, in PreTrainedTokenizerBase.batch encode plus self, batch text or text pairs, add special tokens, padding, truncation, max length, stride, is split into words, pad to multiple of, padding side, return tensors, return token type ids, return attention mask, return overflowing tokens, return special tokens mask, return offsets mapping, return length, verbose, split special tokens, kwargs 3358 padding strategy, truncation strategy, max length, kwargs = self. get padding truncation strategies 3359 padding=padding, 3360 truncation=truncation, ... 3364 kwargs, 3365 - 3367 return self. batch encode plus 3368 batch text or text pairs=batch text or text pairs, 3369 add special tokens=add special tokens, 3370 padding strategy=padding strategy, 3371 truncation strategy=truncation strategy, 3372 max length=max length, 3373 stride=stride, 3374 is split into words=is split into words, 3375 pad to multiple of=pad to multiple of, 3376 padding side=padding side, 3377 return tensors=return tensors, 3378 return token type ids=return token type ids, 3379 return attention mask=return attention mask, 3380 return overflowing tokens=return overflowing tokens, 3381 return special tokens mask=return special tokens mask, 3382 return offsets mapping=return offsets mapping, 3383 return length=return length, 3384 verbose=verbose, 3385 split special tokens=split special tokens, 3386 kwargs, 3387 File /opt/anaconda3/lib/python3.12/site-packages/transformers/tokenization utils fast.py:553, in PreTrainedTokenizerFast. batch encode plus self, batch text or text pairs, add special tokens, padding strategy, truncation strategy, max length, stride, is split into words, pad to multiple of, padding side, return tensors, return token type ids, return attention mask, return overflowing tokens, return special tokens mask, return offsets mapping, return length, verbose, split special tokens 551 self. tokenizer.encode special tokens = split special tokens -- 553 encodings = self. tokenizer.encode batch 554 batch text or text pairs, 555 add special tokens=add special tokens, 556 is pretokenized=is split into words, 557 559 Convert encoding to dict 560 Tokens has type: tuple 561 list dict str, list list int or list dict str, 2D-Tensor , 562 list EncodingFast 563 564 with nested dimensions corresponding to batch, overflows, sequence length TypeError: TextEncodeInput must be Union TextInputSequence, Tuple InputSequence, InputSequence During handling of the above exception, another exception occurred: TypeError Traceback most recent call last Cell In 4 , line 21 15 docs = pickle.load f 18 splitter = SemanticSplitterNodeParser buffer size=1, embed model=embed model,include metadata=True --- 21 nodes = splitter.get nodes from documents docs File /opt/anaconda3/lib/python3.12/site-packages/llama index/core/node parser/interface.py:176, in NodeParser.get nodes from documents self, documents, show progress, kwargs 171 doc id to document = {doc.id : doc for doc in documents} 173 with self.callback manager.event 174 CBEventType.NODE PARSING, payload={EventPayload.DOCUMENTS: documents} 175 as event: -- 176 nodes = self. parse nodes documents, show progress=show progress, kwargs 177 nodes = self. postprocess parsed nodes nodes, doc id to document 179 event.on end {EventPayload.NODES: nodes} File /opt/anaconda3/lib/python3.12/site-packages/llama index instrumentation/dispatcher.py:413, in Dispatcher.span.