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.
@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
@wannaphong
wannaphong / ngrams.py
Last active September 8, 2017 07:59 — forked from benhoyt/ngrams.py
Print most frequent N-grams in given file
# -*- coding: utf-8 -*-
"""Print most frequent N-grams in given file.
Usage: python ngrams.py filename
Problem description: Build a tool which receives a corpus of text,
analyses it and reports the top 10 most frequent bigrams, trigrams,
four-grams (i.e. most frequently occurring two, three and four word
consecutive combinations).
@wannaphong
wannaphong / LK82.py
Last active June 29, 2017 04:29 — forked from korakot/LK82.py
Thai Soundex LK82, Udom83
# ตาม guru.sanook.com/1520
import re
t1 = str.maketrans("กขฃคฅฆงจฉชฌซศษสญยฎดฏตณนฐฑฒถทธบปผพภฝฟมรลฬฤฦวหฮอ",
"กกกกกกงจชชชซซซซยยดดตตนนททททททบปพพพฟฟมรรรรรวหหอ")
t2 = str.maketrans(
"กขฃคฅฆงจฉชซฌฎฏฐฑฒดตถทธศษสญณนรลฬฤฦบปพฟภผฝมำยวไใหฮาๅึืเแโุูอ",
"1111112333333333333333333444444445555555667777889AAABCDEEF")
def LK82(s):
res = []
@wannaphong
wannaphong / Tensorflow-GPU-ubuntu16.04.md
Last active June 13, 2017 10:00 — forked from unsalted/Tensorflow-GPU-ubuntu16.04.md
Ubuntu 16.04 - Tensorflow (GPU) setup
@wannaphong
wannaphong / builder.py
Created March 8, 2017 16:30 — forked from pazdera/builder.py
Example of `builder' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `builder' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@wannaphong
wannaphong / jdutil.py
Created February 11, 2017 16:58 — forked from jiffyclub/jdutil.py
Functions for converting dates to/from JD and MJD
"""
Functions for converting dates to/from JD and MJD. Assumes dates are historical
dates, including the transition from the Julian calendar to the Gregorian
calendar in 1582. No support for proleptic Gregorian/Julian calendars.
:Author: Matt Davis
:Website: http://github.com/jiffyclub
"""
@wannaphong
wannaphong / q.py
Created January 22, 2017 12:42 — forked from fheisler/q.py
Q-learning Tic-tac-toe
import random
class TicTacToe:
def __init__(self, playerX, playerO):
self.board = [' ']*9
self.playerX, self.playerO = playerX, playerO
self.playerX_turn = random.choice([True, False])
def play_game(self):