vllm.multimodal.base
MediaIO
¶
Source code in vllm/multimodal/base.py
MultiModalPlaceholderMap
¶
Relates multi-modal embeddings to their corresponding placeholders.
Note: This is only used in V0.
Source code in vllm/multimodal/base.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
dest_len
instance-attribute
¶
dest_len: int = 0
The total number of embeddings in the destination tensor.
dest_ranges
instance-attribute
¶
The indices of the placeholder embeddings that will be replaced by the multimodal embeddings.
src_ranges
instance-attribute
¶
The indices of the multi-modal embeddings that will replace the
corresponding placeholder embeddings pointed to by dest_ranges
.
IndexMap
¶
__init__
¶
append_items_from_seq_group
¶
append_items_from_seq_group(
positions: range,
multi_modal_items: list[_T],
multi_modal_placeholders: Sequence[PlaceholderRange],
) -> list[_T]
Adds the multi-modal items that intersect `positions
to this
placeholder map and returns the intersecting items.
Source code in vllm/multimodal/base.py
extend
¶
extend(other: MultiModalPlaceholderMap)
Adds the placeholders from another MultiModalPlaceholderMap
to this
instance based on the source and destination tensors being
concatenated.
Source code in vllm/multimodal/base.py
from_seq_group
classmethod
¶
from_seq_group(
seq_group: SequenceGroupMetadata, positions: range
) -> tuple[
MultiModalKwargs, dict[str, MultiModalPlaceholderMap]
]
Returns the multi-modal items that intersect with the portion of a
prompt (seq_group
) represented by positions
, as well as a
MultiModalPlaceholderMap
that relates the multi-modal embedding
vectors to their corresponding placeholders.
Examples:
Prompt: |AAAA BBBB What's in these images?|
Positions: |.................................|
images = [A, B]
src_ranges = [(0, 4), (4, 8)]
dest_ranges = [(0, 4), (5, 9)]
Prompt: |AAAA BBBB What's in these images?|
Positions: | ..... |
images = [A, B]
src_ranges = [(2, 4), (4, 6)]
dest_ranges = [(0, 2), (3, 5)]
Prompt: |AAAA BBBB What's in these images?|
Positions: | ......... |
images = [B]
src_ranges = [(0, 4)]
dest_ranges = [(0, 4)]
Prompt: |AAAA BBBB What's in these images?|
Positions: | .......................|
images = []
src_ranges = []
dest_ranges = []
Source code in vllm/multimodal/base.py
index_map
¶
index_map() -> IndexMap
Finalizes the placeholder map into lists of indices that can be used to index the source and destination tensors.