Skip to content

Instantly share code, notes, and snippets.

View alexlimh's full-sized avatar

Minghan Li alexlimh

View GitHub Profile
# (c) Facebook, Inc. and its affiliates. Confidential and proprietary.
# @manual=//faiss/python:pyfaiss
import faiss
import hydra
import glob
import json
import os
import pickle
import torch
import os
import time
import argparse
import numpy as np
import pickle
import collections
import jsonlines
import torch
import glob
import scipy
import os
import time
import argparse
import numpy as np
import pickle
import collections
import jsonlines
import torch
import glob
import scipy
#
# Pyserini: Python interface to the Anserini IR toolkit built on Lucene
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Command line tool to get dense results and validate them
"""
@alexlimh
alexlimh / mutual information.py
Last active May 12, 2021 15:41
mutual information
# 1. retrieve top-k passages for each query
# 2. merge the top-k passages and get the union
# 3. calculate the dot-product on the union for each query
# 3.5. save the dot-products into .pkl or .npy file
# 4. put the score into this function and get mutual information
def get_mi(self, logits, tau=1.0): # logits are the dot-product scores, size: QxP, where Q is the number of queries, P is the number of retrieved passages
# tau is the temperature coef that controls the sharpness of the distribution
# numeric stability
max_logit = np.max(logits, axis=-1, keepdims=True)
probs = np.exp((logits - max_logit)/tau)/np.sum(np.exp((logits - max_logit)/tau), -1, keepdims=True)
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Mission xmlns="http://ProjectMalmo.microsoft.com">
<About>
<Summary>$(ENV_NAME)</Summary>
</About>
<ModSettings>
<MsPerTick>50</MsPerTick>
<!--<PrioritiseOffscreenRendering>true</PrioritiseOffscreenRendering>-->
</ModSettings>
#!/bin/bash
#SBATCH --mem=50G
#SBATCH -c 8
#SBATCH --gres=gpu:1
#SBATCH -p gpu
CKPT=/checkpoint/minghan/${SLURM_JOB_ID}
touch $CKPT
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
from dm_control import mujoco
from dm_control.rl import control
from dm_control.suite import base
from dm_control.suite import common

Running Minecraft in Headless Linux System

Prerequisite

  1. xpra

    sudo apt-get install xpra

  2. jdk 1.8