vllm.entrypoints.openai.translations.speech_to_text ¶
Modules:
| Name | Description |
|---|---|
envs | |
PromptType module-attribute ¶
PromptType: TypeAlias = (
DecoderOnlyPrompt | EncoderDecoderPrompt
)
Schema for any prompt, regardless of model type.
This is the input format accepted by most LLM APIs.
EncoderDecoderDictPrompt ¶
Bases: TypedDict
A EncoderDecoderPrompt that has been standardized into a dictionary.
Source code in vllm/renderers/inputs/preprocess.py
EngineClient ¶
Bases: ABC
Protocol class for Clients to Engine
Source code in vllm/engine/protocol.py
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
abort abstractmethod async ¶
add_lora abstractmethod async ¶
add_lora(lora_request: LoRARequest) -> bool
check_health abstractmethod async ¶
collective_rpc async ¶
collective_rpc(
method: str,
timeout: float | None = None,
args: tuple = (),
kwargs: dict | None = None,
)
Perform a collective RPC call to the given path.
encode abstractmethod ¶
encode(
prompt: PromptType | DictPrompt | TokPrompt,
pooling_params: PoolingParams,
request_id: str,
lora_request: LoRARequest | None = None,
trace_headers: Mapping[str, str] | None = None,
priority: int = 0,
tokenization_kwargs: dict[str, Any] | None = None,
) -> AsyncGenerator[PoolingRequestOutput, None]
Generate outputs for a request from a pooling model.
Source code in vllm/engine/protocol.py
generate abstractmethod ¶
generate(
prompt: EngineCoreRequest
| PromptType
| DictPrompt
| TokPrompt
| AsyncGenerator[StreamingInput, None],
sampling_params: SamplingParams,
request_id: str,
*,
prompt_text: str | None = None,
lora_request: LoRARequest | None = None,
tokenization_kwargs: dict[str, Any] | None = None,
trace_headers: Mapping[str, str] | None = None,
priority: int = 0,
data_parallel_rank: int | None = None,
) -> AsyncGenerator[RequestOutput, None]
Generate outputs for a request.
Source code in vllm/engine/protocol.py
init_weight_transfer_engine async ¶
init_weight_transfer_engine(
init_request: WeightTransferInitRequest,
) -> None
pause_generation abstractmethod async ¶
pause_generation(
*,
mode: PauseMode = "abort",
wait_for_inflight_requests: bool = False,
clear_cache: bool = True,
) -> None
Pause new generation/encoding requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode | PauseMode | How to handle in-flight requests: - | 'abort' |
wait_for_inflight_requests | bool | DEPRECATED. Use | False |
clear_cache | bool | DEPRECATED. Whether to clear KV and prefix caches after draining. | True |
Source code in vllm/engine/protocol.py
reset_encoder_cache abstractmethod async ¶
reset_mm_cache abstractmethod async ¶
reset_prefix_cache abstractmethod async ¶
Reset the prefix cache and optionally any configured connector cache
resume_generation abstractmethod async ¶
scale_elastic_ep async ¶
start_profile abstractmethod async ¶
stop_profile abstractmethod async ¶
update_weights async ¶
update_weights(
request: WeightTransferUpdateRequest,
) -> None
FlatLogprobs dataclass ¶
Bases: MutableSequence[LogprobsOnePosition | None]
Flat logprobs of a request into multiple primitive type lists.
Compared to list[dict[int, Logprob]], this data structure reduced GC overhead significantly. As it flattened logprob information for all positions and ranks in to multiple primitive type lists (i.e. logprobs, token_ids, ranks per token_ids, decoded_tokens). So regardless of the sequence length and top_logprobs setup, FlatLogprobs would only introduce a constant amount of objects.
As each position might contains different amount of ranks, start_indices_per_position would be used to access the logprob ranges for different positions.
NOTE: To reduce the migration overhead and improve backward compatibility, we support the key Sequence APIs of list, so it could act as list[LogprobsOnePosition]
Source code in vllm/logprobs.py
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 | |
__getitem__ ¶
__getitem__(position: int) -> LogprobsOnePosition
__getitem__(s: slice) -> FlatLogprobs
Extracts logprobs of a given position or slice
Source code in vllm/logprobs.py
__iter__ ¶
__iter__() -> Iterator[LogprobsOnePosition]
Iterates the container and yields LogprobsOnePosition for each position.
append ¶
Appends the container with logprobs for the next position
Source code in vllm/logprobs.py
append_fast ¶
append_fast(
token_ids: list[int],
logprobs: list[float],
ranks: chain[int],
decoded_tokens: Iterable[str | None],
) -> None
Appends logprobs for the next position without creating the intermediate logprob dictionary.
Source code in vllm/logprobs.py
extend ¶
Extends the container with logprobs for the next multiple positions
Logprob dataclass ¶
Infos for supporting OpenAI compatible logprobs and token ranks.
Attributes:
| Name | Type | Description |
|---|---|---|
logprob | float | The logprob of chosen token |
rank | int | None | The vocab rank of chosen token (>=1) |
decoded_token | str | None | The decoded chosen token index |
Source code in vllm/logprobs.py
OpenAIServing ¶
Source code in vllm/entrypoints/openai/engine/serving.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 | |
_base_request_id staticmethod ¶
Pulls the request id to use from a header, if provided
Source code in vllm/entrypoints/openai/engine/serving.py
_build_response ¶
Default response builder. Subclass may override this method to return the appropriate response object.
Source code in vllm/entrypoints/openai/engine/serving.py
_collect_batch async ¶
Collect batch results from the result generator.
Source code in vllm/entrypoints/openai/engine/serving.py
_convert_generation_error_to_response ¶
_convert_generation_error_to_response(
e: GenerationError,
) -> ErrorResponse
Convert GenerationError to ErrorResponse.
Source code in vllm/entrypoints/openai/engine/serving.py
_convert_generation_error_to_streaming_response ¶
_convert_generation_error_to_streaming_response(
e: GenerationError,
) -> str
Convert GenerationError to streaming error response.
Source code in vllm/entrypoints/openai/engine/serving.py
_get_active_default_mm_loras ¶
_get_active_default_mm_loras(
request: AnyRequest,
) -> LoRARequest | None
Determine if there are any active default multimodal loras.
Source code in vllm/entrypoints/openai/engine/serving.py
_get_data_parallel_rank staticmethod ¶
_get_data_parallel_rank(
raw_request: Request | None,
) -> int | None
Pulls the data parallel rank from a header, if provided
Source code in vllm/entrypoints/openai/engine/serving.py
_get_message_types ¶
Retrieve the set of types from message content dicts up until _; we use this to match potential multimodal data with default per modality loras.
Source code in vllm/entrypoints/openai/engine/serving.py
_pipeline async ¶
_pipeline(
ctx: ServeContext,
) -> AsyncGenerator[AnyResponse | ErrorResponse, None]
Execute the request processing pipeline yielding responses.
Source code in vllm/entrypoints/openai/engine/serving.py
_prepare_extra_chat_template_kwargs staticmethod ¶
_prepare_extra_chat_template_kwargs(
request_chat_template_kwargs: dict[str, Any]
| None = None,
default_chat_template_kwargs: dict[str, Any]
| None = None,
) -> dict[str, Any]
Helper to merge server-default and request-specific chat template kwargs.
Source code in vllm/entrypoints/openai/engine/serving.py
_prepare_generators async ¶
Schedule the request and get the result generator.
Source code in vllm/entrypoints/openai/engine/serving.py
_preprocess async ¶
Default preprocessing hook. Subclasses may override to prepare ctx (classification, embedding, etc.).
_raise_if_error ¶
Raise GenerationError if finish_reason indicates an error.
Source code in vllm/entrypoints/openai/engine/serving.py
OpenAIServingModels ¶
Shared instance to hold data about the loaded base model(s) and adapters.
Handles the routes: - /v1/models - /v1/load_lora_adapter - /v1/unload_lora_adapter
Source code in vllm/entrypoints/openai/models/serving.py
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 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 | |
init_static_loras async ¶
Loads all static LoRA modules. Raises if any fail to load
Source code in vllm/entrypoints/openai/models/serving.py
model_name ¶
model_name(lora_request: LoRARequest | None = None) -> str
Returns the appropriate model name depending on the availability and support of the LoRA or base model. Parameters: - lora: LoRARequest that contain a base_model_name. Returns: - str: The name of the base model or the first available model path.
Source code in vllm/entrypoints/openai/models/serving.py
resolve_lora async ¶
resolve_lora(lora_name: str) -> LoRARequest | ErrorResponse
Attempt to resolve a LoRA adapter using available resolvers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lora_name | str | Name/identifier of the LoRA adapter | required |
Returns:
| Type | Description |
|---|---|
LoRARequest | ErrorResponse | LoRARequest if found and loaded successfully. |
LoRARequest | ErrorResponse | ErrorResponse (404) if no resolver finds the adapter. |
LoRARequest | ErrorResponse | ErrorResponse (400) if adapter(s) are found but none load. |
Source code in vllm/entrypoints/openai/models/serving.py
show_available_models async ¶
Show available models. This includes the base model and all adapters
Source code in vllm/entrypoints/openai/models/serving.py
OpenAISpeechToText ¶
Bases: OpenAIServing
Base class for speech-to-text operations like transcription and translation.
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | |
_create_speech_to_text async ¶
_create_speech_to_text(
audio_data: bytes,
request: SpeechToTextRequest,
raw_request: Request,
response_class: type[ResponseType],
stream_generator_method: Callable[
..., AsyncGenerator[str, None]
],
) -> T | V | AsyncGenerator[str, None] | ErrorResponse
Base method for speech-to-text operations like transcription and translation.
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
_find_split_point ¶
Find the best point to split audio by looking for silence or low amplitude. Args: wav: Audio tensor [1, T] start_idx: Start index of search region end_idx: End index of search region Returns: Index of best splitting point
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
_get_verbose_segments ¶
_get_verbose_segments(
tokens: tuple,
log_probs: FlatLogprobs | list[dict[int, Logprob]],
request: SpeechToTextRequest,
segment_class: type[SpeechToTextSegment],
start_time: float = 0,
) -> list[SpeechToTextSegment]
Convert tokens to verbose segments.
This method expects the model to produce timestamps as tokens (similar to Whisper). If the tokens do not include timestamp information, the segments may not be generated correctly.
Note: No_speech_prob field is not supported in this implementation and will be None. See docs for details.
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
_warmup_audio_preprocessing ¶
Warm up audio processing libraries to avoid first-request latency.
The first call to librosa functions (load, get_duration, mel-spectrogram) triggers JIT compilation and library initialization which can take ~7s. This method warms up these operations during server initialization.
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
_warmup_input_processor ¶
Warm up input processor with dummy audio to avoid first-request latency.
The first call to input_processor.process_inputs() with multimodal audio triggers multimodal processing initialization which can take ~2.5s. This method processes a dummy audio request to warm up the pipeline.
Source code in vllm/entrypoints/openai/speech_to_text/speech_to_text.py
PlaceholderModule ¶
Bases: _PlaceholderBase
A placeholder object to use when a module does not exist.
This enables more informative errors when trying to access attributes of a module that does not exist.
Source code in vllm/utils/import_utils.py
RequestOutput ¶
The output data of a completion request to the LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id | str | The unique ID of the request. | required |
prompt | str | None | The prompt string of the request. For encoder/decoder models, this is the decoder input prompt. | required |
prompt_token_ids | list[int] | None | The token IDs of the prompt. For encoder/decoder models, this is the decoder input prompt token ids. | required |
prompt_logprobs | PromptLogprobs | None | The log probabilities to return per prompt token. | required |
outputs | list[CompletionOutput] | The output sequences of the request. | required |
finished | bool | Whether the whole request is finished. | required |
metrics | RequestStateStats | None | Metrics associated with the request. | None |
lora_request | LoRARequest | None | The LoRA request that was used to generate the output. | None |
encoder_prompt | str | None | The encoder prompt string of the request. None if decoder-only. | None |
encoder_prompt_token_ids | list[int] | None | The token IDs of the encoder prompt. None if decoder-only. | None |
num_cached_tokens | int | None | The number of tokens with prefix cache hit. | None |
kv_transfer_params | dict[str, Any] | None | The params for remote K/V transfer. | None |
Source code in vllm/outputs.py
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 | |
add ¶
add(next_output: RequestOutput, aggregate: bool) -> None
Merge subsequent RequestOutput into this one
Source code in vllm/outputs.py
SupportsTranscription ¶
Bases: Protocol
The interface required for all models that support transcription.
Source code in vllm/model_executor/models/interfaces.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | |
supports_segment_timestamp class-attribute ¶
supports_segment_timestamp: bool = False
Enables the segment timestamp option for supported models by setting this to True.
supports_transcription_only class-attribute ¶
supports_transcription_only: bool = False
Transcription models can opt out of text generation by setting this to True.
get_generation_prompt classmethod ¶
get_generation_prompt(
audio: ndarray,
stt_config: SpeechToTextConfig,
model_config: ModelConfig,
language: str | None,
task_type: Literal["transcribe", "translate"],
request_prompt: str,
to_language: str | None,
) -> PromptType
Get the prompt for the ASR model. The model has control over the construction, as long as it returns a valid PromptType.
Source code in vllm/model_executor/models/interfaces.py
get_num_audio_tokens classmethod ¶
get_num_audio_tokens(
audio_duration_s: float,
stt_config: SpeechToTextConfig,
model_config: ModelConfig,
) -> int | None
Map from audio duration to number of audio tokens produced by the ASR model, without running a forward pass. This is used for estimating the amount of processing for this audio.
Source code in vllm/model_executor/models/interfaces.py
get_speech_to_text_config classmethod ¶
get_speech_to_text_config(
model_config: ModelConfig,
task_type: Literal["transcribe", "translate"],
) -> SpeechToTextConfig
Get the speech to text config for the ASR model.
post_process_output classmethod ¶
Post-process the raw model output text.
Some ASR models output structured formats (e.g., language tags, special tokens) that need to be stripped before returning to the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | Raw decoded text from the model. | required |
Returns:
| Type | Description |
|---|---|
str | Cleaned transcription text. |
Source code in vllm/model_executor/models/interfaces.py
validate_language classmethod ¶
Ensure the language specified in the transcription request is a valid ISO 639-1 language code. If the request language is valid, but not natively supported by the model, trigger a warning (but not an exception).
Source code in vllm/model_executor/models/interfaces.py
TranscriptionResponse ¶
TranscriptionResponseVerbose ¶
Bases: OpenAIBaseModel
Source code in vllm/entrypoints/openai/speech_to_text/protocol.py
segments class-attribute instance-attribute ¶
segments: list[TranscriptionSegment] | None = None
Segments of the transcribed text and their corresponding details.
words class-attribute instance-attribute ¶
words: list[TranscriptionWord] | None = None
Extracted words and their corresponding timestamps.
TranscriptionSegment ¶
Bases: OpenAIBaseModel
Source code in vllm/entrypoints/openai/speech_to_text/protocol.py
avg_logprob instance-attribute ¶
avg_logprob: float
Average logprob of the segment.
If the value is lower than -1, consider the logprobs failed.
compression_ratio instance-attribute ¶
compression_ratio: float
Compression ratio of the segment.
If the value is greater than 2.4, consider the compression failed.
no_speech_prob class-attribute instance-attribute ¶
no_speech_prob: float | None = None
Probability of no speech in the segment.
If the value is higher than 1.0 and the avg_logprob is below -1, consider this segment silent.
TranslationResponse ¶
TranslationResponseVerbose ¶
Bases: OpenAIBaseModel
Source code in vllm/entrypoints/openai/speech_to_text/protocol.py
segments class-attribute instance-attribute ¶
segments: list[TranslationSegment] | None = None
Segments of the translated text and their corresponding details.
words class-attribute instance-attribute ¶
words: list[TranslationWord] | None = None
Extracted words and their corresponding timestamps.
TranslationSegment ¶
Bases: OpenAIBaseModel
Source code in vllm/entrypoints/openai/speech_to_text/protocol.py
avg_logprob instance-attribute ¶
avg_logprob: float
Average logprob of the segment.
If the value is lower than -1, consider the logprobs failed.
compression_ratio instance-attribute ¶
compression_ratio: float
Compression ratio of the segment.
If the value is greater than 2.4, consider the compression failed.
no_speech_prob class-attribute instance-attribute ¶
no_speech_prob: float | None = None
Probability of no speech in the segment.
If the value is higher than 1.0 and the avg_logprob is below -1, consider this segment silent.
VLLMValidationError ¶
Bases: ValueError
vLLM-specific validation error for request validation failures.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message | str | The error message describing the validation failure. | required |
parameter | str | None | Optional parameter name that failed validation. | None |
value | Any | Optional value that was rejected during validation. | None |
Source code in vllm/exceptions.py
get_tokenizer ¶
get_tokenizer(
tokenizer_name: str | Path,
*args,
tokenizer_cls: type[_T] = TokenizerLike,
trust_remote_code: bool = False,
revision: str | None = None,
download_dir: str | None = None,
**kwargs,
) -> _T
Gets a tokenizer for the given model name via HuggingFace or ModelScope.
Source code in vllm/tokenizers/registry.py
init_logger ¶
init_logger(name: str) -> _VllmLogger
The main purpose of this function is to ensure that loggers are retrieved in such a way that we can be sure the root vllm logger has already been configured.
Source code in vllm/logger.py
parse_enc_dec_prompt ¶
parse_enc_dec_prompt(
prompt: object,
) -> EncoderDecoderDictPrompt
Parse a prompt for an encoder-decoder model and normalize it to a dictionary.