【发布时间】:2019-11-05 14:29:37
【问题描述】:
我正在研究一组社交媒体 cmets(包括 youtube 链接)作为输入特征,并将 Myers-Biggs 人格档案作为目标标签:
type posts
0 INFJ 'http://www.youtube.com/watch?v=qsXHcwe3krw|||...
1 ENTP 'I'm finding the lack of me in these posts ver...
2 INTP 'Good one _____ https://www.youtube.com/wat...
3 INTJ 'Dear INTP, I enjoyed our conversation the o...
4 ENTJ 'You're fired.|||That's another silly misconce...
但据我发现,BERT 希望 DataFrame 采用这种格式:
a label posts
0 a 8 'http://www.youtube.com/watch?v=qsXHcwe3krw|||...
1 a 3 'I'm finding the lack of me in these posts ver...
2 a 11 'Good one _____ https://www.youtube.com/wat...
3 a 10 'Dear INTP, I enjoyed our conversation the o...
4 a 2 'You're fired.|||That's another silly misconce...
生成的输出必须是对分成四列的 cmets 测试集的预测,每个列对应一个 Personality Profile,例如,'Mind' = 1 是 Extrovert 的标签。基本上将像INFJ这样的类型分为'Mind','Energy','Nature','Tactics',就像这样:
type post Mind Energy Nature Tactics
0 INFJ 'url-web 0 1 0 1
1 INFJ url-web 0 1 0 1
2 INFJ enfp and intj moments url-web sportscenter n... 0 1 0 1
3 INFJ What has been the most life-changing experienc... 0 1 0 1
4 INFJ url-web url-web On repeat for most of today. 0 1 0 1
我已经安装了 pytorch-pretrained-bert 使用:
!pip install pytorch-pretrained-bert
我已导入模型并尝试使用以下方法标记“帖子”列:
import torch
from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
tokenized_train = tokenizer.tokenize(train)
但收到此错误:
TypeError: ord() expected a character, but string of length 5 found
我根据 pytorch-pretrained-bert GitHub Repo 和 Youtube 视频尝试了这个。
我是一名数据科学实习生,完全没有深度学习经验。我只是想以最简单的方式来试验 BERT 模型来预测多类分类输出,这样我就可以将结果与我们目前正在研究的更简单的文本分类模型进行比较。我在 Google Colab 工作,结果输出应该是 .csv 文件。
我知道这是一个复杂的模型,并且围绕模型的所有文档和示例都很复杂(微调层等),但对于初学者数据科学家的简单实现(如果实际上有这样的事情)有任何帮助具有最少的软件工程经验,将不胜感激。
【问题讨论】:
标签: python pytorch data-science google-colaboratory bert-language-model