Skip to content

Instantly share code, notes, and snippets.

@Maximilian-Winter
Maximilian-Winter / gbnf_grammar_generator.py
Last active November 17, 2024 06:13
GBNF grammar generator for always valid function calls and object creation in JSON with llama.cpp
import inspect
import json
import re
import typing
from inspect import isclass, getdoc
from types import NoneType
from pydantic import BaseModel, Field
from pydantic.fields import FieldInfo
from typing import Any, Type, List, get_args, get_origin, Tuple, Union, Optional
@lapp0
lapp0 / calc_vram.py
Last active September 18, 2024 01:54
LLM Memory Requirement Calculator Script (Full Finetune and Inference)
import urllib.request
import json
def bits_to_gb(bits):
return bits / (8 * 1024**3)
def calculate_train_vram_requirements(
batch_size, seq_len, params, precision, num_layers, num_attn_heads, hidden_size, **ignored
@shawwn
shawwn / 65b_samples.txt
Last active May 18, 2023 06:35
Some LLaMA 65B outputs after fixing the sampler settings.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{"seed": 374894, "temp": 0.7, "top_p": 0.0, "top_k": 40, "repetition_penalty": 1.1764705882352942, "max_seq_len": 512, "max_gen_len": 511}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Loading
Loaded in 8.72 seconds
============== sample 1 =================
I believe the meaning of life is to grow, learn and give.
@trygvebw
trygvebw / find_noise.py
Last active June 21, 2024 15:31
A "reverse" version of the k_euler sampler for Stable Diffusion, which finds the noise that will reconstruct the supplied image
import torch
import numpy as np
import k_diffusion as K
from PIL import Image
from torch import autocast
from einops import rearrange, repeat
def pil_img_to_torch(pil_img, half=False):
image = np.array(pil_img).astype(np.float32) / 255.0
@480
480 / gist:3b41f449686a089f34edb45d00672f28
Last active January 23, 2025 16:11
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@pgorczak
pgorczak / imgmatrix.py
Last active March 21, 2023 16:48
Arrange images of equal dimensions in a grid, using Python and OpenCV.
#! /usr/bin/env python
import argparse
import itertools
import cv2
import numpy as np
if __name__=='__main__':
parser = argparse.ArgumentParser(
@daxadax
daxadax / burgerbot.rb
Last active April 13, 2022 09:20
burgerbot
#!/usr/bin/env ruby
# modified from https://gist.github.com/pbock/3ab260f3862c350e6b5f #
require 'watir-webdriver'
class BurgerBot
def initialize
@attempt_count = 0
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active March 13, 2025 07:34
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/