This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Sample script to use ThreadPoolExecutor in a way that is easy to interrupt. | |
""" | |
import concurrent.futures | |
import threading | |
from tqdm import tqdm | |
# A flag indicating whether jobs should be cancelled. | |
cancel_jobs = threading.Event() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup conda | |
conda create -n mosaic python=3.10 -y | |
conda activate mosaic | |
# Load cuda | |
module load cuda/11.7.0 | |
# Install torch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pushLeft = slate.operation("push", { | |
"direction" : "left", | |
"style" : "bar-resize:screenSizeX/2" | |
}); | |
var pushRight = slate.operation("push", { | |
"direction" : "right", | |
"style" : "bar-resize:screenSizeX/2" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import os | |
import shutil | |
import subprocess | |
import sys | |
import tempfile | |
# env |
NewerOlder