Skip to content

Instantly share code, notes, and snippets.

View cdfox's full-sized avatar

Christopher Fox cdfox

View GitHub Profile
@cdfox
cdfox / numba_lda.py
Last active August 29, 2015 14:12
Gibbs sampling for latent Dirichlet allocation using Numba.
import re
import sys
import numpy as np
import numba
file_name = sys.argv[1] # one document per line
num_topics = int(sys.argv[2])
num_iterations = int(sys.argv[3])
alpha = float(sys.argv[4])
alpha0 = float(sys.argv[5])
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
class foo:
def __eq__(self, o):
return False
t = (foo(),)
t2 = (t[0],)
t == t2 # True
t[0] == t2[0] # False
t[0] is t2[0] # True
@cdfox
cdfox / reproduce_roblox_distilbert.py
Last active August 9, 2020 22:37
Reproducing Roblox DistilBERT Medium Post
# Reproducing Roblox DistilBERT Medium Post
# https://blog.roblox.com/2020/05/scaled-bert-serve-1-billion-daily-requests-cpus/
#
# 1. Launch C5 12xlarge with Deep Learning AMI (Ubuntu 18.04) Version 32.0 (ami-0dc2264cd927ca9eb)
# 2. pip install transformers[torch]
# 3. python reproduce_roblox_distilbert.py
import timeit
from transformers import DistilBertTokenizerFast, \
DistilBertForSequenceClassification