Skip to content

Instantly share code, notes, and snippets.

View pszemraj's full-sized avatar

Peter pszemraj

View GitHub Profile
Model Average CR⬆️ AGIEval Mean (Min, Max) AGIEval CR MMLU-Pro Mean (Min, Max) MMLU-Pro CR Math Mean (Min, Max) Math CR #Params (B)
meta-llama/Llama-3.1-70B-Instruct 72.39 72.43, (65.34, 74.66) 81.79 66.63, (55.16, 70.68) 73.19 65.88, (64.58, 67.86) 62.18 0
mistralai/Mistral-Large-Instruct-2407 71.93 68.78, (61.41, 74.49) 75.77 65.1, (50.28, 69.23) 72.31 71.04, (69.66, 72.72) 67.71 0
meta-llama/Meta-Llama-3-70B-Instruct 69.11 69.71, (60.77, 71.2) 83.13 58.75, (49.3, 63.16) 75.24 51.29, (49.66, 54.2) 48.96 0
01-ai/Yi-1.5-34B-Chat 58.43 63.89
@pszemraj
pszemraj / tensorboard_inspect.py
Last active March 11, 2025 00:33
CLI utility to quickly inspect the latest scalar values from TensorBoard logs.
#!/usr/bin/env python
"""
CLI utility to quickly inspect the latest scalar values from TensorBoard logs.
Dependencies:
pip install tbparse pandas fire tqdm
Usage:
python tensorboard_inspect.py --logdir ./path/to/logs
"""

bash/zsh util for readerlm-v2

Warning

Using this will send the data of your (public URL) to jina ai, and the license for readerlm-v2 is cc-by-nc

Here's the improved version of your smart_curl function that better handles filename extraction and works in Zsh:

function smart_curl() {
@pszemraj
pszemraj / rag_search_localllama.py
Last active January 22, 2025 17:18
basic rag search system for top_k posts w gte-modernbert-base
import logging
from typing import Dict, List
import faiss
import numpy as np
from datasets import load_dataset
from sentence_transformers import CrossEncoder, SentenceTransformer
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@pszemraj
pszemraj / push_reddit_articshift.py
Created January 7, 2025 03:14
util script for loading, basic processing, converting reddit posts -> hf dataset
"""
util script for loading, basic processing, converting reddit posts -> hf dataset
https://arctic-shift.photon-reddit.com/download-tool
"""
import pandas as pd
from datasets import Dataset, load_dataset
src = "./data/r_LocalLLaMA_posts.jsonl" # update with relevant path
df = pd.read_json(src, lines=True).convert_dtypes()
@pszemraj
pszemraj / cautious_adamw.py
Last active November 27, 2024 03:53
Implements Cautious AdamW optimizer by subclassing AdamW https://github.com/kyleliang919/C-Optim
import math
import torch
from torch.optim.adamw import AdamW
class CautiousAdamW(AdamW):
"""
Implements Cautious AdamW optimizer by subclassing AdamW.
All hyperparameters remain identical to AdamW.
@pszemraj
pszemraj / chibihash64.py
Created November 18, 2024 16:38
Compute the 64-bit hash of the input bytes object using the chibihash64 algorithm.
def chibihash64__load64le(p, offset=0):
"""Load 8 bytes from the input bytes object as a little-endian 64-bit integer."""
return int.from_bytes(p[offset : offset + 8], "little", signed=False)
def chibihash64(key, seed=0):
"""
Compute the 64-bit hash of the input bytes object using the chibihash64 algorithm.
Parameters:
"""
based on the megalodon implementation
https://github.com/XuezheMax/megalodon/blob/53cbaa3a3b3e05ea439564bd67cb352012ba6b97/megalodon/modules/complex_exponential_moving_average.py
"""
import math
import torch
from torch import nn
from typing import Optional, Tuple
@pszemraj
pszemraj / pdf2markdown_openai.py
Created October 11, 2024 03:40
transcribe PDF files to markdown text with openai
import base64
import tempfile
from pathlib import Path
import fire
import mdformat
from joblib import Memory
from openai import OpenAI
from pdf2image import convert_from_path
from tqdm.auto import tqdm