Skip to content

Instantly share code, notes, and snippets.

View andreasgrv's full-sized avatar

Andreas Grivas andreasgrv

View GitHub Profile
@JohnGiorgi
JohnGiorgi / biaffine_classifier.py
Last active November 2, 2023 04:58
PyTorch implementation of the biaffine attention operator from "End-to-end neural relation extraction using deep biaffine attention" (https://arxiv.org/abs/1812.11275) which can be used as a classifier for binary relation classification. If you spot an error or have an improvement, let me know!
import torch
class BiaffineAttention(torch.nn.Module):
"""Implements a biaffine attention operator for binary relation classification.
PyTorch implementation of the biaffine attention operator from "End-to-end neural relation
extraction using deep biaffine attention" (https://arxiv.org/abs/1812.11275) which can be used
as a classifier for binary relation classification.