[Docs] optimize and supplement docs system (#86)
Signed-off-by: Gaohan123 <gaohan19@huawei.com>
This commit is contained in:
1 parent
38f58064eb
commit
db81ee9f69
75 files changed
+2452
-512
No files matched your search
@@ -11,6 +11,17 @@ from vllm.inputs.data import EmbedsPrompt, TokenInputs, TokensPrompt
|
||||
|
||||
|
||||
class OmniTokensPrompt(TokensPrompt):
|
||||
"""Tokens prompt with optional embeddings and additional information.
|
||||
|
||||
Extends TokensPrompt to support prompt embeddings and additional
|
||||
information payloads for direct transfer between pipeline stages.
|
||||
|
||||
Attributes:
|
||||
prompt_embeds: Optional tensor containing prompt embeddings
|
||||
additional_information: Optional dictionary containing additional
|
||||
information (tensors or lists) to pass along with the prompt
|
||||
"""
|
||||
|
||||
prompt_embeds: NotRequired[torch.Tensor]
|
||||
"""The embeddings of the prompt."""
|
||||
|
||||
@@ -20,6 +31,18 @@ class OmniTokensPrompt(TokensPrompt):
|
||||
|
||||
|
||||
class OmniTokenInputs(TokenInputs):
|
||||
"""Token inputs with optional embeddings and additional information.
|
||||
|
||||
Extends TokenInputs to support prompt embeddings and additional
|
||||
information payloads for direct transfer between pipeline stages.
|
||||
|
||||
Attributes:
|
||||
prompt_embeds: Optional tensor containing prompt embeddings
|
||||
aligned with token IDs
|
||||
additional_information: Optional dictionary containing additional
|
||||
information (tensors or lists) to pass along with the inputs
|
||||
"""
|
||||
|
||||
# New: optional prompt embeddings aligned with token ids
|
||||
prompt_embeds: NotRequired[torch.Tensor]
|
||||
|
||||
@@ -29,6 +52,17 @@ class OmniTokenInputs(TokenInputs):
|
||||
|
||||
|
||||
class OmniEmbedsPrompt(EmbedsPrompt):
|
||||
"""Embeddings prompt with optional additional information.
|
||||
|
||||
Extends EmbedsPrompt to support additional information payloads
|
||||
for direct transfer between pipeline stages.
|
||||
|
||||
Attributes:
|
||||
prompt_embeds: Optional tensor containing prompt embeddings
|
||||
additional_information: Optional dictionary containing additional
|
||||
information (tensors or lists) to pass along with the prompt
|
||||
"""
|
||||
|
||||
# New: optional prompt embeddings aligned with token ids
|
||||
prompt_embeds: NotRequired[torch.Tensor]
|
||||
|
||||
@@ -44,7 +78,22 @@ def token_inputs_omni(
|
||||
prompt_embeds: Optional[torch.Tensor] = None,
|
||||
additional_information: Optional[dict[str, Any]] = None,
|
||||
) -> OmniTokenInputs:
|
||||
"""Construct token inputs with optional embeddings and metadata."""
|
||||
"""Construct token inputs with optional embeddings and metadata.
|
||||
|
||||
Creates an OmniTokenInputs object with token IDs and optional
|
||||
embeddings and additional information for pipeline stage transfer.
|
||||
|
||||
Args:
|
||||
prompt_token_ids: List of token IDs for the prompt
|
||||
prompt: Optional prompt string
|
||||
cache_salt: Optional cache salt for prefix caching
|
||||
prompt_embeds: Optional tensor containing prompt embeddings
|
||||
additional_information: Optional dictionary containing additional
|
||||
information (tensors or lists)
|
||||
|
||||
Returns:
|
||||
OmniTokenInputs instance with the provided data
|
||||
"""
|
||||
inputs = OmniTokenInputs(type="token", prompt_token_ids=prompt_token_ids)
|
||||
|
||||
if prompt is not None:
|
||||
|
||||
@@ -9,6 +9,23 @@ from vllm.inputs.parse import (
|
||||
|
||||
|
||||
def parse_singleton_prompt_omni(prompt: SingletonPrompt) -> ParsedSingletonPrompt:
|
||||
"""Parse a singleton prompt into a typed parsed prompt.
|
||||
|
||||
Handles omni-specific prompt types including tokens prompts with
|
||||
embeddings and additional information. Supports string, text,
|
||||
tokens, and embeddings prompts.
|
||||
|
||||
Args:
|
||||
prompt: Singleton prompt to parse. Can be a string, TextPrompt,
|
||||
TokensPrompt (with optional prompt_embeds and additional_information),
|
||||
or EmbedsPrompt.
|
||||
|
||||
Returns:
|
||||
ParsedSingletonPrompt containing the parsed prompt with type information
|
||||
|
||||
Raises:
|
||||
TypeError: If the prompt type is not supported
|
||||
"""
|
||||
if isinstance(prompt, str):
|
||||
return ParsedStrPrompt(type="str", content=prompt)
|
||||
elif isinstance(prompt, dict):
|
||||
|
||||
@@ -13,6 +13,13 @@ logger = init_logger(__name__)
|
||||
|
||||
|
||||
class OmniInputPreprocessor(InputPreprocessor):
|
||||
"""Input preprocessor for omni models.
|
||||
|
||||
Extends the base InputPreprocessor to handle omni-specific input
|
||||
types including prompt embeddings and additional information payloads.
|
||||
Supports processing tokens, embeddings, text, and multimodal inputs.
|
||||
"""
|
||||
|
||||
def _process_tokens(
|
||||
self,
|
||||
parsed_content: TokensPrompt,
|
||||
|
||||
Reference in new issue
Block a user