
NLP
yuhengshi
这个作者很懒,什么都没留下…
展开
-
文本数据增强(data augmentation)nlpaug使用
环境python==3.7nlpaug==1.1.7文档https://nlpaug.readthedocs.io/en/latest/overview/overview.htmlhttps://github.com/makcedward/nlpaug安装pip install numpy requests nlpaug数据增强主要方式https://zhuanlan.zhihu.com/p/150600950nlpaug简单介绍Support textual and a原创 2022-04-21 17:35:48 · 2259 阅读 · 0 评论 -
RNN维度
Pytorch RNN参数import torchfrom torch import nnrnn = nn.RNN(input_size=4, hidden_size=5, num_layers=2, batch_first=True, bidirectional=True)input_size (输入维度)hidden_size (hidden state h)num_layers (RNN堆叠层数)nonlinearity (non-linearity 默认tanh)bia原创 2022-01-13 15:01:56 · 470 阅读 · 0 评论 -
去除字符串中的符号
import stringclass Preprocessor: def __init__(self): pass @staticmethod def remove_punctuation(content: str, remove_blank=True, lower=True): """ 把文本里的符号去除 以及空格 :param content: :param remove_blank: defa原创 2022-01-10 15:15:34 · 870 阅读 · 0 评论 -
基于预训练模型Bart的英文文本摘要summary生成
环境python==3.7transformers==4.9.2rouge-score==0.0.4数据准备将数据放在一个txt中,每行为一条,文章正文跟label的摘要用\t分割构建数据集from datasets import Datasetclass Data: def __init__(self, data_path, tokenizer): self.path = data_path self.max_input_length =原创 2021-10-26 14:23:05 · 3483 阅读 · 4 评论 -
文本分类pytorch Bert fine tune
基于Bert预训练模型的文本分类fine tune环境python==3.7torch==1.7.1transformers==4.9.2scikit-learn==0.21.3pandasnumpy构建数据集将数据放到如下图格式的dataframe中,label对应的数字为每种类别的下标。random seed设置import torchimport numpy as nprandom_seed = 2018np.random.seed(random_seed)t原创 2021-09-15 10:49:14 · 821 阅读 · 3 评论 -
文本数据增强(data augmentation)textattack使用
环境python==3.7textattack==0.3.3数据增强主要方式https://zhuanlan.zhihu.com/p/150600950textattack文档https://textattack.readthedocs.io/en/latest/apidoc/textattack.transformations.word_swaps.html#word-swaptextattack使用import nltkfrom textattack.transformations原创 2021-08-25 13:48:07 · 1947 阅读 · 4 评论