class_docstr: Wrapper around the BigDL-LLM Transformer-INT4 model in Transformer.pipeline()
  
  Example:
      .. code-block:: python
  
          from langchain.llms import TransformersPipelineLLM
          llm = TransformersPipelineLLM.from_model_id(model_id="decapoda-research/llama-7b-hf")
class_docstr_tok: ["Wrapper","around","the","BigDL-LLM","Transformer-INT4","model","in","Transformer.pipeline","(",")","Example",":","..","code-block",":",":","python","from","langchain.llms","import","TransformersPipelineLLM","llm","=","TransformersPipelineLLM.from_model_id","(","model_id=","''","decapoda-research\/llama-7b-hf","''",")"]
docstr: Construct the pipeline object from model_id and task.
docstr_tok: ["Construct","the","pipeline","object","from","model_id","and","task","."]
code: def from_model_id(
      cls,
      model_id: str,
      task: str,
      model_kwargs: Optional[dict] = None,
      pipeline_kwargs: Optional[dict] = None,
      **kwargs: Any,
  ) -> LLM:
      """Construct the pipeline object from model_id and task."""
      try:
          from bigdl.llm.transformers import (
              AutoModel,
              AutoModelForCausalLM,
              # AutoModelForSeq2SeqLM,
          )
          from transformers import AutoTokenizer, LlamaTokenizer
          from transformers import pipeline as hf_pipeline
  
      except ImportError:
          raise ValueError(
              "Could not import transformers python package. "
              "Please install it with `pip install transformers`."
          )
  
      _model_kwargs = model_kwargs or {}
      # TODO: may refactore this code in the future
      try:
          tokenizer = AutoTokenizer.from_pretrained(
              model_id, **_model_kwargs
          )
      except:
          tokenizer = LlamaTokenizer.from_pretrained(
              model_id, **_model_kwargs
          )
  
      try:
          if task == "text-generation":
              model = AutoModelForCausalLM.from_pretrained(
                  model_id, load_in_4bit=True, **_model_kwargs
              )
          elif task in ("text2text-generation", "summarization"):
              # TODO: support this when related PR merged
              model = AutoModelForSeq2SeqLM.from_pretrained(
                  model_id, load_in_4bit=True, **_model_kwargs
              )
          else:
              raise ValueError(
                  f"Got invalid task {task}, "
                  f"currently only {VALID_TASKS} are supported"
              )
      except ImportError as e:
          raise ValueError(
              f"Could not load the {task} model due to missing dependencies."
          ) from e
  
      if "trust_remote_code" in _model_kwargs:
          _model_kwargs = {
              k: v
              for k, v in _model_kwargs.items()
              if k != "trust_remote_code"
          }
      _pipeline_kwargs = pipeline_kwargs or {}
      pipeline = hf_pipeline(
          task=task,
          model=model,
          tokenizer=tokenizer,
          device="cpu",  # only cpu now
          model_kwargs=_model_kwargs,
          **_pipeline_kwargs,
      )
      if pipeline.task not in VALID_TASKS:
          raise ValueError(
              f"Got invalid task {pipeline.task}, "
              f"currently only {VALID_TASKS} are supported"
          )
      return cls(
          pipeline=pipeline,
          model_id=model_id,
          model_kwargs=_model_kwargs,
          pipeline_kwargs=_pipeline_kwargs,
          **kwargs,
      )
  
file_path: BigDL/python/llm/src/bigdl/llm/langchain/llms/transformerspipelinellm.py
imports: import importlib.util
  import logging
  from typing import Any, List, Mapping, Optional
  from pydantic import Extra
  from langchain.callbacks.manager import CallbackManagerForLLMRun
  from langchain.llms.base import LLM
  from langchain.llms.utils import enforce_stop_tokens
label_desc: Use image node_id 1 for calling the TransformersPipelineLLM obj's underlying member method code with example usage: obj.from_model_id(cls, model_id, task, model_kwargs, pipeline_kwargs) and returns: cls