Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OpenOrca's prompt format. (& other ChatML local model) #572

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions guidance/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# local models
from .transformers._transformers import Transformers, TransformersChat
from .llama_cpp import LlamaCpp, LlamaCppChat, MistralInstruct, MistralChat
from .llama_cpp import LlamaCpp, LlamaCppChat, MistralInstruct, MistralChat, MistralChatOpenOrca
from ._mock import Mock, MockChat

# remote models
Expand All @@ -13,4 +13,4 @@
from ._lite_llm import LiteLLM, LiteLLMChat, LiteLLMInstruct, LiteLLMCompletion
from ._cohere import Cohere,CohereCompletion, CohereInstruct
from ._anthropic import Anthropic, AnthropicChat
from ._googleai import GoogleAI, GoogleAIChat
from ._googleai import GoogleAI, GoogleAIChat
2 changes: 1 addition & 1 deletion guidance/models/llama_cpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from ._llama_cpp import LlamaCpp, LlamaCppChat
from ._mistral import MistralChat, MistralInstruct
from ._mistral import MistralChat, MistralInstruct , MistralChatOpenOrca
19 changes: 17 additions & 2 deletions guidance/models/llama_cpp/_mistral.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .._model import Chat, Instruct
from ._llama_cpp import LlamaCpp
from ._llama_cpp import LlamaCpp , LlamaCppChat

class MistralChat(LlamaCpp, Chat):
def get_role_start(self, role_name, **kwargs):
Expand Down Expand Up @@ -27,4 +27,19 @@ def get_role_start(self, role_name, **kwargs):

def get_role_end(self, role_name=None):
if role_name == "instruction":
return " [/INST]"
return " [/INST]"


class MistralChatOpenOrca(LlamaCppChat, Chat):
def get_role_start(self, role_name, **kwargs):
if role_name == "user":
return "<|im_start|>user\n"

elif role_name == "assistant":
return "<|im_start|>assistant\n"

elif role_name == "system":
return "<|im_start|>system\n"

def get_role_end(self, role_name=None):
return "<|im_end|>\n"