AI-Researcher

repository·main·Indexed 26 days ago

https://github.com/hkuds/ai-researcher

An autonomous system for scientific discovery that automates the research lifecycle, including literature review, idea generation, algorithm implementation, and manuscript creation. It features a Research Agent for conducting surveys and experiments (Level 1 and Level 2 tasks), a Paper Writing Agent for generating academic manuscripts, and a Gradio-based web GUI. The system supports Docker-based interactive environments and includes tools for creating innovation benchmark datasets and performing reasoning inference on the MATH-500 dataset.

Tokens
3.5K
Snippets
8
Records
20
Agent score
90%

What's inside AI-Researcher

  1. Run Level 2 Research Tasks (Idea Generation & Experiments)

    main

    Use the Research Agent to generate novel research ideas from a list of reference papers and then conduct experiments (Level 2 tasks). This requires setting up environment variables for Docker workplace, base images, and LLM models.

    Execute the command found in research_agent/run_infer_level_2.sh to run the run_infer_idea.py script.

    current_dir=$(dirname "$(readlink -f "$0")")
    cd $current_dir
    export DOCKER_WORKPLACE_NAME=workplace_paper
    
    export BASE_IMAGES=tjbtech1/paperagent:latest
    
    export COMPLETION_MODEL=claude-3-5-sonnet-20241022
    export CHEEP_MODEL=claude-3-5-haiku-20241022
    
    category=vq
    instance_id=one_layer_vq
    export GPUS='"device=0,1"'
    
    python run_infer_idea.py --instance_path ../benchmark/final/${category}/${instance_id}.json --container_name paper_eval --model $COMPLETION_MODEL --workplace_name workplace --cache_path cache --port 12372 --max_iter_times 0 --category ${category}
  2. Create the innovation benchmark dataset

    main

    Follow these three steps to generate the innovation benchmark dataset:

    1. Prepare search terms: Create a list of paper titles or keywords in the papers_to_search file.
    2. Collect papers: Run python 0_crawl_paper.py to collect papers and their related metadata.
    3. Generate dataset: Run python 1_create_inno_graph.py to produce the final innovation dataset.

    Important Configuration Notes:

    • Keyword Search: To collect papers based on keywords rather than exact titles, set exact_match to False in 0_crawl_paper.py.
    • OpenAI API Key: You must set your OpenAI key globally in your environment or edit utils/openai_utils.py directly.

    Output Locations:

    • The final results are stored at innovation_graph/innovation_graph_final.json.
    • Note that the specific dataset used in the project's evaluation is merged_papers_with_fields.json, which includes manual revisions.
  3. Run Level 1 Research Tasks (Survey & Experiments)

    main

    Use the Research Agent to conduct extensive surveys and experiments based on a provided idea (Level 1 tasks). This requires setting up environment variables for Docker workplace, base images, and LLM models (Completion and Cheap models).

    Execute the command found in research_agent/run_infer_level_1.sh to run the run_infer_plan.py script.

    current_dir=$(dirname "$(readlink -f "$0")")
    cd $current_dir
    export DOCKER_WORKPLACE_NAME=workplace_paper
    
    export BASE_IMAGES=tjbtech1/paperagent:latest
    
    export COMPLETION_MODEL=claude-3-5-sonnet-20241022
    export CHEEP_MODEL=claude-3-5-haiku-20241022
    
    category=vq
    instance_id=one_layer_vq
    export GPUS='"device=0,1"'
    
    python run_infer_plan.py --instance_path ../benchmark/final/${category}/${instance_id}.json --container_name paper_eval --task_level task1 --model $COMPLETION_MODEL --workplace_name workplace --cache_path cache --port 12372 --max_iter_times 0 --category ${category}
  4. Install AI-Researcher using uv

    main

    The recommended way to install AI-Researcher is using uv for faster package management. Follow these steps to clone the repository, set up a Python 3.11 virtual environment, and install dependencies including Playwright.

    # install uv
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source ~/.bashrc
    
    # clone the project
    git clone https://github.com/HKUDS/AI-Researcher.git
    cd AI-Researcher
    
    # install and activate enviroment
    uv venv --python 3.11
    source ./.venv/bin/activate
    uv pip install -e .
    playwright install
    # install uv
    curl -LsSf https://astral.sh/uv/install.sh | sh
    source ~/.bashrc
    
    # clone the project
    git clone https://github.com/HKUDS/AI-Researcher.git
    cd AI-Researcher
    
    # install and activate enviroment
    uv venv --python 3.11
    source ./.venv/bin/activate
    uv pip install -e .
    playwright install
  5. Generate Academic Papers with the Paper Writing Agent

    main

    After the research agent has completed its tasks, use the Paper Writing Agent to automatically generate a full-length academic manuscript. You must provide an OPENAI_API_KEY and specify the research_field and instance_id.

    Execute the writing.py script located in the paper_agent directory.

    #!/bin/bash
    
    cd path/to/AI-Researcher/paper_agent
    
    export OPENAI_API_KEY=sk-SKlupNntta4WPmvDCRo7uuPbYGwOnUQcb25Twn8c718tPpXN
    
    
    research_field=vq
    instance_id=rotated_vq
    
    python path/to/AI-Researcher/paper_agent/writing.py --research_field ${research_field} --instance_id ${instance_id}
  6. Install AI-Researcher using Docker

    main

    To set up the agent-interactive environment via Docker, you can either pull the pre-built image or build it from the provided Dockerfile. Ensure Docker is installed on your system.

    To pull the image:

    docker pull tjbtech1/airesearcher:v1

    To build the image from source:

    cd ./docker && docker build -t tjbtech1/airesearcher:v1 .
    docker pull tjbtech1/airesearcher:v1
  7. Configure HGCL Hyperparameters

    main

    The HGCL model is implemented in PyTorch and optimized using the Adam optimizer. When configuring the model, the following hyperparameter search spaces are used:

    • Batch size: {1024, 2048, 4096, 8192}
    • Learning rate: {4e-2, 4.5e-2, 5e-2, 5.5e-2, 6e-2}
    • Embedding size: {8, 16, 32, 64, 128}
    • GNN layers: {1, 2, 3}
    • Contrastive loss coefficient (β): {0.2, 0.25, 0.3, 0.35, 0.55, 0.6, 0.65}
    • Low rank matrix decomposition dimension (meta knowledge extraction): {1, 2, 3, 4, 5}
  8. Configure AI-Researcher environment variables

    main

    AI-Researcher requires configuration via an environment variable file (created from .env.template). The configuration is divided into container, LLM, and task settings.

    Container Configuration

    • DOCKER_WORKPLACE_NAME: Name of the research agent's workplace.
    • BASE_IMAGES: Base image for the agent (e.g., tjbtech1/airesearcher:v1).
    • COMPLETION_MODEL: Primary completion model name (compatible with LiteLLM).
    • CHEEP_MODEL: Secondary/cheaper model name.
    • GPUS: GPU allocation (e.g., '"device=0"', '"device=0,1"', '"all"', or None).
    • CONTAINER_NAME: Name of the container.
    • WORKPLACE_NAME: Name of the workplace.
    • CACHE_PATH: Path for caching.
    • PORT: Port for the research agent.
    • PLATFORM: Platform (e.g., linux/amd64).

    LLM Configuration

    • GITHUB_AI_TOKEN: GitHub AI token for the agent.
    • OPENROUTER_API_KEY: OpenRouter API key.
    • OPENROUTER_API_BASE: OpenRouter API base URL.

    Task Configuration

    • CATEGORY: Research category (e.g., diffu_flow, gnn, reasoning, recommendation, vq).
    • INSTANCE_ID: Instance ID for the research task.
    • TASK_LEVEL: Task level (task1 or task2).
    • MAX_ITER_TIMES: Maximum number of research iterations.
  9. Example: Implement recommendation ideas from reference papers

    main
    AI-Researcher can take a high-level prompt describing a research idea and a list of reference papers to generate a complete implementation plan. This includes identifying core techniques (e.g., GNNs, Contrastive Learning), defining component purposes, specifying implementation details (parameters, input/output, constraints), and outlining step-by-step interactions and critical implementation considerations.
  10. Run AI-Researcher Web GUI

    main

    AI-Researcher includes a web-based graphical interface built with Gradio. You can launch it by running the web_ai_researcher.py script. The GUI allows you to configure environment variables directly through a tab within the interface.

    python web_ai_researcher.py