Skip to content

Instantly share code, notes, and snippets.

View wannaphong's full-sized avatar

Wannaphong Phatthiyaphaibun wannaphong

View GitHub Profile
@wannaphong
wannaphong / sft_trainer.py
Created October 28, 2023 11:01 — forked from lewtun/sft_trainer.py
Fine-tuning Mistral 7B with TRL & DeepSpeed ZeRO-3
# This is a modified version of TRL's `SFTTrainer` example (https://github.com/huggingface/trl/blob/main/examples/scripts/sft_trainer.py),
# adapted to run with DeepSpeed ZeRO-3 and Mistral-7B-V1.0. The settings below were run on 1 node of 8 x A100 (80GB) GPUs.
#
# Usage:
# - Install the latest transformers & accelerate versions: `pip install -U transformers accelerate`
# - Install deepspeed: `pip install deepspeed==0.9.5`
# - Install TRL from main: pip install git+https://github.com/huggingface/trl.git
# - Clone the repo: git clone github.com/huggingface/trl.git
# - Copy this Gist into trl/examples/scripts
# - Run from root of trl repo with: accelerate launch --config_file=examples/accelerate_configs/deepspeed_zero3.yaml --gradient_accumulation_steps 8 examples/scripts/sft_trainer.py
@wannaphong
wannaphong / git_submodules.md
Created August 18, 2023 09:00 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
# MIT License
from web3 import Web3 # pip install web3
FoodcourtRouterAbi=[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_factory","internalType":"address"},{"type":"address","name":"_WETH","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"WETH","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"amountA","internalType":"uint256"},{"type":"uint256","name":"amountB","internalType":"uint256"},{"type":"uint256","name":"liquidity","internalType":"uint256"}],"name":"addLiquidity","inputs":[{"type":"address","name":"tokenA","internalType":"address"},{"type":"address","name":"tokenB","internalType":"address"},{"type":"uint256","name":"amountADesired","internalType":"uint256"},{"type":"uint256","name":"amountBDesired","internalType":"uint256"},{"type":"uint256","name":"amountAMin","internalType":"uint256"},{"type":"uint256","name":"
@wannaphong
wannaphong / pypromptpay.py
Last active August 23, 2021 17:33
เขียนโดย นาย วรรณพงษ์ ภัททิยไพบูลย์
import libscrc
def text_qr(account,one_time=True,country="TH",money="",currency="THB"):
"""
text_qr(account,one_time=True,country="TH",money="",currency="THB")
account is phone number or identification number.
one_time : if you use once than it's True.
country : TH
money : money (if have)
currency : THB
"""
เราจะไปเดินเล่นที่[LOCATION]หนองคาย[/LOCATION] พร้อมกับนั่งเรือข้ามไป[LOCATION]ประเทศลาว[/LOCATION]
ผมเรียนอยู่ที่[LOCATION]มหาวิทยาลัยขอนแก่น วิทยาเขตหนองคาย[/LOCATION]
ผมเป็นนักศึกษา[ORGANIZATION]คณะวิทยาศาสตร์ประยุกต์และวิศวกรรมศาสตร์[/ORGANIZATION] [ORGANIZATION]มหาวิทยาลัยขอนแก่น วิทยาเขตหนองคาย[/ORGANIZATION]
ผู้อพยพจาก[LOCATION]อเมริกากลาง[/LOCATION]มุดกำแพงเข้า[LOCATION]สหรัฐ[/LOCATION]
ประธาน [ORGANIZATION]สนช.[/ORGANIZATION] เชื่อ [ORGANIZATION]สนช.[/ORGANIZATION]ชุดนี้มีคุณสมบัติเป็นส.ว.ได้
[ORGANIZATION]กกร.[/ORGANIZATION]ฟันธงปีนี้เศรษฐกิจโตร้อยละ 4.4
นักวิจัยจากทุนวิจัย [ORGANIZATION]สกว.[/ORGANIZATION] วิจัยถึงต้นตอของปัญหาหมอกควันที่เกิดขึ้นในพื้นที่[LOCATION]ภาคเหนือ[/LOCATION] ซึ่งจะเป็นฐานในการสร้างสรรค์
[LOCATION]ฮ่องกง[/LOCATION]กลายเป็นเมืองในหมอก
[LOCATION]แคลิฟอร์เนีย[/LOCATION]ตั้งเป้ามีรถไฟฟ้า 5 ล้านคันภายในปี 2573
[ORGANIZATION]กรมควบคุมมลพิษ[/ORGANIZATION]แนะวิธีแก้น้ำเสียจากสีย้อมผ้าดำ
!pip install pythainlp
<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" lang="th" xml:lang="th"><head><title>Scala</title><meta name="keywords" content=" reddit, reddit.com, vote, comment, submit " /><meta name="description" content="reddit: the front page of the internet" /><meta name="referrer" content="always"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link type="application/opensearchdescription+xml" rel="search" href="/static/opensearch.xml"/><link rel="canonical" href="https://www.reddit.com/r/Python/" /><meta name="viewport" content="width=1024"><link rel="dns-prefetch" href="//out.reddit.com"><link rel="preconnect" href="//out.reddit.com"><link rel='icon' href="//www.redditstatic.com/icon.png" sizes="256x256" type="image/png" /><link rel='shortcut icon' href="//www.redditstatic.com/favicon.ico" type="image/x-icon" /><link rel='apple-touch-icon-precomposed' href="//www.redditstatic.com/icon-touch.png" /><link rel="alternate" type="application/atom+xml" title="RSS" href="https://www.reddit.
<!DOCTYPE html>
<body>
<?php
session_start(); // ถ้าใช้งาน session อย่าลืม session_start();
if(isset($_POST["logout"])){ // มี SESSION ชื่อ checklogin ให้ทำในส่วนนี้
//unset($_SESSION['checklogin']); // ทำลาย SESSION ชื่อ checklogin
$_SESSION['checklogin'] = false; //
echo "ออกจากระบบแล้ว";
header("refresh: 2; url=./"); // รีเพจอีก 2 วินาที
exit(0);
@wannaphong
wannaphong / process_wikipedia.py
Last active July 17, 2019 03:53 — forked from snakers4/process_wikipedia.py
Post process wikipedia files produced by wikiextractor
import os
import re
import sys
import glob
import nltk
import gensim
import numpy as np
import pandas as pd
from tqdm import tqdm
from uuid import uuid4
@wannaphong
wannaphong / how-to-gource.sh
Last active June 25, 2019 12:23 — forked from miguelsaddress/how-to-gource.sh
Install Gource in Ubuntu (gource.io)
#Install Gource in Ubuntu
========================
#Go to the folder.... and
#see http://tylerfrankenstein.com/code/install-gource-ubuntu-1010-visualize-git-repo
# https://github.com/acaudwell/Gource/releases/download/gource-0.49/gource-0.49.tar.gz
sudo apt-get update
sudo apt-get install libglew-dev
sudo apt-get install libsdl2-dev
sudo apt install libsdl2-image-dev