Skip to content

Instantly share code, notes, and snippets.

@manueldeprada
manueldeprada / example.py
Created July 27, 2023 16:07
Minimal example for Decoders usage
from decoders import inject_supervitamined_decoders, StochasticBeamSearchDecoder, FakeTransformer
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch
# pip install decoders
# this demonstration uses a fake toy transformer (https://manueldeprada.com/blog/posts/toy-probabilistic-transformer/)
# to test the correctness of the stochastic beam search implementation
def test_fake_transformer():
@iandanforth
iandanforth / jupyter-scroll.txt
Created December 3, 2017 22:59
Enable smooth scrolling with arrow keys in Jupyter Notebooks
%%javascript
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('up');
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('down');
@matthewfl
matthewfl / latexc.py
Last active May 25, 2021 21:17
Get a notification when latexmk fails
#!/usr/bin/env python3
import subprocess
import sys
def main():
proc = subprocess.Popen(['latexmk', '-pvc'] + sys.argv[1:],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
@michaelchughes
michaelchughes / RankOneUpdate.m
Created April 19, 2013 21:25
Rank one update of cholesky and log determinant of the posterior parameters of a Wishart distribution.
function [] = RankOneUpdateTest( D )
nTrial = 1000;
invW = randn( 3*D, D);
invW = invW'*invW;
x = randn(D,1);
cholinvW = chol(invW,'upper');
logdetinvW = 2*sum(log(diag(cholinvW)));
@z-m-k
z-m-k / footnotes.ipynb
Last active March 24, 2018 14:07
Latex footnotes, citations, etc. in IPython Notebook; see at http://nbviewer.ipython.org/4492534/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.