Coder Social home page Coder Social logo

principled-prompter's Introduction

principled-prompter

Introduction

Among the 26 principles presented in the paper "Principled Instructions Are All You Need for Questioning LLaMA-1/2, GPT-3.5/4", 24 principles, examples of which can be obtained from the source GitHub, are followed.

From the data provided by the source GitHub, we were able to obtain data before and after correction for about 20 prompts for each principle, and used this as a few shot example to give instructions to LLM.

At the same time, when asked to create a prompt that satisfies too many principles, we observe issues that lead to poor performance. Accordingly, we attempt to achieve only 5 to 10 principles at a time and then gradually increase the principles achieved through iteration.

In order to control unexpected corrections that occur in the process of leaving everything to LLM, an Analyzer and Observer that control the process were implemented separately.

Features

Diagram

structure

Prompt Editor

  • Make the user's prompt follow the principle as much as possible
  • Cut the principle into chunks of num_agent to enable divide and conquer.

Prompt Observer

  • Check whether the corrected prompt is a correction to the prompt and not an answer to the prompt.

Prompt Analyzer

  • Check whether the corrected prompt follows any of the overall principles

Get Started

prompt leaking

can try with

poetry run python examples/example.py
from principled_prompter import agent

if __name__ == "__main__":
    model = agent.PromptCalibrator(num_agent=3)
    result = model.calibrate(
        question="Craft a beginner's introduction to the concept of gravity. Aim it at students in the early stages of elementary school.",
    )
    pprint(result.model_dump())

{
    "calibrated_question": "Explain to me like I'm 9 years old: What is gravity "
    "and how does it affect things on Earth? You MUST "
    "provide an example of gravity in action and explain "
    "how it's connected to the Earth and other objects in "
    "space. You will be penalized if you don't use simple "
    "language.",
    "followed_principles": [
        "Integrate the intended audience in the prompt, e.g., "
        "the audience is an expert in the field.",
        "Employ affirmative directives such as ‘do,’ while "
        "steering clear of negative language like ‘don’t’.",
        "When you need clarity or a deeper understanding of a "
        "topic, idea, or any piece of information, utilize "
        "the\n"
        "following prompts:\n"
        "o Explain [insert specific topic] in simple terms.\n"
        "o Explain to me like I’m 11 years old.\n"
        "o Explain to me as if I’m a beginner in [field].\n"
        "o Write the [essay/text/paragraph] using simple "
        "English like you’re explaining something to a "
        "5-year-old.\n",
        "Incorporate the following phrases: “Your task is” " "and “You MUST”.",
        "Incorporate the following phrases: “You will be " "penalized”.",
        "Use leading words like writing “think step by " "step”.",
    ],
    "question": "Craft a beginner's introduction to the concept of gravity. Aim "
    "it at students in the early stages of elementary school.",
}

principled-prompter's People

Contributors

hskimim avatar

Watchers

Kostas Georgiou avatar  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.