Skip to content

Instantly share code, notes, and snippets.

View insujeon's full-sized avatar

Insu Jeon insujeon

View GitHub Profile
@pszemraj
pszemraj / matmul_free.md
Created June 6, 2024 03:35
Technical Overview and Explanation of "Scalable MatMul-free Language Modeling" by gpt-4o

Technical Overview and Explanation of "Scalable MatMul-free Language Modeling"

Introduction

This paper presents a novel approach to large language models (LLMs) that eliminates matrix multiplication (MatMul) operations, which are typically the most computationally expensive part of such models. By doing so, the authors aim to significantly reduce memory usage and improve computational efficiency, enabling the models to scale up to billions of parameters while maintaining performance comparable to state-of-the-art Transformers.

Key Contributions

  1. MatMul-Free Dense Layers: The core innovation lies in replacing MatMul operations in dense layers with addition operations using ternary weights. These ternary weights take values from {-1, 0, +1}, which allows matrix multiplications to be transformed into simple additions and subtractions.
@codelahoma
codelahoma / README.md
Last active November 11, 2023 13:29
Automatically generate summaries of YouTube videos with transcriptions, using OpenAI's language model and create Markdown files with the output.

(DEFUNCT - NO LONGER WORKS) YouTube Video Summarizer (yt_summarize.py)

This gist contains a Python script that generates a transcript or summary of a YouTube video. It fetches video information, transcribes the audio using the Whisper ASR model, and generates a summary using the OpenAI language model.

Features

  • Fetch YouTube video information (title, description, channel title, etc.)
  • Transcribe video audio
  • Generate a summary of the video transcript
  • Save output as a markdown file
import numpy as np
import torch
import torch.nn as nn
from functorch import vmap, jacrev, make_functional_with_buffers
batch_size = 2
in_channels = 5
out_channels = 20
feature_shape = 8
feature = torch.rand(batch_size, in_channels, feature_shape, feature_shape)
@Bill-tran
Bill-tran / how-to-install-openssl-1.1.1-on-centos-7.md
Created September 7, 2021 09:22
How to install openssl 1.1.1 on CentOS 7

How To Install OpenSSL 1.1.1 on CentOS 7

This tutorial goes through how to install openssl 1.1.1 on CentOS 7, since the yum repo only installs up to openssl 1.0.

Requirements

Upgrade the system

yum -y update
@mlelarge
mlelarge / mnist_download.ipynb
Created March 3, 2021 16:07
MNIST_download.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gpantalos
gpantalos / laplace_approximation.py
Created February 4, 2021 13:48
Laplace Approximation in PyTorch
"""
Laplace approximation of a Beta distribution.
"""
import matplotlib.pyplot as plt
import torch
x = torch.linspace(0, 1, 200)
p = torch.distributions.Beta(2, 5)
@DrustZ
DrustZ / pvanet.py
Last active January 20, 2018 07:59
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
def debug(debug_open, x, layername):
if debug_open:
print x.size(), 'after', layername
class PVANet(nn.Module):
@oeway
oeway / imageUtils.py
Last active May 8, 2024 14:21
Improved image transform functions for dense predictions (for pytorch, keras etc.)
import numpy as np
import scipy
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.interpolation import map_coordinates
import collections
from PIL import Image
import numbers
__author__ = "Wei OUYANG"
@rtqichen
rtqichen / pytorch_weight_norm.py
Last active May 11, 2023 06:58
Pytorch weight normalization - works for all nn.Module (probably)
## Weight norm is now added to pytorch as a pre-hook, so use that instead :)
import torch
import torch.nn as nn
from torch.nn import Parameter
from functools import wraps
class WeightNorm(nn.Module):
append_g = '_g'
append_v = '_v'
@ndronen
ndronen / model.py
Last active April 28, 2018 19:50
Semantic segmentation with ENet in PyTorch
#!/usr/bin/env python
"""
A quick, partial implementation of ENet (https://arxiv.org/abs/1606.02147) using PyTorch.
The original Torch ENet implementation can process a 480x360 image in ~12 ms (on a P2 AWS
instance). TensorFlow takes ~35 ms. The PyTorch implementation takes ~25 ms, an improvement
over TensorFlow, but worse than the original Torch.
"""
from __future__ import absolute_import