# HuggingFaceTextGenInference

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/llms/huggingface_text_gen_inference/HuggingFaceTextGenInference)

HuggingFace text generation API.
! This class is deprecated, you should use HuggingFaceEndpoint instead !

To use, you should have the `text-generation` python package installed and
a text-generation server running.

## Signature

```python
HuggingFaceTextGenInference()
```

## Description

**Example:**

.. code-block:: python

# Basic Example (no streaming)
llm = HuggingFaceTextGenInference(
    inference_server_url="http://localhost:8010/",
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.01,
    repetition_penalty=1.03,
)
print(llm.invoke("What is Deep Learning?"))  # noqa: T201

# Streaming response example
from langchain_community.callbacks import streaming_stdout

callbacks = [streaming_stdout.StreamingStdOutCallbackHandler()]
llm = HuggingFaceTextGenInference(
    inference_server_url="http://localhost:8010/",
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.01,
    repetition_penalty=1.03,
    callbacks=callbacks,
    streaming=True
)
print(llm.invoke("What is Deep Learning?"))  # noqa: T201

## Extends

- `LLM`

## Properties

- `max_new_tokens`
- `top_k`
- `top_p`
- `typical_p`
- `temperature`
- `repetition_penalty`
- `return_full_text`
- `truncate`
- `stop_sequences`
- `seed`
- `inference_server_url`
- `timeout`
- `streaming`
- `do_sample`
- `watermark`
- `server_kwargs`
- `model_kwargs`
- `client`
- `async_client`
- `model_config`

## Methods

- [`build_extra()`](https://reference.langchain.com/python/langchain-community/llms/huggingface_text_gen_inference/HuggingFaceTextGenInference/build_extra)
- [`validate_environment()`](https://reference.langchain.com/python/langchain-community/llms/huggingface_text_gen_inference/HuggingFaceTextGenInference/validate_environment)

## ⚠️ Deprecated

Deprecated since version 0.0.21. Will be removed in version 1.0.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/llms/huggingface_text_gen_inference.py#L17)