Giter Site home page Giter Site logo

delmaksym / allennlp-light Goto Github PK

View Code? Open in Web Editor NEW
52.0 4.0 3.0 161 KB

allennlp-light is a port of AllenNLP's core modules and nn portions into a standalone package with minimum dependencies

License: Apache License 2.0

Makefile 0.07% Python 99.82% Shell 0.12%

allennlp-light's Introduction

allennlp-light

About

As AllenNLP framework honorably retires and will not update dependencies, allennlp-light is a port of AllenNLP's core modules and nn portions into a standalone package with minimum dependencies.
allennlp-light natively integrates with Tango (check it out!) by using its FromParams/Registrable so you get allennlp's components registered and ready to use.

The modules are thoroughly documented and tested in the original AllenNLP repository.

To learn how to use them, check the relevant section in the AllenNLP guide.

AllenNLP is licensed under Apache 2 Licence, so please see below the copyright notice and the list of changes.

Installation

  1. Install PyTorch: pytorch.org
  2. pip install allennlp-light

Example

>>> from allennlp_light import Seq2SeqEncoder
>>> Seq2SeqEncoder.list_available()
['compose', 'feedforward', 'gated-cnn-encoder', 'pass_through', 'gru', 'lstm', 'rnn', 'augmented_lstm', 'alternating_lstm', 'stacked_bidirectional_lstm', 'pytorch_transformer']

Copyright

Below is the copyright notice that applies to all source codes.

Copyright 2017 The Allen Institute for Artificial Intelligence
Adapted by Maksym Del from https://github.com/allenai/allennlp/tree/8571d930fe6dc6291c6351c6e599576b007cf22f
SPDX-License-Identifier: Apache-2.0

List of changes

To make sure users know exactly what they are using, I kept the log of how I got from allennlp to allennlp-light.

Copied with changes from 
   
    https://github.com/allenai/allennlp/tree/8571d930fe6dc6291c6351c6e599576b007cf22f

Only codes from allennlp/modules and allennlp/nn folders are copied.

The purpose is to integrate AllenNLP modules with the Tango project (https://github.com/allenai/tango).

The following is the list of the changes made to the AllenNLP original (allennlp/modules and allennlp/nn) files:

Removed files and folders:
- allennlp/modules/transformer
- allennlp/modules/token_embedders
- allennlp/modules/text_field_embedders
- allennlp/modules/backbones
- allennlp/modules/elmo.py
- allennlp/modules/elmo_lstm.py
- allennlp/nn/parallel
- allennlp/nn/checkpoint
- allennlp/nn/beam_search.py
- allennlp/nn/module.py

Removed from the nn/util.py file:
- line: from itertools import chain
- line: import torch.distributed as dist
- line: from allennlp.common.util import int_to_device, is_distributed, is_global_primary
- func: find_text_field_embedder
- func: find_embedding_layer
- func: move_to_device
- func: distributed_device
- line: _V = TypeVar("_V", int, float, torch.Tensor)
- func: dist_reduce
- func: dist_reduce_sum
- func: _collect_state_dict
- func: load_state_dict_distributed
- func: _broadcast_params
- class: _IncompatibleKeys
- func: _check_incompatible_keys 

Removed from the nn/__init__.py file:
- line: from allennlp.nn.module import Module

Removed/added from/to the modules/__init__.py file:
- line: from allennlp.modules.backbones import Backbone
- line: from allennlp.modules.elmo import Elmo
- line: from allennlp.modules.text_field_embedders import TextFieldEmbedder
- line: from allennlp.modules.token_embedders import TokenEmbedder, Embedding
+ line: from allennlp.modules.span_extractors import SpanExtractor

Removed/added from/to the modules/span_extractors/span_extractor_with_span_width_embedding.py file:
- from allennlp.modules.token_embedders.embedding import Embedding
+ from torch.nn import Embedding

Removed from /nn/initializers.py file:
- class: PretrainedModelInitializer

Renamed across all files and folders:
* from allennlp.common.checks import ConfigurationError -> from tango.common.exceptions import ConfigurationError 
* from allennlp.common -> from tango.common // this line redirects imports of Registrable and FromParams classes to Tango versions
* allennlp -> allennlp-light

allennlp-light's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

allennlp-light's Issues

Add allowed_transitions in allennlp_light.modules.conditional_random_field.__init__.py

I am working a class that inherits ConditionalRandomField class from allennlp_light.modules.conditional_random_field.

I think it would be more flexible if the allowed_transitions function is allowed to be imported like from allennlp_light.modules.conditional_random_field import allowed_transitions.

I did go through the original https://github.com/allenai/allennlp, they already did it.

allenai/allennlp#5695
allenai/allennlp#5697
allenai/allennlp#5706

Although this will be a small patch, I think there will be many parts we still can update and improve from time to time.

If you agree to update, I can PR this small change.

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.