Skip to content

Instantly share code, notes, and snippets.

@kyo-takano
kyo-takano / making-the-most-of-local-llms.ipynb
Last active June 10, 2024 19:12
ローカルLLMはこーやって使うの💢
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 / 三値ニューラルネットワーク入門.ipynb
Last active March 6, 2024 14:11
三値ニューラルネットワーク入門
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
Created March 6, 2024 12:29
Introduction to Ternary Neural Networks
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 / training-a-rubiks-cube-solver-under-a-minute.ipynb
Last active May 4, 2024 10:10
training-a-rubiks-cube-solver-under-a-minute.ipynb
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).
@kyo-takano
kyo-takano / few-shot-learning-on-function-calling.ipynb
Last active January 9, 2024 17:41
few-shot-learning-on-function-calling.ipynb
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 / OpenCALM-7B-8bit.ipynb
Last active July 25, 2023 05:27
0c7bf0479158aa137e0ba935dec70461
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.