Giter Site home page Giter Site logo

jjhw / gpt-htn-planner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daemonib/gpt-htn-planner

0.0 0.0 0.0 343 KB

A Hierarchical Task Network planner utilizing LLMs like OpenAI's GPT-4 to create complex plans from natural language that can be converted into an executable form.

JavaScript 4.39% Python 91.01% CSS 1.61% HTML 2.99%

gpt-htn-planner's Introduction

The HTN Planner automatically generates detailed plans utilizing OpenAI's GPT and the Hierarchical Task Network (HTN) architecture. The system generates tasks to achieve a goal using the LLM and then iteratively decomposes it into subtasks that can be executed.

For best results use GPT-4, though other OpenSource LLMs may suffice with modifications to the api

Components:

  • Decomposition - Takes a task and decomposes it into subtasks until the max depth is reached or the plan has failed. The system keeps track of candidate decompositions and attempts to choose the best option. May exit early if results are good.
  • Re-planning - When planning fails or part of a plan fails, re-planning occurs
  • Task Execution - Identifies a task as an executable unit
    • At present tasks are not actually executed in a terminal
  • State Tracking - The LLM tracks and updates the state as execution occurs
  • Text Parsing - Parses and extracts information from the natural language responses produced by the LLM
  • Task Translation - Attempts to translate a low level task into a command or piece of code that can be executed.
  • Frontend - A simple react frontend to display a hierarchy representing the plan
  • Prompt Evolver - An application designed to automatically generate prompts using evolutionary algorithms
    • Selection is performed using roulette wheel selection
    • Mutation is performed by the LLM
    • Recombination is performed by the LLM using the results of selection
    • Fitness is determined by the LLM and is normalized using a z-score so that results can be compared using standard deviations
    • Environment topology is a 2D toroidal grid that adjusts to local or global optimization dynamically
  • Logs - A large variety of logs are generated in the "logs" folder and function traces can be found in "function_trace.log"
    • function_trace.log - Tracks all the function calls annotated with "@trace_function_calls"
    • The logs in the "logs" folder each track a particular sub-system using the "log_response" function
    • parsing_errors - Tracks any issues with parsing the output from the LLM so that updates can be made to the parser to fix the issue
    • state_changes - Tracks the state transitions over time generated by the LLM based on the information it has

ToDo:

  • Store the pieces of successful plans in a vector db for later use and reduce generation costs
  • Continue to improve text parsing to deal with more edge cases
  • More post-processing
  • Re-evaluate preconditions as a requirement for task execution

Installation:

  • Backend

    • Set the environment variable OPENAI_KEY to your OpenAI api key
    • Install Dependencies
      • Run pip install -r requirements.txt
    • Run Planning Application
      • python src/main.py
      • Enter the initial state
        • This is any information that you want the system to know before it begins planning
        • You may put None or nothing in this input
      • Describe your goal
        • Enter the goal that the system is planning to reach
        • Ex: eat a ham sandwich
      • Default capabilities
        • These are the tools that the planner may consider using when creating the plan
        • This defaults to Linux terminal, internet access, you can just press enter to use these
      • Choose planner
        • Options for creating plans using different types of planning algorithms. Options like, the HTN Planner and A* Search Planner.
        • This defaults to using the HTN Planner
    • Run Prompt Evolver Application
      • python src/prompt_evolver.py
      • Enter in the goal or problem that you'd like prompts designed around.
  • Frontend:

    • Go into the frontend directory
      • cd src/frontend
    • Start the frontend
      • npm start

Credits:

  • DaemonIB
  • GPT-4
  • Bard

References:

gpt-htn-planner's People

Contributors

daemonib avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.