code-as-policies / README.md
jackyliang42's picture
updated model to use text-davinci-003
8a9e562
metadata
title: Code As Policies
emoji: πŸ“ˆ
colorFrom: purple
colorTo: indigo
sdk: gradio
sdk_version: 3.3.1
app_file: app.py
pinned: false
license: apache-2.0

Code as Policies Tabletop Manipulation Interactive Demo

This demo is from the paper:

Code as Policies: Language Model Programs for Embodied Control

Below is an interactive demo for the simulated tabletop manipulation domain, seen in the paper section IV.D

Preparations

  1. Obtain an OpenAI API Key

Usage

  1. Fill in the API Key and how many blocks and bowls to be spawned in the environment.
  2. Click Setup/Reset Simulation
  3. Based on the new randomly sampled object names, input an instruction and click Run Instruction. If successful, this will render a video and update the simulation environment visualization.

You can run instructions in sequence and refer back to previous instructions (e.g. do the same with other blocks, move the same block to the other bowl, etc). To reset, click Setup/Reset Env, and this will clear the current instruction history.

Supported Instructions

  • Spatial reasoning (e.g. to the left of the red block, the closest corner, the farthest bowl, the second block from the right)
  • Sequential actions (e.g. put blocks in matching bowls, stack blocks on the bottom right corner)
  • Contextual instructions (e.g. do the same with the blue block, undo that)
  • Language-based reasoning (e.g. put the forest-colored block on the ocean-colored bowl).
  • Simple Q&A (e.g. how many blocks are to the left of the blue bowl?)

Example Instructions

Note object names may need to be changed depending the sampled object names.

  • put the sun-colored block on the bowl closest to it
  • stack the blocks on the bottom most bowl
  • arrange the blocks as a square in the middle
  • move the square 5cm to the right
  • how many blocks are to the right of the orange bowl?
  • pick up the block closest to the top left corner and place it on the bottom right corner

Known Limitations

  • 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.
  • 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.
  • The pick place primitive is also unable to pick up bowls.
  • 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.
  • 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)
  • Maximum token length - you may hit the maximum token length if running multiple commands in sequence. Please reset the simulation when this happens.