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

[SCRIPT] - Add static BERT base export script (for use with MXNet Module API) #672

Merged
merged 3 commits into from
May 7, 2019

Conversation

gigasquid
Copy link
Contributor

Description

This will export the base BERT model for use with the MXNet Module API.

It was adapted from the static_export_squad.py

Use cases can include fine tuning for Clojure and Scala APIs.

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

Comments

Python is not my usual language - so feedback is welcome :)

@gigasquid gigasquid requested a review from szha as a code owner April 20, 2019 23:31
@codecov
Copy link

codecov bot commented Apr 20, 2019

Codecov Report

Merging #672 into master will increase coverage by 0.1%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #672     +/-   ##
=========================================
+ Coverage   90.94%   91.04%   +0.1%     
=========================================
  Files          64       64             
  Lines        5887     5887             
=========================================
+ Hits         5354     5360      +6     
+ Misses        533      527      -6
Impacted Files Coverage Δ
src/gluonnlp/data/dataloader.py 88.79% <0%> (+5.17%) ⬆️

@gigasquid
Copy link
Contributor Author

Nice bot 🤖

@mli
Copy link
Member

mli commented Apr 21, 2019

Job PR-672/1 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/1/index.html

Copy link
Member

@szha szha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, @gigasquid (and glad to see you here!). Do you intend to use such model for feature extraction with mxnet module?

@gigasquid
Copy link
Contributor Author

@szha The intent is to use of BERT to more than just inference in the Clojure/Scala MXNet apis. Initially, I'm interested in the fine tuning tasks like classification, but feature extraction would be cool too. Basically everything in this http://jalammar.github.io/illustrated-bert/

Thanks so much for the static export feature! It opens up a whole new BERT world for the JVM MXNet langs 💯

@haven-jeon - Good point on the parameters. I'll double check to see if they are all used and remove the ones that are not.

@szha szha requested a review from haven-jeon April 23, 2019 18:57
@gigasquid
Copy link
Contributor Author

gigasquid commented Apr 25, 2019

I was able to put together a walkthrough Clojure jupyter notebook and then export it to markdown 😸
https://github.com/gigasquid/incubator-mxnet/blob/new-bert-example-with-finetuning/contrib/clojure-package/examples/bert/fine-tune-bert.md

The PR for MXNet is here apache/mxnet#14769

I'll plan on spending some time tomorrow to double check this script and the params.

@gigasquid
Copy link
Contributor Author

@haven-jeon - I cleaned up some unneeded args and checked the rest.
Tested with python static_export_base.py --seq_length 128

Please take another look when you have a chance.

@mli
Copy link
Member

mli commented Apr 30, 2019

Job PR-672/5 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/5/index.html

@szha
Copy link
Member

szha commented May 6, 2019

@gigasquid we recently upgraded the CI setup. It will work once you rebase the PR to latest master.

@gigasquid gigasquid force-pushed the static-export-bert-base branch 2 times, most recently from 48bdfc3 to 965e799 Compare May 6, 2019 17:10
@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/1 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/1/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/3 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/3/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/4 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/4/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/5 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/5/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/7 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/7/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/8 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/8/index.html

@mli
Copy link
Member

mli commented May 6, 2019

Job PR-672/10 is complete.
Docs are uploaded to http://gluon-nlp-staging.s3-accelerate.dualstack.amazonaws.com/PR-672/10/index.html

@gigasquid
Copy link
Contributor Author

tests & docs adds and CI is green 💚 - please take another look when you get a chance

Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@eric-haibin-lin eric-haibin-lin merged commit 5216840 into dmlc:master May 7, 2019
astonzhang pushed a commit that referenced this pull request May 10, 2019
…ule API) (#672)

* Add static BERT base export (for using with MXNet Module API)

add docs

add test

adjust params

* remove unused out variable

* add test and tweak doc
paperplanet pushed a commit to paperplanet/gluon-nlp that referenced this pull request Jun 9, 2019
…ule API) (dmlc#672)

* Add static BERT base export (for using with MXNet Module API)

add docs

add test

adjust params

* remove unused out variable

* add test and tweak doc
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants