Skip to content

Instantly share code, notes, and snippets.

View bigsnarfdude's full-sized avatar

BigsnarfDude bigsnarfdude

View GitHub Profile
@bigsnarfdude
bigsnarfdude / keyword_vector_search_combined.py
Created March 3, 2025 15:54
keyword_vector_search_combined.py
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
from sentence_transformers import SentenceTransformer
class HybridSearch:
def __init__(self, documents):
self.documents = documents
# Initialize keyword search (TF-IDF)
@bigsnarfdude
bigsnarfdude / cgm_spike_detection_python.py
Created February 26, 2025 16:49
cgm_spike_detection_python.py
"""
CGM Spike Detection Algorithm
This module provides functions to analyze Continuous Glucose Monitoring (CGM) data
and detect various patterns including rapid rises, sustained high periods,
meal responses, and hypoglycemic events.
"""
import pandas as pd
import numpy as np
@bigsnarfdude
bigsnarfdude / gm8k_eval.py
Created February 24, 2025 15:58
gm8k_eval.py
from mlx_lm import load
import mlx.core as mx
import mlx.nn as nn
from mlx_lm.utils import (cache, maybe_quantize_kv_cache)
from mlx_lm.models.base import create_attention_mask
from mlx_lm.sample_utils import make_sampler
from tqdm import tqdm
import json
import re
from typing import List, Optional, Union, Tuple, Any, Callable, Generator
@bigsnarfdude
bigsnarfdude / codeGen.txt
Last active February 22, 2025 16:23
code gen
Ask me one question at a time so we can develop a thorough, step-by-step spec for this idea. Each question should build on my previous answers, and our end goal is to have a detailed specification I can hand off to a developer. Let’s do this iteratively and dig into every relevant detail. Remember, only one question at a time.
Ask me one question at a time so we can develop a thorough, step-by-step spec for this idea. Each question should build on my previous answers, and our end goal is to have a detailed specification I can hand off to a developer. Let’s do this iteratively and dig into every relevant detail. Remember, only one question at a time.
Here’s the idea:
<IDEA>
@bigsnarfdude
bigsnarfdude / first_10_data_tructures.md
Last active February 13, 2025 16:36
first 10 data structures

1. Arrays (or Lists)

  • What it is: A collection of elements stored in contiguous memory locations. Elements are accessed by their index.
  • Why learn it: Arrays are one of the simplest and most fundamental data structures. They are the building block for many other structures, like lists in Python.
  • Operations: Insertion, deletion, accessing an element by index.
  • Time complexity:
    • Access: O(1)
    • Insert/Delete (at the end): O(1)
    • Insert/Delete (at the start or middle): O(n)

2. Linked Lists

@bigsnarfdude
bigsnarfdude / 42_percent_babyR1.py
Last active February 13, 2025 00:08
42% babyR1
import json
import re
from typing import List, Dict, Union, Tuple
import math
from collections import defaultdict
def clean_expression(expr: str) -> str:
"""Clean up the expression before processing."""
if not expr:
return ""
@bigsnarfdude
bigsnarfdude / baseline_eval_phi4
Created February 11, 2025 04:43
baseline_eval_phi4
Create a Python script that:
1. Uses Pydantic for a structured output model with fields:
- nums: List[int] # The input numbers
- target: int # Target number to reach
- expression: str # Model's arithmetic expression
- valid: bool # Whether expression is valid
2. Loads a single sample from "Jiayi-Pan/Countdown-Tasks-3to4-Unique" dataset
@bigsnarfdude
bigsnarfdude / phi_4_-14b-grpo.ipynb
Last active February 9, 2025 03:25
phi_4_-14b-grpo.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bigsnarfdude
bigsnarfdude / unsloth_3B_thinking_trainer.py
Last active February 7, 2025 05:58
unsloth_3B_thinking_trainer.py
import os
import transformers
import torch
from unsloth import FastLanguageModel, PatchFastRL, is_bfloat16_supported
import re
from datasets import load_dataset, Dataset
from trl import GRPOConfig, GRPOTrainer
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig
from peft import get_peft_model_state_dict, PeftConfig, PeftModel
import logging