Skip to content

Dissertation Project: Human-Robot Interaction using GPT-3 and First-Order Logic

Notifications You must be signed in to change notification settings

StefanMorar/HRI-Quantifiers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HRI-Quantifiers

Installation

  • Recommended OS: Linux
  • Python 3.10
  • Add the mace4/bin directory to PATH:
    • Open the ~/.bashrc file (e.g., by running nano ~/.bashrc), add the following line at the end of it: export PATH="[...]:$PATH", where [..] should be replaced with the absolute path of the bin folder (e.g., export PATH="/home/user/HRI-Quantifier/mace4/bin:$PATH")
    • Save the file and load the new $PATH executing source ~/.bashrc
  • Add the value of OPENAI_API_KEY in .env or use the mocked mode by setting IS_OPENAI_CALL_MOCKED to true
  • requests: pip install requests
  • python-dotenv: pip install python-dotenv
  • OpenAI: pip install --upgrade openai
  • abe_sim: https://github.com/mpomarlan/abe_sim

Execution

  1. In the src folder of abe_sim, run python3 ./runBrain.py -g -l ./abe_sim/logicScene.json
    • You can define more objects in abe_sim/logicScene.json
  2. In the root folder of this repository, run python3 src/main.py

Testing

Alternatively, each component can be executed independently:

  • python3 mace4/run_mace4.py: will evaluate the expression from expression.in against background_knowledge.in and sensors.in and write the models to result.out
  • python3 src/evaluator.py: will evaluate the expressions from the main() function. Update the contents of this function to test different expressions
  • python3 src/converter.py: will convert the sentences from the main() function to expressions that can be used to query the state or send commands to the robot using the abe_sim agent simulation in PyBullet

Examples

Queries

Sentence Conversion
There are twice as many onions than carrots {'type':'query','expressions':['|exists x0 (onion(x0)).| == 2 * |exists x0 (carrot(x0)).|']}
There are twice as many onions than carrots {'type':'query','expressions':['|exists x0 (vegetable(x0) & redOnion(x0)).| > |exists x0 (vegetable(x0) & -redOnion(x0)).|']}
There are exactly 2 ovens {'type':'query','expressions':['|exists x0 (oven(x0)).| == 2']}

Commands

Sentence Conversion
Fetch a couple of red chilli peppers {'type':'command','expressions':[['|exists x1 (redChilliPepper(x1)).| >= 2']],'commands':['robot(x0) & redChilliPepper(x1) -> fetch(x0, x1).']}
Cut several broccoli {'type':'command','expressions':[['|exists x1 (broccoli(x1)).| >= 3']],'commands':['robot(x0) & broccoli(x1) & cuttingTool(x2) -> cut(x0, x1, x2).']}
Line a baking tray with paper {'type':'command','expressions':[['|exists x1 (bakingSheet(x1)).| >= 1','|exists x2 (bakingTray(x2)).| >= 1']],'commands':['robot(x0) & bakingSheet(x1) & bakingTray(x2) -> line(x0, x1, x2).']}

For more examples, check train_data.csv.

Article

https://arxiv.org/abs/2308.13192

About

Dissertation Project: Human-Robot Interaction using GPT-3 and First-Order Logic

Topics

Resources

Stars

Watchers

Forks