Skip to content

Instantly share code, notes, and snippets.

View wannaphong's full-sized avatar
🧭
out-of-time

Wannaphong Phatthiyaphaibun wannaphong

🧭
out-of-time
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":"
!pip install pythainlp
<!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
เราจะไปเดินเล่นที่[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]แนะวิธีแก้น้ำเสียจากสีย้อมผ้าดำ
@wannaphong
wannaphong / ner.py
Last active December 11, 2018 14:52
# Apache License 2.0
file_name="data" # ชื่อไฟล์คลังข้อมูล
import codecs
from pythainlp.tokenize import word_tokenize
from pythainlp.tag import pos_tag
from nltk.tokenize import RegexpTokenizer
import glob
import nltk
import re
#จัดการประโยคซ้ำ
from sklearn_crfsuite import scorers,metrics
from sklearn.metrics import make_scorer
from sklearn.model_selection import cross_validate,train_test_split
import sklearn_crfsuite
def doc2features(doc, i):
word = doc[i][0]
postag = doc[i][1]
# Features from current word
features={
'word.word': word,