Skip to content

Instantly share code, notes, and snippets.

@Birch-san
Birch-san / llama-convert.md
Created June 1, 2023 18:24
Converting LLaMA model weights to huggingface format + safetensors

Loading LLaMA via Huggingface + Safetensors, with 4-bit quantization

Let's say we're trying to load a LLaMA model via AutoModelForCausalLM.from_pretrained with 4-bit quantization in order to inference from it:

python -m generate.py

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, LlamaTokenizerFast, LlamaForCausalLM
import transformers
@grongierisc
grongierisc / download-vs-code-server.sh
Last active November 1, 2022 08:06 — forked from b01/download-vs-code-server.sh
Linux script to download latest VS Code Server, good for Docker (tested in Alpine).
#!/bin/sh
set -e
ARCH="amd64"
U_NAME=$(uname -m)
if [ "${U_NAME}" = "aarch64" ]; then
ARCH="arm64"
fi
@hardyscc
hardyscc / gitlab-microk8s.md
Last active August 26, 2023 02:44
Gitlab MicroK8s CI/CD Integration

Gitlab MicroK8s CI/CD Integration

Install microk8s

sudo apt-get update
sudo apt-get upgrade -y

sudo snap install microk8s --classic --channel=1.25/stable
sudo microk8s status --wait-ready
@p3jitnath
p3jitnath / install-docker.sh
Last active June 26, 2025 20:17
Docker and Nvidia Docker installation in Ubuntu 20.04 LTS
# WARNING : This gist in the current form is a collection of command examples. Please exercise caution where mentioned.
# Docker
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
docker --version
@slowkow
slowkow / needleman-wunsch.py
Last active July 28, 2025 18:11
A simple version of the Needleman-Wunsch algorithm in Python.
#!/usr/bin/env python
"""
The Needleman-Wunsch Algorithm
==============================
This is a dynamic programming algorithm for finding the optimal alignment of
two strings.
Example
-------
#! -*- coding: utf-8 -*-
import sys
import time
import numpy as np
import gensim
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
from sklearn.manifold import TSNE
from sklearn.cluster import MiniBatchKMeans
@cneud
cneud / ocros.md
Last active August 23, 2019 15:56

基本是按照文档顺序,此处对INSTALL.md做补充

安装BLAS/LAPACK

Ubuntu

不必按照INSTALL.md里面的编译安装方法,只要安装源里的包即可

$ sudo apt install libopenblas-dev
$ sudo apt install liblapack
$ sudo apt install swig

CentOS7

@loretoparisi
loretoparisi / fasttext_lid_training.sh
Last active January 28, 2018 09:28
FastText Language Detection - Training on macOS
#!bin/bash
# grab labeled dataset
wget http://downloads.tatoeba.org/exports/sentences.tar.bz2
bunzip2 sentences.tar.bz2
tar xvf sentences.tar
# macos only for gshuf
brew install coreutils
awk -F"\t" '{print"__label__"$2" "$3}' < sentences.csv | gshuf > all.txt
@norswap
norswap / Node.java
Created September 13, 2017 13:00
Fast Java Reflection
package demo;
public interface Node {}