我使用下面的代码为我的文本分类生成嵌入。
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
bert_preprocess =hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3")
bert_encoder = hub.KerasLayer("https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-1
我正在读BERT模型论文。在预训练BERT模型的掩蔽语言模型任务中,本文表示模型将随机选择15%的令牌。在选择的标记( Ti )中,80%将被替换为掩码标记,10%的Ti保持不变,10%的Ti将替换为另一个单词。我认为模型只需要替换为掩码或其他单词就足够了。为什么模型必须随机选择一个单词并保持不变?预训练过程是只预测掩码令牌,还是预测15%的整个随机令牌?
我是rasa的新手,开始创建一个非常特定于领域的聊天机器人。作为其中的一部分,我理解更好地使用监督嵌入作为nlu管道的一部分,因为我的用例是特定于领域的。
我的nlu.md中有一个示例意图
## create_system_and_config
- create a [VM](system) of [12 GB](config)
如果我尝试使用监督特征器,它可能可以很好地与我的领域特定实体一起工作,但我在这里担心的是,如果只使用监督学习,我们不会失去预训练模型的优势吗?例如,在诸如add a (some_system) of (some_config)之类的查询中。add和create是紧密
我有一个推文语料库,我正在尝试使用BERT进行分类。我已经使用我的语料库成功地预先训练了BERT,并且它已经生成了检查点文件。现在我需要使用这个新的训练模型,并向其添加更多的层。我尝试使用keras_bert中的"load_trained_model_from_checkpoint“函数,但它失败了,并出现错误"cls/predictions/transform/dense/kernel not found in checkpoint”。有没有人能帮我修复这个bug。谢谢
我下载了基于bert的预训练模型。我编辑config.json (从512到256) "max_position_embeddings": 256, 然后我想使用bert模型, from transformers import BertForSequenceClassification
model = BertForSequenceClassification.from_pretrained(
MODEL_PATH,
num_labels = 2, # The number of output labels--2 for binary classifica