Update README.md
Browse files
README.md
CHANGED
@@ -29,22 +29,32 @@ pip install vllm --pre --extra-index-url https://wheels.vllm.ai/nightly
|
|
29 |
```Py
|
30 |
from vllm import LLM, SamplingParams
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
{"role": "user", "content": "What about solving an 2x + 3 = 7 equation?"},
|
39 |
]
|
40 |
-
|
41 |
-
sampling_params = SamplingParams(
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
```
|
49 |
|
50 |
## Serving
|
|
|
29 |
```Py
|
30 |
from vllm import LLM, SamplingParams
|
31 |
|
32 |
+
# Sample prompts.
|
33 |
+
prompts = [
|
34 |
+
"Hello, my name is",
|
35 |
+
"The president of the United States is",
|
36 |
+
"The capital of France is",
|
37 |
+
"The future of AI is",
|
|
|
38 |
]
|
39 |
+
# Create a sampling params object.
|
40 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
41 |
+
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
# Create an LLM.
|
45 |
+
llm = LLM(model="pytorch/Phi-4-mini-instruct-float8dq")
|
46 |
+
# Generate texts from the prompts.
|
47 |
+
# The output is a list of RequestOutput objects
|
48 |
+
# that contain the prompt, generated text, and other information.
|
49 |
+
outputs = llm.generate(prompts, sampling_params)
|
50 |
+
# Print the outputs.
|
51 |
+
print("\nGenerated Outputs:\n" + "-" * 60)
|
52 |
+
for output in outputs:
|
53 |
+
prompt = output.prompt
|
54 |
+
generated_text = output.outputs[0].text
|
55 |
+
print(f"Prompt: {prompt!r}")
|
56 |
+
print(f"Output: {generated_text!r}")
|
57 |
+
print("-" * 60)
|
58 |
```
|
59 |
|
60 |
## Serving
|