class_docstr: Wrapper around bigdl-llm transformers embedding models.
  
  To use, you should have the ``transformers`` python package installed.
  
  Example:
      .. code-block:: python
  
          from bigdl.llm.langchain.embeddings import TransformersEmbeddings
          embeddings = TransformersEmbeddings.from_model_id(model_id)
class_docstr_tok: ["Wrapper","around","bigdl-llm","transformers","embedding","models",".","To","use",",","you","should","have","the","``","transformers","``","python","package","installed",".","Example",":","..","code-block",":",":","python","from","bigdl.llm.langchain.embeddings","import","TransformersEmbeddings","embeddings","=","TransformersEmbeddings.from_model_id","(","model_id",")"]
docstr: Compute doc embeddings using a HuggingFace transformer model.
  
  Args:
      texts: The list of texts to embed.
  
  Returns:
      List of embeddings, one for each text.
docstr_tok: ["Compute","doc","embeddings","using","a","HuggingFace","transformer","model",".","Args",":","texts",":","The","list","of","texts","to","embed",".","Returns",":","List","of","embeddings",",","one","for","each","text","."]
code: def embed(self, text: str):
      """Compute doc embeddings using a HuggingFace transformer model.
  
      Args:
          texts: The list of texts to embed.
  
      Returns:
          List of embeddings, one for each text.
      """
      input_ids = self.tokenizer.encode(
          text, return_tensors="pt"
      )  # shape: [1, T]
      embeddings = self.model(input_ids, return_dict=False)[
          0
      ]  # shape: [1, T, N]
      embeddings = embeddings.squeeze(0).detach().numpy()
      embeddings = np.mean(embeddings, axis=0)
      return embeddings
  
file_path: BigDL/python/llm/src/bigdl/llm/langchain/embeddings/transformersembeddings.py
imports: from typing import Any, Dict, List, Optional
  import numpy
  from pydantic import BaseModel, Extra, Field
  from langchain.embeddings.base import Embeddings
label_desc: Use image node_id 2 for calling the TransformersEmbeddings obj's underlying member method code with example usage: obj.embed(text) and returns: embeddings