Skip to content

Instantly share code, notes, and snippets.

View mrdrozdov's full-sized avatar

Andrew Drozdov mrdrozdov

View GitHub Profile
@mrdrozdov
mrdrozdov / iclr_2024_stats.py
Last active April 22, 2024 08:34
ICLR 2024 Stats
import collections
import json
import os
import openreview
with open('creds.json') as f:
creds = json.loads(f.read())
cache_file = 'iclr_2024_submissions.json'
# Setup conda
conda create -n mosaic python=3.10 -y
conda activate mosaic
# Load cuda
module load cuda/11.7.0
# Install torch
import asyncio
import openai
async def dispatch_openai_requests(llm_kwargs, prompts):
"""Dispatches requests to OpenAI API asynchronously.
Args:
llm_kwargs: Dictionary with options such as max_tokens, temperature, etc.
prompts: List of messages to be sent to OpenAI Completion API.
@mrdrozdov
mrdrozdov / peano.py
Created January 11, 2022 14:35
peano demo
import random
def Merge(x, y):
return ''.join([a for t in zip(x, y) for a in t])
def Peano(x, y):
interim = ''.join(Merge(format(x, '08b'), format(y, '08b')))
return int(interim, base=2)
def generate(n=100, ln=30):
@mrdrozdov
mrdrozdov / slate.js
Created May 24, 2021 14:24
slate.js
var pushLeft = slate.operation("push", {
"direction" : "left",
"style" : "bar-resize:screenSizeX/2"
});
var pushRight = slate.operation("push", {
"direction" : "right",
"style" : "bar-resize:screenSizeX/2"
});
@mrdrozdov
mrdrozdov / fromstring.py
Created May 3, 2020 02:55
fromstring.py
"""
Use at own risk.
I use nltk for many purposes, but I needed a faster version of nltk.Tree.fromstring.
This implementation is much faster and works for my use case, but it
has not been tested extensively on complex input.
Original fromstring implementation from nltk is here:
https://github.com/nltk/nltk/blob/develop/nltk/tree.py
@mrdrozdov
mrdrozdov / context_insensitive_word_embeddings.py
Created March 30, 2020 15:09
context_insensitive_word_embeddings.py
import os
import hashlib
from allennlp.commands.elmo import ElmoEmbedder
from allennlp.data.token_indexers.elmo_indexer import ELMoCharacterMapper
import numpy as np
def save_elmo_cache(path, vectors):
np.save(path, vectors)
@mrdrozdov
mrdrozdov / ep1-outline.txt
Created March 19, 2020 17:49
ep1-outline.txt
YES Bernard's secret revealed. # His name was an anagram.
NO Man in black pays a visit to Dolores.
YES Host gets repaired. # Bernard
YES There's a flashback. # Bernard has a flashback
? Radiohead's song played.
? The maze is referenced.
NO Maeve uses her powers.
YES A character gets redemption. # Dolores gets redemption on some of the wealthy men.
? "Wake up, Dolores".
? A new host storyline is presented (perhaps by Sizemore).
@mrdrozdov
mrdrozdov / git-tmp.py
Created February 22, 2020 23:10
git-tmp.py
#!/usr/bin/env python
import json
import os
import shutil
import subprocess
import sys
import tempfile
# env
@mrdrozdov
mrdrozdov / akbc
Created October 18, 2019 14:47
akbc
https://docs.google.com/presentation/d/1vtsYo064-oO1ZeFuB5uOBHIM5dMt3bUh6qkgFlj_kbU/edit?usp=sharing