forked from sgl-project/sglang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add offline engine launch example and documentation (sgl-projec…
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
This example demonstrates how to launch the offline engine. | ||
""" | ||
|
||
import sglang as sgl | ||
|
||
|
||
def main(): | ||
llm = sgl.Engine(model_path="meta-llama/Meta-Llama-3.1-8B-Instruct") | ||
llm.generate("What is the capital of France?") | ||
llm.shutdown() | ||
|
||
|
||
# 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.Engine | ||
if __name__ == "__main__": | ||
main() |