MCPcopy Create free account
hub / github.com/Tencent/digitalhuman / classify

Method classify

RLVER/code/llm.py:1005–1043  ·  view source on GitHub ↗

Generate class logits for each prompt. This class automatically batches the given prompts, considering the memory constraint. For the best performance, put all of your prompts into a single list and pass it to this method. Args: prompts: The pro

(
        self,
        prompts: Union[PromptType, Sequence[PromptType]],
        /,
        *,
        use_tqdm: bool = True,
        lora_request: Optional[Union[list[LoRARequest], LoRARequest]] = None,
        prompt_adapter_request: Optional[PromptAdapterRequest] = None,
    )

Source from the content-addressed store, hash-verified

1003 return [EmbeddingRequestOutput.from_base(item) for item in items]
1004
1005 def classify(
1006 self,
1007 prompts: Union[PromptType, Sequence[PromptType]],
1008 /,
1009 *,
1010 use_tqdm: bool = True,
1011 lora_request: Optional[Union[list[LoRARequest], LoRARequest]] = None,
1012 prompt_adapter_request: Optional[PromptAdapterRequest] = None,
1013 ) -> list[ClassificationRequestOutput]:
1014 """
1015 Generate class logits for each prompt.
1016
1017 This class automatically batches the given prompts, considering
1018 the memory constraint. For the best performance, put all of your prompts
1019 into a single list and pass it to this method.
1020
1021 Args:
1022 prompts: The prompts to the LLM. You may pass a sequence of prompts
1023 for batch inference. See :class:`~vllm.inputs.PromptType`
1024 for more details about the format of each prompts.
1025 use_tqdm: Whether to use tqdm to display the progress bar.
1026 lora_request: LoRA request to use for generation, if any.
1027 prompt_adapter_request: Prompt Adapter request to use for
1028 generation, if any.
1029
1030 Returns:
1031 A list of ``ClassificationRequestOutput`` objects containing the
1032 embedding vectors in the same order as the input prompts.
1033 """
1034 if self.llm_engine.model_config.task != "classify":
1035 raise ValueError(
1036 "Classification API is only enabled for `--task classify`")
1037
1038 items = self.encode(prompts,
1039 use_tqdm=use_tqdm,
1040 lora_request=lora_request,
1041 prompt_adapter_request=prompt_adapter_request)
1042
1043 return [ClassificationRequestOutput.from_base(item) for item in items]
1044
1045 def _embedding_score(
1046 self,

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.95

Tested by

no test coverage detected