"vllm/vscode:/vscode.git/clone" did not exist on "d9e00dbd1fcf9e4b6b0b42a228d7bb26175cbba4"
langchain.md 780 Bytes
Newer Older
1
# LangChain
2

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

5
To install LangChain, run
6

7
```bash
8
pip install langchain langchain_community -q
9
10
11
12
```

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

13
??? code
14
15
16
17

    ```python
    from langchain_community.llms import VLLM

18
    llm = VLLM(
19
        model="Qwen/Qwen3-4B",
20
21
22
23
24
25
26
        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=...,
27
28
29
30
    )

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

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