Skip to content

Instantly share code, notes, and snippets.

@ivanfioravanti
ivanfioravanti / mlx_memory.sh
Created January 4, 2025 16:42
Script to set MLX memory limits
#!/usr/bin/env bash
# Default values for percentages
DEFAULT_WIRED_LIMIT_PERCENT=85
DEFAULT_WIRED_LWM_PERCENT=75
# Read input parameters or use default values
WIRED_LIMIT_PERCENT=${1:-$DEFAULT_WIRED_LIMIT_PERCENT}
WIRED_LWM_PERCENT=${2:-$DEFAULT_WIRED_LWM_PERCENT}
@charlesfrye
charlesfrye / wrapper.py
Last active July 28, 2025 03:54
Train GPT-2 in five minutes -- for free!
# Train GPT-2 in five minutes -- for free
#
# ```bash
# pip install modal
# modal setup
# modal run wrapper.py
# ```
#
# Note that the end-to-end latency the first time is more like 25 minutes:
# - five minutes to install Torch (rip)
@charlesfrye
charlesfrye / README.md
Last active January 3, 2025 02:04
Reproducing results from "Beat GPT-4o at Python by Searching with 100 Dumb LLaMAs"

See rune2e.sh for info on how to run the experiment.

@mlabonne
mlabonne / merge_peft.py
Last active May 29, 2025 13:58
Merge base model and peft adapter and push it to HF hub
# Example usage:
# python merge_peft.py --base_model=meta-llama/Llama-2-7b-hf --peft_model=./qlora-out --hub_id=alpaca-qlora
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
import argparse
def get_args():
@ssugimoto
ssugimoto / Dockerfile
Created August 8, 2021 12:26
AWS Lambda and VSCode Remote container ,for Python3.8
FROM mcr.microsoft.com/vscode/devcontainers/python:3.8
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install --no-install-recommends java-common zip \
&& wget https://corretto.aws/downloads/latest/amazon-corretto-8-x64-linux-jdk.deb \
&& dpkg --install amazon-corretto-8-x64-linux-jdk.deb \
&& wget https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip \
&& unzip awscli-exe-linux-x86_64.zip \
&& ./aws/install \
# Clean up
@brockmanmatt
brockmanmatt / explain2secondgraderlogprob.ipynb
Created July 30, 2020 16:28
explain2SecondGraderLogprob.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brockmanmatt
brockmanmatt / defaultapinotebook.ipynb
Last active November 18, 2023 02:50
defaultapinotebook.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chad-m
chad-m / streamlit_download_button.py
Last active November 25, 2024 14:38
A download function and examples app for Streamlit
import base64
import os
import json
import pickle
import uuid
import re
import streamlit as st
import pandas as pd
@korakot
korakot / youtube_to_json.py
Last active April 12, 2021 17:46
Transcribe YouTube with Google Cloud Speech API (on Colab)
import json
from subprocess import check_output
from time import sleep
!pip -q install youtube-dl
from google.colab import auth
auth.authenticate_user()
!gcloud config set project kora-id
gcs = 'gs://co-lab/dhamma' # use your own project, gcs
@ines
ines / Install
Last active September 21, 2023 17:14
Streamlit + spaCy
pip install streamlit
pip install spacy
python -m spacy download en_core_web_sm
python -m spacy download en_core_web_md
python -m spacy download de_core_news_sm