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 February 24, 2025 16:16
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 March 3, 2025 05:36
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():
@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
@choongng
choongng / notes.md
Last active December 29, 2019 23:01
Swift for TensorFlow quick start with Docker on Mac

A good way to get a taste of Swift for Tensorflow language and tools is to set it up with Jupyter with the fastai Swift notebooks. I wanted a quick setup, which the Mac install experience currently not, so instead I installed the release binaries in a Ubuntu container via Docker. The setup process for this scenario is not well documented, so here it is for you / future me.

What we're about to do is install the S4TF 0.4 release and the fastai v3 Swift notebooks on Ubuntu 18.04. Generally we follow the swift-jupyter docker file, but install cpu-only release versions of the packages.

Below are some of the references I looked at:

Rationale for S4TF and background reading

https://github.com/tensorflow/swift/blob/master/docs/WhySwiftForTensorFlow.md https://github.com/tensorflow/swift/blob/master/docs/DifferentiableFunctions.md