Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Ironieser/MMTok
/ functions
Functions
75 in github.com/Ironieser/MMTok
⨍
Functions
75
◇
Types & classes
8
↓ 4 callers
Method
flatten
(self, input)
example/lmms_eval_llava_mmtok.py:292
↓ 3 callers
Method
_l2_normalize
(x: torch.Tensor)
mmtok/core/semantic_selector.py:85
↓ 3 callers
Method
device
(self)
example/lmms_eval_llava_mmtok.py:198
↓ 2 callers
Method
_encode_text_with_token_pooling
Encode text (question/keywords) into text token embeddings for coverage. Uses LLaVA embed_tokens; batch size must be 1. No BOS.
mmtok/core/mmtok_core.py:71
↓ 2 callers
Method
apply_selection
Apply coverage-based subset selection: select vision tokens that cover text tokens (question) and the vision token set (multimodal co
mmtok/core/mmtok_core.py:87
↓ 2 callers
Method
device
(self)
example/lmms_eval_qwen_mmtok.py:175
↓ 2 callers
Method
extract_keywords_simple
Filter stopwords and return descriptive text for text token embedding (coverage).
mmtok/core/text_processor.py:44
↓ 2 callers
Function
extract_question_from_messages
Extract question text from Qwen2.5-VL message format. User messages may have content as str or list of {"type": "text", "text": "..."} / {"ty
mmtok/qwen/qwen2_5_vl_mmtok.py:124
↓ 2 callers
Function
mmtok
Inject MMTok into a LLaVA model: coverage-based subset selection of vision tokens. A subset of vision tokens is selected under the maximum c
mmtok/llava/llava_inject.py:35
↓ 2 callers
Function
mmtok_qwen2_5_vl
Inject MMTok token selection into Qwen2.5-VL. Qwen2.5-VL uses dynamic resolution, so the number of vision tokens per image varies. MMTok
mmtok/qwen/qwen2_5_vl_mmtok.py:19
↓ 2 callers
Method
select_vision_tokens
Subset selection under maximum coverage: greedy selection of vision tokens to cover text tokens (question) and the vision token set.
mmtok/core/mmtok_core.py:118
↓ 1 callers
Method
_init_processors
Initialize token selector and text processor.
mmtok/core/mmtok_core.py:62
↓ 1 callers
Function
apply_llava_patches
Apply monkey-patch to llava.mm_utils.process_images so that latest images and padding patch indices are stored for MMTok. Idempotent; safe to
mmtok/llava/patch_llava.py:115
↓ 1 callers
Method
apply_selection_preprocess_qwen
Coverage-based subset selection for Qwen2.5-VL: select vision tokens to cover text (question only, or question+answer if provided) an
mmtok/core/mmtok_core.py:174
↓ 1 callers
Function
calculate_padding_patch_indices
Compute patch indices that fall inside the padding region (after resize to target_size). Args: original_size: (width, height) of the
mmtok/llava/patch_llava.py:33
↓ 1 callers
Method
get_image_features
Encodes images into continuous embeddings that can be forwarded to the language model. Args: pixel_values (`torch.FloatT
mmtok/qwen/qwen2_5_VLmodel_mmtok.py:38
↓ 1 callers
Function
get_padding_patch_indices
Return padding patch indices (List[List[int]]) set by the last process_images call.
mmtok/llava/patch_llava.py:104
↓ 1 callers
Method
get_video_features
Encodes videos into continuous embeddings that can be forwarded to the language model. Args: pixel_values_videos (`torch
mmtok/qwen/qwen2_5_VLmodel_mmtok.py:24
↓ 1 callers
Function
greedy_merged_jit_kernel
Greedy maximum-coverage selection (JIT). Combined = [P; Q*alpha]: P = text–vision coverage, Q = vision–vision coverage (diversity). Args
mmtok/core/semantic_selector.py:24
↓ 1 callers
Method
mm_coverage_selection
Greedy maximum-coverage subset selection. Combined = [P; Q*alpha]: cover text tokens (P) and vision tokens (Q). Uses JIT kern
mmtok/core/semantic_selector.py:88
↓ 1 callers
Method
model
(self)
example/lmms_eval_llava_mmtok.py:169
↓ 1 callers
Method
pad_sequence
(self, input_ids, batch_first, padding_value)
example/lmms_eval_llava_mmtok.py:185
↓ 1 callers
Function
patch_conv_copy_for_hook
Patch the 'copy' method of a conversation template to capture the prompt for MMTok. Imports llava.conversation only inside this function so L
mmtok/llava/llava_inject.py:138
↓ 1 callers
Function
patch_qwen2_5_vl_processor_for_question_hook
Patch processor.apply_chat_template to capture question text and set it on mmtok_model_instance.
mmtok/qwen/qwen2_5_vl_mmtok.py:90
↓ 1 callers
Function
set_use_padding_indices
Enable/disable padding index computation in the process_images wrapper (LLaVA-1.5 only).
mmtok/llava/patch_llava.py:27
↓ 1 callers
Method
tok_decode
(self, tokens)
example/lmms_eval_llava_mmtok.py:218
↓ 1 callers
Method
tok_encode
example/lmms_eval_llava_mmtok.py:209
Method
DivPrune
(visual_feature_vectors, target_vision_tokens=1)
mmtok/qwen/qwen2_5_VLmodel_mmtok.py:163
Method
__init__
( self, pretrained: str = "liuhaotian/llava-v1.5-7b", truncation: Optional[bool] = Tru
example/lmms_eval_llava_mmtok.py:56
Method
__init__
( self, pretrained: str = "Qwen/Qwen2.5-VL-3B-Instruct", device: Optional[str] = "cuda
example/lmms_eval_qwen_mmtok.py:38
Method
__init__
( self, target_vision_tokens=64, alpha=0.5, softmax_tv_temperature=0.02,
mmtok/core/mmtok_core.py:39
Method
__init__
(self, device: Optional[torch.device] = None)
mmtok/core/text_processor.py:40
Method
__init__
( self, target_vision_tokens: int = 32, alpha: float = 0.5, )
mmtok/core/semantic_selector.py:76
Method
_collate
(x)
example/lmms_eval_llava_mmtok.py:305
Method
_collate
(x)
example/lmms_eval_qwen_mmtok.py:199
Function
_get_question
(self)
mmtok/llava/llava_inject.py:134
Function
_get_question
Get question from qwen_model.model.
mmtok/qwen/qwen2_5_vl_mmtok.py:85
Function
_new_process_images
(flattened_visuals, *args, **kwargs)
mmtok/llava/patch_llava.py:134
Function
_set_question
(self, question: str)
mmtok/llava/llava_inject.py:130
Function
_set_question
Set question on qwen_model; stored on model.
mmtok/qwen/qwen2_5_vl_mmtok.py:80
Method
batch_size
(self)
example/lmms_eval_llava_mmtok.py:194
Method
batch_size
(self)
example/lmms_eval_qwen_mmtok.py:171
Method
config
(self)
example/lmms_eval_llava_mmtok.py:160
Method
config
(self)
example/lmms_eval_qwen_mmtok.py:146
Function
encode_images_mmtok
(self, images)
mmtok/llava/llava_arch_mmtok.py:36
Function
encode_images_mmtok_multi
(self, images)
mmtok/llava/llava_arch_mmtok.py:42
Method
eot_token_id
(self)
example/lmms_eval_llava_mmtok.py:177
Method
eot_token_id
(self)
example/lmms_eval_qwen_mmtok.py:163
Method
flatten
(self, input)
example/lmms_eval_qwen_mmtok.py:189
Method
forward
Forward with coverage-based subset selection: CLIP -> mm_projector -> select vision tokens that cover text (question) and vision set;
mmtok/llava/clip_encoder_mmtok.py:27
Method
forward
Args: hidden_states (`torch.Tensor` of shape `(seq_len, hidden_size)`): The final hidden states of the model.
mmtok/qwen/modeling_qwen2_5_vl_mmtok.py:14
Method
forward
r""" pixel_values_videos (`torch.FloatTensor` of shape `(seq_length, num_channels * temporal_size * image_size * image_size)): The
mmtok/qwen/qwen2_5_VLmodel_mmtok.py:53
Method
generate_until
(self, requests: List[Instance])
example/lmms_eval_llava_mmtok.py:302
Method
generate_until
(self, requests: List[Instance])
example/lmms_eval_qwen_mmtok.py:196
Method
generate_until_multi_round
(self, requests)
example/lmms_eval_llava_mmtok.py:444
Method
generate_until_multi_round
(self, requests)
example/lmms_eval_qwen_mmtok.py:382
Function
get_latest_images
(clear=True)
mmtok/llava/patch_llava.py:96
Method
loglikelihood
(self, requests: List[Instance])
example/lmms_eval_llava_mmtok.py:224
Method
loglikelihood
(self, requests: List[Instance])
example/lmms_eval_qwen_mmtok.py:186
Method
max_length
(self)
example/lmms_eval_llava_mmtok.py:182
Method
max_length
(self)
example/lmms_eval_qwen_mmtok.py:167
Method
model
(self)
example/lmms_eval_qwen_mmtok.py:155
Method
pairwise_cosine_similarity
(matrix)
mmtok/qwen/qwen2_5_VLmodel_mmtok.py:167
Function
patch_qwen2_5_vl_for_question_hook
Patch processor.apply_chat_template on the lmms_eval Qwen wrapper to capture question.
mmtok/qwen/qwen2_5_vl_mmtok.py:107
Function
patched_append_message
(self, role, message)
mmtok/llava/llava_inject.py:163
Function
patched_apply_chat_template
(messages, tokenize=False, add_generation_prompt=True, **kwargs)
mmtok/qwen/qwen2_5_vl_mmtok.py:96
Function
patched_copy
(self)
mmtok/llava/llava_inject.py:159
Function
prepare_inputs_labels_for_multimodal_mmtok
( self, input_ids, position_ids, attention_mask, past_key_values, labels, images,
mmtok/llava/llava_arch_mmtok.py:82
Method
rank
(self)
example/lmms_eval_llava_mmtok.py:202
Method
rank
(self)
example/lmms_eval_qwen_mmtok.py:179
Function
restore_image_features_sorted
(self, image_feature, cur_keep_idx, width, height)
mmtok/llava/llava_arch_mmtok.py:48
Method
tokenizer
(self)
example/lmms_eval_llava_mmtok.py:165
Method
tokenizer
(self)
example/lmms_eval_qwen_mmtok.py:151
Method
world_size
(self)
example/lmms_eval_llava_mmtok.py:206
Method
world_size
(self)
example/lmms_eval_qwen_mmtok.py:183