DEV Community

Cover image for State of the Art Prompt Builder with AiConfig
Ranjan Dailata
Ranjan Dailata

Posted on

State of the Art Prompt Builder with AiConfig

Introduction

In this blog post, you will be demonstrated with the state-of-the-art prompt building mechanism. Prompt Engineering is the hottest topic of the year since from 2022 when the ChatGPT got into the public. Building of suitable prompts is an art and engineering too. One needs to have a detailed understanding on various things - Domain, Requirements, Knowledge and working experience with the large language model.

Background

For this purpose, we'll be making use of AiConig driven approach of LastMileAI. If you are new to the LastMileAI or AiConfig, I request you to please read the following blogs

Building with generative AI
Prompt Chaining
HumanAndAIConfig

Hands-on

When it comes to the hands on, As a preference, AiConfig is the framework through which you will be presented with the prompt building mechanism. There are various reasons like easy to iterate, test and see the responses in real-time with the LastMileAI Workbook. When it comes to the Prompt Chaining I personally prefer the AiConfig and the Workbook approach. However, it's purely optional for this development.

Let's deep dive into the prompt template and chaining concept. Here's the template which will be utilized for building or fulfilling any tasks. Please make sure to replace the task with your own preferred task for generation. Ex: Long Summary Generation

Use the below prompt template as a pattern and come a mechanism for {{task}}

You can come up with as many prompt steps as you wish

Here's an example prompt template for Job Description Parsing

---
Prompt 1: Identify sections in the job description

Prompt 2: Extract role title 

Prompt 3: Extract department and reporting manager

Prompt 4: Classify job type as full-time, part-time, contract

Prompt 5: Identify seniority level like junior, mid, senior

Prompt 6: Parse out key responsibilities and duties 

Prompt 7: Split responsibilities into individual duty statements  

Prompt 8: Extract qualifications section

Prompt 9: Define required years of experience for role 

Prompt 10: List minimum academic degree needed 

Prompt 11: Specify essential skill requirements

Prompt 12: Identify nice-to-have skills  

Prompt 13: Extract industry or technologies job relates to

Prompt 14: Classify extracted information into schema
---
Enter fullscreen mode Exit fullscreen mode

Next thing is, let's say you wish to output the response in a JSON format, you could do that one easily as below. Here I am considering the summary generation example, However it could be anything. If you are wondering how to build the JSON schema, do not worry. You can simply execute the above prompt template on ChatGPT or the Lastmile Workbook and get the JSON formatted responses. Just copy, past and reuse or fine-tune the same.

Output the response in the following JSON format.

{
  "summary": "",

  "keypoints": [

  ]
}
Enter fullscreen mode Exit fullscreen mode

You need to do the following steps and tweak the prompts based on your requirements.

Here's the AiConfig template that you would need. Please copy the below one and save that one to your local.

{
  "name": "State of the Art Prompt Builder",
  "schema_version": "latest",
  "metadata": {
    "models": {
      "gpt-3.5-turbo": {
        "model": "gpt-3.5-turbo",
        "top_p": 1,
        "temperature": 1,
        "presence_penalty": 0,
        "frequency_penalty": 0
      }
    },
    "parameters": {}
  },
  "prompts": [
    {
      "name": "prompt_builder",
      "input": "Use the below prompt template as a pattern and come a mechanism for {{task}}\n\nYou can come up with as many prompt steps as you wish\n\nHere's an example prompt template for Job Description Parsing\n\n---\nPrompt 1: Identify sections in the job description\n\nPrompt 2: Extract role title \n\nPrompt 3: Extract department and reporting manager\n\nPrompt 4: Classify job type as full-time, part-time, contract\n\nPrompt 5: Identify seniority level like junior, mid, senior\n\nPrompt 6: Parse out key responsibilities and duties \n\nPrompt 7: Split responsibilities into individual duty statements  \n\nPrompt 8: Extract qualifications section\n\nPrompt 9: Define required years of experience for role \n\nPrompt 10: List minimum academic degree needed \n\nPrompt 11: Specify essential skill requirements\n\nPrompt 12: Identify nice-to-have skills  \n\nPrompt 13: Extract industry or technologies job relates to\n\nPrompt 14: Classify extracted information into schema\n---",
      "metadata": {
        "model": {
          "name": "gpt-3.5-turbo",
          "settings": {}
        },
        "parameters": {
          "task": "Named Entity Recognition"
        },
        "remember_chat_context": true
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode
  1. Login to LastMileAI
  2. Navigate to the Workbooks and then do the following to upload the above prompt template aiconfig file.
  3. Once the upload is done, you will be seeing the {{task}} placeholder which you could easily edit and get the prompts as per your needs.

StateOfTheArtPromptBuilder1

StateOfTheArtPromptBuilde2

Top comments (0)