Code Monkey home page Code Monkey logo

tensorflow-syntaxnet's Introduction

Tensorflow SyntaxNet/DRAGNN

Pulls Stars

docker pull nardeas/tensorflow-syntaxnet

Minimal Docker image based on Alpine with Tensorflow and SyntaxNet/DRAGNN support.

This is a production ready base image for your ML needs. Build your TF apps on top of this lean image to get the most out of your precious disk space.

Build typically takes 1-1.5 hours on a 2017 MacBook Pro.

Compressed size: ~190MB
Tensorflow version: 1.3.0-rc2
Python version: 2.7.14

Note that the Tensorflow version depends on what is supported by SyntaxNet. Building a working SN installation requires some additional operations not supported by TF as is.

This version uses the latest DRAGNN mode, which is much faster than the original SyntaxNet implementation!

hub.docker.com

You can pull the image from DockerHub via

docker pull nardeas/tensorflow-syntaxnet:latest

How to actually use

You can create your own image for your TF application by using this as base image.

Included is an easy to use DRAGNN wrapper that works with the pre-trained CoNLL17 models. Here is a reference how you can download the models.

You can obviously train your own models as well. Please note that this version doesn't include GPU support.

Wrapper

The included DRAGNN wrapper is built into /usr/lib/python2.7/site-packages/dragnn/wrapper so you can simply do:

from dragnn.wrapper import SyntaxNet
sn = SyntaxNet(lang="English", model_dir="/path/to/model/dir", logging=False)
sn.parse("This is an example")

It will output a dict:

{
  "input": "This is an example",
  "output": [
    {
      "break_level": 0,
      "category": "",
      "dep": "nsubj",
      "fpos": "PRON++DT",
      "head": 3,
      "label": "nsubj",
      "number": "Sing",
      "pos_tag": "DT",
      "prontype": "Dem",
      "word": "This"
    },
    {
      ...

Note that lang is the subfolder name in model_dir which should contain the language specific segmenter and parser models. The default directory to search for models is /usr/local/tfmodels/. If you have downloaded and extracted the conll17.zip via the instructions above, you can launch the container like this:

# Mount the extracted models dir on host machine as volume in container

docker run -it -v <path/to/extracted/zip>:/usr/local/tfmodels/ nardeas/tensorflow-syntaxnet

and the above example should work out of the box. Only provide lang parameter to constructor (default "English").

Notes

This image contains a full Tensorflow installation. Any readily available pre-trained models are excluded from this image to keep it as lean as possible. Having SyntaxNet support doesn't produce much overhead so this image is well suited for use with any other TF applications as well.

Also note that this version doesn't include Bazel ops from the original SN. In other words you won't use stuff like bazel-bin/syntaxnet/parser_eval - you should use DRAGNN parser instead. The easiest way to get up and running fast is using the included DRAGNN wrapper.

tensorflow-syntaxnet's People

Watchers

 avatar  avatar

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.