File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
examples/offline_inference Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 19
19
print (outputs [0 ].outputs [0 ].text )
20
20
21
21
# Guided decoding by Regex
22
- guided_decoding_params = GuidedDecodingParams (regex = "\w+@\w+\.com\n " )
22
+ guided_decoding_params = GuidedDecodingParams (regex = r "\w+@\w+\.com\n" )
23
23
sampling_params = SamplingParams (guided_decoding = guided_decoding_params ,
24
24
stop = ["\n " ])
25
25
prompt = ("Generate an email address for Alan Turing, who works in Enigma."
@@ -57,17 +57,12 @@ class CarDescription(BaseModel):
57
57
58
58
# Guided decoding by Grammar
59
59
simplified_sql_grammar = """
60
- ?start: select_statement
61
-
62
- ?select_statement: "SELECT " column_list " FROM " table_name
63
-
64
- ?column_list: column_name ("," column_name)*
65
-
66
- ?table_name: identifier
67
-
68
- ?column_name: identifier
69
-
70
- ?identifier: /[a-zA-Z_][a-zA-Z0-9_]*/
60
+ root ::= select_statement
61
+ select_statement ::= "SELECT " column " from " table " where " condition
62
+ column ::= "col_1 " | "col_2 "
63
+ table ::= "table_1 " | "table_2 "
64
+ condition ::= column "= " number
65
+ number ::= "1 " | "2 "
71
66
"""
72
67
guided_decoding_params = GuidedDecodingParams (grammar = simplified_sql_grammar )
73
68
sampling_params = SamplingParams (guided_decoding = guided_decoding_params )
You can’t perform that action at this time.
0 commit comments