This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
wget https://s3.amazonaws.com/conceptnet/downloads/2017/edges/conceptnet-assertions-5.5.5.csv.gz | |
gunzip -k conceptnet-assertions-5.5.5.csv.gz | |
``` | |
import json | |
def del_pos(s): | |
""" | |
Deletes part-of-speech encoding from an entity string, if present. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import OpenAIGPTTokenizer, OpenAIGPTLMHeadModel | |
from transformers import GPT2Tokenizer, GPT2LMHeadModel | |
import numpy as np | |
from scipy.special import softmax | |
def model_init(model_string, cuda): | |
if model_string.startswith("gpt2"): | |
tokenizer = GPT2Tokenizer.from_pretrained(model_string) | |
model = GPT2LMHeadModel.from_pretrained(model_string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import BertTokenizer, BertModel, BertForMaskedLM | |
import logging | |
logging.basicConfig(level=logging.INFO)# OPTIONAL | |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') | |
model = BertForMaskedLM.from_pretrained('bert-base-uncased') | |
model.eval() |
NewerOlder