"...git@developer.sourcefind.cn:2222/OpenDAS/vllm_cscc.git" did not exist on "d0feea31c70f9540a8993c4e96103a03cd935416"
Unverified Commit 2755c34a authored by Russell Bryant's avatar Russell Bryant Committed by GitHub
Browse files

[V1] Update structured output offline inference example (#15721)


Signed-off-by: default avatarRussell Bryant <rbryant@redhat.com>
parent db104221
...@@ -19,7 +19,7 @@ outputs = llm.generate( ...@@ -19,7 +19,7 @@ outputs = llm.generate(
print(outputs[0].outputs[0].text) print(outputs[0].outputs[0].text)
# Guided decoding by Regex # Guided decoding by Regex
guided_decoding_params = GuidedDecodingParams(regex="\w+@\w+\.com\n") guided_decoding_params = GuidedDecodingParams(regex=r"\w+@\w+\.com\n")
sampling_params = SamplingParams(guided_decoding=guided_decoding_params, sampling_params = SamplingParams(guided_decoding=guided_decoding_params,
stop=["\n"]) stop=["\n"])
prompt = ("Generate an email address for Alan Turing, who works in Enigma." prompt = ("Generate an email address for Alan Turing, who works in Enigma."
...@@ -57,17 +57,12 @@ print(outputs[0].outputs[0].text) ...@@ -57,17 +57,12 @@ print(outputs[0].outputs[0].text)
# Guided decoding by Grammar # Guided decoding by Grammar
simplified_sql_grammar = """ simplified_sql_grammar = """
?start: select_statement root ::= select_statement
select_statement ::= "SELECT " column " from " table " where " condition
?select_statement: "SELECT " column_list " FROM " table_name column ::= "col_1 " | "col_2 "
table ::= "table_1 " | "table_2 "
?column_list: column_name ("," column_name)* condition ::= column "= " number
number ::= "1 " | "2 "
?table_name: identifier
?column_name: identifier
?identifier: /[a-zA-Z_][a-zA-Z0-9_]*/
""" """
guided_decoding_params = GuidedDecodingParams(grammar=simplified_sql_grammar) guided_decoding_params = GuidedDecodingParams(grammar=simplified_sql_grammar)
sampling_params = SamplingParams(guided_decoding=guided_decoding_params) sampling_params = SamplingParams(guided_decoding=guided_decoding_params)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment