Skip to content

Instantly share code, notes, and snippets.

# 懶得裝 zsh 跟整套 oh my 時,塞上去 bash 版本
_my_ssh_autocomplete() {
local cur=${COMP_WORDS[COMP_CWORD]}
if [[ $cur =~ ^[0-9]{1,3}$ ]]; then
local full_ip="[email protected].${cur}"
COMPREPLY=( $(compgen -W "$full_ip" -- "$cur") )
fi
}
@LewisGet
LewisGet / llm_4bit_dpo_train.py
Created August 15, 2025 09:50
4bit 跑 dpo 沒對齊提問種類,因為資料不足。
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
from datasets import Dataset
from torch.cuda.amp import autocast
import json
import glob
import os
@LewisGet
LewisGet / llm_4bit_train.py
Last active August 13, 2025 23:43
用 4bit int8 的訓練資料來訓練 llm
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline, BitsAndBytesConfig
import json
import os
model_path = "/workspace/Qwen3-0.6B"
fine_tune_path = "/workspace/4bit-train"
per_device_train_batch_size=3
learning_rate=5e-6
@LewisGet
LewisGet / ask_script.py
Last active August 12, 2025 05:18
私人 llm,用 ollama 批量翻譯或者整理概要,也可以刪除廣告用,目前是在做 role play rpg 的訓練資料
from ollama import Client
import json
import re
client = Client(
host='http://ollama:11434',
headers={'x-some-header': 'some-value'}
)
f = open("text.txt", "r")
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from time import sleep
class WebCrawler:
def __init__(self, default_url):
self.driver = webdriver.Chrome()
{
// space
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": "all",
"trim_only_modified_white_space": false,
// style
"font_size": 16,
}
javascipt:(function(content){let utterance = new SpeechSynthesisUtterance(content); speechSynthesis.speak(utterance);})("hello world");
let utterance = new SpeechSynthesisUtterance("Hello world!");
speechSynthesis.speak(utterance);
data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Crect width='100%25' height='100%25' fill='%23{input_your_color}' /%3E%3C/svg%3E
import subprocess
import glob
import sys
import os
for i in glob.glob("./*"):
t = subprocess.check_output(["file", "--mime-type", "-b", i], shell=True)
t = t[-4:-1]
if t == b"mp4":