[英]How to run inference using pre-trained Tensorflow model from their Github and CheckPoint file
I would like to collect text embeddings from the model in this github 我想从这个github中的模型中收集文本嵌入
https://github.com/dmis-lab/biobert https://github.com/dmis-lab/biobert
Under installation, all it says is 在安装下,它说的都是
To use BioBERT, we need pre-trained weights of BioBERT, which you can download from Naver GitHub repository for BioBERT pre-trained weights. 要使用BioBERT,我们需要预先培训的BioBERT重量,您可以从Naver GitHub存储库下载BioBERT预训练重量。 Make sure to specify the versions of pre-trained weights used in your works. 确保指定您作品中使用的预训练重量的版本。 Also, note that this repository is based on the BERT repository by Google. 另请注意,此存储库基于Google的BERT存储库。
All the fine-tuning experiments were conducted on a single TITAN Xp GPU machine which has 12GB of RAM. 所有的微调实验都是在一台拥有12GB内存的TITAN Xp GPU机器上进行的。 The code was tested with Python2 and Python3 (We used Python2 for experiments). 代码用Python2和Python3测试(我们使用Python2进行实验)。 You might want to install java to use official evaluation script of BioASQ. 您可能希望安装java以使用BioASQ的官方评估脚本。 See requirements.txt for other details. 有关其他详细信息,请参阅requirements.txt。
I can download their checkpoint file and load it using something like 我可以下载他们的检查点文件并使用类似的东西加载它
with tf.Session(graph=graph) as session:
saver.restore(session, 'BioBert.ckpt' )
And install their github using something like 并使用类似的东西安装他们的github
!test -d bioBert_repo|| git clone https://github.com/dmis-lab/biobert bioBert_repo
But how do I get the embedding from a text input. 但是如何从文本输入中获取嵌入。 The instructions say it's based on BERT, but for BERT all we have to do is import the tf.hub model 说明说它基于BERT,但是对于BERT,我们所要做的就是导入tf.hub模型
bert_module = hub.Module(
"https://tfhub.dev/google/bert_uncased_L-12_H-768_A-12/1",
trainable=False)
then put the tokenized sentence into that 然后将标记化的句子放入其中
bert_embedding= bert_module(inputs=tokenized_sentence, signature="tokens", as_dict=True)[
"pooled_output"
]
I'm guessing there's a similar method where I can install the github and load the weights but I can't seem to find it. 我猜有一个类似的方法,我可以安装github并加载权重,但我似乎无法找到它。
You should see example from extract_features.py. 您应该看一下extract_features.py中的示例。 I suppose that BIOBert don't use tf.hub. 我想BIOBert不使用tf.hub。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.