Skip to content

Instantly share code, notes, and snippets.

View kyunghyuncho's full-sized avatar

Kyunghyun Cho kyunghyuncho

View GitHub Profile

Jason Eisner

Jason Eisner is a Professor of Computer Science at Johns Hopkins University (JHU). He is recognized for his significant research contributions to natural language processing (NLP), programming languages, and artificial intelligence. His work is characterized by its theoretical depth and practical application, aiming to bridge the gap between current language models and robust reasoning capabilities.

Academic Affiliations

Eisner is a prominent faculty member in the Department of Computer Science at Johns Hopkins University. His affiliations extend across several key research centers and departments within JHU, reflecting the interdisciplinary nature of his work:

  • Department of Computer Science, Johns Hopkins University
  • Center for Language and Speech Processing (CLSP), Johns Hopkins University
# download `https://github.com/dwyl/english-words/raw/refs/heads/master/words_alpha.txt`
# and save it as `words_alpha.txt` in the same directory as this notebook
import os
import requests
if not os.path.exists('words_alpha.txt'):
url = 'https://github.com/dwyl/english-words/raw/refs/heads/master/words_alpha.txt'
r = requests.get(url, allow_redirects=True)
open('words_alpha.txt', 'wb').write(r.content)
@kyunghyuncho
kyunghyuncho / cost_tokens_7bn_llm.py
Created August 13, 2023 20:19
7bn llm cost and tokens
n_months = 4 # let's say 4 months of continuous training
sec_per_grad = 1.7 # 1.7 seconds per gradient computation (a very rough number)
instance_price_per_hour = 24.01 # assuming AWS p4de instances with 1yr reservation
discount = 0.2 # assuming you can get some discount from AWS or whatever your cloud vendor is
n_gpu = 8 # 8x A100's with 80G each
n_instances = 4 # the number of AWS p4de instances
ex_per_gpu = 2 # the number of training examples processed per gpu
n_tokens_per_ex = 2000 # the length of each training example
@kyunghyuncho
kyunghyuncho / label_smoothing_coeff.py
Created August 9, 2023 21:56
how to turn the target smoothed probability into label_smoothing coefficient in pytorch
import numpy
'''
(1./n_classes) * (1.-label_smoothing) + 1. * label_smoothing = target_prob
1./n_classes - label_smoothing * (1./n_classes - 1.) = target_prob
label_smoothing * (1. - 1./n_classes) = target_prob - 1./n_classes
label_smoothing * (n_classes - 1.) / n_classes = target_prob - 1./n_classes
label_smoothing = (target_prob * n_classes - 1.) /n_classes * n_classes / (n_classes - 1.)
label_smoothing = (target_prob * n_classes - 1.) / (n_classes - 1.)
'''
@kyunghyuncho
kyunghyuncho / softmax_clip_logits.py
Created August 9, 2023 21:27
softmax probability clipping at the logit level
import numpy
s = numpy.random.randn(10)
def clip_probability_logits(logit, epsilon=0.):
s_max = numpy.max(logit)
s_transf = logit - s_max
normalization_const = numpy.exp(s_transf).sum()
p_transf = numpy.exp(s_transf) / normalization_const
import numpy
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"
import torch
os.environ["CUDA_VISIBLE_DEVICES"]="1"
import tensorflow as tf
import copy
import re
import numpy
def align_sents(more_sentences, fewer_sentences):
j_more = 0
fewer2more = [None] * len(fewer_sentences)
more_sentences = more_sentences
import sys
import argparse
import logging
from collections import OrderedDict
import numpy
import torch
from torch import nn
import torch
from torch import nn
from torch.distributions import Categorical
from torch.optim import Adam, SGD
import numpy
import argparse
import glob
@kyunghyuncho
kyunghyuncho / pull-vid.py
Last active December 27, 2018 20:37
pull-vid.py
import time
import requests
import browsercookie
from bs4 import BeautifulSoup
# TODO: make sure you have already login-ed to the site on your browser