MCPcopy Create free account
hub / github.com/OpenSparseLLMs/Linear-MoE / insert_separator

Function insert_separator

linear_moe/data/llava/mm_utils.py:58–59  ·  view source on GitHub ↗
(X, sep)

Source from the content-addressed store, hash-verified

56def tokenizer_image_token(prompt, tokenizer, image_token_index=IMAGE_TOKEN_INDEX, return_tensors=None):
57 prompt_chunks = [tokenizer(chunk).input_ids for chunk in prompt.split('<image>')]
58 def insert_separator(X, sep):
59 return [ele for sublist in zip(X, [sep]*len(X)) for ele in sublist][:-1]
60 input_ids = []
61 offset = 0
62 if len(prompt_chunks) > 0 and len(prompt_chunks[0]) > 0 and prompt_chunks[0][0] == tokenizer.bos_token_id:

Callers 1

tokenizer_image_tokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected