Skip to content

Instantly share code, notes, and snippets.

View sksq96's full-sized avatar

Shubham Chandel sksq96

View GitHub Profile
@sksq96
sksq96 / search.py
Created April 7, 2023 21:49
SentenceTransformer with AutoFaisss
from tqdm import tqdm
from sentence_transformers import SentenceTransformer, util
from autofaiss import build_index
import sys
spacefile = sys.argv[1]
queryfile = sys.argv[2]
WARMUP_UPDATES=15000 # Warmup the learning rate over this many updates
TOTAL_UPDATES=5000000 # Total number of training steps
MAX_TOKENS=1024
MAX_POSITIONS=1024 # Num. positional embeddings (usually same as above)
PEAK_LR=[0.0006] # Peak learning rate, adjust as needed
UPDATE_FREQ=[2] # Increase the batch size 16x
MODEL=bart_large
@sksq96
sksq96 / setup.sh
Last active March 19, 2021 10:13
# zsh
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "exec zsh" >> ~/.bashrc
# zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
@sksq96
sksq96 / unfollow.js
Created June 4, 2020 07:27 — forked from JamieMason/unfollow.js.md
Unfollow everyone on twitter.com
// Unfollow everyone on twitter.com, by Jamie Mason (https://twitter.com/fold_left)
// https://gist.github.com/JamieMason/7580315
//
// 1. Go to https://twitter.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated: 09 April 2020
(() => {
const $followButtons = '[data-testid$="-unfollow"]';
import pyautogui
import pyperclip
from time import sleep
import sys
message = f"""Hello
I'm in search of fulltime opportunity at {sys.argv[1]}, could refer me, or pass along my CV to a recruiter?
I'm a graduate student at NYU, currently working at the intersection of Reinforcement Learning and Natural Language Processing, under the supervision of Prof. Yann LeCun.
@sksq96
sksq96 / histogram.py
Last active December 2, 2019 16:53
Plot histogram from list
def hist(d, count=True):
import matplotlib.pyplot as plt
if count:
d = list(map(len, d))
n, bins, patches = plt.hist(x=d, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85)
plt.grid(axis='y', alpha=0.75)
plt.xlabel('Value')
plt.ylabel('Frequency')
maxfreq = n.max()
plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10)
@sksq96
sksq96 / AdamW.py
Created July 4, 2018 12:54 — forked from thomwolf/AdamW.py
Implements Adam algorithm with weight decay fix in PyTorch (paper: https://arxiv.org/abs/1711.05101)
from torch.optim import Optimizer
class AdamW(Optimizer):
"""
Implements Adam algorithm with weight decay fix in PyTorch
Paper: Fixing Weight Decay Regularization in Adam by Ilya Loshchilov, Frank Hutter
https://arxiv.org/abs/1711.05101
"""
def __init__(self, params, lr, b1=0.9, b2=0.999, e=1e-8, l2=0,
vector_l2=False, max_grad_norm=-1, **kwargs):
@sksq96
sksq96 / wordvec_example.py
Created January 13, 2018 00:25 — forked from tylerneylon/wordvec_example.py
Quick reference on how to work with pre-trained word2vec vectors in Python.
# wordvec_example.py
#
# This file shows one way to work with word2vec data in Python.
#
# Setup:
#
# 1. Install gensim:
#
# pip install gensim
#
@sksq96
sksq96 / wordvec_example.py
Created January 13, 2018 00:25 — forked from tylerneylon/wordvec_example.py
Quick reference on how to work with pre-trained word2vec vectors in Python.
# wordvec_example.py
#
# This file shows one way to work with word2vec data in Python.
#
# Setup:
#
# 1. Install gensim:
#
# pip install gensim
#
@sksq96
sksq96 / google_twunter_lol
Created January 11, 2018 11:51 — forked from ryanlewis/google_twunter_lol
Naughty word list, compiled by Google and @jamiew
4r5e
5h1t
5hit
a55
anal
anus
ar5e
arrse
arse
ass