Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

How to apply BERT to a custom classification model? #6

Closed
Scarlettg opened this issue Dec 6, 2018 · 1 comment
Closed

How to apply BERT to a custom classification model? #6

Scarlettg opened this issue Dec 6, 2018 · 1 comment

Comments

@Scarlettg
Copy link

Let's say I'm trying to load a pretrained BERT model from a checkpoint, add layers after it and build the model with Model.compile():

What does the input have to look like if BERT is the first "layer"? Would be nice to have a simple example.

@CyberZHG
Copy link
Owner

CyberZHG commented Dec 6, 2018

See extract demo.

There are two inputs with shape (batch_size, 512). For token input you should load vocab.txt just like the demo, then map words to indices. The segment input is a zero array if you don't need to compare two parts of the text input.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants