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:
# 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 |
""" | |
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: |
I hereby claim:
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
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) |
Shortlink: goo.gl/wSuuS9
The github repository will soon be available at github.com/tensorflow/tensor2tensor/tree/master/tensor2tensor/data_generators/wikisum
import torch, torch.nn as nn | |
from torch.autograd import Variable | |
text = ['BOS', 'How', 'are', 'you', 'EOS'] | |
seq_len = len(text) | |
batch_size = 1 | |
embedding_size = 1 | |
hidden_size = 1 | |
output_size = 1 |