vllm.model_executor.models.clef_joint_schema
¶
Shared joint schema head for Clef decision models.
The head reads the final hidden states of the whole prompt, so it runs as a
token_classify pooler.
Each request carries its schema in PoolingParams.extra_kwargs under
"joint_schema":
question_types: 0 (noul), 1 (choice) or 2 (score) per question.question_spans: the[start, end)of each question's instructions.option_spans: the[start, end)of each option, question by question.option_counts: the number of options of each question.
Spans count from the end of the prompt (-len(prompt) <= start < end <= 0),
so they hold after multimodal placeholders are expanded. The output has one
value per option, in option_spans order: its probability within its
question, or its logit with use_activation=False.
Classes:
-
JointSchemaHead– -
JointSchemaPooler–Runs the joint schema head on each finished prompt.
-
SchemaIndices–Where one prompt's questions and options are, on the model's device.
Functions:
-
parse_joint_schema–The question types, the absolute spans of the questions then of the
JointSchemaHead
¶
Bases: Module
Methods:
-
forward–The
[O]option logits of one prompt, from its[L, hidden]
Source code in vllm/model_executor/models/clef_joint_schema.py
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 201 202 203 204 205 206 207 | |
forward(hidden_states, lexical, schema)
¶
The [O] option logits of one prompt, from its [L, hidden]
final hidden states and each option's [O, hidden] mean output
embedding.
Source code in vllm/model_executor/models/clef_joint_schema.py
JointSchemaPooler
¶
Bases: Pooler
Runs the joint schema head on each finished prompt.
It never raises, because it runs in the engine core: a prompt without a valid schema, such as a profiling dummy, gets an empty output.
Source code in vllm/model_executor/models/clef_joint_schema.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
_indices(types, spans, counts, device)
staticmethod
¶
The schema's indices, plus the option tokens' positions (on the CPU) and their option spans, for the lexical embeddings.
Source code in vllm/model_executor/models/clef_joint_schema.py
SchemaIndices
dataclass
¶
Where one prompt's questions and options are, on the model's device.
Attributes:
-
option_mask(Tensor) –[Q, max_options], true at the slots of options. -
option_question(Tensor) –The question of each option,
[O]. -
option_slots(Tensor) –Each option's flat index in a
[Q, max_options]grid,[O]. -
positions(Tensor) –Every token of every span, questions first.
-
question_types(Tensor) –[Q]. -
span_ids(Tensor) –The span of each of
positions. -
span_lengths(Tensor) –[Q + O].
Source code in vllm/model_executor/models/clef_joint_schema.py
option_mask
instance-attribute
¶
[Q, max_options], true at the slots of options.
option_question
instance-attribute
¶
The question of each option, [O].
option_slots
instance-attribute
¶
Each option's flat index in a [Q, max_options] grid, [O].
positions
instance-attribute
¶
Every token of every span, questions first.
question_types
instance-attribute
¶
[Q].
span_ids
instance-attribute
¶
The span of each of positions.
span_lengths
instance-attribute
¶
[Q + O].
parse_joint_schema(extra_kwargs, prompt_len)
¶
The question types, the absolute spans of the questions then of the options, and the option counts. None if the schema is missing or invalid.