Skip to content

Instantly share code, notes, and snippets.

Avatar
🤗
hacking 🎧 , UTC +2

Stefan Schweter stefan-it

🤗
hacking 🎧 , UTC +2
View GitHub Profile
View convert_roberta_original_pytorch_checkpoint_to_pytorch.py
# 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 Sep 19, 2019
Prediction script for PyTorch-Transformers NER
View ner_prediction.py
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 Jul 30, 2021
NER fine-tuning with PyTorch-Transformers (heavily based on https://github.com/kamalkraj/BERT-NER)
View run_ner.py
from __future__ import absolute_import, division, print_function
import argparse
import glob
import logging
import os
import random
import numpy as np
import torch