langchain.md 780 Bytes
Newer Older
raojy's avatar
raojy committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# LangChain

vLLM is also available via [LangChain](https://github.com/langchain-ai/langchain) .

To install LangChain, run

```bash
pip install langchain langchain_community -q
```

To run inference on a single or multiple GPUs, use `VLLM` class from `langchain`.

??? code

    ```python
    from langchain_community.llms import VLLM

    llm = VLLM(
        model="Qwen/Qwen3-4B",
        trust_remote_code=True,  # mandatory for hf models
        max_new_tokens=128,
        top_k=10,
        top_p=0.95,
        temperature=0.8,
        # for distributed inference
        # tensor_parallel_size=...,
    )

    print(llm("What is the capital of France ?"))
    ```

Please refer to this [Tutorial](https://python.langchain.com/docs/integrations/llms/vllm) for more details.