Skip to content

Instantly share code, notes, and snippets.

View stefan-it's full-sized avatar
🤓
hacking 🎧

Stefan Schweter stefan-it

🤓
hacking 🎧
View GitHub Profile
@stefan-it
stefan-it / tpu_vm_cheatsheet.md
Last active April 9, 2023 21:05
TPU VM Cheatsheet

TPU VM Cheetsheat

This TPU VM cheatsheet uses and was tested with the following library versions:

Library Version
JAX 0.3.25
FLAX 0.6.4
Datasets 2.10.1
Transformers 4.27.1
# coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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
@stefan-it
stefan-it / ner_prediction.py
Created September 19, 2019 10:19
Prediction script for PyTorch-Transformers NER
import click
import numpy as np
import torch
from collections import namedtuple
from pytorch_transformers import BertForTokenClassification, BertTokenizer
from torch.nn import CrossEntropyLoss
from torch.utils.data import DataLoader, SequentialSampler, TensorDataset
@stefan-it
stefan-it / run_ner.py
Last active April 2, 2022 13:28
NER fine-tuning with PyTorch-Transformers (heavily based on https://github.com/kamalkraj/BERT-NER)
from __future__ import absolute_import, division, print_function
import argparse
import glob
import logging
import os
import random
import numpy as np
import torch