Skip to content

Instantly share code, notes, and snippets.

View CiaoHe's full-sized avatar
:octocat:
god bless us

He Cao CiaoHe

:octocat:
god bless us
View GitHub Profile
@CiaoHe
CiaoHe / r1-fs-trace.txt
Last active March 12, 2025 05:56
r1-fs
# right case
[27]
given: CC(=O)O.CC(C)=O.CCO.CCOC(=O)C(CCC=C(C)C)C(C)=O.[BH4-].[Na+]
pred: CCOC(=O)C(CCC=C(C)C)C(C)O
gt: CCOC(=O)C(CCC=C(C)C)C(C)O
acc: 1.0
<think>
Alright, let's tackle this problem. The user provided a list of reactants and reagents and wants a possible product's SMILES string. Let me see. The reactants are:
@CiaoHe
CiaoHe / min_p.py
Created December 12, 2024 12:59
min_p sampling
# this code snippet is taken from the Huggingface implementation of Min P
import inspect
import math
import warnings
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
import numpy as np
import torch
@CiaoHe
CiaoHe / s2.py
Created December 12, 2024 03:41
scaling_on_scales
"""
ref https://github.com/bfshi/scaling_on_scales/blob/master/s2wrapper/core.py
"""
import torch
import torch.nn.functional as F
import math
from einops import rearrange
from typing import Callable, List, Tuple, Union
@CiaoHe
CiaoHe / hf_mirror_download.sh
Created November 28, 2024 03:38
hf-mirror download
#!/bin/bash
# 从hf-mirror上下载model
user="Salesforce"
repo="blip2-opt-2.7b"
curl "https://hf-mirror.com/${user}/${repo}/tree/main" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep "^/${user}/${repo}/blob/main/" | sed "s|^|https://hf-mirror.com|; s|/blob/|/resolve/|g" > files.txt && wget -nc -i files.txt && rm files.txt
# 从hf-mirror上下载dataset
user="yuvalkirstain"
repo="pickapic_v1"
curl "https://hf-mirror.com/datasets/${user}/${repo}/tree/main/data" | grep -o 'href="[^"]*"' | cut -d'"' -f2 | grep "^/datasets/${user}/${repo}/blob/main/" | sed "s|^|https://hf-mirror.com|; s|/blob/|/resolve/|g" > files.txt && wget -nc -i files.txt && rm files.txt
@CiaoHe
CiaoHe / DiT_variants.py
Last active March 25, 2024 10:33
DiT variants
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# --------------------------------------------------------
# References:
# GLIDE: https://github.com/openai/glide-text2im
# MAE: https://github.com/facebookresearch/mae/blob/main/models_mae.py
# --------------------------------------------------------
@CiaoHe
CiaoHe / pub_your_project.md
Created November 27, 2023 08:38
Publish Your Project

Clean project codes

  • export project-dependent pip requirement.txt
    • pip install pipreqs then pipreqs path/to/project
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@CiaoHe
CiaoHe / llm_foundation_knowledge.md
Created October 14, 2023 01:48
LLM Foundation Knowledge
@CiaoHe
CiaoHe / transformers_benchmark.py
Created August 7, 2023 15:26
transformers_benchmark from limu
import torch
import contextlib
print('Pytorch version\t:', torch.__version__)
print('CUDA version\t:', torch.version.cuda)
for i in range(torch.cuda.device_count()):
print(f'GPU{i}\t\t:',torch.cuda.get_device_name(i))
import os
import re
@CiaoHe
CiaoHe / Print_Model_Structure_from_ckpt.py
Last active September 20, 2023 07:08
Print Model Structure from `ckpt`
"""
Simply use peek_model_from_ckpt(CKPT_PATH)
"""
import torch
from typing import Dict
class TrieNode:
def __init__(self):
self.is_end = False
self.children = {}