GithubHelp home page GithubHelp logo

language-models's Introduction

Understanding Language Models

Since 2021, there have been enormous advances in the field of NLP, most notably GPT-4 and ChatGPT. The aim of this repository is to understand the mechanics behind powerful language models by coding and training them from scratch. Currently, I am working on understanding the LLaMA model and using LoRA/qLoRA to train it more efficiently.

GPT

Jump to the karpathy-gpt directory.

Starting from a simple bigram language model, building out GPT from scratch. The completed GPT model be trained on character-level text data (e.g. tiny shakespeare) to generate convincing shakespeare-like text. Key concepts include:

  1. Self-Attention
  2. Scaled Dot-Product Attention
  3. Multi-Head Self-Attention
  4. Layer Normalization

LLaMA

Jump to the llama directory.

Building out the LLaMA 2 language model from Meta AI. The model can load pre-trained weights and perform inference. Key concepts include:

  1. Rotary Positional Embeddings
  2. KV-Cache
  3. Grouped-Query Attention
  4. RMSNorm
  5. SwiGLU Activation Function

LoRA

Jump to the lora directory.

LoRA is a fine-tuning method that drastically reduces the number of trainable parameters in pre-trained language models by adding two trainable weight matrices to the original model weights. It is based on singular value decomposition, in which a large matrix is broken down into its component eigenvalues and eigenvectors. The most important information in a matrix is often contained in just the first few singular values. Key concepts include:

  1. Singular Value Decomposition

Min-LoRA

Jump to the lora directory.

A minimal reproduction of adding LoRA to fine-tune a pre-trained GPT2 model from OpenAI. A starting point for my own LLM fine-tuning method, adapted from diffusion models.

language-models's People

Contributors

alif-munim avatar

Watchers

Kostas Georgiou avatar  avatar

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.