HuggingFaceLLM

pydantic model llama_index.llms.huggingface.HuggingFaceLLM

HuggingFace LLM.

Show JSON schema
{
   "title": "HuggingFaceLLM",
   "description": "HuggingFace LLM.",
   "type": "object",
   "properties": {
      "callback_manager": {
         "title": "Callback Manager"
      },
      "model_name": {
         "title": "Model Name",
         "description": "The model name to use from HuggingFace. Unused if `model` is passed in directly.",
         "type": "string"
      },
      "context_window": {
         "title": "Context Window",
         "description": "The maximum number of tokens available for input.",
         "type": "integer"
      },
      "max_new_tokens": {
         "title": "Max New Tokens",
         "description": "The maximum number of tokens to generate.",
         "type": "integer"
      },
      "system_prompt": {
         "title": "System Prompt",
         "description": "The system prompt, containing any extra instructions or context. The model card on HuggingFace should specify if this is needed.",
         "type": "string"
      },
      "query_wrapper_prompt": {
         "title": "Query Wrapper Prompt",
         "description": "The query wrapper prompt, containing the query placeholder. The model card on HuggingFace should specify if this is needed. Should contain a `{query_str}` placeholder.",
         "type": "string"
      },
      "tokenizer_name": {
         "title": "Tokenizer Name",
         "description": "The name of the tokenizer to use from HuggingFace. Unused if `tokenizer` is passed in directly.",
         "type": "string"
      },
      "device_map": {
         "title": "Device Map",
         "description": "The device_map to use. Defaults to 'auto'.",
         "type": "string"
      },
      "stopping_ids": {
         "title": "Stopping Ids",
         "description": "The stopping ids to use. Generation stops when these token IDs are predicted.",
         "type": "array",
         "items": {
            "type": "integer"
         }
      },
      "tokenizer_outputs_to_remove": {
         "title": "Tokenizer Outputs To Remove",
         "description": "The outputs to remove from the tokenizer. Sometimes huggingface tokenizers return extra inputs that cause errors.",
         "type": "array",
         "items": {}
      },
      "tokenizer_kwargs": {
         "title": "Tokenizer Kwargs",
         "description": "The kwargs to pass to the tokenizer.",
         "type": "object"
      },
      "model_kwargs": {
         "title": "Model Kwargs",
         "description": "The kwargs to pass to the model during initialization.",
         "type": "object"
      },
      "generate_kwargs": {
         "title": "Generate Kwargs",
         "description": "The kwargs to pass to the model during generation.",
         "type": "object"
      }
   },
   "required": [
      "model_name",
      "context_window",
      "max_new_tokens",
      "system_prompt",
      "query_wrapper_prompt",
      "tokenizer_name",
      "device_map"
   ]
}

Config
  • arbitrary_types_allowed: bool = True

Fields
Validators
  • _validate_callback_manager Β» callback_manager

field context_window: int [Required]

The maximum number of tokens available for input.

field device_map: str [Required]

The device_map to use. Defaults to β€˜auto’.

field generate_kwargs: dict [Optional]

The kwargs to pass to the model during generation.

field max_new_tokens: int [Required]

The maximum number of tokens to generate.

field model_kwargs: dict [Optional]

The kwargs to pass to the model during initialization.

field model_name: str [Required]

The model name to use from HuggingFace. Unused if model is passed in directly.

field query_wrapper_prompt: str [Required]

The query wrapper prompt, containing the query placeholder. The model card on HuggingFace should specify if this is needed. Should contain a {query_str} placeholder.

field stopping_ids: List[int] [Optional]

The stopping ids to use. Generation stops when these token IDs are predicted.

field system_prompt: str [Required]

The system prompt, containing any extra instructions or context. The model card on HuggingFace should specify if this is needed.

field tokenizer_kwargs: dict [Optional]

The kwargs to pass to the tokenizer.

field tokenizer_name: str [Required]

The name of the tokenizer to use from HuggingFace. Unused if tokenizer is passed in directly.

field tokenizer_outputs_to_remove: list [Optional]

The outputs to remove from the tokenizer. Sometimes huggingface tokenizers return extra inputs that cause errors.

classmethod class_name() str

Get the class name, used as a unique ID in serialization.

This provides a key that makes serialization robust against actual class name changes.

complete(*args: Any, **kwargs: Any) Any

Completion endpoint for LLM.

stream_complete(*args: Any, **kwargs: Any) Any

Streaming completion endpoint for LLM.

property metadata: LLMMetadata

LLM metadata.