Coder Social home page Coder Social logo

explain-extended-2024's Introduction

Explain Extended New Year 2024: GPT in 500 lines of SQL

https://explainextended.com/2023/12/31/happy-new-year-15/

About

This repository contains the code for the article Explain Extended New Year 2024: GPT in 500 lines of SQL.

The SQL code described in the article runs on PostgreSQL 15.0 and uses pgvector. It depends on tables populated with the parameters of the GPT-2 language model, which are not included in this repository.

To create the database and the tables, you need to build and run the Docker image explainextended2024. Alternatively, you can manually create the database, install pgvector, and run the script create.sql.

To populate the tables, you need to run the script populate.py. This script will download the GPT-2 parameters from OpenAI's website and populate the tables.

Requirements

  • Docker
  • Python 3.8 or later

Installation

  1. Build and run the database image:

    docker build --tag explainextended2024 .
    docker run -d --name pgvector -e POSTGRES_DB=explainextended2024 -e POSTGRES_PASSWORD=MySecretPassword -e POSTGRES_USER=explainextended2024 -p 5432:5432 -v "explainextended2024:/var/lib/postgresql/data" explainextended2024
    

    Consider changing the password if your machine is exposed to the Internet.

  2. Install Python dependencies:

    pip install -r requirements.txt
    
  3. Populate the tables:

    python populate.py --connection_string="postgresql://explainextended2024:MySecretPassword@localhost:5432/explainextended2024"
    

    Make sure you're using the same password as in the docker run command.

  4. The scripts mentioned in the article are located in the scripts directory.

Enjoy!

explain-extended-2024's People

Contributors

quassnoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

explain-extended-2024's Issues

Thoughts on GPU vs CPU

I'm assuming this can't be optimised to run on GPU (unless Postgres has some extension)
How long does it take comparatively. Is it 100x slower?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.