Skip to content

Instantly share code, notes, and snippets.

View goddoe's full-sized avatar

Sungju Kim goddoe

View GitHub Profile
Begin by enclosing all thoughts within <thinking> tags, exploring multiple angles and approaches.
Break down the solution into clear steps within <step> tags. Start with a 20-step budget, requesting more for complex problems if needed.
Use <count> tags after each step to show the remaining budget. Stop when reaching 0.
Continuously adjust your reasoning based on intermediate results and reflections, adapting your strategy as you progress.
Regularly evaluate progress using <reflection> tags. Be critical and honest about your reasoning process.
Assign a quality score between 0.0 and 1.0 using <reward> tags after each reflection. Use this to guide your approach:
0.8+: Continue current approach
0.5-0.7: Consider minor adjustments
Below 0.5: Seriously consider backtracking and trying a different approach
@goddoe
goddoe / 설치된 버전만 확인하기.md
Created July 17, 2024 07:37
설치된 버전만 확인하기.md

pip freeze를 통해 나온 결과에서 특정 패키지 목록에 해당하는 패키지만 필터링하려면 아래와 같은 쉘 스크립트를 사용할 수 있습니다. 이 예시는 Unix 기반 시스템(Linux, macOS)에서 사용할 수 있습니다.

  1. pip freeze의 결과를 installed_packages.txt 파일에 저장합니다.
  2. 패키지 목록이 포함된 텍스트 파일을 packages_list.txt라고 가정합니다.
# 패키지 목록을 파일로 저장
pip freeze > installed_packages.txt

# 파일에 있는 패키지 목록을 기반으로 필터링
@goddoe
goddoe / kmeans_choose_k_using_eblow.py
Created May 13, 2024 16:47
choosing best k from Kmeans using Elbow method.
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs
# 예제 데이터 생성
X, _ = make_blobs(n_samples=300, centers=4, cluster_std=0.60, random_state=0)
# SSE 값을 저장할 리스트
sse = []
@goddoe
goddoe / 8k_to_4k.py
Last active December 8, 2023 05:41
8k_to_4k.py
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
input_path = "./model_in"
output_path = "./model_out"
max_shard_size = "5GB"
new_max_length = 4096
print("load model...start")
@goddoe
goddoe / extract_code.py
Created November 28, 2023 14:48
extract_code.py
def extract_code(inputs: dict) -> dict:
text = inputs["text"]
result = re.search(r'```.*?\n(.*?)\n```', text, re.DOTALL)
result = result.group(1) if result else text
return {"output": result}
@goddoe
goddoe / script_dir.sh
Created November 6, 2023 22:10
script_dir
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
cd $SCRIPT_DIR
@goddoe
goddoe / finetune_llama_v2.py
Created October 3, 2023 08:22 — forked from younesbelkada/finetune_llama_v2.py
Fine tune Llama v2 models on Guanaco Dataset
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@goddoe
goddoe / pip_install_fast.sh
Created September 21, 2023 14:12
pip_install_fast.sh
Tested this works https://stackoverflow.com/a/57014278/6147756
Single command:
MAKEFLAGS="-j$(nproc)" pip install xxx
Enable for all commands in a script:
export MAKEFLAGS="-j$(nproc)"
@goddoe
goddoe / find_available_ports.py
Created September 14, 2023 17:18
find_available_ports.py
def get_available_ports(port_from=5000, port_to=6000):
import socket
for port in range(port_from, port_to):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('localhost', port))
s.close()
yield port
except:
continue
def strip_codeblock(code_with_codeblock):
first_newline_idx = code_with_codeblock.find("\n")
code_tmp = code_with_codeblock[first_newline_idx+1:]
code_closing_idx = code_tmp.find("```")
code_striped = code_tmp[:code_closing_idx]
return code_striped