Skip to content

Commit

Permalink
Optimize 2
Browse files Browse the repository at this point in the history
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
  • Loading branch information
DarkLight1337 committed Nov 20, 2024
1 parent ad1675e commit 4b23817
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vllm/multimodal/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ def find_token_match_by_text(

left_idx = len(_encode(tokenizer, left_text, add_special_tokens=False))
right_idx = len(_encode(tokenizer, right_text, add_special_tokens=True))
avg_idx = (left_idx + right_idx) // 2
window_size = len(match_ids)

valid_candidates = list[_Candidate]()
for start_idx in range(left_idx, right_idx - window_size + 1):
for start_idx in sorted(range(left_idx, right_idx - window_size + 1),
key=lambda x: abs(x - avg_idx)):
end_idx = start_idx + window_size
candidate_text = tokenizer.decode(
token_ids[start_idx:end_idx],
Expand Down

0 comments on commit 4b23817

Please sign in to comment.