Skip to content

Instantly share code, notes, and snippets.

@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).
@kyo-takano
kyo-takano / few-shot-learning-on-function-calling.ipynb
Last active July 10, 2025 23:32
few-shot-learning-on-function-calling.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 / OpenCALM-7B-8bit.ipynb
Last active July 25, 2023 05:27
0c7bf0479158aa137e0ba935dec70461
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 / generate_review_improve.py
Last active July 15, 2023 17:40
Iteratively generate, review, and improve a code snippet using OpenAI's `Completion` and `Embedding` APIs
""" Iteratively generate, review, and improve a code snippet using OpenAI's `Completion` and `Embedding` APIs """
import os
import openai
import textwrap
from scipy.spatial import distance
import matplotlib.pyplot as plt
from tqdm import trange
from IPython.display import display, Code, clear_output