Skip to content

Instantly share code, notes, and snippets.

@haotian-liu
haotian-liu / 1_eval.py
Created November 4, 2023 19:11
gqa evaluation
# Evaluation code for GQA.
# Computes a suite of metrics such as accuracy, consistency, plausibility and scores per question type and length.
# Visit https://gqadataset.org/ for all information about the dataset, including examples, visualizations, paper and slides.
#
#
# Metrics:
# - Accuracy: Standard accuracy, computed over the balanced version of the dataset, which is more robust against
# cheating by making educated guesses. For each question-answer pair (q,a), we give 1 point if the
# predicted answer p matches a and 0 otherwise, and average over all questions in the dataset.
#
@haotian-liu
haotian-liu / quantize.py
Created July 31, 2023 16:32
AutoGPTQ quantization for LLaVA
from transformers import AutoTokenizer, TextGenerationPipeline
from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
import logging
logging.basicConfig(
format="%(asctime)s %(levelname)s [%(name)s] %(message)s", level=logging.INFO, datefmt="%Y-%m-%d %H:%M:%S"
)
"""
Download https://huggingface.co/liuhaotian/llava-llama-2-13b-chat-lightning-preview to local
@haotian-liu
haotian-liu / gh-pages-deploy.md
Created June 19, 2022 07:02 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@haotian-liu
haotian-liu / karabiner.json
Created June 24, 2020 02:49
karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@haotian-liu
haotian-liu / karabiner.json
Created October 22, 2019 18:30
Keep 'spacebar' from being pressed twice
{
"description": "Keep 'spacebar' from being pressed twice",
"manipulators":
[
{
"from": { "key_code": "spacebar" },
"parameters": { "basic.to_if_held_down_threshold_milliseconds": 50 },
"to_if_held_down":[
{
"key_code": "spacebar",
@haotian-liu
haotian-liu / list-user-installed-packages.sh
Created June 27, 2019 12:37 — forked from ejona86/list-user-installed-packages.sh
List user-installed packages on LEDE
#!/bin/sh
FLASH_TIME="$(awk '
$1 == "Installed-Time:" && ($2 < OLDEST || OLDEST=="") {
OLDEST=$2
}
END {
print OLDEST
}
' /usr/lib/opkg/status)"
@haotian-liu
haotian-liu / kaomoji.plist
Last active March 8, 2019 15:57
Import this to text substitution in macOS to type kaomoji conveniently with built-in software.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>phrase</key>
<string>˙Ꙫ˙</string>
<key>shortcut</key>
<string>vv</string>
</dict>
@haotian-liu
haotian-liu / script.js
Created December 26, 2018 05:23
Bookmarklet for 19 Fall admission results in 1.3acres
(() => {
const form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "https://www.1point3acres.com/bbs/forum.php?mod=forumdisplay&fid=82&filter=sortid&sortid=164&orderby=dateline");
/* form.setAttribute("target", "view"); */
const hiddenField = (name, value) => {
const field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", name);
field.setAttribute("value", value);
@haotian-liu
haotian-liu / sendmail.py
Created October 19, 2018 04:12
Send Email with SMTP using Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
mail_host = "smpt.xxxx.com"
mail_user = "[email protected]"
mail_pass = "password"
@haotian-liu
haotian-liu / morning-city.glsl
Created November 28, 2017 11:48
Shader-based animation forked from https://www.shadertoy.com/view/XsBSRG
//#define CARS
#define I_MAX 70
float rand(vec2 n) {
return fract(sin((n.x*1e2+n.y*1e4+1475.4526)*1e-4)*1e6);
}
float noise(vec2 p)
{
p = floor(p*200.0);