class_docstr: An LLM for generating texts from given prompts and sampling parameters.
  
  This class includes a tokenizer, a language model (possibly distributed
  across multiple GPUs), and GPU memory space allocated for intermediate
  states (aka KV cache). Given a batch of prompts and sampling parameters,
  this class generates texts from the model, using an intelligent batching
  mechanism and efficient memory management.
  
  NOTE: This class is intended to be used for offline inference. For online
  serving, use the `AsyncLLMEngine` class instead.
  NOTE: For the comprehensive list of arguments, see `EngineArgs`.
  
  Args:
      model: The name or path of a HuggingFace Transformers model.
      tokenizer: The name or path of a HuggingFace Transformers tokenizer.
      tokenizer_mode: The tokenizer mode. "auto" will use the fast tokenizer
          if available, and "slow" will always use the slow tokenizer.
      trust_remote_code: Trust remote code (e.g., from HuggingFace) when
          downloading the model and tokenizer.
      tensor_parallel_size: The number of GPUs to use for distributed
          execution with tensor parallelism.
      dtype: The data type for the model weights and activations. Currently,
          we support `float32`, `float16`, and `bfloat16`. If `auto`, we use
          the `torch_dtype` attribute specified in the model config file.
          However, if the `torch_dtype` in the config is `float32`, we will
          use `float16` instead.
      quantization: The method used to quantize the model weights. Currently,
          we support "awq". If None, we assume the model weights are not
          quantized and use `dtype` to determine the data type of the weights.
      revision: The specific model version to use. It can be a branch name,
          a tag name, or a commit id.
      tokenizer_revision: The specific tokenizer version to use. It can be a
          branch name, a tag name, or a commit id.
      seed: The seed to initialize the random number generator for sampling.
      gpu_memory_utilization: The ratio (between 0 and 1) of GPU memory to
          reserve for the model weights, activations, and KV cache. Higher
          values will increase the KV cache size and thus improve the model's
          throughput. However, if the value is too high, it may cause out-of-
          memory (OOM) errors.
      swap_space: The size (GiB) of CPU memory per GPU to use as swap space.
          This can be used for temporarily storing the states of the requests
          when their `best_of` sampling parameters are larger than 1. If all
          requests will have `best_of=1`, you can safely set this to 0.
          Otherwise, too small values may cause out-of-memory (OOM) errors.
      device: The device to be used for the model. If None, we will default
          to use CPU as the device.
class_docstr_tok: ["An","LLM","for","generating","texts","from","given","prompts","and","sampling","parameters",".","This","class","includes","a","tokenizer",",","a","language","model","(","possibly","distributed","across","multiple","GPUs",")",",","and","GPU","memory","space","allocated","for","intermediate","states","(","aka","KV","cache",")",".","Given","a","batch","of","prompts","and","sampling","parameters",",","this","class","generates","texts","from","the","model",",","using","an","intelligent","batching","mechanism","and","efficient","memory","management",".","NOTE",":","This","class","is","intended","to","be","used","for","offline","inference",".","For","online","serving",",","use","the","`","AsyncLLMEngine","`","class","instead",".","NOTE",":","For","the","comprehensive","list","of","arguments",",","see","`","EngineArgs","`",".","Args",":","model",":","The","name","or","path","of","a","HuggingFace","Transformers","model",".","tokenizer",":","The","name","or","path","of","a","HuggingFace","Transformers","tokenizer",".","tokenizer_mode",":","The","tokenizer","mode",".","``","auto","''","will","use","the","fast","tokenizer","if","available",",","and","``","slow","''","will","always","use","the","slow","tokenizer",".","trust_remote_code",":","Trust","remote","code","(","e.g.",",","from","HuggingFace",")","when","downloading","the","model","and","tokenizer",".","tensor_parallel_size",":","The","number","of","GPUs","to","use","for","distributed","execution","with","tensor","parallelism",".","dtype",":","The","data","type","for","the","model","weights","and","activations",".","Currently",",","we","support","`","float32","`",",","`","float16","`",",","and","`","bfloat16","`",".","If","`","auto","`",",","we","use","the","`","torch_dtype","`","attribute","specified","in","the","model","config","file",".","However",",","if","the","`","torch_dtype","`","in","the","config","is","`","float32","`",",","we","will","use","`","float16","`","instead",".","quantization",":","The","method","used","to","quantize","the","model","weights",".","Currently",",","we","support","``","awq","''",".","If","None",",","we","assume","the","model","weights","are","not","quantized","and","use","`","dtype","`","to","determine","the","data","type","of","the","weights",".","revision",":","The","specific","model","version","to","use",".","It","can","be","a","branch","name",",","a","tag","name",",","or","a","commit","id",".","tokenizer_revision",":","The","specific","tokenizer","version","to","use",".","It","can","be","a","branch","name",",","a","tag","name",",","or","a","commit","id",".","seed",":","The","seed","to","initialize","the","random","number","generator","for","sampling",".","gpu_memory_utilization",":","The","ratio","(","between","0","and","1",")","of","GPU","memory","to","reserve","for","the","model","weights",",","activations",",","and","KV","cache",".","Higher","values","will","increase","the","KV","cache","size","and","thus","improve","the","model's","throughput",".","However",",","if","the","value","is","too","high",",","it","may","cause","out-of-","memory","(","OOM",")","errors",".","swap_space",":","The","size","(","GiB",")","of","CPU","memory","per","GPU","to","use","as","swap","space",".","This","can","be","used","for","temporarily","storing","the","states","of","the","requests","when","their","`","best_of","`","sampling","parameters","are","larger","than","1",".","If","all","requests","will","have","`","best_of=1","`",",","you","can","safely","set","this","to","0",".","Otherwise",",","too","small","values","may","cause","out-of-memory","(","OOM",")","errors",".","device",":","The","device","to","be","used","for","the","model",".","If","None",",","we","will","default","to","use","CPU","as","the","device","."]
docstr: Generates the completions for the input prompts.
  
  NOTE: 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: A list of prompts to generate completions for.
      sampling_params: The sampling parameters for text generation. If
          None, we use the default sampling parameters.
      prompt_token_ids: A list of token IDs for the prompts. If None, we
          use the tokenizer to convert the prompts to token IDs.
      use_tqdm: Whether to use tqdm to display the progress bar.
  
  Returns:
      A list of `RequestOutput` objects containing the generated
      completions in the same order as the input prompts.
docstr_tok: ["Generates","the","completions","for","the","input","prompts",".","NOTE",":","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",":","A","list","of","prompts","to","generate","completions","for",".","sampling_params",":","The","sampling","parameters","for","text","generation",".","If","None",",","we","use","the","default","sampling","parameters",".","prompt_token_ids",":","A","list","of","token","IDs","for","the","prompts",".","If","None",",","we","use","the","tokenizer","to","convert","the","prompts","to","token","IDs",".","use_tqdm",":","Whether","to","use","tqdm","to","display","the","progress","bar",".","Returns",":","A","list","of","`","RequestOutput","`","objects","containing","the","generated","completions","in","the","same","order","as","the","input","prompts","."]
code: def generate(
      self,
      prompts: Optional[Union[str, List[str]]] = None,
      sampling_params: Optional[SamplingParams] = None,
      prompt_token_ids: Optional[List[List[int]]] = None,
      use_tqdm: bool = True,
  ) -> List[RequestOutput]:
      """Generates the completions for the input prompts.
  
      NOTE: 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: A list of prompts to generate completions for.
          sampling_params: The sampling parameters for text generation. If
              None, we use the default sampling parameters.
          prompt_token_ids: A list of token IDs for the prompts. If None, we
              use the tokenizer to convert the prompts to token IDs.
          use_tqdm: Whether to use tqdm to display the progress bar.
  
      Returns:
          A list of `RequestOutput` objects containing the generated
          completions in the same order as the input prompts.
      """
      if prompts is None and prompt_token_ids is None:
          raise ValueError(
              "Either prompts or prompt_token_ids must be " "provided."
          )  # noqa
      if isinstance(prompts, str):
          # Convert a single prompt to a list.
          prompts = [prompts]
      if prompts is not None and prompt_token_ids is not None:
          if len(prompts) != len(prompt_token_ids):
              raise ValueError(  # noqa
                  "The lengths of prompts and prompt_token_ids "
                  "must be the same."
              )
      if sampling_params is None:
          # Use default sampling params.
          sampling_params = SamplingParams()
  
      # Add requests to the engine.
      if prompts is not None:
          num_requests = len(prompts)
      else:
          num_requests = len(prompt_token_ids)
      for i in range(num_requests):
          prompt = prompts[i] if prompts is not None else None
          if prompt_token_ids is None:
              token_ids = None
          else:
              token_ids = prompt_token_ids[i]
          self._add_request(prompt, sampling_params, token_ids)
      return self._run_engine(use_tqdm)
  
file_path: BigDL/python/llm/src/bigdl/llm/vllm/entrypoints/llm.py
imports: from typing import List, Optional, Union
  from tqdm import tqdm
  from transformers import PreTrainedTokenizer, PreTrainedTokenizerFast
  from bigdl.llm.vllm.engine.arg_utils import EngineArgs
  from bigdl.llm.vllm.engine.llm_engine import LLMEngine
  from bigdl.llm.vllm.outputs import RequestOutput
  from bigdl.llm.vllm.sampling_params import SamplingParams
  from bigdl.llm.vllm.utils import Counter
label_desc: Use image node_id 4 for calling the LLM obj's underlying member method code with example usage: obj.generate(prompts, sampling_params, prompt_token_ids, use_tqdm) and returns: self