-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update docs for llama3.1 and bump up version
- Loading branch information
Showing
15 changed files
with
503 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,138 @@ | ||
.. _examples: | ||
|
||
Examples | ||
======== | ||
======== | ||
|
||
You can use ScaleLLM for offline batch completions or online inference. Below are some examples to help you get started. More examples can be found in the `examples <https://github.com/vectorch-ai/ScaleLLM/tree/main/examples>`_ folder. | ||
|
||
Chat Completion | ||
--------------- | ||
|
||
Start the REST API server with the following command: | ||
|
||
.. code-block:: bash | ||
$ python3 -m scalellm.serve.api_server --model=meta-llama/Meta-Llama-3.1-8B-Instruct | ||
You can query the chat completions using `curl` or the OpenAI client: | ||
|
||
.. tabs:: | ||
|
||
.. group-tab:: curl | ||
|
||
.. code-block:: bash | ||
$ curl http://localhost:8080/v1/chat/completions \ | ||
-H "Content-Type: application/json" \ | ||
-d '{ | ||
"model": "meta-llama/Meta-Llama-3.1-8B-Instruct", | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "You are a helpful assistant." | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "Hello!" | ||
} | ||
] | ||
}' | ||
.. group-tab:: openai | ||
|
||
.. code-block:: python | ||
import openai | ||
client = openai.Client( | ||
base_url="http://localhost:8080/v1", | ||
api_key="EMPTY", | ||
) | ||
# List available models | ||
models = client.models.list() | ||
print("==== Available models ====") | ||
for model in models.data: | ||
print(model.id) | ||
# Choose the first model | ||
model = models.data[0].id | ||
stream = client.chat.completions.create( | ||
model=model, | ||
messages=[ | ||
{"role": "system", "content": "You are a helpful assistant."}, | ||
{"role": "user", "content": "Hello"}, | ||
], | ||
stream=True, | ||
) | ||
print(f"==== Model: {model} ====") | ||
for chunk in stream: | ||
choice = chunk.choices[0] | ||
delta = choice.delta | ||
if delta.content: | ||
print(delta.content, end="") | ||
print() | ||
Completions | ||
----------- | ||
|
||
Start the REST API server with the following command: | ||
|
||
.. code-block:: bash | ||
$ python3 -m scalellm.serve.api_server --model=meta-llama/Meta-Llama-3.1-8B | ||
You can query the completions using `curl` or the OpenAI client: | ||
|
||
.. tabs:: | ||
|
||
.. group-tab:: curl | ||
|
||
.. code-block:: bash | ||
$ curl http://localhost:8080/v1/completions \ | ||
-H "Content-Type: application/json" \ | ||
-d '{ | ||
"model": "meta-llama/Meta-Llama-3-8B", | ||
"prompt": "hello", | ||
"max_tokens": 32, | ||
"temperature": 0.7, | ||
"stream": true | ||
}' | ||
.. group-tab:: openai | ||
|
||
.. code-block:: python | ||
import openai | ||
client = openai.Client( | ||
base_url="http://localhost:8080/v1", | ||
api_key="EMPTY", | ||
) | ||
# List available models | ||
models = client.models.list() | ||
print("==== Available models ====") | ||
for model in models.data: | ||
print(model.id) | ||
# Choose the first model | ||
model = models.data[0].id | ||
stream = client.completions.create( | ||
model=model, | ||
prompt="hello", | ||
max_tokens=32, | ||
temperature=0.7, | ||
stream=True, | ||
) | ||
print(f"==== Model: {model} ====") | ||
for chunk in stream: | ||
choice = chunk.choices[0] | ||
if choice.text: | ||
print(choice.text, end="") | ||
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,90 @@ | ||
.. _quick_start: | ||
|
||
Quick Start | ||
=========== | ||
This section will guide you through the process of setting up a simple project... | ||
|
||
Installation | ||
------------ | ||
|
||
Install with pip | ||
~~~~~~~~~~~~~~~~ | ||
ScaleLLM is available as a Python Wheel package on `PyPI <https://pypi.org/project/scalellm/>`_. You can install it using pip: | ||
|
||
.. code-block:: bash | ||
# Install ScaleLLM with CUDA 12.1 and PyTorch 2.3 | ||
$ pip install scalellm | ||
Install other versions | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
If you want to install ScaleLLM with different versions of CUDA and PyTorch, you can use pip by providing the index URL of the desired version. | ||
|
||
.. tabs:: | ||
|
||
.. tab:: CUDA 12.1 | ||
|
||
.. tabs:: | ||
|
||
.. tab:: PyTorch 2.3 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu121/torch2.3/ | ||
.. tab:: PyTorch 2.2 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu121/torch2.2/ | ||
.. tab:: PyTorch 2.1 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu121/torch2.1/ | ||
.. tab:: CUDA 11.8 | ||
|
||
.. tabs:: | ||
|
||
.. tab:: PyTorch 2.3 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu118/torch2.3/ | ||
.. tab:: PyTorch 2.2 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu118/torch2.2/ | ||
.. tab:: PyTorch 2.1 | ||
|
||
.. code-block:: bash | ||
$ pip install scalellm -i https://whl.vectorch.com/cu118/torch2.1/ | ||
Build from source | ||
~~~~~~~~~~~~~~~~~ | ||
If no wheel package is available for your configuration, you can build ScaleLLM from source code. Clone the repository and install it locally using the following commands: | ||
|
||
.. code-block:: bash | ||
$ git clone --recursive https://github.com/vectorch-ai/ScaleLLM.git | ||
$ cd ScaleLLM | ||
$ python3 setup.py bdist_wheel | ||
$ pip install dist/scalellm-*.whl | ||
Inference | ||
------- | ||
|
||
You can use ScaleLLM for offline batch inference or online distributed inference. | ||
|
||
OpenAI-Compatible Server | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
To start a server that is compatible with the OpenAI API, run the following command: | ||
|
||
.. code-block:: bash | ||
$ python3 -m scalellm.serve.api_server --model=meta-llama/Meta-Llama-3.1-8B-Instruct |
Oops, something went wrong.