Skip to content

Instantly share code, notes, and snippets.

View Leo-Lee15's full-sized avatar
๐Ÿ˜
Busy!

Leo Lee Leo-Lee15

๐Ÿ˜
Busy!
  • China
View GitHub Profile
import time
from vllm import LLM, SamplingParams
from vllm.outputs import PoolingRequestOutput, RequestOutput
from typing import Union
import threading
from threading import Event
class MyLLM(LLM):
def keep_running(
self,
@fakerybakery
fakerybakery / mistral-convert.py
Last active March 24, 2025 10:36
Convert the text portion of Mistral 3.1 -> HF format (IMPORTANT: Does not convert vision layers yet! The resulting model will be a text-only LLM.)
# Copyright 2023 Mistral AI and 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
# distributed under the License is distributed on an "AS IS" BASIS,
@qunash
qunash / grpo_qwen-0-5b_single_t4.ipynb
Last active October 15, 2025 03:21
grpo_qwen-0-5b_single_t4.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@willccbb
willccbb / grpo_demo.py
Last active October 25, 2025 16:39
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
"""
citation:
@misc{brown2025grpodemo,
title={Granular Format Rewards for Eliciting Mathematical Reasoning Capabilities in Small Language Models},
author={Brown, William},
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except:
from collections import defaultdict
import random
from huggingface_hub import hf_hub_download
from datasets import Dataset
import numpy as np
import pandas as pd
from transformers import AutoTokenizer
from rich.console import Console
from rich.table import Table
from trl import DPOTrainer
@Quentin-Anthony
Quentin-Anthony / transformer_mem.py
Last active June 20, 2025 13:09
Transformer Training/Inference Memory
import argparse
import math
# Helper function to pretty-print message sizes
def convert_params(params):
if params == 0:
return "0"
size_name = ("", "K", "M", "B", "T", "P", "E", "Z", "Y")
i = int(math.floor(math.log(params, 1000)))
p = math.pow(1000, i)
from torch.utils.data import DataLoader
import math
from sentence_transformers import models, losses
from sentence_transformers import SentencesDataset, LoggingHandler, SentenceTransformer, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator, SimilarityFunction
import logging
from datetime import datetime
import sys
import os
import gzip
@timelyportfolio
timelyportfolio / example.R
Created July 3, 2020 22:40
cell in rhansontable trigger modal with additional information
library(shiny)
library(htmltools)
library(rhandsontable)
library(dplyr)
rht <- rhandsontable(
head(mtcars) %>%
mutate(name = rownames(.)) %>%
select(name, everything()),
rowHeaders = NULL
@tylermorganwall
tylermorganwall / ortho_example.R
Created October 7, 2019 12:18
rayrender orthographic projection example
library(rayrender)
#Create base scene
basescene = xz_rect(x=555/2,y=0.1,z=555/2,555,555,
material = lambertian(color="#bababa", checkercolor = "grey10", checkerperiod = 100)) %>%
add_object(xz_rect(x=555/2,y=1000,z=555/2,343,332,
material = lambertian(color="white", lightintensity=40,implicit_sample = TRUE),
flipped=TRUE))
#Function for sphere bouncing