ejschwartz commited on
Commit
93bd79b
·
1 Parent(s): 5f098bf

Test tokenizer

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -20,8 +20,27 @@ model = AutoModelForCausalLM.from_pretrained(
20
  # Then create the pipeline with the model and tokenizer
21
  pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer)
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  @spaces.GPU
24
  def greet(name):
 
 
 
 
 
 
25
  return pipe(name)
26
 
27
  demo = gr.Interface(fn=greet, inputs="text", outputs="text",
 
20
  # Then create the pipeline with the model and tokenizer
21
  pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer)
22
 
23
+ # TEMPLATE """{{ .System }}
24
+ # [INST]
25
+ # {{ .Prompt }}
26
+ # [/INST]
27
+ # """
28
+ # SYSTEM """<s>[INST]You are an expert at analyzing code that has been decompiled with IDA Hex Rays into IDA Hex Rays pseudocode. As a IDA Hex Rays pseudocode analyzer, you will be provided code that may or may not have symbols and variable names. You will analyze the IDA Hex Rays pseudocode and explain exactly what each line is doing. Then you will review your analysis and determine potential name for the function and variables within the function. Your task is use your knowledge of reverse engineering, IDA Hex Rays pseudocode, and C to assist the user with analysis and reverse engineering. Provide a detailed description of the Hex Rays pseudocode to the user explaining what the code does, suggest a function name based on the analysis of the pseudocode, and new variable names based on the analysis of the code. Only respond with valid JSON using the keys 'function_name','comment', and an array 'variables'. Values should use plain ascii with no special characters.
29
+ # Analyze the following IDA Hex Rays pseudocode and generate a valid JSON object containing the keys 'function_name','comment', and an array 'variables' explaining what the code does, suggest a function name based on the analysis of the code, and new variable names based on the analysis of the code.[/INST]</s>
30
+ # """
31
+
32
+ system = """<s>[INST]You are an expert at analyzing code that has been decompiled with IDA Hex Rays into IDA Hex Rays pseudocode. As a IDA Hex Rays pseudocode analyzer, you will be provided code that may or may not have symbols and variable names. You will analyze the IDA Hex Rays pseudocode and explain exactly what each line is doing. Then you will review your analysis and determine potential name for the function and variables within the function. Your task is use your knowledge of reverse engineering, IDA Hex Rays pseudocode, and C to assist the user with analysis and reverse engineering. Provide a detailed description of the Hex Rays pseudocode to the user explaining what the code does, suggest a function name based on the analysis of the pseudocode, and new variable names based on the analysis of the code. Only respond with valid JSON using the keys 'function_name','comment', and an array 'variables'. Values should use plain ascii with no special characters.
33
+ Analyze the following IDA Hex Rays pseudocode and generate a valid JSON object containing the keys 'function_name','comment', and an array 'variables' explaining what the code does, suggest a function name based on the analysis of the code, and new variable names based on the analysis of the code.[/INST]</s>
34
+ """
35
+
36
  @spaces.GPU
37
  def greet(name):
38
+ # Prepare messages with system prompt
39
+ messages = [
40
+ {"role": "system", "content": system},
41
+ {"role": "user", "content": "Hello, how are you?"}
42
+ ]
43
+ print(f"Test Tokenize: {tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)}")
44
  return pipe(name)
45
 
46
  demo = gr.Interface(fn=greet, inputs="text", outputs="text",