You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importargparseimportdataclassesimportsglangassglfromsglang.srt.server_argsimportServerArgsdefmain(
server_args: ServerArgs,
):
# Sample prompts.prompts= [
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
# Create a sampling params object.sampling_params= {"temperature": 0.8, "top_p": 0.95}
# Create an LLM.llm=sgl.Engine(**dataclasses.asdict(server_args))
outputs=llm.generate(prompts, sampling_params)
# Print the outputs.forprompt, outputinzip(prompts, outputs):
print("===============================")
print(f"Prompt: {prompt}\nGenerated text: {output['text']}")
# The __main__ condition is necessary here because we use "spawn" to create subprocesses# Spawn starts a fresh program every time, if there is no __main__, it will run into infinite loop to keep spawning processes from sgl.Engineif__name__=="__main__":
parser=argparse.ArgumentParser()
ServerArgs.add_cli_args(parser)
args=parser.parse_args()
server_args=ServerArgs.from_cli_args(args)
main(server_args)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The following code provided in https://github.com/sgl-project/sglang/blob/main/examples/runtime/engine/offline_batch_inference.py doesn't have progress bar during LLM generation, how can I add it?
Beta Was this translation helpful? Give feedback.
All reactions