Skip to content

Instantly share code, notes, and snippets.

View lapp0's full-sized avatar

Andrew Lapp lapp0

View GitHub Profile
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
with open('optimizer.py', 'r', encoding='utf-8') as f:
source_code = f.read()
code += source_code
with open('model.py', 'r', encoding='utf-8') as f:
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import time
import contextlib
from dataclasses import dataclass
import math
from pathlib import Path
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import time
import contextlib
from dataclasses import dataclass
import math
from pathlib import Path
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import time
import contextlib
from dataclasses import dataclass
from pathlib import Path
import os
import sys
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import glob
import time
import contextlib
from dataclasses import dataclass
from typing import Optional
Running pytorch 2.6.0.dev20241126+cu124 compiled for CUDA 12.4
nvidia-smi:
Fri Nov 29 00:54:16 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.76 Driver Version: 550.76 CUDA Version: 12.4 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|

Remove evil parts of answer.

Code

import outlines

qwen_model = outlines.models.transformers("Qwen/Qwen2.5-14B-Instruct", model_kwargs=dict(load_in_8bit=True))


def ask_non_evil_question(prompt, pattern, model=qwen_model, max_tokens=100):
import random
import collections
def trial(first_to=2):
flips = [random.choice([True, False]) for _ in range(100)]
alice_flip_checks = flips
bob_flip_checks = [flips[i] for i in range(1, len(flips), 2)] + [flips[i] for i in range(0, len(flips), 2)]
# get second_head
try:
from datasets import Dataset, load_from_disk
from transformers import TrainingArguments
from transformers.trainer_utils import EvalLoopOutput
from unsloth import FastLanguageModel
import random
from huggingface_hub import create_repo
from scipy.spatial.distance import cosine
from sentence_transformers import SentenceTransformer
import statistics
@lapp0
lapp0 / gist:ee9e1035945a838868805e941f73bb25
Created March 31, 2024 20:26
Regex Pattern for Dates between 0001-01-01 and 9999-12-31, Accounting for All Leap Year Rules
# Huge Pattern
`0(0(0([1235679]-(0(2-(0[1-9]|1\\d|2[0-8])|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d)))|[48]-(0(2-(0[1-9]|[12]\\d)|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d))))|[13579]([01345789]-(0(2-(0[1-9]|1\\d|2[0-8])|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d)))|[26]-(0(2-(0[1-9]|[12]\\d)|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d))))|[2468]([048]-(0(2-(0[1-9]|[12]\\d)|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d)))|[1235679]-(0(2-(0[1-9]|1\\d|2[0-8])|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30|[12]\\d)|[02]-(0[1-9]|3[01]|[12]\\d)))))|[1235679](0([0-35679]-(0(2-(0[1-9]|1\\d|2[0-8])|[13578]-(0[1-9]|3[01]|[12]\\d)|[469]-(0[1-9]|30|[12]\\d))|1(1-(0[1-9]|30