serving_with_langchain.rst 888 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
.. _run_on_langchain:

Serving with Langchain
============================

vLLM is also available via `Langchain <https://github.com/langchain-ai/langchain>`_ .

To install langchain, run

.. code-block:: console

12
    $ pip install langchain langchain_community -q
13
14
15
16
17

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

.. code-block:: python

18
    from langchain_community.llms import VLLM
19
20
21
22
23
24
25
26
27
28
29
30

    llm = VLLM(model="mosaicml/mpt-7b",
               trust_remote_code=True,  # mandatory for hf models
               max_new_tokens=128,
               top_k=10,
               top_p=0.95,
               temperature=0.8,
               # tensor_parallel_size=... # for distributed inference
    )

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

31
Please refer to this `Tutorial <https://python.langchain.com/docs/integrations/llms/vllm>`_ for more details.