Skip to content

Instantly share code, notes, and snippets.

View levskaya's full-sized avatar

Anselm Levskaya levskaya

View GitHub Profile
from __future__ import annotations
from contextlib import contextmanager
from typing import NamedTuple, Callable, Optional, Any
import numpy as np
Array = Any
class Node(NamedTuple):
vjp: Optional[Callable]
parents: List[Node]
@levskaya
levskaya / papers.md
Created December 16, 2021 05:22 — forked from pdarragh/papers.md
Approachable PL Papers for Undergrads

Approachable PL Papers for Undergrads

On September 28, 2021, I asked on Twitter:

PL Twitter:

you get to recommend one published PL paper for an undergrad to read with oversight by someone experienced. the paper should be interesting, approachable, and (mostly) self-contained.

what paper do you recommend?

@levskaya
levskaya / top-k-top-p.py
Created May 3, 2019 23:54 — forked from thomwolf/top-k-top-p.py
Sample the next token from a probability distribution using top-k and/or nucleus (top-p) sampling
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (..., vocabulary size)
top_k >0: keep only top k tokens with highest probability (top-k filtering).
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering).
"""
top_k = min(top_k, logits.size(-1)) # Safety check
if top_k > 0:
# Remove all tokens with a probability less than the last token of the top-k
-- For anyone who liked the PRIME DETECTOR puzzle included in some of the early access
-- builds of TIS-100...
-- INSTALLATION: Copy everything in this file. Open TIS-100. Go to the SPECIFICATION
-- EDITOR. Click on IMPORT SPECIFICATION FROM CLIPBOARD. Done!
-- The function get_name() should return a single string that is the name of the puzzle.
--
function get_name()
return "PRIME DETECTOR"
/**
http://closure-library.googlecode.com/svn-history/r440/trunk/third_party/closure/goog/jpeg_encoder/jpeg_encoder_basic.js
* @license
Copyright (c) 2008, Adobe Systems Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met: