Skip to content

Instantly share code, notes, and snippets.

@kyo-takano
kyo-takano / xet-gc.md
Created July 29, 2026 05:28
Xet-GC: Garbage Collector for Hugging Face Storage with Xet Backend

Xet-GC semi-automates the cleanup of Hugging Face repositories bloated by Xet.

image

With the "LFS Files" modal open in your settings, this script maps each row of the table to its corresponding "Possible filename," which is hidden within a tooltip mask. By parsing the DOM to extract this information, the script retains only the most recent version of each unique filename (assuming the first occurrence from top to bottom is the latest) and automatically selects all older duplicates.


  1. Open the Settings of your Hugging Face repository and navigate to Storage Usage > List Large Files.
@kyo-takano
kyo-takano / the-poor-mans-guide-to-cloud-gpu-selection--ja.md
Created January 26, 2026 11:07
貧者のクラウドGPU選択ガイド

cost-efficiency

投資コストに対して得られる計算量は、GPUと演算強度(Arithmetic Intensity)によって大きく異なります。Runpodの価格設定に基づき、`batch_size=1024` (tokens) でLLMを事前学習した場合、0.5Bパラメータ未満のモデルではL4が、それ以上の規模ではH100が圧倒的なコストパフォーマンスを示します。

貧者のクラウドGPU選択ガイド

@kyo-takano
kyo-takano / the-poor-mans-guide-to-cloud-gpu-selection.md
Created January 26, 2026 10:53
The Poor Man’s Guide to Cloud GPU Selection

cost-efficiency

Compute obtained per dollar varies significantly by GPU and arithmetic intensity. According to Runpod's pricing, when pre-training LLMs with `batch_size=1024` (tokens), the L4 offers superior cost-performance for models under 0.5B parameters, while the H100 dominates for larger scales.

The Poor Man’s Guide to Cloud GPU Selection

@kyo-takano
kyo-takano / making-the-most-of-local-llms.ipynb
Last active May 12, 2026 04:03
ローカルLLMはこーやって使うの💢
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kyo-takano
kyo-takano / openai_batch_generation.py
Created April 16, 2024 09:31
Submitting an Asyncronous Large-Batch Request with OpenAI Python SDK
#!/usr/bin/python
import json
import textwrap
import time
from openai import OpenAI
client = OpenAI()
@kyo-takano
kyo-takano / pandas-concise-query.py
Created March 16, 2024 03:16
Creating a concise query for Pandas DataFrame
init_std, lr = 0.02, 2e-5 # example
""" Redundant """
indices = df["init_std"] == init_std) & (df["lr"] == lr)
print(df[(indices])
""" Concise """
query = f"{init_std=} & {lr=}".replace("=", "==")
print(df.query(query)) # "init_std==0.02 & lr==2e-05"
@kyo-takano
kyo-takano / cheat-sheet--pytorch-on-tpu.md
Created March 10, 2024 04:40
Cheat Sheet: PyTorch on TPU

Cheatsheet: Migrating a PyTorch script to a single TPU

Mar 10, 2024.

See pytorch.org/xla for up-to-date info and implementation with multiple TPUs

Installing PyTorch/XLA for TPU

# Usually pre-installed on TPU instances
pip install torch_xla[tpu] -f https://storage.googleapis.com/libtpu-releases/index.html
@kyo-takano
kyo-takano / introduction-to-ternary-neural-networks.ipynb
Last active December 26, 2024 11:23
三値ニューラルネットワーク入門
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kyo-takano
kyo-takano / introduction-to-ternary-neural-networks.ipynb
Last active April 1, 2026 12:42
introduction-to-ternary-neural-networks.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kyo-takano
kyo-takano / lexical_search_with_gzip.py
Last active March 11, 2024 03:39
Lexical Search with gzip (gzipによる語彙検索)
import gzip
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1):
"""
文字列ベースで類似したテキストチャンクを推定するアルゴリズム.
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し編集距離のようなものをベースに評価する.
Parameters:
query (str): 検索クエリとして使用する文字列.
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1).