npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quality-prompts-js

v0.0.3

Published

Use and evaluate prompting techniques quickly. QualityPrompts implements 58 prompting techniques.

Downloads

4

Readme

QualityPrompts

Write Quality Prompts - TypeScript/JavaScript edition

Use and evaluate prompting techniques quickly

🔬 QualityPrompts implements 58 prompting techniques explained in this survey from OpenAI, Microsoft, et al.. Original Python implementation by Sarthak Rastogi.

📚 Usage

1. Install Quality Prompts:

npm/yarn/bun install quality-prompts-js

2. Write the components of your prompt:

import { qualityPrompt } from "quality-prompts-js"

const directive = "You are given a document and your task..."
const additionalInformation = "In the knowledge graph, ..."
const outputFormatting = "You will respond with a knowledge graph in..."

const prompt = qualityPrompt(
  directive,
  additionalInformation,
  outputFormatting,
  []
)

3. QualityPrompts searches and uses only the few-shot examples that are relevant to the user's query

import { fewShot } from "quality-prompts-js"

// see ./examples/few-shot.ts for a fully working example
const relevantExamples = await fewShot(
 "list the disorders included in cvd",
  [...],
  2 // 2-shot 
)

4. Simply call one of several prompting techniques to your prompt

System2Attention

Helps clarify the given context as an additinoal step before it's used to answer the question

import { system2Attention } from "quality-prompts-js"

const inputText = "list the disorders included in cvd"
const userContextInformation = "Problem with heart rate."

const attentionOptimizedPrompt = await system2Attention(inputText, userContextInformation)

console.log("Optimized attention prompt: ", attentionOptimizedPrompt)
>> You are given a document and your task is to create a knowledge graph from it.
        
In the knowledge graph, entities such as people, places, objects, institutions, topics, ideas, etc. are represented as nodes.
Whereas the relationships and actions between them are represented as edges.

Example input: Cardiovascular disease (CVD) encompasses a spectrum of...
Example output: [{'entity': 'cardiovascular disease (cvd)', 'connections': ...

You will respond with a knowledge graph in the given JSON format:

[
    {"entity" : "Entity_name", "connections" : [
        {"entity" : "Connected_entity_1", "relationship" : "Relationship_with_connected_entity_1},
        {"entity" : "Connected_entity_2", "relationship" : "Relationship_with_connected_entity_2},
        ]
    },
]

Tabular Chain of Thought Prompting

Prompts the LLM to think step by step and write the step, process and result of each step in a markdown table. Significantly boosts accuracy in solving math problems.

import { tabularChainOfThoughtPrompting, qualityPrompt } from "quality-prompts-js"

const inputText = `Jackson is planting tulips. He can fit 6 red tulips in a row and 8 blue
tulips in a row. If Jackson buys 36 red tulips and 24 blue tulips, how
many rows of flowers will he plant?`

const directive = "Solve the given math problem"

const tabularChain = await tabularChainOfThoughtPrompting(inputText, directive, "")

const systemPrompt = qualityPrompt(tabularChain.directive, tabularChain.outputFormatting)

console.log("Optimized tabular chain of thought prompt: ", systemPrompt)
Solve the given math problem.
Think through the problem step by step to solve it.
At each step, you have to figure out:
- the step number,
- the sub-question to be answered in that step,
- the thought process of solving that step, and
- the result of solving that step.
Respond in the following markdown table format for each step:
|step|subquestion|process|result|    

6. Upcoming: Easily evaluate different prompting techniques