Skip to content

Commit fa2333a

Browse files
authored
Add basic example (#85)
Signed-off-by: gc-fu <guancheng.fu@intel.com>
1 parent 0dbec1b commit fa2333a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

vllm/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ CMD ["bash", "-c", "source /root/.bashrc && exec bash"]
110110
# ======== OpenAI Serving Stage ========
111111
FROM vllm-base AS vllm-openai
112112

113+
COPY ./examples/offline_inference.py /llm/
114+
113115
ARG http_proxy
114116
ARG https_proxy
115117

vllm/examples/offline_inference.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3+
4+
from vllm import LLM, SamplingParams
5+
6+
# Sample prompts.
7+
prompts = [
8+
"Hello, my name is",
9+
"The president of the United States is",
10+
"The capital of France is",
11+
"The future of AI is",
12+
]
13+
# Create a sampling params object.
14+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
15+
16+
17+
def main():
18+
# Create an LLM.
19+
llm = LLM(model="MODEL_PATH")
20+
# Generate texts from the prompts.
21+
# The output is a list of RequestOutput objects
22+
# that contain the prompt, generated text, and other information.
23+
outputs = llm.generate(prompts, sampling_params)
24+
# Print the outputs.
25+
print("\nGenerated Outputs:\n" + "-" * 60)
26+
for output in outputs:
27+
prompt = output.prompt
28+
generated_text = output.outputs[0].text
29+
print(f"Prompt: {prompt!r}")
30+
print(f"Output: {generated_text!r}")
31+
print("-" * 60)
32+
33+
34+
if __name__ == "__main__":
35+
main()

0 commit comments

Comments
 (0)