Skip to content

daaniyaan/ClassGPT

 
 

Repository files navigation

ClassGPT

ChatGPT for my lecture slides

SCR-20230307-isgj

Built with Streamlit, powered by LlamaIndex and LangChain.

Uses the latest ChatGPT API from OpenAI.

Inspired by AthensGPT

App Demo

demo.mp4

How this works

  1. Parses pdf with pypdf
  2. Index Construction with LlamaIndex's GPTSimpleVectorIndex
  3. indexes and files are stored on s3
  4. Query the index
    • uses the latest ChatGPT model gpt-3.5-turbo

Usage

Configuration and secrets

  1. configure aws (quickstart)
    aws configure
  1. create s3 bucket named "classgpt"

  2. rename [.env.local.example] to .env and add your openai credentials

Locally

  1. create python env
    conda create -n classgpt python=3.9
    conda activate classgpt
  1. install dependencies
    pip install -r requirements.txt
  1. run streamlit app
    cd app/
    streamlit run app/01_❓_Ask.py

Docker

Alternative, you can use Docker

    docker compose up

Then open up a new tab and navigate to http://localhost:8501/

TODO

FAQ

Tokens

Tokens can be thought of as pieces of words. Before the API processes the prompts, the input is broken down into tokens. These tokens are not cut up exactly where the words start or end - tokens can include trailing spaces and even sub-words. Here are some helpful rules of thumb for understanding tokens in terms of lengths:

  • 1 token ~= 4 chars in English
  • 1 token ~= ¾ words
  • 100 tokens ~= 75 words
  • 1-2 sentence ~= 30 tokens
  • 1 paragraph ~= 100 tokens
  • 1,500 words ~= 2048 tokens

Try the OpenAI Tokenizer tool

Source

Embeddings

An embedding is a vector (list) of floating point numbers. The distance between two vectors measures their relatedness. Small distances suggest high relatedness and large distances suggest low relatedness.

For text-embedding-ada-002, cost is $0.0004 / 1k tokens or 3000 pages/dollar

Models

For gpt-3.5-turbo model (ChatGPTAPI) cost is $0.002 / 1K tokens

For text-davinci-003 model, cost is $0.02 / 1K tokens

References

Streamlit

Deplyoment

LlamaIndex

Loading data

ChatGPT

Langchain

Boto3

Docker stuff

About

ChatGPT for lecture slides

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 74.8%
  • Python 24.0%
  • Dockerfile 1.2%