GithubHelp home page GithubHelp logo

wzzzd / pretrain_bert_with_masklm Goto Github PK

View Code? Open in Web Editor NEW
40.0 40.0 10.0 7.38 MB

使用Mask LM预训练任务来预训练Bert模型。训练垂直领域语料的模型表征,提升下游任务的表现。

Python 100.00%

pretrain_bert_with_masklm's Introduction

Nice to meet U 👋

tree's GitHub stats

pretrain_bert_with_masklm's People

Contributors

wzzzd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pretrain_bert_with_masklm's Issues

请教多卡训练问题

您好,我想使用单机多卡训练,但是多卡不生效,只有1张卡会被使用,配置如下

        self.mode = 'train'  
        self.cuda_visible_devices = '0,1,2,3'                           # 可见的GPU   
        self.device = 'cuda'                                      # 这里改成cuda:0 也是同样不生效   
        self.port = str(random.randint(10000,60000))                # 多卡训练进程间通讯端口   
        self.init_method = 'tcp://localhost:' + self.port           # 多卡训练的通讯地址   
        self.world_size = 1                                         # 线程数,默认为1   

执行命令:python main.py
请教一下,是哪里配置的不对吗?

请教个人数据集预训练的问题

请教一下,如果要使用个人搜集的中文数据集进行wwm预训练,

  1. 是否要预先进行分词后再进行存储?
  2. 如果数据集中某一行的文本过长,需要分成好几行送入模型吗?例如,文本过长的话,是否要根据句子标识符,或者根据max_length分成若干行?

请教wwm的分词问题

最近我在做一个垂直域预训练的技术储备,看了你DataManager里面的代码,但是没有能够理解wwm的实现方法,比如如何分词确定词语的边界。我以为是先使用分词器做的分词然后做的Masking操作。

我之前有了解过pkuseg分词器:https://github.com/lancopku/pkuseg-python

它不光可以确定词边界而且还能给出每个词的词性,感觉做masking的时候如果可以更大概率的去Mask实词,少一些放在虚词上应该效果会更好,欢迎探讨。wechat:yiyaoh

金标准有问题

datasets里面train.txt和test.txt里面的文本有UNK标识,导致训练的时候金标准和训练样本一致,结果就是最后训练出来的模型我用来预测[MASK]的时候发现,出来的都是[MASK]。。

断点打在train.py第70行位置,watch一下list(zip(batch['input_ids'][0].tolist(), batch['labels'][0].tolist())),会发现input_ids和labels是一模一样的。

请教词嵌入

您好,最近正在学习词嵌入,看到您的代码,我想请问一下可以预训练自己的语料来做词嵌入吗?我的想法是,用maskLM来训练自己的语料,然后得到的model.bin再用transformer的AutoModel.from_pretrained调用得到词嵌入。请问是这种操作方式吗?这样得到的效果会比原本的bert直接得到的词嵌入效果更好吗?

关于制作预训练数据的时间优化

制作bert预训练数据集DataManager的op_mask_wwm和op_mask那里,其实可以使用numpy取一个值域在[0,1]上的维度保持一样的array,然后用numpy来操作,应该会快得多,数据量太大会消耗很多时间。比如可以使用这种写法:
random_tensor = torch.rand(inputs['input_ids'].shape)
masked_tensor = (random_tensor < 0.15)(inputs['input_ids'] != 101)(inputs['input_ids'] != 102)*(inputs['input_ids'] != 0)

测试准确率

你好,我请问下我在测试的时候发现准确率好低啊,我在一个G的语料上训练,训练结果我看是已经收敛了,但是测试准确率只有48%

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.