updated registry to fix conflict

pull/1077/head
Katia Gil Guzman 3 months ago
commit 81570a8360

@ -83,7 +83,7 @@
"1. **Data Type Check**: Checks whether each entry in the dataset is a dictionary (`dict`). Error type: `data_type`.\n",
"2. **Presence of Message List**: Checks if a `messages` list is present in each entry. Error type: `missing_messages_list`.\n",
"3. **Message Keys Check**: Validates that each message in the `messages` list contains the keys `role` and `content`. Error type: `message_missing_key`.\n",
"4. **Unrecognized Keys in Messages**: Logs if a message has keys other than `role`, `content`, and `name`. Error type: `message_unrecognized_key`.\n",
"4. **Unrecognized Keys in Messages**: Logs if a message has keys other than `role`, `content`, `weight`, `function_call`, and `name`. Error type: `message_unrecognized_key`.\n",
"5. **Role Validation**: Ensures the `role` is one of \"system\", \"user\", or \"assistant\". Error type: `unrecognized_role`.\n",
"6. **Content Validation**: Verifies that `content` has textual data and is a string. Error type: `missing_content`.\n",
"7. **Assistant Message Presence**: Checks that each conversation has at least one message from the assistant. Error type: `example_missing_assistant_message`.\n",
@ -123,7 +123,7 @@
" if \"role\" not in message or \"content\" not in message:\n",
" format_errors[\"message_missing_key\"] += 1\n",
" \n",
" if any(k not in (\"role\", \"content\", \"name\", \"function_call\") for k in message):\n",
" if any(k not in (\"role\", \"content\", \"name\", \"function_call\", \"weight\") for k in message):\n",
" format_errors[\"message_unrecognized_key\"] += 1\n",
" \n",
" if message.get(\"role\", None) not in (\"system\", \"user\", \"assistant\", \"function\"):\n",

@ -114,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -125,6 +125,7 @@
" temperature=1.0,\n",
" stop=None,\n",
" tools=None,\n",
" functions=None\n",
") -> str:\n",
" params = {\n",
" 'model': model,\n",
@ -134,6 +135,8 @@
" 'stop': stop,\n",
" 'tools': tools,\n",
" }\n",
" if functions:\n",
" params['functions'] = functions\n",
"\n",
" completion = client.chat.completions.create(**params)\n",
" return completion.choices[0].message\n"
@ -181,279 +184,240 @@
"source": [
"function_list = [\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"takeoff_drone\",\n",
" \"description\": \"Initiate the drone's takeoff sequence.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"altitude\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Specifies the altitude in meters to which the drone should ascend.\",\n",
" }\n",
" },\n",
" \"required\": [\"altitude\"],\n",
" \"name\": \"takeoff_drone\",\n",
" \"description\": \"Initiate the drone's takeoff sequence.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"altitude\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Specifies the altitude in meters to which the drone should ascend.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"altitude\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"land_drone\",\n",
" \"description\": \"Land the drone at its current location or a specified landing point.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"location\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"current\", \"home_base\", \"custom\"],\n",
" \"description\": \"Specifies the landing location for the drone.\",\n",
" },\n",
" \"coordinates\": {\n",
" \"type\": \"object\",\n",
" \"description\": \"GPS coordinates for custom landing location. Required if location is 'custom'.\",\n",
" },\n",
" \"name\": \"land_drone\",\n",
" \"description\": \"Land the drone at its current location or a specified landing point.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"location\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"current\", \"home_base\", \"custom\"],\n",
" \"description\": \"Specifies the landing location for the drone.\"\n",
" },\n",
" \"required\": [\"location\"],\n",
" \"coordinates\": {\n",
" \"type\": \"object\",\n",
" \"description\": \"GPS coordinates for custom landing location. Required if location is 'custom'.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"location\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"control_drone_movement\",\n",
" \"description\": \"Direct the drone's movement in a specific direction.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"direction\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"forward\", \"backward\", \"left\", \"right\", \"up\", \"down\"],\n",
" \"description\": \"Direction in which the drone should move.\",\n",
" },\n",
" \"distance\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Distance in meters the drone should travel in the specified direction.\",\n",
" },\n",
" \"name\": \"control_drone_movement\",\n",
" \"description\": \"Direct the drone's movement in a specific direction.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"direction\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"forward\", \"backward\", \"left\", \"right\", \"up\", \"down\"],\n",
" \"description\": \"Direction in which the drone should move.\"\n",
" },\n",
" \"required\": [\"direction\", \"distance\"],\n",
" \"distance\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Distance in meters the drone should travel in the specified direction.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"direction\", \"distance\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_drone_speed\",\n",
" \"description\": \"Adjust the speed of the drone.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"speed\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Specifies the speed in km/h.\",\n",
" }\n",
" },\n",
" \"required\": [\"speed\"],\n",
" \"name\": \"set_drone_speed\",\n",
" \"description\": \"Adjust the speed of the drone.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"speed\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Specifies the speed in km/h.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"speed\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"control_camera\",\n",
" \"description\": \"Control the drone's camera to capture images or videos.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"photo\", \"video\", \"panorama\"],\n",
" \"description\": \"Camera mode to capture content.\",\n",
" },\n",
" \"duration\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Duration in seconds for video capture. Required if mode is 'video'.\",\n",
" },\n",
" \"name\": \"control_camera\",\n",
" \"description\": \"Control the drone's camera to capture images or videos.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"photo\", \"video\", \"panorama\"],\n",
" \"description\": \"Camera mode to capture content.\"\n",
" },\n",
" \"required\": [\"mode\"],\n",
" \"duration\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Duration in seconds for video capture. Required if mode is 'video'.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"mode\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"control_gimbal\",\n",
" \"description\": \"Adjust the drone's gimbal for camera stabilization and direction.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"tilt\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Tilt angle for the gimbal in degrees.\",\n",
" },\n",
" \"pan\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Pan angle for the gimbal in degrees.\",\n",
" },\n",
" \"name\": \"control_gimbal\",\n",
" \"description\": \"Adjust the drone's gimbal for camera stabilization and direction.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"tilt\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Tilt angle for the gimbal in degrees.\"\n",
" },\n",
" \"required\": [\"tilt\", \"pan\"],\n",
" \"pan\": {\n",
" \"type\": \"integer\",\n",
" \"description\": \"Pan angle for the gimbal in degrees.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"tilt\", \"pan\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_drone_lighting\",\n",
" \"description\": \"Control the drone's lighting for visibility and signaling.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\", \"blink\", \"sos\"],\n",
" \"description\": \"Lighting mode for the drone.\",\n",
" }\n",
" },\n",
" \"required\": [\"mode\"],\n",
" \"name\": \"set_drone_lighting\",\n",
" \"description\": \"Control the drone's lighting for visibility and signaling.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\", \"blink\", \"sos\"],\n",
" \"description\": \"Lighting mode for the drone.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"mode\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"return_to_home\",\n",
" \"description\": \"Command the drone to return to its home or launch location.\",\n",
" \"parameters\": {\"type\": \"object\", \"properties\": {}},\n",
" },\n",
" \"name\": \"return_to_home\",\n",
" \"description\": \"Command the drone to return to its home or launch location.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {}\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_battery_saver_mode\",\n",
" \"description\": \"Toggle battery saver mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle battery saver mode.\",\n",
" }\n",
" },\n",
" \"required\": [\"status\"],\n",
" \"name\": \"set_battery_saver_mode\",\n",
" \"description\": \"Toggle battery saver mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle battery saver mode.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"status\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_obstacle_avoidance\",\n",
" \"description\": \"Configure obstacle avoidance settings.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle obstacle avoidance.\",\n",
" }\n",
" },\n",
" \"required\": [\"mode\"],\n",
" \"name\": \"set_obstacle_avoidance\",\n",
" \"description\": \"Configure obstacle avoidance settings.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"mode\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle obstacle avoidance.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"mode\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_follow_me_mode\",\n",
" \"description\": \"Enable or disable 'follow me' mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle 'follow me' mode.\",\n",
" }\n",
" },\n",
" \"required\": [\"status\"],\n",
" \"name\": \"set_follow_me_mode\",\n",
" \"description\": \"Enable or disable 'follow me' mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle 'follow me' mode.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"status\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"calibrate_sensors\",\n",
" \"description\": \"Initiate calibration sequence for drone's sensors.\",\n",
" \"parameters\": {\"type\": \"object\", \"properties\": {}},\n",
" },\n",
" \"name\": \"calibrate_sensors\",\n",
" \"description\": \"Initiate calibration sequence for drone's sensors.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {}\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_autopilot\",\n",
" \"description\": \"Enable or disable autopilot mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle autopilot mode.\",\n",
" }\n",
" },\n",
" \"required\": [\"status\"],\n",
" \"name\": \"set_autopilot\",\n",
" \"description\": \"Enable or disable autopilot mode.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"status\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"on\", \"off\"],\n",
" \"description\": \"Toggle autopilot mode.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"status\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"configure_led_display\",\n",
" \"description\": \"Configure the drone's LED display pattern and colors.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"pattern\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"solid\", \"blink\", \"pulse\", \"rainbow\"],\n",
" \"description\": \"Pattern for the LED display.\",\n",
" },\n",
" \"color\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"red\", \"blue\", \"green\", \"yellow\", \"white\"],\n",
" \"description\": \"Color for the LED display. Not required if pattern is 'rainbow'.\",\n",
" },\n",
" \"name\": \"configure_led_display\",\n",
" \"description\": \"Configure the drone's LED display pattern and colors.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"pattern\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"solid\", \"blink\", \"pulse\", \"rainbow\"],\n",
" \"description\": \"Pattern for the LED display.\"\n",
" },\n",
" \"required\": [\"pattern\"],\n",
" \"color\": {\n",
" \"type\": \"string\",\n",
" \"enum\": [\"red\", \"blue\", \"green\", \"yellow\", \"white\"],\n",
" \"description\": \"Color for the LED display. Not required if pattern is 'rainbow'.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"pattern\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"set_home_location\",\n",
" \"description\": \"Set or change the home location for the drone.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"coordinates\": {\n",
" \"type\": \"object\",\n",
" \"description\": \"GPS coordinates for the home location.\",\n",
" }\n",
" },\n",
" \"required\": [\"coordinates\"],\n",
" \"name\": \"set_home_location\",\n",
" \"description\": \"Set or change the home location for the drone.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {\n",
" \"coordinates\": {\n",
" \"type\": \"object\",\n",
" \"description\": \"GPS coordinates for the home location.\"\n",
" }\n",
" },\n",
" },\n",
" \"required\": [\"coordinates\"]\n",
" }\n",
" },\n",
" {\n",
" \"type\": \"function\",\n",
" \"function\": {\n",
" \"name\": \"reject_request\",\n",
" \"description\": \"Use this function if the request is not possible.\",\n",
" \"parameters\": {\"type\": \"object\", \"properties\": {}},\n",
" },\n",
" \"name\": \"reject_request\",\n",
" \"description\": \"Use this function if the request is not possible.\",\n",
" \"parameters\": {\n",
" \"type\": \"object\",\n",
" \"properties\": {}\n",
" }\n",
" },\n",
"]\n"
]
@ -487,16 +451,16 @@
"output_type": "stream",
"text": [
"Land the drone at the home base\n",
"Function(arguments='{\\n \"location\": \"home_base\"\\n}', name='land_drone') \n",
"FunctionCall(arguments='{\\n \"location\": \"home_base\"\\n}', name='land_drone') \n",
"\n",
"Take off the drone to 50 meters\n",
"Function(arguments='{\\n \"altitude\": 50\\n}', name='takeoff_drone') \n",
"FunctionCall(arguments='{\\n \"altitude\": 50\\n}', name='takeoff_drone') \n",
"\n",
"change speed to 15 kilometers per hour\n",
"Function(arguments='{\\n \"speed\": 15\\n}', name='set_drone_speed') \n",
"FunctionCall(arguments='{ \"speed\": 15 }', name='set_drone_speed') \n",
"\n",
"turn into an elephant!\n",
"Function(arguments='{}', name='reject_request') \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n"
]
}
@ -508,7 +472,7 @@
" messages.append({\"role\": \"user\", \"content\": prompt})\n",
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list)\n",
" print(prompt)\n",
" print(completion.tool_calls[0].function,'\\n')\n"
" print(completion.function_call,'\\n')\n"
]
},
{
@ -533,7 +497,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@ -541,28 +505,23 @@
"output_type": "stream",
"text": [
"Play pre-recorded audio message\n",
"Function(arguments='{}', name='reject_request') \n",
"\n",
"FunctionCall(arguments='{}', name='reject_request')\n",
"\n",
"\n",
"Initiate live-streaming on social media\n",
"Function(arguments='{\\n\"mode\": \"video\",\\n\"duration\": 0\\n}', name='control_camera') \n",
"\n",
"FunctionCall(arguments='{\\n \"mode\": \"video\",\\n \"duration\": 0\\n}', name='control_camera')\n",
"\n",
"\n",
"Scan environment for heat signatures\n",
"Function(arguments='{ \"mode\": \"photo\" }', name='control_camera') \n",
"\n",
"FunctionCall(arguments='{\\n \"mode\": \"photo\"\\n}', name='control_camera')\n",
"\n",
"\n",
"Enable stealth mode\n",
"Function(arguments='{\\n \"mode\": \"off\"\\n}', name='set_drone_lighting') \n",
"\n",
"FunctionCall(arguments='{\\n \"mode\": \"off\"\\n}', name='set_drone_lighting')\n",
"\n",
"\n",
"Change drone's paint job color\n",
"Function(arguments='{\\n \"pattern\": \"solid\",\\n \"color\": \"blue\"\\n}', name='configure_led_display') \n",
"\n",
"FunctionCall(arguments='{\\n \"pattern\": \"solid\",\\n \"color\": \"blue\"\\n}', name='configure_led_display')\n",
"\n",
"\n"
]
@ -576,10 +535,10 @@
" completion = get_chat_completion(model=\"gpt-3.5-turbo\",messages=messages,tools=function_list)\n",
" print(prompt)\n",
" try:\n",
" print(completion.tool_calls[0].function,'\\n')\n",
" print(completion.function_call)\n",
" print('\\n')\n",
" except:\n",
" print(completion.tool_calls[0].content,'\\n')\n",
" print(completion.content)\n",
" print('\\n')\n"
]
},
@ -625,7 +584,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@ -645,7 +604,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@ -752,7 +711,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@ -822,7 +781,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@ -830,8 +789,8 @@
"all_but_reject = [f for f in function_list if f.get('name') != 'reject_request']\n",
"\n",
"for function in all_but_reject:\n",
" func_name = function['function']['name']\n",
" params = function['function']['parameters']\n",
" func_name = function[\"name\"]\n",
" params = function[\"parameters\"]\n",
" for arguments in generate_permutations(params):\n",
" if any(val in arguments.values() for val in ['fill_in_int', 'fill_in_str']):\n",
" input_object = {\n",
@ -858,21 +817,22 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def create_commands(invocation_list):\n",
" example_list = []\n",
" for i, invocation in enumerate(invocation_list):\n",
" print(f'\\033[34m{np.round(100*i/len(invocation_list),1)}% complete\\033[0m')\n",
" print(invocation)\n",
" if i<10:\n",
" print(f'\\033[34m{np.round(100*i/len(invocation_list),1)}% complete\\033[0m')\n",
" print(invocation)\n",
"\n",
" # Format the prompt with the invocation string\n",
" request_prompt = COMMAND_GENERATION_PROMPT.format(invocation=invocation)\n",
"\n",
" messages = [{\"role\": \"user\", \"content\": f\"{request_prompt}\"}]\n",
" completion = get_chat_completion(messages,temperature=0.8).content\n",
" completion = get_chat_completion(messages,temperature=0.8)\n",
" command_dict = {\n",
" \"Input\": invocation,\n",
" \"Prompt\": completion\n",
@ -883,7 +843,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -894,121 +854,28 @@
"{'name': 'takeoff_drone', 'arguments': {'altitude': 100}}\n",
"\u001b[34m1.8% complete\u001b[0m\n",
"{'name': 'land_drone', 'arguments': {'location': 'current'}}\n",
"\u001b[34m3.5% complete\u001b[0m\n",
"\u001b[34m3.6% complete\u001b[0m\n",
"{'name': 'land_drone', 'arguments': {'location': 'home_base'}}\n",
"\u001b[34m5.3% complete\u001b[0m\n",
"\u001b[34m5.4% complete\u001b[0m\n",
"{'name': 'land_drone', 'arguments': {'location': 'custom'}}\n",
"\u001b[34m7.0% complete\u001b[0m\n",
"\u001b[34m7.1% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'forward', 'distance': 50}}\n",
"\u001b[34m8.8% complete\u001b[0m\n",
"\u001b[34m8.9% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'backward', 'distance': 10}}\n",
"\u001b[34m10.5% complete\u001b[0m\n",
"\u001b[34m10.7% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'left', 'distance': 10}}\n",
"\u001b[34m12.3% complete\u001b[0m\n",
"\u001b[34m12.5% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'right', 'distance': 10}}\n",
"\u001b[34m14.0% complete\u001b[0m\n",
"\u001b[34m14.3% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'up', 'distance': 20}}\n",
"\u001b[34m15.8% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'down', 'distance': 10}}\n",
"\u001b[34m17.5% complete\u001b[0m\n",
"{'name': 'set_drone_speed', 'arguments': {'speed': 20}}\n",
"\u001b[34m19.3% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'photo'}}\n",
"\u001b[34m21.1% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'photo', 'duration': 0}}\n",
"\u001b[34m22.8% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'video'}}\n",
"\u001b[34m24.6% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'video', 'duration': 60}}\n",
"\u001b[34m26.3% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'panorama'}}\n",
"\u001b[34m28.1% complete\u001b[0m\n",
"{'name': 'control_camera', 'arguments': {'mode': 'panorama', 'duration': 0}}\n",
"\u001b[34m29.8% complete\u001b[0m\n",
"{'name': 'control_gimbal', 'arguments': {'tilt': 45, 'pan': 30}}\n",
"\u001b[34m31.6% complete\u001b[0m\n",
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'on'}}\n",
"\u001b[34m33.3% complete\u001b[0m\n",
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'off'}}\n",
"\u001b[34m35.1% complete\u001b[0m\n",
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'blink'}}\n",
"\u001b[34m36.8% complete\u001b[0m\n",
"{'name': 'set_drone_lighting', 'arguments': {'mode': 'sos'}}\n",
"\u001b[34m38.6% complete\u001b[0m\n",
"{'name': 'return_to_home', 'arguments': {}}\n",
"\u001b[34m40.4% complete\u001b[0m\n",
"{'name': 'set_battery_saver_mode', 'arguments': {'status': 'on'}}\n",
"\u001b[34m42.1% complete\u001b[0m\n",
"{'name': 'set_battery_saver_mode', 'arguments': {'status': 'off'}}\n",
"\u001b[34m43.9% complete\u001b[0m\n",
"{'name': 'set_obstacle_avoidance', 'arguments': {'mode': 'on'}}\n",
"\u001b[34m45.6% complete\u001b[0m\n",
"{'name': 'set_obstacle_avoidance', 'arguments': {'mode': 'off'}}\n",
"\u001b[34m47.4% complete\u001b[0m\n",
"{'name': 'set_follow_me_mode', 'arguments': {'status': 'on'}}\n",
"\u001b[34m49.1% complete\u001b[0m\n",
"{'name': 'set_follow_me_mode', 'arguments': {'status': 'off'}}\n",
"\u001b[34m50.9% complete\u001b[0m\n",
"{'name': 'calibrate_sensors', 'arguments': {}}\n",
"\u001b[34m52.6% complete\u001b[0m\n",
"{'name': 'set_autopilot', 'arguments': {'status': 'on'}}\n",
"\u001b[34m54.4% complete\u001b[0m\n",
"{'name': 'set_autopilot', 'arguments': {'status': 'off'}}\n",
"\u001b[34m56.1% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid'}}\n",
"\u001b[34m57.9% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'red'}}\n",
"\u001b[34m59.6% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'blue'}}\n",
"\u001b[34m61.4% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'green'}}\n",
"\u001b[34m63.2% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'yellow'}}\n",
"\u001b[34m64.9% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'solid', 'color': 'white'}}\n",
"\u001b[34m66.7% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink'}}\n",
"\u001b[34m68.4% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'red'}}\n",
"\u001b[34m70.2% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'blue'}}\n",
"\u001b[34m71.9% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'green'}}\n",
"\u001b[34m73.7% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'yellow'}}\n",
"\u001b[34m75.4% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'blink', 'color': 'white'}}\n",
"\u001b[34m77.2% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse'}}\n",
"\u001b[34m78.9% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'red'}}\n",
"\u001b[34m80.7% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'blue'}}\n",
"\u001b[34m82.5% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'green'}}\n",
"\u001b[34m84.2% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'yellow'}}\n",
"\u001b[34m86.0% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'pulse', 'color': 'white'}}\n",
"\u001b[34m87.7% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow'}}\n",
"\u001b[34m89.5% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'red'}}\n",
"\u001b[34m91.2% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'blue'}}\n",
"\u001b[34m93.0% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'green'}}\n",
"\u001b[34m94.7% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'yellow'}}\n",
"\u001b[34m96.5% complete\u001b[0m\n",
"{'name': 'configure_led_display', 'arguments': {'pattern': 'rainbow', 'color': 'white'}}\n",
"\u001b[34m98.2% complete\u001b[0m\n",
"{'name': 'reject_request', 'arguments': {}}\n"
"\u001b[34m16.1% complete\u001b[0m\n",
"{'name': 'control_drone_movement', 'arguments': {'direction': 'down', 'distance': 10}}\n"
]
}
],
"source": [
"training_examples_unformatted = create_commands(input_objects)"
"#Only printing the first 10 rows\n",
"training_examples_unformatted = create_commands(input_objects)\n"
]
},
{
@ -1020,23 +887,25 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"training_examples = []\n",
"\n",
"for prompt in training_examples_unformatted:\n",
" #adjust formatting for training data specs\n",
" try:\n",
" prompt[\"Input\"] = ast.literal_eval(prompt[\"Input\"])\n",
" except:\n",
" continue\n",
"\n",
" #if its not a dict, convert to dict\n",
" if type(prompt['Input'])!=dict:\n",
" prompt['Input'] = ast.literal_eval(prompt['Input'])\n",
" prompt['Input']['arguments']=json.dumps(prompt['Input']['arguments'])\n",
" for p in prompt['Prompt']:\n",
" for p in ast.literal_eval(prompt['Prompt'].content):\n",
" training_examples.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT\n",
" },{\"role\":\"user\",\"content\": p},\n",
" {\"role\":\"assistant\",\"function_call\": prompt['Input']}],\n",
" \"functions\":[func['function'] for func in function_list]})\n"
" \"functions\":function_list})\n",
"\n"
]
},
{
@ -1048,7 +917,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@ -1071,7 +940,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
@ -1082,7 +951,7 @@
" reject_training_list.append({\"messages\": [{\"role\":\"system\",\"content\":DRONE_SYSTEM_PROMPT\n",
" },{\"role\":\"user\",\"content\": prompt},\n",
" {\"role\":\"assistant\",\"function_call\": {\"name\": \"reject_request\",\"arguments\": \"{}\"}}],\n",
" \"functions\":[func['function'] for func in function_list]})\n"
" \"functions\":function_list})\n"
]
},
{
@ -1094,7 +963,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@ -1103,7 +972,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@ -1130,14 +999,14 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"file-CGMggG5iZYKTocwgCp7kV7C6\n"
"file-xrLV8EbNZk31QPT1TB5KIx7E\n"
]
}
],
@ -1172,7 +1041,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@ -1180,19 +1049,19 @@
"output_type": "stream",
"text": [
"Play pre-recorded audio message\n",
"reject_request \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n",
"Initiate live-streaming on social media\n",
"reject_request \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n",
"Scan environment for heat signatures\n",
"reject_request \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n",
"Enable stealth mode\n",
"reject_request \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n",
"Change drone's paint job color\n",
"reject_request \n",
"FunctionCall(arguments='{}', name='reject_request') \n",
"\n"
]
}
@ -1204,7 +1073,7 @@
" messages.append({\"role\": \"user\", \"content\": eval_question})\n",
" completion = get_chat_completion(model=\"ft:gpt-3.5-turbo-0613:openai-internal::8DloQKS2\",messages=messages,tools=function_list)\n",
" print(eval_question)\n",
" print(completion.tool_calls[0].function.name,'\\n')\n"
" print(completion.function_call,'\\n')\n"
]
},
{

@ -34,65 +34,17 @@
"is_executing": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: scipy in /usr/local/lib/python3.11/site-packages (1.12.0)\n",
"Requirement already satisfied: numpy<1.29.0,>=1.22.4 in /usr/local/lib/python3.11/site-packages (from scipy) (1.26.3)\n",
"Requirement already satisfied: tenacity in /usr/local/lib/python3.11/site-packages (8.2.3)\n",
"Requirement already satisfied: tiktoken==0.3.3 in /usr/local/lib/python3.11/site-packages (0.3.3)\n",
"Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.11/site-packages (from tiktoken==0.3.3) (2023.12.25)\n",
"Requirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.11/site-packages (from tiktoken==0.3.3) (2.31.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken==0.3.3) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken==0.3.3) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken==0.3.3) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken==0.3.3) (2023.11.17)\n",
"Requirement already satisfied: termcolor in /usr/local/lib/python3.11/site-packages (2.4.0)\n",
"Requirement already satisfied: openai in /usr/local/lib/python3.11/site-packages (1.10.0)\n",
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.11/site-packages (from openai) (4.2.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.11/site-packages (from openai) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.11/site-packages (from openai) (0.26.0)\n",
"Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.11/site-packages (from openai) (2.5.3)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.11/site-packages (from openai) (1.3.0)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.11/site-packages (from openai) (4.66.1)\n",
"Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.11/site-packages (from openai) (4.9.0)\n",
"Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.11/site-packages (from anyio<5,>=3.5.0->openai) (3.6)\n",
"Requirement already satisfied: certifi in /usr/local/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (2023.11.17)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (1.0.2)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.11/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.14.6 in /usr/local/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (2.14.6)\n",
"Requirement already satisfied: arxiv in /usr/local/lib/python3.11/site-packages (2.1.0)\n",
"Requirement already satisfied: feedparser==6.0.10 in /usr/local/lib/python3.11/site-packages (from arxiv) (6.0.10)\n",
"Requirement already satisfied: requests==2.31.0 in /usr/local/lib/python3.11/site-packages (from arxiv) (2.31.0)\n",
"Requirement already satisfied: sgmllib3k in /usr/local/lib/python3.11/site-packages (from feedparser==6.0.10->arxiv) (1.0.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/site-packages (from requests==2.31.0->arxiv) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/site-packages (from requests==2.31.0->arxiv) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/site-packages (from requests==2.31.0->arxiv) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests==2.31.0->arxiv) (2023.11.17)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.11/site-packages (2.2.0)\n",
"Requirement already satisfied: numpy<2,>=1.23.2 in /usr/local/lib/python3.11/site-packages (from pandas) (1.26.3)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.11/site-packages (from pandas) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/site-packages (from pandas) (2023.3.post1)\n",
"Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/site-packages (from pandas) (2023.4)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\n",
"Requirement already satisfied: PyPDF2 in /usr/local/lib/python3.11/site-packages (3.0.1)\n",
"Requirement already satisfied: tqdm in /usr/local/lib/python3.11/site-packages (4.66.1)\n"
]
}
],
"outputs": [],
"source": [
"!pip install scipy\n",
"!pip install tenacity\n",
"!pip install tiktoken==0.3.3\n",
"!pip install termcolor \n",
"!pip install openai\n",
"!pip install arxiv\n",
"!pip install pandas\n",
"!pip install PyPDF2\n",
"!pip install tqdm"
"!pip install scipy --quiet\n",
"!pip install tenacity --quiet\n",
"!pip install tiktoken==0.3.3 --quiet\n",
"!pip install termcolor --quiet\n",
"!pip install openai --quiet\n",
"!pip install arxiv --quiet\n",
"!pip install pandas --quiet\n",
"!pip install PyPDF2 --quiet\n",
"!pip install tqdm --quiet"
]
},
{
@ -240,10 +192,10 @@
{
"data": {
"text/plain": [
"{'title': 'Entanglement entropy and deconfined criticality: emergent SO(5) symmetry and proper lattice bipartition',\n",
" 'summary': \"We study the R\\\\'enyi entanglement entropy (EE) of the two-dimensional $J$-$Q$\\nmodel, the emblematic quantum spin model of deconfined criticality at the phase\\ntransition between antiferromagnetic and valence-bond-solid ground states.\\nQuantum Monte Carlo simulations with an improved EE scheme reveal critical\\ncorner contributions that scale logarithmically with the system size, with a\\ncoefficient in remarkable agreement with the form expected from a large-$N$\\nconformal field theory with SO($N=5$) symmetry. However, details of the\\nbipartition of the lattice are crucial in order to observe this behavior. If\\nthe subsystem for the reduced density matrix does not properly accommodate\\nvalence-bond fluctuations, logarithmic contributions appear even for\\ncorner-less bipartitions. We here use a $45^\\\\circ$ tilted cut on the square\\nlattice. Beyond supporting an SO($5$) deconfined quantum critical point, our\\nresults for both the regular and tilted cuts demonstrate important microscopic\\naspects of the EE that are not captured by conformal field theory.\",\n",
" 'article_url': 'http://arxiv.org/abs/2401.14396v1',\n",
" 'pdf_url': 'http://arxiv.org/pdf/2401.14396v1'}"
"{'title': 'Quantum types: going beyond qubits and quantum gates',\n",
" 'summary': 'Quantum computing is a growing field with significant potential applications.\\nLearning how to code quantum programs means understanding how qubits work and\\nlearning to use quantum gates. This is analogous to creating classical\\nalgorithms using logic gates and bits. Even after learning all concepts, it is\\ndifficult to create new algorithms, which hinders the acceptance of quantum\\nprogramming by most developers. This article outlines the need for higher-level\\nabstractions and proposes some of them in a developer-friendly programming\\nlanguage called Rhyme. The new quantum types are extensions of classical types,\\nincluding bits, integers, floats, characters, arrays, and strings. We show how\\nto use such types with code snippets.',\n",
" 'article_url': 'http://arxiv.org/abs/2401.15073v1',\n",
" 'pdf_url': 'http://arxiv.org/pdf/2401.15073v1'}"
]
},
"execution_count": 6,
@ -416,7 +368,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 15/15 [00:08<00:00, 1.76it/s]\n"
"100%|██████████| 6/6 [00:06<00:00, 1.08s/it]\n"
]
},
{
@ -442,7 +394,25 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The academic paper discusses the unique decomposition of generators of completely positive dynamical semigroups in infinite dimensions. The main result of the paper is that for any separable complex Hilbert space, any trace-class operator B that does not have a purely imaginary trace, and any generator L of a norm-continuous one-parameter semigroup of completely positive maps, there exists a unique bounded operator K and a unique completely positive map Φ such that L=K(·) + (·)K+ Φ. The paper also introduces a modified version of the Choi formalism, which relates completely positive maps to positive semi-definite operators, and characterizes when this correspondence is injective and surjective. The paper concludes by discussing the challenges and questions that arise when generalizing the results to non-separable Hilbert spaces.\n"
"Core Argument:\n",
"- The academic paper explores the connection between the transverse field Ising (TFI) model and the ϕ4 model, highlighting the analogy between topological solitary waves in the ϕ4 model and the effect of the transverse field on spin flips in the TFI model.\n",
"- The study reveals regimes of memory/loss of memory and coherence/decoherence in the classical ϕ4 model subjected to periodic perturbations, which are essential in annealing phenomena.\n",
"- The exploration of the analogy between lower-dimensional linear quantum systems and higher-dimensional classical nonlinear systems can lead to a deeper understanding of information processing in these systems.\n",
"\n",
"Evidence:\n",
"- The authors analyze the dynamics and relaxation of weakly coupled ϕ4 chains through numerical simulations, observing kink and breather excitations and investigating the structural phase transition associated with the double well potential.\n",
"- The critical temperature (Tc) approaches zero as the inter-chain coupling strength (C⊥) approaches zero, but there is a finite Tc for C⊥>0.\n",
"- The spectral function shows peaks corresponding to particle motion across the double-well potential at higher temperatures and oscillations in a single well at lower temperatures.\n",
"- The soft-mode frequency (ωs) decreases as temperature approaches Ts, the dynamical crossover temperature.\n",
"- The relaxation process of the average displacement (QD) is controlled by spatially extended vibrations and large kink densities.\n",
"- The mean domain size (⟨DS⟩) exhibits an algebraic decay for finite C⊥>0.\n",
"- The probability of larger domain sizes is higher before a kick compared to after a kick for C⊥>0.\n",
"\n",
"Conclusions:\n",
"- The authors suggest further exploration of the crossover between decoherence and finite coherence in periodic-kick strength space.\n",
"- They propose extending the study to different kick profiles, introducing kink defects, and studying weakly-coupled chains in higher dimensions.\n",
"- Recognizing similarities between classical nonlinear equations and quantum linear ones in information processing is important.\n",
"- Future research directions include investigating the dynamics of quantum annealing, measurement and memory in the periodically driven complex Ginzburg-Landau equation, and the behavior of solitons and domain walls in various systems.\n"
]
}
],
@ -667,23 +637,21 @@
{
"data": {
"text/markdown": [
"PPO (Proximal Policy Optimization) is a reinforcement learning algorithm used in training agents to make sequential decisions in dynamic environments. It belongs to the family of policy optimization algorithms and addresses the challenge of optimizing policies in a stable and sample-efficient manner. \n",
"\n",
"PPO works by iteratively collecting a batch of data from interacting with the environment, computing advantages to estimate the quality of actions, and then performing multiple policy updates using a clipped surrogate objective. This objective function helps prevent excessive policy updates that could lead to policy divergence and instability. \n",
"\n",
"By iteratively updating the policy using the collected data, PPO seeks to maximize the expected cumulative rewards obtained by the agent. It has been used successfully in a variety of reinforcement learning tasks, including robotic control, game playing, and simulated environments. \n",
"\n",
"To learn more about PPO reinforcement learning, you can read the following papers:\n",
"PPO (Proximal Policy Optimization) is a reinforcement learning algorithm that aims to find the optimal policy for an agent by optimizing the policy parameters in an iterative manner. Here are a few papers that discuss PPO in more detail:\n",
"\n",
"1. Title: \"Proximal Policy Optimization Algorithms\"\n",
" Article URL: [arxiv.org/abs/1707.06347v2](http://arxiv.org/abs/1707.06347v2)\n",
" Summary: This paper introduces PPO and presents two versions of the algorithm: PPO-Penalty and PPO-Clip. It provides a detailed description of PPO's update rule and compares its performance against other popular reinforcement learning algorithms.\n",
" Summary: This paper introduces two algorithms, PPO (Proximal Policy Optimization) and TRPO (Trust Region Policy Optimization), that address the issue of sample efficiency and stability in reinforcement learning. PPO uses a surrogate objective function that makes smaller updates to the policy parameters, resulting in more stable and efficient learning.\n",
"\n",
"2. Title: \"Emergent Properties of PPO Reinforcement Learning in Resource-Limited Environments\"\n",
" Article URL: [arxiv.org/abs/2001.14342v1](http://arxiv.org/abs/2001.14342v1)\n",
" Summary: This paper explores the emergent properties of PPO reinforcement learning algorithms in resource-limited environments. It discusses the impact of varying the resource constraints and agent population sizes on the learning process and performance.\n",
"2. Title: \"Emergence of Locomotion Behaviours in Rich Environments with PPO\"\n",
" Article URL: [arxiv.org/abs/1707.02286v3](http://arxiv.org/abs/1707.02286v3)\n",
" Summary: This paper explores the use of PPO in training agents to learn locomotion behaviors in complex and dynamic environments. The authors demonstrate the effectiveness of PPO in learning a variety of locomotion skills, such as walking, jumping, and climbing.\n",
"\n",
"Reading these papers will give you a deeper understanding of PPO reinforcement learning and its applications in different domains."
"3. Title: \"Proximal Policy Optimization for Multi-Agent Systems\"\n",
" Article URL: [arxiv.org/abs/2006.14171v2](http://arxiv.org/abs/2006.14171v2)\n",
" Summary: This paper extends PPO to the domain of multi-agent systems, where multiple agents interact and learn together. The authors propose a decentralized version of PPO that allows each agent to update its policy independently based on its local observations, resulting in more scalable and efficient learning in multi-agent environments.\n",
"\n",
"These papers provide detailed explanations of the PPO algorithm, its advantages, and its applications in different scenarios. Reading them can give you a deeper understanding of how PPO reinforcement learning works."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
@ -724,7 +692,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 15/15 [00:09<00:00, 1.67it/s]\n"
"100%|██████████| 6/6 [00:07<00:00, 1.19s/it]\n"
]
},
{
@ -737,7 +705,25 @@
{
"data": {
"text/markdown": [
"The paper discusses the unique decomposition of generators of completely positive dynamical semigroups in infinite dimensions. The main result is that for any separable complex Hilbert space, any trace-class operator B that does not have a purely imaginary trace, and any generator L of a norm-continuous one-parameter semigroup of completely positive maps, there exists a unique bounded operator K and a unique completely positive map Φ such that L=K(·) + (·)K+ Φ. The paper also introduces a modified version of the Choi formalism and characterizes when this correspondence is injective and surjective. The paper concludes by discussing the challenges and questions that arise when generalizing the results to non-separable Hilbert spaces."
"Core Argument:\n",
"- The academic paper explores the connection between the transverse field Ising (TFI) model and the ϕ4 model, highlighting the analogy between the coupling of topological solitary waves in the ϕ4 model and the effect of the transverse field on spin flips in the TFI model.\n",
"- The study reveals regimes of memory/loss of memory and coherence/decoherence in the classical ϕ4 model subjected to periodic perturbations, which are essential in annealing phenomena.\n",
"- The exploration of the analogy between lower-dimensional linear quantum systems and higher-dimensional classical nonlinear systems can lead to a deeper understanding of information processing in these systems.\n",
"\n",
"Evidence:\n",
"- The authors analyze the dynamics and relaxation of weakly coupled ϕ4 chains through numerical simulations, studying the behavior of kink and breather excitations and the structural phase transition associated with the double well potential.\n",
"- The critical temperature (Tc) approaches zero as the inter-chain coupling strength (C⊥) approaches zero, but there is a finite Tc for C⊥>0.\n",
"- The spectral function shows peaks corresponding to particle motion across the double-well potential at higher temperatures and oscillations in a single well at lower temperatures.\n",
"- The soft-mode frequency (ωs) decreases as temperature approaches Ts, the dynamical crossover temperature.\n",
"- The relaxation process of the average displacement (QD) is controlled by spatially extended vibrations and large kink densities.\n",
"- The mean domain size (⟨DS⟩) exhibits an algebraic decay for finite C⊥>0.\n",
"- The probability of larger domain sizes is higher before a kick compared to after a kick for C⊥>0.\n",
"\n",
"Conclusions:\n",
"- The study of weakly-coupled classical ϕ4 chains provides insights into quantum annealing architectures and the role of topological excitations in these systems.\n",
"- The equilibration of the system is faster for higher kick strengths, and the mean domain size increases with higher final temperatures.\n",
"- Further exploration of the crossover between decoherence and finite coherence in periodic-kick strength space is suggested.\n",
"- The paper highlights the importance of recognizing similarities between classical nonlinear equations and quantum linear ones in information processing and suggests future research directions in this area."
],
"text/plain": [
"<IPython.core.display.Markdown object>"

@ -12,7 +12,7 @@
"\n",
"`tools` is an optional parameter in the Chat Completion API which can be used to provide function specifications. The purpose of this is to enable models to generate function arguments which adhere to the provided specifications. Note that the API will not actually execute any function calls. It is up to developers to execute function calls using model outputs.\n",
"\n",
"Within the `tools` parameter, if the `functions` parameter is provided then by default the model will decide when it is appropriate to use one of the functions. The API can be forced to use a specific function by setting the `tool_choice` parameter to `{\"name\": \"<insert-function-name>\"}`. The API can also be forced to not use any function by setting the `tool_choice` parameter to `\"none\"`. If a function is used, the output will contain `\"finish_reason\": \"function_call\"` in the response, as well as a `tool_choice` object that has the name of the function and the generated function arguments.\n",
"Within the `tools` parameter, if the `functions` parameter is provided then by default the model will decide when it is appropriate to use one of the functions. The API can be forced to use a specific function by setting the `tool_choice` parameter to `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}`. The API can also be forced to not use any function by setting the `tool_choice` parameter to `\"none\"`. If a function is used, the output will contain `\"finish_reason\": \"tool_calls\"` in the response, as well as a `tool_calls` object that has the name of the function and the generated function arguments.\n",
"\n",
"### Overview\n",
"\n",
@ -40,45 +40,13 @@
"is_executing": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: scipy in /usr/local/lib/python3.11/site-packages (1.12.0)\n",
"Requirement already satisfied: numpy<1.29.0,>=1.22.4 in /usr/local/lib/python3.11/site-packages (from scipy) (1.26.3)\n",
"Requirement already satisfied: tenacity in /usr/local/lib/python3.11/site-packages (8.2.3)\n",
"Requirement already satisfied: tiktoken in /usr/local/lib/python3.11/site-packages (0.3.3)\n",
"Requirement already satisfied: regex>=2022.1.18 in /usr/local/lib/python3.11/site-packages (from tiktoken) (2023.12.25)\n",
"Requirement already satisfied: requests>=2.26.0 in /usr/local/lib/python3.11/site-packages (from tiktoken) (2.31.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken) (3.3.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken) (3.6)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken) (2.1.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests>=2.26.0->tiktoken) (2023.11.17)\n",
"Requirement already satisfied: termcolor in /usr/local/lib/python3.11/site-packages (2.4.0)\n",
"Requirement already satisfied: openai in /usr/local/lib/python3.11/site-packages (1.10.0)\n",
"Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.11/site-packages (from openai) (4.2.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.11/site-packages (from openai) (1.9.0)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.11/site-packages (from openai) (0.26.0)\n",
"Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.11/site-packages (from openai) (2.5.3)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.11/site-packages (from openai) (1.3.0)\n",
"Requirement already satisfied: tqdm>4 in /usr/local/lib/python3.11/site-packages (from openai) (4.66.1)\n",
"Requirement already satisfied: typing-extensions<5,>=4.7 in /usr/local/lib/python3.11/site-packages (from openai) (4.9.0)\n",
"Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.11/site-packages (from anyio<5,>=3.5.0->openai) (3.6)\n",
"Requirement already satisfied: certifi in /usr/local/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (2023.11.17)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (1.0.2)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.11/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
"Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0)\n",
"Requirement already satisfied: pydantic-core==2.14.6 in /usr/local/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (2.14.6)\n"
]
}
],
"outputs": [],
"source": [
"!pip install scipy\n",
"!pip install tenacity\n",
"!pip install tiktoken\n",
"!pip install termcolor \n",
"!pip install openai"
"!pip install scipy --quiet\n",
"!pip install tenacity --quiet\n",
"!pip install tiktoken --quiet\n",
"!pip install termcolor --quiet\n",
"!pip install openai --quiet"
]
},
{
@ -247,7 +215,7 @@
{
"data": {
"text/plain": [
"ChatCompletionMessage(content='Sure, I can help you with that. Could you please provide me with your location?', role='assistant', function_call=None, tool_calls=None)"
"ChatCompletionMessage(content='Sure, could you please tell me the location for which you would like to know the weather?', role='assistant', function_call=None, tool_calls=None)"
]
},
"execution_count": 6,
@ -285,7 +253,7 @@
{
"data": {
"text/plain": [
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_qOYhFO7fKaU6wpG2f1XzkDjW', function=Function(arguments='{\\n \"location\": \"Glasgow, Scotland\",\\n \"format\": \"celsius\"\\n}', name='get_current_weather'), type='function')])"
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_2PArU89L2uf4uIzRqnph4SrN', function=Function(arguments='{\\n \"location\": \"Glasgow, Scotland\",\\n \"format\": \"celsius\"\\n}', name='get_current_weather'), type='function')])"
]
},
"execution_count": 7,
@ -321,7 +289,7 @@
{
"data": {
"text/plain": [
"ChatCompletionMessage(content='Sure! Please provide the number of days you would like to know the weather forecast for.', role='assistant', function_call=None, tool_calls=None)"
"ChatCompletionMessage(content='Sure, I can help you with that. How many days would you like to get the weather forecast for?', role='assistant', function_call=None, tool_calls=None)"
]
},
"execution_count": 8,
@ -359,7 +327,7 @@
{
"data": {
"text/plain": [
"Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_HwWHsNZsmkZUroPj6glmEgA5', function=Function(arguments='{\\n \"location\": \"Glasgow, Scotland\",\\n \"format\": \"celsius\",\\n \"num_days\": 5\\n}', name='get_n_day_weather_forecast'), type='function')]), internal_metrics=[{'cached_prompt_tokens': 0, 'total_accepted_tokens': 0, 'total_batched_tokens': 269, 'total_predicted_tokens': 0, 'total_rejected_tokens': 0, 'total_tokens_in_completion': 270, 'cached_embeddings_bytes': 0, 'cached_embeddings_n': 0, 'uncached_embeddings_bytes': 0, 'uncached_embeddings_n': 0, 'fetched_embeddings_bytes': 0, 'fetched_embeddings_n': 0, 'n_evictions': 0, 'sampling_steps': 40, 'sampling_steps_with_predictions': 0, 'batcher_ttft': 0.055008649826049805, 'batcher_initial_queue_time': 0.00098419189453125}])"
"Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_ujD1NwPxzeOSCbgw2NOabOin', function=Function(arguments='{\\n \"location\": \"Glasgow, Scotland\",\\n \"format\": \"celsius\",\\n \"num_days\": 5\\n}', name='get_n_day_weather_forecast'), type='function')]), internal_metrics=[{'cached_prompt_tokens': 128, 'total_accepted_tokens': 0, 'total_batched_tokens': 273, 'total_predicted_tokens': 0, 'total_rejected_tokens': 0, 'total_tokens_in_completion': 274, 'cached_embeddings_bytes': 0, 'cached_embeddings_n': 0, 'uncached_embeddings_bytes': 0, 'uncached_embeddings_n': 0, 'fetched_embeddings_bytes': 0, 'fetched_embeddings_n': 0, 'n_evictions': 0, 'sampling_steps': 40, 'sampling_steps_with_predictions': 0, 'batcher_ttft': 0.035738229751586914, 'batcher_initial_queue_time': 0.0007979869842529297}])"
]
},
"execution_count": 9,
@ -402,7 +370,7 @@
{
"data": {
"text/plain": [
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_240XQedt4Gi8VZsUwOvFpQfZ', function=Function(arguments='{\\n \"location\": \"Toronto, Canada\",\\n \"format\": \"celsius\",\\n \"num_days\": 1\\n}', name='get_n_day_weather_forecast'), type='function')])"
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_MapM0kaNZBR046H4tAB2UGVu', function=Function(arguments='{\\n \"location\": \"Toronto, Canada\",\\n \"format\": \"celsius\",\\n \"num_days\": 1\\n}', name='get_n_day_weather_forecast'), type='function')])"
]
},
"execution_count": 10,
@ -430,7 +398,7 @@
{
"data": {
"text/plain": [
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_lQhrFlzIVPpeYG1QrSv7e3H3', function=Function(arguments='{\\n \"location\": \"Toronto, Canada\",\\n \"format\": \"celsius\"\\n}', name='get_current_weather'), type='function')])"
"ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_z8ijGSoMLS7xcaU7MjLmpRL8', function=Function(arguments='{\\n \"location\": \"Toronto, Canada\",\\n \"format\": \"celsius\"\\n}', name='get_current_weather'), type='function')])"
]
},
"execution_count": 11,
@ -504,8 +472,8 @@
{
"data": {
"text/plain": [
"[ChatCompletionMessageToolCall(id='call_q8k4geh0uGPRtIfOXYPB0yM8', function=Function(arguments='{\"location\": \"San Francisco, CA\", \"format\": \"celsius\", \"num_days\": 4}', name='get_n_day_weather_forecast'), type='function'),\n",
" ChatCompletionMessageToolCall(id='call_Hdl7Py7aLswCBPptrD4y5BD3', function=Function(arguments='{\"location\": \"Glasgow\", \"format\": \"celsius\", \"num_days\": 4}', name='get_n_day_weather_forecast'), type='function')]"
"[ChatCompletionMessageToolCall(id='call_8BlkS2yvbkkpL3V1Yxc6zR6u', function=Function(arguments='{\"location\": \"San Francisco, CA\", \"format\": \"celsius\", \"num_days\": 4}', name='get_n_day_weather_forecast'), type='function'),\n",
" ChatCompletionMessageToolCall(id='call_vSZMy3f24wb3vtNXucpFfAbG', function=Function(arguments='{\"location\": \"Glasgow\", \"format\": \"celsius\", \"num_days\": 4}', name='get_n_day_weather_forecast'), type='function')]"
]
},
"execution_count": 13,
@ -720,7 +688,7 @@
"\u001b[0m\n",
"\u001b[32muser: Hi, who are the top 5 artists by number of tracks?\n",
"\u001b[0m\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT artist.Name, COUNT(track.TrackId) AS num_tracks FROM artist JOIN album ON artist.ArtistId = album.ArtistId JOIN track ON album.AlbumId = track.AlbumId GROUP BY artist.ArtistId ORDER BY num_tracks DESC LIMIT 5\"\\n}', name='ask_database')\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT Artist.Name, COUNT(Track.TrackId) AS TrackCount FROM Artist JOIN Album ON Artist.ArtistId = Album.ArtistId JOIN Track ON Album.AlbumId = Track.AlbumId GROUP BY Artist.ArtistId ORDER BY TrackCount DESC LIMIT 5;\"\\n}', name='ask_database')\n",
"\u001b[0m\n",
"\u001b[35mfunction (ask_database): [('Iron Maiden', 213), ('U2', 135), ('Led Zeppelin', 114), ('Metallica', 112), ('Lost', 92)]\n",
"\u001b[0m\n"
@ -757,13 +725,13 @@
"\u001b[0m\n",
"\u001b[32muser: Hi, who are the top 5 artists by number of tracks?\n",
"\u001b[0m\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT artist.Name, COUNT(track.TrackId) AS num_tracks FROM artist JOIN album ON artist.ArtistId = album.ArtistId JOIN track ON album.AlbumId = track.AlbumId GROUP BY artist.ArtistId ORDER BY num_tracks DESC LIMIT 5\"\\n}', name='ask_database')\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT Artist.Name, COUNT(Track.TrackId) AS TrackCount FROM Artist JOIN Album ON Artist.ArtistId = Album.ArtistId JOIN Track ON Album.AlbumId = Track.AlbumId GROUP BY Artist.ArtistId ORDER BY TrackCount DESC LIMIT 5;\"\\n}', name='ask_database')\n",
"\u001b[0m\n",
"\u001b[35mfunction (ask_database): [('Iron Maiden', 213), ('U2', 135), ('Led Zeppelin', 114), ('Metallica', 112), ('Lost', 92)]\n",
"\u001b[0m\n",
"\u001b[32muser: What is the name of the album with the most tracks?\n",
"\u001b[0m\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT album.Title, COUNT(track.TrackId) AS num_tracks FROM album JOIN track ON album.AlbumId = track.AlbumId GROUP BY album.AlbumId ORDER BY num_tracks DESC LIMIT 1\"\\n}', name='ask_database')\n",
"\u001b[34massistant: Function(arguments='{\\n \"query\": \"SELECT Album.Title, COUNT(Track.TrackId) AS TrackCount FROM Album JOIN Track ON Album.AlbumId = Track.AlbumId GROUP BY Album.AlbumId ORDER BY TrackCount DESC LIMIT 1;\"\\n}', name='ask_database')\n",
"\u001b[0m\n",
"\u001b[35mfunction (ask_database): [('Greatest Hits', 57)]\n",
"\u001b[0m\n"
@ -792,12 +760,6 @@
"\n",
"See our other [notebook](How_to_call_functions_for_knowledge_retrieval.ipynb) that demonstrates how to use the Chat Completions API and functions for knowledge retrieval to interact conversationally with a knowledge base."
]
},
{
"cell_type": "markdown",
"id": "ec721d07",
"metadata": {},
"source": []
}
],
"metadata": {

@ -11,7 +11,7 @@
"\n",
"This guide shares tips for avoiding and handling rate limit errors.\n",
"\n",
"To see an example script for throttling parallel requests to avoid rate limit errors, see [api_request_parallel_processor.py](api_request_parallel_processor.py).\n",
"To see an example script for throttling parallel requests to avoid rate limit errors, see [api_request_parallel_processor.py](https://github.com/openai/openai-cookbook/blob/main/examples/api_request_parallel_processor.py).\n",
"\n",
"## Why rate limits exist\n",
"\n",
@ -43,9 +43,7 @@
"\n",
"### Requesting a rate limit increase\n",
"\n",
"If you'd like your organization's rate limit increased, please fill out the following form:\n",
"\n",
"- [OpenAI Rate Limit Increase Request form](https://forms.gle/56ZrwXXoxAN1yt6i9)\n"
"If you'd like your organization's rate limit increased, please visit your [Limits settings page](https://platform.openai.com/account/limits) to see how you can increase your usage tier\n",
]
},
{

@ -787,7 +787,7 @@
"\n",
"There is also a latency impact of using ```text-davinci-003``` that you'll need to consider, with even our few examples above taking a couple seconds each - again, the ```Fine-tuning``` endpoint may help you here if you are able to get decent results from an ```ada``` or ```babbage``` fine-tuned model.\n",
"\n",
"We've used the ```Completions``` endpoint from OpenAI to build our cross-encoder, but this area is well-served by the open-source community. [Here](https://huggingface.co/cross-encoder/mmarco-mMiniLMv2-L12-H384-v1) is an example from HuggingFace, for example.\n",
"We've used the ```Completions``` endpoint from OpenAI to build our cross-encoder, but this area is well-served by the open-source community. [Here](https://huggingface.co/jeffwan/mmarco-mMiniLMv2-L12-H384-v1) is an example from HuggingFace, for example.\n",
"\n",
"We hope you find this useful for tuning your search use cases, and look forward to seeing what you build."
]

@ -431,9 +431,16 @@
"source": [
"For the first two questions, our model asserts with (near) 100% confidence that the article has sufficient context to answer the posed questions.<br><br>\n",
"On the other hand, for the more tricky questions which are less clearly answered in the article, the model is less confident that it has sufficient context. This is a great guardrail to help ensure our retrieved content is sufficient.<br><br>\n",
"This self-evaluation can help reduce hallucinations, as you can restrict answers or re-prompt the user when your `sufficient_context_for_answer` log probability is below a certain threshold. Methods like this have been shown to significantly reduce RAG for Q&A hallucinations and errors ([Example]((https://jfan001.medium.com/how-we-cut-the-rate-of-gpt-hallucinations-from-20-to-less-than-2-f3bfcc10e4ec)))"
"This self-evaluation can help reduce hallucinations, as you can restrict answers or re-prompt the user when your `sufficient_context_for_answer` log probability is below a certain threshold. Methods like this have been shown to significantly reduce RAG for Q&A hallucinations and errors ([Example](https://jfan001.medium.com/how-we-cut-the-rate-of-gpt-hallucinations-from-20-to-less-than-2-f3bfcc10e4ec)) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},

@ -110,7 +110,7 @@
"\n",
"# call the OpenAI API\n",
"generation_response = client.images.generate(\n",
" model = \"dall-e-3\"\n",
" model = \"dall-e-3\",\n",
" prompt=prompt,\n",
" n=1,\n",
" size=\"1024x1024\",\n",

@ -26,5 +26,6 @@ Each provider has their own named directory, with a standard notebook to introdu
- [Supabase](https://supabase.com/docs/guides/ai)
- [Tembo](https://tembo.io/docs/tembo-stacks/vector-db)
- [Typesense](https://typesense.org/docs/guide/)
- [Vespa AI](https://vespa.ai/)
- [Weaviate](https://weaviate.io/developers/weaviate/quickstart)
- [Zilliz](https://docs.zilliz.com/docs/quick-start-1)

@ -60,10 +60,10 @@
"Successfully installed certifi-2023.5.7 grpcio-1.56.0 grpcio-tools-1.56.0 h11-0.14.0 h2-4.1.0 hpack-4.0.0 httpcore-0.17.2 httpx-0.24.1 hyperframe-6.0.1 numpy-1.25.0 portalocker-2.7.0 protobuf-4.23.3 pydantic-1.10.9 qdrant-client-1.3.1 typing-extensions-4.5.0 urllib3-1.26.16\r\n",
"Collecting wget\r\n",
" Using cached wget-3.2.zip (10 kB)\r\n",
" Preparing metadata (setup.py) ... \u001b[?25ldone\r\n",
"\u001b[?25hBuilding wheels for collected packages: wget\r\n",
" Building wheel for wget (setup.py) ... \u001b[?25ldone\r\n",
"\u001b[?25h Created wheel for wget: filename=wget-3.2-py3-none-any.whl size=9657 sha256=eb5f15f12150fc304e7b14973424f696fa8d95225772bc0cbc0b318bf92e04b9\r\n",
" Preparing metadata (setup.py) ... \u001B[?25ldone\r\n",
"\u001B[?25hBuilding wheels for collected packages: wget\r\n",
" Building wheel for wget (setup.py) ... \u001B[?25ldone\r\n",
"\u001B[?25h Created wheel for wget: filename=wget-3.2-py3-none-any.whl size=9657 sha256=eb5f15f12150fc304e7b14973424f696fa8d95225772bc0cbc0b318bf92e04b9\r\n",
" Stored in directory: /home/user/.cache/pip/wheels/04/5f/3e/46cc37c5d698415694d83f607f833f83f0149e49b3af9d0f38\r\n",
"Successfully built wget\r\n",
"Installing collected packages: wget\r\n",
@ -384,7 +384,9 @@
"\n",
"For the local deployment, we are going to use Docker, according to the Qdrant documentation: https://qdrant.tech/documentation/quick_start/. Qdrant requires just a single container, but an example of the docker-compose.yaml file is available at `./qdrant/docker-compose.yaml` in this repo.\n",
"\n",
"You can start Qdrant instance locally by navigating to this directory and running `docker-compose up -d `"
"You can start Qdrant instance locally by navigating to this directory and running `docker-compose up -d `\n",
"\n",
"> You might need to increase the memory limit for Docker to 8GB or more. Or Qdrant might fail to execute with an error message like `7 Killed`.\n"
]
},
{

@ -164,15 +164,6 @@
- completions
- functions
- title: How to combine GPTV with RAG Create a Clothing Matchmaker App
path: examples/How_to_Combine_GPTv_with_RAG_Outfit_Assistant.ipynb
date: 2024-02-16
authors:
- teomusatoiu
tags:
- vision
- embeddings
- title: How to count tokens with tiktoken
path: examples/How_to_count_tokens_with_tiktoken.ipynb
date: 2022-12-16
@ -1214,3 +1205,11 @@
- vision
- embeddings
- title: How to combine GPT-V with RAG to create a clothing matchmaker app
path: examples/How_to_Combine_GPTv_with_RAG_Outfit_Assistant.ipynb
date: 2024-02-16
authors:
- teomusatoiu
tags:
- vision
- embeddings

Loading…
Cancel
Save