Home

Awesome

<h1 align="center"> ScienceWorld </h1> <p align="center"> <!-- Version badge using shields.io --> <a href="https://github.com/allenai/ScienceWorld/releases"> <img src="https://img.shields.io/github/v/release/allenai/ScienceWorld"> </a> <!-- Link to tutorials badge using shields.io --> <a href="https://huggingface.co/spaces/MarcCote/ScienceWorld"> <img src="https://img.shields.io/badge/🤗-Demo-yellow"> </a> <!-- Follow on twitter badge using shields.io --> <a href="https://sciworld.apps.allenai.org"> <img src="https://img.shields.io/badge/Website-green"> </a> </p>

ScienceWorld is a text-based virtual environment centered around accomplishing tasks from the standardized elementary science curriculum. This code accompanies the paper ScienceWorld: Is your Textual Agent Smarter than a 5th grader?.

<h3 align="center"><img src="https://github.com/allenai/ScienceWorld/blob/main/media/scienceworld_environment.png" width="75%"/></h3>

Demo and examples

You can try ScienceWorld yourself via our HuggingFace Space or read some of the playthrough transcripts.

Citation

@misc{scienceworld2022,
    title={ScienceWorld: Is your Agent Smarter than a 5th Grader?},
    author={Ruoyao Wang and Peter Jansen and Marc-Alexandre C{\^o}t{\'e} and Prithviraj Ammanabrolu},
    year={2022},
    eprint={2203.07540},
    archivePrefix={arXiv},
    primaryClass={cs.CL},
    url={https://arxiv.org/abs/2203.07540}
}

Quickstart

Before running: You will have to have Java 1.8+ installed on your system (shipped with most linux distributions) and Python 3.8+. We recommend creating a conda environment like this:

conda create --name scienceworld python=3.8
conda activate scienceworld

Then, install ScienceWorld either from PyPi:

pip install scienceworld

or from source in development mode:

git clone https://github.com/allenai/ScienceWorld.git
cd ScienceWorld
pip install .

Run an example random agent, on task 13 (classification: place a non-living thing in a box), for 5 episodes:

python examples/random_agent.py --task-num=13 --num-episodes=5 --simplifications-preset easy

Run a user console where you can interact with the environment, on task 3 (change of state: melting):

python examples/human.py --task-num=3 --num-episodes=5

Web Server Demo

A web server demo is also available, that allows running a ScienceWorld user console that can be interacted with in a web browser.

<h3 align="center"><img src="https://github.com/allenai/ScienceWorld/blob/main/media/web_demo_screenshot.png" width="75%"/></h3>

To run the web server demo:

conda create --name scienceworld python=3.8
conda activate scienceworld
pip install scienceworld[webserver]

Run the web server:

python examples/scienceworld-web-server-example.py

Point your web browser to: localhost:8080

ScienceWorld Design

ScienceWorld is written in Scala (2.12.9), and compiles using sbt into a JAR file that is run with Java. For convenience, a Python API is provided (Python >= 3.8), which interfaces using the py4j package.

If you modified the Scala code, you can recompile the JAR file by running:

./simulator/package.sh
pip install -e .

Tasks

The tasks are listed in the table below along with their number of variations. Either the task ID or its name can be used to a task with env.load().

Task IDTask Name# Variations
1-1boil30
1-2melt30
1-3freeze30
1-4change-the-state-of-matter-of30
2-1use-thermometer540
2-2measure-melting-point-known-substance436
2-3measure-melting-point-unknown-substance300
3-1power-component20
3-2power-component-renewable-vs-nonrenewable-energy20
3-3test-conductivity900
3-4test-conductivity-of-unknown-substances600
4-1find-living-thing300
4-2find-non-living-thing300
4-3find-plant300
4-4find-animal300
5-1grow-plant126
5-2grow-fruit126
6-1chemistry-mix32
6-2chemistry-mix-paint-secondary-color36
6-3chemistry-mix-paint-tertiary-color36
7-1lifespan-longest-lived125
7-2lifespan-shortest-lived125
7-3lifespan-longest-lived-then-shortest-lived125
8-1identify-life-stages-114
8-2identify-life-stages-210
9-1inclined-plane-determine-angle168
9-2inclined-plane-friction-named-surfaces1386
9-3inclined-plane-friction-unnamed-surfaces162
10-1mendelian-genetics-known-plant120
10-2mendelian-genetics-unknown-plant480

Baseline Agents

DRRN: https://github.com/cognitiveailab/drrn-scienceworld

KG-A2C: https://github.com/cognitiveailab/kga2c-scienceworld

CALM: https://github.com/cognitiveailab/calm-scienceworld

Behavior Cloning and Decision Transformer: https://github.com/cognitiveailab/t5-scienceworld