Skip to content

Instantly share code, notes, and snippets.

View sroecker's full-sized avatar

Steffen Röcker sroecker

View GitHub Profile
@sroecker
sroecker / opn_sections_thomas_attractor.py
Last active January 3, 2025 20:23
Ordinal Partition Network (OPN) approach for Poincaré section estimation of the Thomas attractor based on https://github.com/hinsley/MultimodalMaps/blob/main/maps/thomas.jl
import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from itertools import permutations
from collections import Counter
# Define the Thomas attractor system
def thomas_derivatives(t, u, b):
x, y, z = u
@sroecker
sroecker / p.sh
Last active November 15, 2024 14:10 — forked from algal/p.sh
bash script to query perplexity.ai
#!/usr/bin/env bash
# based off of https://gist.github.com/rauchg/c5f0b1dc245ad95c593de8336aa382ac?permalink_comment_id=4842642#gistcomment-4842642
# further adapted from https://gist.github.com/algal/5e815ffd371d57d3a6a37056db1bd281
if [ "$#" -eq 0 ]; then
echo "Usage: $(basename $0) promt_to_send_to_perplexity"
echo ""
echo " Requirements: PERPLEXITY_API, defined; jq and curl, installed; bash, version 3 or higher."
exit 1
fi
@sroecker
sroecker / evol-instruct-distilabel.py
Created October 18, 2024 15:14
Simple evol-instruct example with distilabel
from distilabel.steps import LoadDataFromDicts
from distilabel.steps.tasks import EvolInstruct
from distilabel.pipeline import Pipeline
from distilabel.llms import OllamaLLM
import pprint
# Set up the pipeline
with Pipeline(name="evol-instruct-example") as pipeline:
# Load initial instructions
@sroecker
sroecker / modal-moondream-label_datikz_v2.py
Last active June 13, 2024 13:01
A script to caption datikz graphs with Moondream using Modal
import modal
app = modal.App(name="moondream-label-datikz_v2")
data_dict = modal.Dict.from_name("HF_DATASET", create_if_missing=True)
def download_dataset():
from datasets import load_dataset
data_dict["HF_DATASET"] = "nllg/datikz-v2"
dataset = load_dataset(data_dict["HF_DATASET"])
@sroecker
sroecker / label_datikz_v2.py
Last active June 11, 2024 19:45
A script to caption datikz graphs with Moondream
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
import xxhash
from tqdm import tqdm
# load moondream model
model_id = "vikhyatk/moondream2"
revision = "2024-05-20"
model = AutoModelForCausalLM.from_pretrained(
@sroecker
sroecker / modal_eval_pokemon.py
Last active June 7, 2024 09:44
Modal: Batch eval Moondream with Pokemon dataset
import modal
app = modal.App(name="pokemon-eval")
moondream_image = modal.Image.micromamba(
python_version="3.11"
).apt_install(
"git"
).micromamba_install(
"cudatoolkit",
@sroecker
sroecker / podman_axolotl.sh
Created April 2, 2024 14:57
Run Axolotl fine-tuning with Podman
podman run --rm --device nvidia.com/gpu=all --security-opt=label=disable --mount type=bind,src="${PWD}",target=/workspace/axol
otl -v ${HOME}/.cache/huggingface:/root/.cache/huggingface winglian/axolotl:main-py3.10-cu118-2.0.1 accelerate launch -m axolotl.cli.train examples/openllam
a-3b/lora.yml
@sroecker
sroecker / build_continue_vscode_extension.sh
Last active January 22, 2024 09:11
How To Build the Continue.dev VSCode Extension for Red Hat Dev Spaces
#!/bin/bash
git clone https://github.com/continuedev/continue
npm config set prefix ~/.local
sh continue/install-dependencies.sh
cd continue/extensions/vscode
node scripts/prepackage.js
npm install @vscode/vsce
PATH=$PATH:~/.local/bin/
npm install yarn
node scripts/package.js
@sroecker
sroecker / debug_pytorch_rocm.py
Last active May 15, 2024 19:51
If this is not crashing then PyTorch is most likely running with your AMD graphics card and ROCm, if not see magic variables
import torch
print("pytorch version: " + torch.__version__)
print("CUDA available: " + str(torch.cuda.is_available()))
print("device count: " + str(torch.cuda.device_count()))
print("current device: " + str(torch.cuda.current_device()))
print("device name: " + torch.cuda.get_device_name(torch.cuda.current_device()))
print("backend:")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(device)
@sroecker
sroecker / paxata_client.py
Created December 1, 2021 14:26
Simple Python client for the Paxata REST API
import json
import requests
import collections
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token):
self.token = token
def __call__(self, r):
r.headers['Authorization'] = 'Bearer ' + self.token
return r