This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Ref: https://daily-dev-tips.com/posts/making-gradient-text-with-tailwind-css/ --> | |
| <div class="grid place-items-center h-screen"> | |
| <h1 class="text-8xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-purple-400 to-pink-600"> | |
| Tailwind CSS | |
| </h1> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find_all_span(d, s): | |
| span_list = [] | |
| offset = -1 | |
| while True: | |
| start_idx = d.find(s, offset + 1) | |
| if start_idx == -1: | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from functools import partial | |
| import pandas as pd | |
| import numpy as np | |
| def apply(df, func): | |
| return df.apply(func, axis=1) | |
| def parallel_apply(df, func, n_cores): | |
| df_split = np.array_split(df, n_cores) | |
| pool = Pool(n_cores) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def binary_search(arr, target): | |
| low, high = 0, len(arr) - 1 | |
| while low <= high: | |
| mid = (low+high) // 2 | |
| if arr[mid] > target: | |
| high = mid -1 | |
| elif arr[mid] == target: | |
| return mid | |
| else: | |
| low = mid + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model_path_list=($(ls -d ${model_ckpt_dir}/model_*)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for loop array | |
| # Reference: https://www.tutorialkart.com/bash-shell-scripting/bash-append-an-array-to-another-array/ | |
| array=( one two three ) | |
| for i in "${array[@]}" | |
| do | |
| echo "$i" | |
| done | |
| # append array | |
| # Reference: https://www.tutorialkart.com/bash-shell-scripting/bash-append-an-array-to-another-array/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| forward_args = inspect.getfullargspec(self.model.forward).args[1:] | |
| x = {k: v for k, vin self.transform(text) if k in forward_args} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Reference: https://www.baeldung.com/linux/bash-parse-command-line-arguments | |
| VALID_ARGS=$(getopt -o abg:d: --long alpha,beta,gamma:,delta: -- "$@") | |
| if [[ $? -ne 0 ]]; then | |
| exit 1; | |
| fi | |
| eval set -- "$VALID_ARGS" | |
| while [ : ]; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reference: https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash | |
| if [ -z ${var+x} ]; then echo "var is unset"; else echo "var is set to '$var'"; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import numpy as np | |
| import torch | |
| from transformers import GPTJForCausalLM, AutoTokenizer | |
| ########################################################### | |
| # Load Model |