Skip to content

Instantly share code, notes, and snippets.

View KOPFYF's full-sized avatar
👽
Focusing

Yifan Fei KOPFYF

👽
Focusing
View GitHub Profile
@lan2720
lan2720 / allennlp_srl.py
Last active June 5, 2021 14:02
Demo for using AllenNLP Semantic Role Labeling (http://allennlp.org/)
"""
Usage:
python allennlp_srl.py \
https://s3-us-west-2.amazonaws.com/allennlp/models/srl-model-2017.09.05.tar.gz \
examples.json
Note:
each line in examples.json is one sentence, such as:
Which NFL team represented the AFC at Super Bowl 50?
Where did Super Bowl 50 take place?
@Tushar-N
Tushar-N / pad_packed_demo.py
Last active October 27, 2024 15:17
How to use pad_packed_sequence in pytorch<1.1.0
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model