Skip to content

Instantly share code, notes, and snippets.

View zhang-ning's full-sized avatar

zhang-ning zhang-ning

View GitHub Profile
@zhang-ning
zhang-ning / beam_search.py
Created June 18, 2025 09:04 — forked from fzyzcjy/beam_search.py
Speed up HuggingFace beam search by 10x
import warnings
from collections import UserDict, defaultdict
from typing import Optional, Tuple, Any
import torch
from transformers import BeamScorer, BeamSearchScorer
from transformers.generation import BeamHypotheses
from ...utils.torch_utils import first_several_nonzero_indices
@zhang-ning
zhang-ning / agent loop
Created May 10, 2025 15:51 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
@zhang-ning
zhang-ning / grpo_demo.py
Created February 8, 2025 16:55 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
# Load and prep dataset
@zhang-ning
zhang-ning / git-json.sh
Created September 17, 2024 02:22 — forked from overengineer/git-json.sh
git log json format
#!/usr/bin/env bash
# Caution: It can break
# Bash unofficial strict mode
set -euo pipefail
IFS=$'\n\t'
LANG=''
function define() { IFS='\n' read -r -d '' ${1} || true; }
" Plugin 'dracula/vim'
" for indent
set autoindent
" tab and space
set smarttab
set tabstop=4
set shiftwidth=4
set expandtab
" fold
Plugin 'dracula/vim'
" for indent
set autoindent
" tab and space
set smarttab
set tabstop=4
set shiftwidth=4
set expandtab
" fold
@zhang-ning
zhang-ning / tmux-cheatsheet.markdown
Created February 5, 2017 06:30 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
This file has been truncated, but you can view the full file.
package {
public class InstanceFactory {
private static var _photoEditor:IPhotoEditor;
private static var _mainApplication:IMainApplication;
public static function get photoEditor():IPhotoEditor{
return (_photoEditor);
}
@zhang-ning
zhang-ning / form.js
Created August 7, 2016 11:12
sending form to hiiden iframe
//copyed from https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_forms_through_JavaScript
// Let's create the iFrame used to send our data
var iframe = document.createElement("iframe");
iframe.name = "myTarget";
// Next, attach the iFrame to the main document
window.addEventListener("load", function () {
iframe.style.display = "none";
document.body.appendChild(iframe);
});
@zhang-ning
zhang-ning / xss.js
Created August 2, 2016 07:40 — forked from daogurtsov/xss.js
xss escaping and parsing html entities
var entityMap = {
"&": "&",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
};
var htmlMap = {