-
Notifications
You must be signed in to change notification settings - Fork 9
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
Smol world (ADV-163) #3
Conversation
def instruct_prompt(question, functions, tokenizer): | ||
messages = [ | ||
{"role": "user", "content": SYSTEM_PROMPT_FOR_CHAT_MODEL.format(functions=format_functions(functions))}, | ||
{"role": "assistant", "content": ASSISTANT_PROMPT_FOR_CHAT_MODEL }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of injecting a first assistant response. Does that improve the subsequent generations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like most prompt engineering things I feel like it does improve outcomes, but hard to say without proper evaluations. Right now it's definitely in the AI-superstition category.
"items": {"type": "float"} | ||
}) | ||
|
||
def build_standard_fc_regex(function_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind documenting these functions? I opened an issue on Outlines to provide an interface for multi-functions function calling and we will probably use this code as a first draft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
Just a few minor comments, otherwise this is looking great! |
@@ -0,0 +1,3 @@ | |||
outlines==0.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outlines==0.1.0 | |
outlines==0.1.1 |
Might be able to go up to 0.1.1
def format_functions(functions): | ||
formatted_functions = [] | ||
for func in functions: | ||
function_info = f"{func['name']}: {func['description']}\n" | ||
if 'parameters' in func and 'properties' in func['parameters']: | ||
for arg, details in func['parameters']['properties'].items(): | ||
description = details.get('description', 'No description provided') | ||
function_info += f"- {arg}: {description}\n" | ||
formatted_functions.append(function_info) | ||
return "\n".join(formatted_functions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def format_functions(functions): | |
formatted_functions = [] | |
for func in functions: | |
function_info = f"{func['name']}: {func['description']}\n" | |
if 'parameters' in func and 'properties' in func['parameters']: | |
for arg, details in func['parameters']['properties'].items(): | |
description = details.get('description', 'No description provided') | |
function_info += f"- {arg}: {description}\n" | |
formatted_functions.append(function_info) | |
return "\n".join(formatted_functions) | |
def format_functions(functions): | |
""" | |
Formats the functions in the given list of functions into a list | |
of human-readable strings. | |
Example output: | |
[ | |
'send_text: Send a text message to a contact | |
- to: The name of the contact to send the text to. | |
- message: The message to send to the contact.', | |
'send_email: Send an email to a contact | |
- to: The name of the contact to send the email to. | |
- subject: The subject of the email. | |
- message: The message to send to the contact.' | |
] | |
""" | |
formatted_functions = [] | |
for func in functions: | |
function_info = f"{func['name']}: {func['description']}\n" | |
if 'parameters' in func and 'properties' in func['parameters']: | |
for arg, details in func['parameters']['properties'].items(): | |
description = details.get('description', 'No description provided') | |
function_info += f"- {arg}: {description}\n" | |
formatted_functions.append(function_info) | |
return "\n".join(formatted_functions) |
Possible comment string
This is the basic implementation of a demo of the HF SMoL model being used as a NL interface for calling applications. The current supported functions are:
The user is prompted to ask a question and the model should translate this into a function call (which could presumable be mapped to a real application in the future).