ForcePilot/scripts/vllm/main.py

21 lines
551 B
Python
Raw Normal View History

2024-10-08 22:16:17 +08:00
from vllm import LLM, SamplingParams
llm = LLM(model="/hdd/zwj/models/meta-llama/Meta-Llama-3-8B-Instruct")
prompts = [
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
outputs = llm.generate(prompts, sampling_params)
# Print the outputs.
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
2025-05-24 11:29:45 +08:00
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")