This file contains hidden or 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 | |
from argparse import ArgumentParser | |
from transformers import AutoModel, AutoTokenizer | |
import torch | |
""" | |
Usage: ./sort_vocab_by_norm.py \ | |
line-corporation/line-distilbert-base-japanese --trust-remote-code |
This file contains hidden or 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 | |
# Efficiently Evaluating Complex Boolean Expressions [Yahoo, SIGMOD 2010] | |
# https://theory.stanford.edu/~sergei/papers/sigmod10-index.pdf | |
class Node(object): | |
__slots__ = ["name", "_children", "_left_leaves", "begin", "end"] | |
def __init__(n, name, *_children): |
This file contains hidden or 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 numpy | |
import sys | |
numpy.set_printoptions(edgeitems=4, linewidth=120, suppress=True) | |
ls = sys.stdin.read().split("\n") | |
from tensorflow_hub import load |
This file contains hidden or 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 | |
class ZScorer(object): | |
__slots__ = ['means', 'stds'] | |
def __init__(self): | |
self.means, self.stds = [], [] | |
def learn(self, rank_lib): |
This file contains hidden or 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 python3 | |
# coding: utf-8 | |
from json import dumps | |
from numpy import array | |
from numpy import logical_and | |
from numpy import piecewise | |
from scipy import optimize | |
from sys import argv |
This file contains hidden or 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 python3 | |
from collections import defaultdict | |
LABEL_CAP = 4 | |
LETOR_DATASET = 'C:/letor/MSLR-WEB10K/Fold1/test.txt' | |
OLQ_CLICK_LOG = 'C:/OpenLiveQ_yahoo_data/OpenLiveQ-clickthrough.tsv' | |
def avg(l): |
This file contains hidden or 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 | |
# coding: utf-8 | |
from math import log | |
class BASE(object): | |
def __init__(self, id_to_relevance): | |
# Document ID -> Relevance |
This file contains hidden or 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 | |
# coding: utf-8 | |
class TrieNode(object): | |
'''A node in a trie.''' | |
__slots__ = ['body', 'list_count', 'metakey'] | |
def __init__(self, metakey='!'): | |
'''intializes a node in a trie.''' |
This file contains hidden or 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 | |
# coding: utf-8 | |
import matplotlib.pyplot as plt | |
import sys | |
from xgboost import Booster | |
from xgboost import plot_tree | |
from xgboost import XGBClassifier | |