GithubHelp home page GithubHelp logo

gabeorlanski / allennlp-hydra Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 727 KB

Plugin For AllenNLP that enables the use of hydra configs.

License: Apache License 2.0

Python 95.76% Makefile 2.52% Jsonnet 1.72%

allennlp-hydra's Introduction

AllenNLP-Hydra

Documentation

Plugin For AllenNLP that enables composing configs through the use of the Hydra Library from Facebook Research.

NOTE there is no affiliation between this project and AllenNLP or the Allen Institute for AI.

We use the same contributions guideline as AllenNLP in order to maintain similar code styles. For this reason our style guide is the same as that found in their repository.

Install Instructions

pip install allennlp-hydra
echo allennlp_hydra >> ~.allennlp_plugins

The second line adds allennlp-hydra to the allennlp plugins file so that it can globally be recognized.

Basic Guide

Say you have the following directory structure:

project
+-- conf
|   +-- dataset_readers
|   |   +-- A.yaml
|   |   +-- B.yaml
|   +-- models
|   |   +-- C.yaml
|   |   +-- D.yaml
|   +-- config.yaml
+-- experiments

conf/dataset_readers/A.yaml:

type: A
start_token: <s>
end_token: </s>

conf/dataset_readers/B.yaml:

type: B
start_token: [CLS]
end_token: [SEP]

conf/models/C.yaml:

type: C
layers: 5

conf/models/D.yaml:

type: D
input_dim: 10

config.yaml

defaults:
    - dataset_reader: A
    - model: C

debug: false

Then running the command

allennlp compose conf config example -s experiments

Produces the file project/experiments/config.json

{
    "dataset_reader":{
        "type": "A",
        "start_token": "<s>",
        "end_token": "</s>"
    },
    "model": {
        "type": "C",
        "layers": 5
    },
    "debug": false
}

If you want to override the config and use the B dataset reader with the D model, you would modify the previous command:

allennlp compose conf config example -s experiments -o model=D dataset_reader=B

Produces the file project/experiments/config.json

{
    "dataset_reader":{
        "type": "B",
        "start_token": "[CLS]",
        "end_token": "[SEP]"
    },
    "model": {
        "type": "D",
        "input_dim": 10
    },
    "debug": false
}

And if you wanted to change input_dim of model D to 25:

allennlp compose conf config example -s experiments -o model=D dataset_reader=B model.input_dim=25

Produces the file project/experiments/config.json

{
    "dataset_reader":{
        "type": "B",
        "start_token": "[CLS]",
        "end_token": "[SEP]"
    },
    "model": {
        "type": "D",
        "input_dim": 25
    },
    "debug": false
}

allennlp-hydra's People

Contributors

gabeorlanski avatar

Stargazers

 avatar  avatar  avatar

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.