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
| import argparse | |
| import os | |
| import re | |
| cache_root = os.path.abspath( | |
| "YOUR_PATH_HERE" | |
| ) | |
| os.environ["HF_HOME"] = cache_root | |
| os.environ["HF_HUB_CACHE"] = os.path.join(cache_root, "hub") | |
| os.environ["VLLM_CACHE_ROOT"] = os.path.join(cache_root, "vllm") |
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
| from glob import glob | |
| import unicodedata | |
| import numpy as np | |
| import pandas as pd | |
| from IPAParser_3_0 import IPAParser | |
| def strip_modifiers(phoneme): | |
| RED_FLAGS = ["MODIFIER", "COMBINING", "SUPERSCRIPT", "DIGIT"] | |
| buffer = [] |
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
| import random | |
| import gzip | |
| import json | |
| import os | |
| import requests | |
| import pickle | |
| from typing import List, Dict, Any, Tuple | |
| from datetime import datetime | |
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
| import argparse | |
| import os | |
| cache_root = os.path.abspath("./hf_cache") | |
| os.environ["HF_HOME"] = cache_root | |
| os.environ["HF_HUB_CACHE"] = os.path.join(cache_root, "hub") | |
| os.environ["VLLM_CACHE_ROOT"] = os.path.join(cache_root, "vllm") | |
| import torch | |
| import pandas as pd |
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
| import pandas as pd | |
| from vllm import LLM, SamplingParams | |
| from transformers import AutoTokenizer | |
| from tqdm import tqdm | |
| def llama3_call(user_prompt, temperature=0.0): | |
| user_prompt = "### DOCUMENT:\n" + user_prompt + "\n### ANSWER" | |
| messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}] | |
| messages = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt = True) | |
| sampling_params = SamplingParams(temperature=temperature, max_tokens=10) |
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
| from math import pi | |
| import numpy as np | |
| x = np.array([1, 0, 0]) | |
| y = np.array([1, 0, 0.001]) # very similar to | |
| z = np.array([0, 1, 0]) # orthogonal to x | |
| q = np.array([-1, 0, 0]) # looks in the opposite direction to x | |
| def angular_distance(v1, v2): | |
| cos_of_angle = np.dot(v1, v2) / np.linalg.norm(v1) / np.linalg.norm(v2) |
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
| """ | |
| Conceptual pseudocode explaining how sliding-window attention works | |
| using loops. This is NOT meant to be efficient or runnable in a real | |
| model. It simply illustrates what PyTorch operations like: | |
| unfold | |
| unsqueeze | |
| squeeze | |
| batched matrix multiplication |
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
| a | |
| abandon | |
| ability | |
| able | |
| abortion | |
| about | |
| above | |
| abroad | |
| absence | |
| absolute |
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
| class Counter: | |
| def __init__(self): | |
| self.count = 0 | |
| def get_value(self): | |
| return self.count | |
| def increment(self): | |
| self.count += 1 |
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
| class Counter: | |
| def __init__(self): | |
| self.count = 0 | |
| def get_value(self): | |
| return self.count | |
| def increment(self): | |
| self.count += 1 |
NewerOlder