Skip to content

Latest commit

 

History

History

env

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

KARL Training & Evaluation Environment Setup

This directory contains the task environment server for KARL, which hosts task workers and a controller for agent interaction. This setup is used for both training and evaluation.


1. Setup Environment

cd KARL/env
conda create -n karl python=3.9
conda activate karl
pip install -r requirements.txt

2. DBBench Setup

Docker

Ensure that Docker is properly installed. Verify it is running with:

docker ps

Pull the required MySQL image for DBBench:

docker pull mysql

Data

Spider 1.0 — Download the dataset from the official website: https://yale-lily.github.io/spider

BIRD — Download the dataset from the official website: https://bird-bench.github.io/

After downloading, fill in the database paths in configs/tasks/dbbench.yaml:

dbbench-spider-100:
  parameters:
    db_file: "path_to_your_spider_database"   # <-- set this

dbbench-bird-dev-100:
  parameters:
    db_file: "path_to_your_bird_dev_database"  # <-- set this

3. KnowledgeGraph Setup

The KnowledgeGraph task depends on a SPARQL endpoint over Freebase. The default configuration points to a remote service which may not always be available. To deploy it locally, follow the steps below.

Step 1. Download the Freebase database dump and set up the Virtuoso SPARQL service by following the instructions at dki-lab/Freebase-Setup.

Step 2. Update the SPARQL endpoint URL in configs/tasks/kg.yaml:

sparql_url: "<your service api of sparql>"   # replace the default URL

Note: Start your KG service before launching the agent task services.


4. Start the Task Services

Configure which tasks to serve and how many workers to allocate in configs/start_task.yaml:

start:
  kg-env_train: 30      # task name: number of workers
  dbbench-env_train: 30
  # add or comment out tasks as needed

Then launch the services:

python -m src.start_task -a

This will start the controller and all configured task workers automatically.

The controller listens on port 8000 by default. To change this, edit the controller_port variable in src/start_task.py.

5. Evaluation Setup

Evaluation of our framework uses exactly the same setup as above. Use start_task to start the controller and workers.

If you want to change the evaluation method of KnowledgeGraph tasks, please change configs/tasks/kg.yaml to test mode, which will use F1 score as the evaluation method instead of pass rate:

start:
  test_mode: true

For the following four tasks: GrailQA, WebQSP, Spider1.0, and BIRD-Dev, the default evaluation mode is to use a small evaluation set as a quick validation. To enable the full evaluation of the four datasets, please modify the task files in configs/tasks/kg.yaml and configs/tasks/dbbench.yaml to the following format:

dbbench-spider-all:
  parameters:
    name: dbbench-spider-all
    data_file: "data/dbbench/spider-test_all.json"
    db_file: "path_to_db_file"  # Replace with the actual path to the database file for spider test

dbbench-bird-dev-all:
  parameters:
    name: dbbench-bird-dev-all
    data_file: "data/dbbench/bird_dev_test_all.json"
    db_file: "path_to_db_file"
kg-grailqa-all:
  parameters:
    name: "kg-grailqa-all"
    data_file: "data/knowledgegraph_new_tools/grailqa_all.json"

kg-webqsp:
  parameters:
    name: "kg-webqsp-all"
    data_file: "data/knowledgegraph_new_tools/webqsp_all.json"