Spaces:
Runtime error
Runtime error
jackyliang42
commited on
Commit
·
e7fd469
1
Parent(s):
4a87cff
reduce prompt size
Browse filesreadme updates
reduced max tokens for tabletop_ui
- README.md +3 -2
- app.py +3 -3
- cfg.yaml +1 -1
- prompts/parse_question.py +0 -3
- prompts/tabletop_ui.py +15 -59
README.md
CHANGED
@@ -22,7 +22,7 @@ Below is an interactive demo for the simulated tabletop manipulation domain, see
|
|
22 |
1. Obtain an [OpenAI API Key](https://openai.com/blog/openai-api/)
|
23 |
2. Gain Codex access by [joining the waitlist](https://openai.com/blog/openai-codex/)
|
24 |
|
25 |
-
Once you have Codex access you can use
|
26 |
|
27 |
## Usage
|
28 |
1. Fill in the API Key, model name, and how many blocks and bowls to be spawned in the environment.
|
@@ -48,9 +48,10 @@ Note object names may need to be changed depending the sampled object names.
|
|
48 |
* pick up the block closest to the top left corner and place it on the bottom right corner
|
49 |
|
50 |
## Known Limitations
|
51 |
-
* In simulation we're using ground truth object poses instead of using vision models. This means that instructions the require knowledge of visual apperances (e.g. darkest bowl, largest object) are not supported.
|
52 |
* Currently, the low-level pick place primitive does not do collision checking, so if there are many objects on the table, placing actions may incur collisions.
|
53 |
* The pick place primitive is also unable to pick up bowls.
|
54 |
* Prompt saturation - if too many instructions (10+) are executed in a row, then the LLM may start to ignore examples in the early parts of the prompt.
|
55 |
* Ambiguous instructions - if a given instruction doesn't lead to the desired actions, try rephrasing it to remove ambiguities (e.g. place the block on the closest bowl -> place the block on its closest bowl)
|
56 |
* Maximum token length - you may hit the maximum token length if running multiple commands in sequence. Please reset the simulation when this happens.
|
|
|
|
22 |
1. Obtain an [OpenAI API Key](https://openai.com/blog/openai-api/)
|
23 |
2. Gain Codex access by [joining the waitlist](https://openai.com/blog/openai-codex/)
|
24 |
|
25 |
+
Once you have Codex access you can use code-davinci-002. Using the GPT-3 model (text-dainvci-002) is also ok, but performance won't be as good (there will be more code logic errors).
|
26 |
|
27 |
## Usage
|
28 |
1. Fill in the API Key, model name, and how many blocks and bowls to be spawned in the environment.
|
|
|
48 |
* pick up the block closest to the top left corner and place it on the bottom right corner
|
49 |
|
50 |
## Known Limitations
|
51 |
+
* In simulation we're using ground truth object poses instead of using vision models. This means that instructions the require knowledge of visual apperances (e.g. darkest bowl, largest object, empty bowls) are not supported.
|
52 |
* Currently, the low-level pick place primitive does not do collision checking, so if there are many objects on the table, placing actions may incur collisions.
|
53 |
* The pick place primitive is also unable to pick up bowls.
|
54 |
* Prompt saturation - if too many instructions (10+) are executed in a row, then the LLM may start to ignore examples in the early parts of the prompt.
|
55 |
* Ambiguous instructions - if a given instruction doesn't lead to the desired actions, try rephrasing it to remove ambiguities (e.g. place the block on the closest bowl -> place the block on its closest bowl)
|
56 |
* Maximum token length - you may hit the maximum token length if running multiple commands in sequence. Please reset the simulation when this happens.
|
57 |
+
* If you get the error "That model does not exist" it means you're trying to use Codex w/o Codex access. Switch to text-davinci-002 instead.
|
app.py
CHANGED
@@ -95,7 +95,7 @@ class DemoRunner:
|
|
95 |
try:
|
96 |
self._lmp_tabletop_ui(instruction, f'objects = {self._env.object_list}')
|
97 |
except Exception as e:
|
98 |
-
return
|
99 |
|
100 |
video_file_name = None
|
101 |
if self._env.cache_video:
|
@@ -140,7 +140,7 @@ if __name__ == '__main__':
|
|
140 |
with gr.Column():
|
141 |
with gr.Row():
|
142 |
inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
|
143 |
-
inp_model_name = gr.Dropdown(label='Model Name', choices=['code-davinci-002', 'text-davinci-002'], value='
|
144 |
with gr.Row():
|
145 |
inp_n_blocks = gr.Slider(label='Number of Blocks', minimum=0, maximum=4, value=3, step=1)
|
146 |
inp_n_bowls = gr.Slider(label='Number of Bowls', minimum=0, maximum=4, value=3, step=1)
|
@@ -154,7 +154,7 @@ if __name__ == '__main__':
|
|
154 |
with gr.Column():
|
155 |
|
156 |
inp_instruction = gr.Textbox(label='Instruction', lines=1)
|
157 |
-
btn_run = gr.Button("Run (this may take
|
158 |
info_run = gr.Markdown(label='Generated Code')
|
159 |
with gr.Column():
|
160 |
video_run = gr.Video(label='Video of Last Instruction')
|
|
|
95 |
try:
|
96 |
self._lmp_tabletop_ui(instruction, f'objects = {self._env.object_list}')
|
97 |
except Exception as e:
|
98 |
+
return f'Error: {e}', None, None
|
99 |
|
100 |
video_file_name = None
|
101 |
if self._env.cache_video:
|
|
|
140 |
with gr.Column():
|
141 |
with gr.Row():
|
142 |
inp_api_key = gr.Textbox(label='OpenAI API Key (this is not stored anywhere)', lines=1)
|
143 |
+
inp_model_name = gr.Dropdown(label='Model Name', choices=['code-davinci-002', 'text-davinci-002'], value='text-davinci-002')
|
144 |
with gr.Row():
|
145 |
inp_n_blocks = gr.Slider(label='Number of Blocks', minimum=0, maximum=4, value=3, step=1)
|
146 |
inp_n_bowls = gr.Slider(label='Number of Bowls', minimum=0, maximum=4, value=3, step=1)
|
|
|
154 |
with gr.Column():
|
155 |
|
156 |
inp_instruction = gr.Textbox(label='Instruction', lines=1)
|
157 |
+
btn_run = gr.Button("Run (this may take 30+ seconds)")
|
158 |
info_run = gr.Markdown(label='Generated Code')
|
159 |
with gr.Column():
|
160 |
video_run = gr.Video(label='Video of Last Instruction')
|
cfg.yaml
CHANGED
@@ -3,7 +3,7 @@ lmps:
|
|
3 |
tabletop_ui:
|
4 |
prompt_path: prompts/tabletop_ui.py
|
5 |
engine: model_name
|
6 |
-
max_tokens:
|
7 |
temperature: 0
|
8 |
query_prefix: '# '
|
9 |
query_suffix: '.'
|
|
|
3 |
tabletop_ui:
|
4 |
prompt_path: prompts/tabletop_ui.py
|
5 |
engine: model_name
|
6 |
+
max_tokens: 256
|
7 |
temperature: 0
|
8 |
query_prefix: '# '
|
9 |
query_suffix: '.'
|
prompts/parse_question.py
CHANGED
@@ -8,9 +8,6 @@ objects = ['yellow bowl', 'blue block', 'yellow block', 'blue bowl', 'fruit', 'g
|
|
8 |
yellow_object_names = parse_obj_name('the yellow objects', f'objects = {get_obj_names()}')
|
9 |
ret_val = len(yellow_object_names)
|
10 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
11 |
-
# is the pink block on the green bowl?
|
12 |
-
ret_val = bbox_contains_pt(container_name='green bowl', obj_name='pink block')
|
13 |
-
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
14 |
# what are the blocks left of the green bowl?
|
15 |
block_names = parse_obj_name('the blocks', f'objects = {get_obj_names()}')
|
16 |
green_bowl_pos = get_obj_pos('green bowl')
|
|
|
8 |
yellow_object_names = parse_obj_name('the yellow objects', f'objects = {get_obj_names()}')
|
9 |
ret_val = len(yellow_object_names)
|
10 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
|
|
|
|
|
|
11 |
# what are the blocks left of the green bowl?
|
12 |
block_names = parse_obj_name('the blocks', f'objects = {get_obj_names()}')
|
13 |
green_bowl_pos = get_obj_pos('green bowl')
|
prompts/tabletop_ui.py
CHANGED
@@ -15,11 +15,6 @@ objects = ['yellow block', 'green block', 'yellow bowl', 'blue block', 'blue bow
|
|
15 |
say('Got it - putting the green block on the top right corner')
|
16 |
corner_pos = parse_position('top right corner')
|
17 |
put_first_on_second('green block', corner_pos)
|
18 |
-
objects = ['yellow block', 'green block', 'yellow bowl', 'blue block', 'blue bowl', 'green bowl']
|
19 |
-
# stack the blue bowl on the yellow bowl on the green block.
|
20 |
-
order_bottom_to_top = ['green block', 'yellow block', 'blue bowl']
|
21 |
-
say(f'Sure - stacking from top to bottom: {", ".join(order_bottom_to_top)}')
|
22 |
-
stack_objects_in_order(object_names=order_bottom_to_top)
|
23 |
objects = ['cyan block', 'white block', 'cyan bowl', 'blue block', 'blue bowl', 'white bowl']
|
24 |
# move the cyan block into its corresponding bowl.
|
25 |
matches = {'cyan block': 'cyan bowl'}
|
@@ -39,7 +34,7 @@ say('Sure thing - putting the yellow block between the blue bowl and the green b
|
|
39 |
target_pos = parse_position('a point in the middle betweeen the blue bowl and the green block')
|
40 |
put_first_on_second('yellow block', target_pos)
|
41 |
objects = ['yellow block', 'red block', 'yellow bowl', 'gray block', 'gray bowl', 'red bowl']
|
42 |
-
# can you cut the
|
43 |
say('no, I can only move objects around')
|
44 |
objects = ['yellow block', 'green block', 'yellow bowl', 'gray block', 'gray bowl', 'green bowl']
|
45 |
# stack the blocks on the right side with the gray one on the bottom.
|
@@ -54,18 +49,18 @@ say('Ok! Stacking everything with the green block on the top')
|
|
54 |
order_bottom_to_top = ['blue bowl', 'pink bowl', 'green bowl', 'pink block', 'blue block', 'green block']
|
55 |
stack_objects_in_order(object_names=order_bottom_to_top)
|
56 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
57 |
-
# move the grass-colored
|
58 |
-
say('Sure - moving the green
|
59 |
-
left_pos = parse_position('a point 10cm left of the green
|
60 |
-
put_first_on_second('green
|
61 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
62 |
-
# why did you move the red
|
63 |
-
say(f'I did not move the red
|
64 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
65 |
# undo that.
|
66 |
-
say('Sure - moving the green
|
67 |
-
left_pos = parse_position('a point 10cm right of the green
|
68 |
-
put_first_on_second('green
|
69 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
70 |
# place the top most block to the corner closest to the bottom most block.
|
71 |
top_block_name = parse_obj_name('top most block', f'objects = {get_obj_names()}')
|
@@ -74,38 +69,16 @@ closest_corner_pos = parse_position(f'the corner closest to the {bottom_block_na
|
|
74 |
say(f'Putting the {top_block_name} on the {get_corner_name(closest_corner_pos)}')
|
75 |
put_first_on_second(top_block_name, closest_corner_pos)
|
76 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
77 |
-
# move the brown
|
78 |
-
closest_side_position = parse_position('the side closest to the green
|
79 |
-
say(f'Got it - putting the brown
|
80 |
-
put_first_on_second('brown
|
81 |
-
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
82 |
-
# place the green block to the right of the bowl that has the blue block.
|
83 |
-
bowl_name = parse_obj_name('the bowl that has the blue block', f'objects = {get_obj_names()}')
|
84 |
-
if bowl_name:
|
85 |
-
target_pos = parse_position(f'a point 10cm to the right of the {bowl_name}')
|
86 |
-
say(f'No problem - placing the green block to the right of the {bowl_name}')
|
87 |
-
put_first_on_second('green block', target_pos)
|
88 |
-
else:
|
89 |
-
say('There are no bowls that has the blue block')
|
90 |
-
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
91 |
-
# place the blue block in the empty bowl.
|
92 |
-
empty_bowl_name = parse_obj_name('the empty bowl', f'objects = {get_obj_names()}')
|
93 |
-
if empty_bowl_name:
|
94 |
-
say(f'Ok! Putting the blue block on the {empty_bowl_name}')
|
95 |
-
put_first_on_second('blue block', empty_bowl_name)
|
96 |
-
else:
|
97 |
-
say('There are no empty bowls')
|
98 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
99 |
# move the other blocks to the bottom corners.
|
100 |
-
block_names = parse_obj_name('blocks other than the
|
101 |
corners = parse_position('the bottom corners')
|
102 |
for block_name, pos in zip(block_names, corners):
|
103 |
put_first_on_second(block_name, pos)
|
104 |
-
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
105 |
-
# move the red bowl a lot to the left of the blocks.
|
106 |
-
say('Sure! Moving the red bowl to a point left of the blocks')
|
107 |
-
left_pos = parse_position('a point 20cm left of the blocks')
|
108 |
-
put_first_on_second('red bowl', left_pos)
|
109 |
objects = ['pink block', 'gray block', 'orange block']
|
110 |
# move the pinkish colored block on the bottom side.
|
111 |
say('Ok - putting the pink block on the bottom side')
|
@@ -134,25 +107,12 @@ say(f'Ok - moving the other {len(block_names)} blocks to different corners')
|
|
134 |
for block_name, pos in zip(block_names, corners):
|
135 |
put_first_on_second(block_name, pos)
|
136 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
137 |
-
# is the pink block on the green bowl.
|
138 |
-
if parse_question('is the pink block on the green bowl', f'objects = {get_obj_names()}'):
|
139 |
-
say('Yes - the pink block is on the green bowl.')
|
140 |
-
else:
|
141 |
-
say('No - the pink block is not on the green bowl.')
|
142 |
-
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
143 |
# what are the blocks left of the green bowl.
|
144 |
left_block_names = parse_question('what are the blocks left of the green bowl', f'objects = {get_obj_names()}')
|
145 |
if len(left_block_names) > 0:
|
146 |
say(f'These blocks are left of the green bowl: {", ".join(left_block_names)}')
|
147 |
else:
|
148 |
say('There are no blocks left of the green bowl')
|
149 |
-
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
150 |
-
# if you see a purple bowl put it on the blue bowl
|
151 |
-
if is_obj_visible('purple bowl'):
|
152 |
-
say('Putting the purple bowl on the pink bowl')
|
153 |
-
put_first_on_second('purple bowl', 'pink bowl')
|
154 |
-
else:
|
155 |
-
say('I don\'t see a purple bowl')
|
156 |
objects = ['yellow block', 'green block', 'yellow bowl', 'blue block', 'blue bowl', 'green bowl']
|
157 |
# imagine that the bowls are different biomes on earth and imagine that the blocks are parts of a building.
|
158 |
say('ok')
|
@@ -161,10 +121,6 @@ objects = ['yellow block', 'green block', 'yellow bowl', 'blue block', 'blue bow
|
|
161 |
order_bottom_to_top = ['green bowl', 'blue block', 'green block', 'yellow block']
|
162 |
say('stacking the blocks on the green bowl')
|
163 |
stack_objects_in_order(object_names=order_bottom_to_top)
|
164 |
-
objects = ['yellow block', 'green block', 'yellow bowl', 'gray block', 'gray bowl', 'green bowl']
|
165 |
-
# show me what happens when the desert gets flooded by the ocean.
|
166 |
-
say('putting the yellow bowl on the blue bowl')
|
167 |
-
put_first_on_second('yellow bowl', 'blue bowl')
|
168 |
objects = ['pink block', 'gray block', 'orange block']
|
169 |
# move all blocks 5cm toward the top.
|
170 |
say('Ok - moving all blocks 5cm toward the top')
|
|
|
15 |
say('Got it - putting the green block on the top right corner')
|
16 |
corner_pos = parse_position('top right corner')
|
17 |
put_first_on_second('green block', corner_pos)
|
|
|
|
|
|
|
|
|
|
|
18 |
objects = ['cyan block', 'white block', 'cyan bowl', 'blue block', 'blue bowl', 'white bowl']
|
19 |
# move the cyan block into its corresponding bowl.
|
20 |
matches = {'cyan block': 'cyan bowl'}
|
|
|
34 |
target_pos = parse_position('a point in the middle betweeen the blue bowl and the green block')
|
35 |
put_first_on_second('yellow block', target_pos)
|
36 |
objects = ['yellow block', 'red block', 'yellow bowl', 'gray block', 'gray bowl', 'red bowl']
|
37 |
+
# can you cut the blocks in half.
|
38 |
say('no, I can only move objects around')
|
39 |
objects = ['yellow block', 'green block', 'yellow bowl', 'gray block', 'gray bowl', 'green bowl']
|
40 |
# stack the blocks on the right side with the gray one on the bottom.
|
|
|
49 |
order_bottom_to_top = ['blue bowl', 'pink bowl', 'green bowl', 'pink block', 'blue block', 'green block']
|
50 |
stack_objects_in_order(object_names=order_bottom_to_top)
|
51 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
52 |
+
# move the grass-colored block to the left.
|
53 |
+
say('Sure - moving the green block left by 10 centimeters')
|
54 |
+
left_pos = parse_position('a point 10cm left of the green block')
|
55 |
+
put_first_on_second('green block', left_pos)
|
56 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
57 |
+
# why did you move the red block.
|
58 |
+
say(f'I did not move the red block')
|
59 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
60 |
# undo that.
|
61 |
+
say('Sure - moving the green block right by 10 centimeters')
|
62 |
+
left_pos = parse_position('a point 10cm right of the green block')
|
63 |
+
put_first_on_second('green block', left_pos)
|
64 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
65 |
# place the top most block to the corner closest to the bottom most block.
|
66 |
top_block_name = parse_obj_name('top most block', f'objects = {get_obj_names()}')
|
|
|
69 |
say(f'Putting the {top_block_name} on the {get_corner_name(closest_corner_pos)}')
|
70 |
put_first_on_second(top_block_name, closest_corner_pos)
|
71 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
72 |
+
# move the brown block to the side closest to the green bowl.
|
73 |
+
closest_side_position = parse_position('the side closest to the green bowl')
|
74 |
+
say(f'Got it - putting the brown block on the {get_side_name(closest_side_position)}')
|
75 |
+
put_first_on_second('brown block', closest_side_position)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
objects = ['brown bowl', 'green block', 'brown block', 'green bowl', 'blue bowl', 'blue block']
|
77 |
# move the other blocks to the bottom corners.
|
78 |
+
block_names = parse_obj_name('blocks other than the green block', f'objects = {get_obj_names()}')
|
79 |
corners = parse_position('the bottom corners')
|
80 |
for block_name, pos in zip(block_names, corners):
|
81 |
put_first_on_second(block_name, pos)
|
|
|
|
|
|
|
|
|
|
|
82 |
objects = ['pink block', 'gray block', 'orange block']
|
83 |
# move the pinkish colored block on the bottom side.
|
84 |
say('Ok - putting the pink block on the bottom side')
|
|
|
107 |
for block_name, pos in zip(block_names, corners):
|
108 |
put_first_on_second(block_name, pos)
|
109 |
objects = ['pink block', 'green block', 'pink bowl', 'blue block', 'blue bowl', 'green bowl']
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
# what are the blocks left of the green bowl.
|
111 |
left_block_names = parse_question('what are the blocks left of the green bowl', f'objects = {get_obj_names()}')
|
112 |
if len(left_block_names) > 0:
|
113 |
say(f'These blocks are left of the green bowl: {", ".join(left_block_names)}')
|
114 |
else:
|
115 |
say('There are no blocks left of the green bowl')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
objects = ['yellow block', 'green block', 'yellow bowl', 'blue block', 'blue bowl', 'green bowl']
|
117 |
# imagine that the bowls are different biomes on earth and imagine that the blocks are parts of a building.
|
118 |
say('ok')
|
|
|
121 |
order_bottom_to_top = ['green bowl', 'blue block', 'green block', 'yellow block']
|
122 |
say('stacking the blocks on the green bowl')
|
123 |
stack_objects_in_order(object_names=order_bottom_to_top)
|
|
|
|
|
|
|
|
|
124 |
objects = ['pink block', 'gray block', 'orange block']
|
125 |
# move all blocks 5cm toward the top.
|
126 |
say('Ok - moving all blocks 5cm toward the top')
|