llama-index parallel ingestion is failing with token exceed error for embedding model deployed externally

I am using the below test code to try parallel llamaindex ingestion. The code is taken from the link: https://docs.llamaindex.ai/en/stable/examples/ingestion/parallel_execution_ingestion_pipeline/

The code runs as expected using openai-embedding model, but when used with a deployed embedding model either on sky or locally it fails. The logs from the model shows that the token exceeds the max token limit of 512(chunk size given is 256). If i run the same code without parallelization it runs with a warning that token count are more and it might cause indexing errors. I have checked the text which returns from the splitter and observed that in case of no parallelization the same text is splitted differently than the case which involves parallelization which might be the cause of failure. Below is the code:

import multiprocessing as mp
from llama_index.core import SimpleDirectoryReader, Document
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.core.node_parser import SentenceSplitter,LangchainNodeParser
from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.text_splitter import TokenTextSplitter
# Set multiprocessing start method
from llama_index.core import set_global_tokenizer
mp.set_start_method("spawn", force=True)

def get_embedding():
    emburl = "http://127.0.0.1:8080/"
    embkey = "dummy"
    batch_size = 10

    headers = {"Authorization": "Bearer " + embkey}
    return OpenAIEmbedding(model_name="BAAI/bge-large-en-v1.5", api_base=emburl, api_key=headers["Authorization"], embed_batch_size=batch_size, 
        default_headers=headers, timeout=300, reuse_client=False)


def main():
    documents = SimpleDirectoryReader(input_dir="<path>",recursive=True).load_data(num_workers=4)
    print(len(documents))
    # Create the pipeline with transformations
    from transformers import AutoTokenizer
    set_global_tokenizer(AutoTokenizer.from_pretrained("BAAI/bge-large-en-v1.5").encode)
    pipeline = IngestionPipeline(
        transformations=[
            SentenceSplitter(chunk_size=256, chunk_overlap=0,tokenizer=AutoTokenizer.from_pretrained("BAAI/bge-large-en-v1.5").encode),
            get_embedding(),
        ]
    )

    node = pipeline.run(documents=documents,num_workers=2)
    # Disable cache for performance testing
    pipeline.disable_cache = True
    print("done")

if __name__ == '__main__':
    main()

I tried with other splitters like tokentextsplitter and could see the same error. Any advice on this would be helpful

I have tried to run the above test code for multiple number of workers and expect it to behave like openai-embedding in parallel. If i reduce the chunk size the code works as expected and looks like there is some issue in parallelizing the splitter passed.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật