Skip to content

Commit

Permalink
Add starcoder template support
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 9, 2024
1 parent 6d0b8e3 commit bfa0851
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions r2ai/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def messages_to_prompt(self, messages):
formatted_messages = template_q4im(self, messages)
elif "gemma" in lowermodel:
formatted_messages = template_gemma(self, messages)
elif "starcoder" in lowermodel:
formatted_messages = template_starcoder(self, messages)
elif "openchat" in lowermodel:
formatted_messages = template_openchat(self, messages)
elif "ferret" in lowermodel:
Expand Down Expand Up @@ -281,6 +283,28 @@ def template_phi3(self,messages):
q += f"<|assistant|>\n"
return q

def template_starcoder(self,messages):
self.terminator = "<|im_end|>"
self.terminator = "##"
system_prompt = self.system_message # messages[0]['content'].strip()
if system_prompt != "":
q = f"<|system|>\n{system_prompt}</s>\n"
else:
q = f""
for index, item in enumerate(messages):
role = item['role']
content = item['content']
if role == 'user':
q += f"## Question\n{content}"
elif role == "hint":
q += f"knowledge: {content}\n"
elif role == 'function':
q += f"## Question\n{content} "
elif role == 'assistant' and self.env["chat.reply"] == "true":
q += f"## Solution\n{content}\n"
q += f"## Solution\n"
return q

def template_zephyr(self,messages):
#<|system|>
#{system_message}</s>
Expand Down

0 comments on commit bfa0851

Please sign in to comment.