• Stars
    star
    220
  • Rank 179,397 (Top 4 %)
  • Language
    Python
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Self-extracting GPT prompts for ~70% token savings

CompressGPT

Self-extracting GPT prompts for ~70% token savings

Check out the accompanying blog post here.

Installation

$ pip install compress-gpt

Usage

Simply change your existing imports of langchain.PromptTemplate to compress_gpt.langchain.CompressTemplate (to compress prompts before populating variables) or compress_gpt.langchain.CompressPrompt (to compress prompts after populating variables).

-from langchain import PromptTemplate
+from compress_gpt.langchain import CompressPrompt as PromptTemplate

For very simple prompts, use CompressSimplePrompt and CompressSimpleTemplate instead.

If compression ever fails or results in extra tokens, the original prompt will be used. Each compression result is aggressively cached, but the first run can take a hot sec.

Clearing the cache

import compress_gpt

compress_gpt.clear_cache()

Demo

asciicast

How CompressGPT Works

My blog post helps explain the below image.

CompressGPT Pipeline

More Repositories

1

gpt-do

GPT-powered bash commands.
Python
215
star
2

summ

GPT-based Conversation Summarizer
Python
144
star
3

shamer

Code Coverage Gamified
Python
37
star
4

bcferries

BC Ferries Python Library
Python
12
star
5

vc

VoteCollector - Voting Platform for Dorm Room Fund
Ruby
11
star
6

python-defer

Golang-style `defer` with no decorators!
Python
10
star
7

controlio

Control your computer through SMS!
Ruby
9
star
8

sentinents

How does the world feel about X?
Python
8
star
9

hardest-game

MIT 6.867: Reinforcement Learning to beat The World's Hardest Game
Python
3
star
10

facelock

Facial recognition for your door
Python
3
star
11

schedule-cli

CLI to generate summary of Google Calendar openings.
Ruby
3
star
12

drfbot

Slack Bot for Dorm Room Fund
JavaScript
3
star
13

hifromtheotherside

Fighting the echo chamber one match at a time
Ruby
2
star
14

safemodels

Cryptographically-secure proof-of-concept for verifying the provenance of ML models.
Python
2
star
15

vcbot

Like VCs but better!
Python
2
star
16

python-secret-type

A google/rune-style `secret` type for Python to prevent accidents.
Python
2
star
17

mitclasses

[WIP] MIT Class API
Ruby
1
star
18

flask-start

Skeleton Flask and Angular App
HTML
1
star
19

drf-www

Ruby
1
star
20

HackMIT

PbNotify + extras written throughout the night
C
1
star
21

pymbta

Python Client for the MBTA Realtime API
Python
1
star
22

bitfieldable

Implement boolean attributes with integer bitfields
Ruby
1
star
23

mit-textbooks

MIT Textbooks
Python
1
star
24

PbNotify

PbNotify: The Remote Pebble Notification API
C
1
star
25

wordle-solver

Solving Wordle, one word at a time
Ruby
1
star
26

PostPushr

PostPushr combines physical delivery with the speed and universality of the cloud. An MHacks III production.
Python
1
star
27

rainbow

Subscribe to events found in documents!
Python
1
star
28

haystack-hybrid-embedding

Sparse-Dense Embeddings for Pinecone in Haystack
Python
1
star