Varun Shenoy Profile picture
Feb 13 10 tweets 2 min read
A short guide to engineering better GPT-3 prompts.

Here's how I redesigned GraphGPT's prompt to become faster, more efficient, and handle larger inputs:
Some quick background:

GraphGPT is a tool that generates knowledge graphs from unstructured text using OpenAI's GPT-3 large language model.

Let's take a look at the original prompt.

This is a one-shot prompt. We share one example of what a graph might look like after processing a sample prompt.

Note how the entire state of the graph is stored within the prompt. Image
While this is fine for most cases (especially for a weekend hack), it comes with some issues.

It's expensive! On every successive query, you have to pass the state as an input and receive an updated state as an output.
It's also slow. GPT has to generate many repeated tokens for the state at the output.

There's a lot of redundancy in our state between prompts!

Finally, if your graph is large, you can run into limits imposed by MAX_TOKENS or context window size.
In sum: maintaining state within a prompt is costly.

Ideally, we want a set of instructions we can carry out on the client side to update the state within the browser.

GraphGPT's new prompt is entirely stateless. Image
In the prompt, I teach a simple domain-specific language (DSL) to the model.

I restrict the model to three kinds of updates: identifying relationships, updating colors, or deleting entities.

This is the power of in-context learning!
Our state is now entirely maintained within the browser. GPT generates far fewer tokens, improving costs and latency.

All we have to do is parse our DSL on the frontend and update our local state.
We can now maintain much larger graphs and process massive chunks of text quickly.

In effect, we've saved time and money by being clever with how we manage state between our personal computer and GPT.
Interested in seeing the rest of the project?

Here's the repo for GraphGPT:
github.com/varunshenoy/Gr…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Varun Shenoy

Varun Shenoy Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @varunshenoy_

Jan 31
Can LLMs extract knowledge graphs from unstructured text?

Introducing GraphGPT!

Pass in any text (summary of a movie, passage from Wikipedia, etc.) to generate a visualization of entities and their relationships.

A quick example:
Here's GraphGPT creating a knowledge graph from the synopsis of Veep:
In case you want to play with it yourself, here's the repo.

All you need is an OpenAI API key.

github.com/varunshenoy/Gr…
Read 5 tweets
Nov 21, 2022
Are you building in the zero knowledge space?

Do you care about speed, energy usage, and cost efficiency?

Then, you NEED to understand hardware acceleration.

This is the only thread you will ever need to read about making ZKPs faster using hardware 🧵 Image
1/ Some quick review:

Why do we care about ZKPs?

ZKPs enable one party to prove to another that a statement is true via a short proof without sharing more information than necessary.

Check out this thread for more info.
2/ How do ZKPs work?

ZK engineers write out circuits using a domain specific language (such as Circom by @identhree), which are then compiled to arithmetic circuits. These circuits are used to compute proofs based on inputs.

This other thread goes in-depth on this topic.
Read 40 tweets
Oct 19, 2022
Confused about how zero knowledge proofs work under the hood? Don't know where to start?

I've got you covered.

Spoiler: you don't need a degree in math to understand zk-SNARKs 😉

Let's dive in 👇
1/ In this thread, we will cover some basic cryptography and build up to a high-level overview of zk-SNARK systems.

I recommend saving this thread for future use!
2/ Don't know what zero knowledge proofs are? My last thread was a high-level deep dive on exactly that!

Check it out below ↓
Read 38 tweets
Sep 19, 2022
Zero knowledge proofs (ZKPs) will revolutionize how we think about privacy and scaling computation.

And they're just starting to take off.

Don't want to get left behind?

Here's a quick primer, just for you👇 Image
1/ Despite becoming popular only recently in the context of crypto, ZKPs have a rich history.

In 1987, @JamesGleick published an article in The New York Times titled "A NEW APPROACH TO PROTECTING SECRETS IS DISCOVERED".

nytimes.com/1987/02/17/sci…
2/ Even before the advent of blockchains, Gleick describes possible uses of ZKPs, such as protecting credit card numbers and military access codes.

Several researchers mentioned in the article won the Turing Award decades later for their work in cryptography. Image
Read 31 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(