nehcgs commited on
Commit
ec35b1c
·
verified ·
1 Parent(s): 601b224

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -4
README.md CHANGED
@@ -49,17 +49,20 @@ import json
49
  from typing import Any, Dict, List
50
  from transformers import AutoModelForCausalLM, AutoTokenizer
51
 
 
52
  model_name = "katanemo/Arch-Agent-7B"
 
53
  model = AutoModelForCausalLM.from_pretrained(
54
  model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True
55
  )
56
  tokenizer = AutoTokenizer.from_pretrained(model_name)
57
 
58
- # Please use our provided prompt for best performance
 
59
  TASK_PROMPT = (
60
  "You are a helpful assistant designed to assist with the user query by making one or more function calls if needed."
61
  "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\n"
62
- "You are provided with function signatures within <tools></tools> XML tags:\n<tools>{tool_text}"
63
  "\n</tools>\n\nFor each function call, return a json object with function name and arguments within "
64
  """<tool_call></tool_call> XML tags:\n<tool_call>\n{{"name": <function-name>, """
65
  """"arguments": <args-json-object>}}\n</tool_call>"""
@@ -107,12 +110,12 @@ messages = [
107
  {"role": "user", "content": "What is the weather in Seattle?"},
108
  ]
109
 
 
110
  model_inputs = tokenizer.apply_chat_template(
111
- messages, add_generation_prompt=True, return_tensors="pt"
112
  ).to(model.device)
113
 
114
  generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
115
-
116
  generated_ids = [
117
  output_ids[len(input_ids) :]
118
  for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
 
49
  from typing import Any, Dict, List
50
  from transformers import AutoModelForCausalLM, AutoTokenizer
51
 
52
+ # Specify the desired model name here
53
  model_name = "katanemo/Arch-Agent-7B"
54
+
55
  model = AutoModelForCausalLM.from_pretrained(
56
  model_name, device_map="auto", torch_dtype="auto", trust_remote_code=True
57
  )
58
  tokenizer = AutoTokenizer.from_pretrained(model_name)
59
 
60
+
61
+ # Please use the recommended prompt for each model.
62
  TASK_PROMPT = (
63
  "You are a helpful assistant designed to assist with the user query by making one or more function calls if needed."
64
  "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\n"
65
+ "You are provided with function signatures within <tools></tools> XML tags:\n<tools>\n{tool_text}"
66
  "\n</tools>\n\nFor each function call, return a json object with function name and arguments within "
67
  """<tool_call></tool_call> XML tags:\n<tool_call>\n{{"name": <function-name>, """
68
  """"arguments": <args-json-object>}}\n</tool_call>"""
 
110
  {"role": "user", "content": "What is the weather in Seattle?"},
111
  ]
112
 
113
+ #### 2.2.3 Run inference
114
  model_inputs = tokenizer.apply_chat_template(
115
+ messages, add_generation_prompt=True, return_tensors="pt", return_dict=True
116
  ).to(model.device)
117
 
118
  generated_ids = model.generate(**model_inputs, max_new_tokens=32768)
 
119
  generated_ids = [
120
  output_ids[len(input_ids) :]
121
  for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)