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 os | |
| import json | |
| from dataclasses import dataclass | |
| from multiprocessing import Pool | |
| from collections import defaultdict | |
| from datetime import datetime | |
| from math_verify import math_metric, LatexExtractionConfig, ExprExtractionConfig, StringExtractionConfig, parse, verify | |
| from tqdm import tqdm | |
| from simpleArgParser import parse_args |
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 torch | |
| import os | |
| import json | |
| from safetensors.torch import load_file, save_file | |
| def replicate_lora_a(name: str, weight: "torch.Tensor") -> dict[str, "torch.Tensor"]: | |
| prefix, suffix = name.split('qkv_proj') | |
| res = {} | |
| for t in ['q_proj', 'k_proj', 'v_proj']: | |
| name = f"{prefix}{t}{suffix}" |
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 os | |
| import time | |
| import requests | |
| from requests.adapters import HTTPAdapter, Retry | |
| from huggingface_hub import configure_http_backend | |
| import argparse | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--model', type=str, help='name of huggingface model to download', default='sshleifer/tiny-gpt2') |
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 openai | |
| import asyncio | |
| from typing import Any | |
| async def dispatch_openai_requests( | |
| messages_list: list[list[dict[str,Any]]], | |
| model: str, | |
| temperature: float, | |
| max_tokens: int, | |
| top_p: float, |
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
| channels: | |
| - anaconda | |
| - pytorch | |
| - nvidia | |
| - conda-forge | |
| dependencies: | |
| - python=3.8 | |
| - pip | |
| - pytorch=1.13.1 | |
| - torchvision |
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
| # note this is a copy from https://paste.ubuntu.com/p/Nx5CcSmhHn/ for convenience | |
| import torch | |
| import torch.nn.functional as F | |
| device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
| def SimCSE_loss(pred, tau=0.05): | |
| ids = torch.arange(0, pred.shape[0], device=device) | |
| y_true = ids + 1 - ids % 2 * 2 | |
| similarities = F.cosine_similarity(pred.unsqueeze(1), pred.unsqueeze(0), dim=2) |