Skip to content

Commit

Permalink
Add support for phi3-mini-4k from Microsoft
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed May 9, 2024
1 parent 66e72b0 commit 38fbf45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions r2ai/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ def messages_to_prompt(self, messages):
formatted_messages = template_zephyr(self, messages)
elif "dolphin" in lowermodel:
formatted_messages = template_ferret(self, messages)
elif "Phi" in lowermodel:
formatted_messages = template_phi3(self, messages)
elif "coder" in lowermodel:
formatted_messages = template_alpaca(self, messages)
elif "deepseek" in lowermodel:
Expand Down Expand Up @@ -256,6 +258,27 @@ def template_falcon(self,messages):
formatted_messages += f"{message['role'].capitalize()}: {message['content']}"
return formatted_messages.strip()

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

def template_zephyr(self,messages):
#<|system|>
#{system_message}</s>
Expand Down
1 change: 1 addition & 0 deletions r2ai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def models():
-m bartowski/stable-code-instruct-3b-GGUF
-m cognitivecomputations/dolphin-2.9-llama3-8b-gguf
-m mlabonne/gemma-7b-it-GGUF
-m microsoft/Phi-3-mini-4k-instruct-gguf
Uncensored:
-m TheBloke/Dawn-v2-70B-GGUF
-m TheBloke/Guanaco-7B-Uncensored-GGUF
Expand Down

0 comments on commit 38fbf45

Please sign in to comment.