Skip to content

Instantly share code, notes, and snippets.

View tokestermw's full-sized avatar

Motoki Wu tokestermw

View GitHub Profile
@tokestermw
tokestermw / claude-code-prompt.txt
Created August 20, 2025 15:15 — forked from agokrani/claude-code-prompt.txt
Claude Code System Prompt
'system':
[
{
'type': 'text',
'text': "You are Claude Code, Anthropic's official CLI for Claude.",
'cache_control': {'type': 'ephemeral'}
},
{
'type': 'text',
'text': 'You are an interactive CLI tool that helps users with software engineering tasks.
@tokestermw
tokestermw / grpo_demo.py
Created February 21, 2025 19:43 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
import torch
import torch.nn as nn
import torch.nn.functional as F
# helpers
def make_unit_length(x, epsilon=1e-6):
norm = x.norm(p=2, dim=-1, keepdim=True)
return x.div(norm + epsilon)
import random
def augmentation_fun(x, augment_by=3):
# augment the original data point by 3
return [x + random.random() * 2 - 1 for i in range(augment_by)]
def train_loop(dataset, do_augment=False):
# emit one data point at a time
@tokestermw
tokestermw / play_elmo_embeddings_softmax.py
Last active September 6, 2018 21:27
Test code of `_ElmoSoftmax`.
"""
To use it inside ELMo script
To get the embeddings:
allennlp elmo sample_sents.txt out1.hdf5 --top
python -c "import h5py; f = h5py.File('out1.hdf5'); print(f['0'][:], f['0'].shape)"
To get probabilities:

Keybase proof

I hereby claim:

  • I am tokestermw on github.
  • I am motoki (https://keybase.io/motoki) on keybase.
  • I have a public key whose fingerprint is 26C6 F8AB C16D 50E4 3A97 05C2 B235 7159 51D6 074D

To claim this, I am signing this object:

Where A is a class (e.g. definite article), and B is another class (e.g. indefinite article). O is the null class.

The cat had a dog .
 A   O   O  B  O  O

v1

| Real | Predicted | Verdict

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tokestermw
tokestermw / tf_percent_confusion_metric.py
Created May 2, 2018 21:15
Calculate a percentage from the confusion matrix in TensorFlow.
import tensorflow as tf
from tensorflow.python.ops.metrics_impl import _streaming_confusion_matrix
# almost the same as
def confusion_matrix(labels, predictions, num_classes, weights=None):
total_cm, update_op = _streaming_confusion_matrix(
labels, predictions, num_classes, weights=weights)