================= pytorch-fast-elmo =================
.. image:: https://img.shields.io/pypi/v/pytorch_fast_elmo.svg :target: https://pypi.python.org/pypi/pytorch_fast_elmo
.. image:: https://img.shields.io/travis/cnt-dev/pytorch-fast-elmo.svg :target: https://travis-ci.org/cnt-dev/pytorch-fast-elmo
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg :target: https://travis-ci.org/cnt-dev/pytorch-fast-elmo
A fast ELMo implementation with features:
Hardware:
Options:
+--------------------------------------+------------------------+------------------------+ | Item | Mean Of Durations (ms) | cumtime(synchronize)% | +======================================+========================+========================+ | Fast ELMo (CUDA, no synchronize) | 31 | N/A | +--------------------------------------+------------------------+------------------------+ | AllenNLP ELMo (CUDA, no synchronize) | 56 | N/A | +--------------------------------------+------------------------+------------------------+ | Fast ELMo (CUDA, synchronize) | 47 | 26.13% | +--------------------------------------+------------------------+------------------------+ | AllenNLP ELMo (CUDA, synchronize) | 57 | 0.02% | +--------------------------------------+------------------------+------------------------+ | Fast ELMo (CPU) | 1277 | N/A | +--------------------------------------+------------------------+------------------------+ | AllenNLP ELMo (CPU) | 1453 | N/A | +--------------------------------------+------------------------+------------------------+
Please install torch==1.0.0 first. Then, simply run this command to install.
.. code-block:: bash
pip install pytorch-fast-elmo
FastElmo
should have the same behavior as AllenNLP's ELMo
.
.. code-block:: python
from pytorch_fast_elmo import FastElmo, batch_to_char_ids
options_file = '/path/to/elmo_2x4096_512_2048cnn_2xhighway_options.json'
weight_file = '/path/to/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5'
elmo = FastElmo(options_file, weight_file)
sentences = [['First', 'sentence', '.'], ['Another', '.']]
character_ids = batch_to_ids(sentences)
embeddings = elmo(character_ids)
Use FastElmoWordEmbedding
if you have disabled char_cnn
in bilm-tf
, or have exported the Char CNN representation to a weight file.
.. code-block:: python
from pytorch_fast_elmo import FastElmoWordEmbedding, load_and_build_vocab2id, batch_to_word_ids
options_file = '/path/to/elmo_2x4096_512_2048cnn_2xhighway_options.json'
weight_file = '/path/to/elmo_2x4096_512_2048cnn_2xhighway_weights.hdf5'
vocab_file = '/path/to/vocab.txt'
embedding_file = '/path/to/cached_elmo_embedding.hdf5'
elmo = FastElmoWordEmbedding(
options_file,
weight_file,
# Could be omitted if the embedding weight is in `weight_file`.
word_embedding_weight_file=embedding_file,
)
vocab2id = load_and_build_vocab2id(vocab_file)
sentences = [['First', 'sentence', '.'], ['Another', '.']]
word_ids = batch_to_word_ids(sentences, vocab2id)
embeddings = elmo(word_ids)
CLI commands:
.. code-block:: bash
# Cache the Char CNN representation.
fast-elmo cache-char-cnn ./vocab.txt ./options.json ./lm_weights.hdf5 ./lm_embd.hdf5
# Export word embedding.
fast-elmo export-word-embd ./vocab.txt ./no-char-cnn.hdf5 ./embd.txt
This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage
_ project template.
.. Cookiecutter: https://github.com/audreyr/cookiecutter
.. audreyr/cookiecutter-pypackage
: https://github.com/audreyr/cookiecutter-pypackage
Bumps wheel from 0.32.3 to 0.38.1.
Sourced from wheel's changelog.
Release Notes
UNRELEASED
- Updated vendored
packaging
to 22.00.38.4 (2022-11-09)
- Fixed
PKG-INFO
conversion inbdist_wheel
mangling UTF-8 header values inMETADATA
(PR by Anderson Bravalheri)0.38.3 (2022-11-08)
- Fixed install failure when used with
--no-binary
, reported on Ubuntu 20.04, by removingsetup_requires
fromsetup.cfg
0.38.2 (2022-11-05)
- Fixed regression introduced in v0.38.1 which broke parsing of wheel file names with multiple platform tags
0.38.1 (2022-11-04)
- Removed install dependency on setuptools
- The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was faulty. Fixed so that future changes in the SOABI will not change the tag.
0.38.0 (2022-10-21)
- Dropped support for Python < 3.7
- Updated vendored
packaging
to 21.3- Replaced all uses of
distutils
withsetuptools
- The handling of
license_files
(including glob patterns and default values) is now delegated tosetuptools>=57.0.0
(#466). The package dependencies were updated to reflect this change.- Fixed potential DoS attack via the
WHEEL_INFO_RE
regular expression- Fixed
ValueError: ZIP does not support timestamps before 1980
when usingSOURCE_DATE_EPOCH=0
or when on-disk timestamps are earlier than 1980-01-01. Such timestamps are now changed to the minimum value before packaging.0.37.1 (2021-12-22)
- Fixed
wheel pack
duplicating theWHEEL
contents when the build number has changed (#415)- Fixed parsing of file names containing commas in
RECORD
(PR by Hood Chatham)0.37.0 (2021-08-09)
- Added official Python 3.10 support
- Updated vendored
packaging
library to v20.9
... (truncated)
6f1608d
Created a new releasecf8f5ef
Moved news item from PR #484 to its proper place9ec2016
Removed install dependency on setuptools (#483)747e1f6
Fixed PyPy SOABI parsing (#484)7627548
[pre-commit.ci] pre-commit autoupdate (#480)7b9e8e1
Test on Python 3.11 finala04dfef
Updated the pypi-publish action94bb62c
Fixed docs not building due to code style changesd635664
Updated the codecov action to the latest versionfcb94cd
Updated version to match the releaseDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps ipython from 7.2.0 to 7.16.3.
d43c7c7
release 7.16.35fa1e40
Merge pull request from GHSA-pq7m-3gw7-gq5x8df8971
back to dev9f477b7
release 7.16.2138f266
bring back release helper from master branch5aa3634
Merge pull request #13341 from meeseeksmachine/auto-backport-of-pr-13335-on-7...bcae8e0
Backport PR #13335: What's new 7.16.28fcdcd3
Pin Jedi to <0.17.2.2486838
release 7.16.120bdc6f
fix conda buildDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Bumps pip from 19.0.1 to 21.1.
Sourced from pip's changelog.
21.1 (2021-04-24)
Process
- Start installation scheme migration from
distutils
tosysconfig
. A warning is implemented to detect differences between the two implementations to encourage user reports, so we can avoid breakages before they happen.Features
- Add the ability for the new resolver to process URL constraints. (
[#8253](https://github.com/pypa/pip/issues/8253) <https://github.com/pypa/pip/issues/8253>
_)- Add a feature
--use-feature=in-tree-build
to build local projects in-place when installing. This is expected to become the default behavior in pip 21.3; seeInstalling from local packages <https://pip.pypa.io/en/stable/user_guide/#installing-from-local-packages>
_ for more information. ([#9091](https://github.com/pypa/pip/issues/9091) <https://github.com/pypa/pip/issues/9091>
_)- Bring back the "(from versions: ...)" message, that was shown on resolution failures. (
[#9139](https://github.com/pypa/pip/issues/9139) <https://github.com/pypa/pip/issues/9139>
_)- Add support for editable installs for project with only setup.cfg files. (
[#9547](https://github.com/pypa/pip/issues/9547) <https://github.com/pypa/pip/issues/9547>
_)- Improve performance when picking the best file from indexes during
pip install
. ([#9748](https://github.com/pypa/pip/issues/9748) <https://github.com/pypa/pip/issues/9748>
_)- Warn instead of erroring out when doing a PEP 517 build in presence of
--build-option
. Warn when doing a PEP 517 build in presence of--global-option
. ([#9774](https://github.com/pypa/pip/issues/9774) <https://github.com/pypa/pip/issues/9774>
_)Bug Fixes
- Fixed
--target
to work with--editable
installs. ([#4390](https://github.com/pypa/pip/issues/4390) <https://github.com/pypa/pip/issues/4390>
_)- Add a warning, discouraging the usage of pip as root, outside a virtual environment. (
[#6409](https://github.com/pypa/pip/issues/6409) <https://github.com/pypa/pip/issues/6409>
_)- Ignore
.dist-info
directories if the stem is not a valid Python distribution name, so they don't show up in e.g.pip freeze
. ([#7269](https://github.com/pypa/pip/issues/7269) <https://github.com/pypa/pip/issues/7269>
_)- Only query the keyring for URLs that actually trigger error 401. This prevents an unnecessary keyring unlock prompt on every pip install invocation (even with default index URL which is not password protected). (
[#8090](https://github.com/pypa/pip/issues/8090) <https://github.com/pypa/pip/issues/8090>
_)- Prevent packages already-installed alongside with pip to be injected into an isolated build environment during build-time dependency population. (
[#8214](https://github.com/pypa/pip/issues/8214) <https://github.com/pypa/pip/issues/8214>
_)- Fix
pip freeze
permission denied error in order to display an understandable error message and offer solutions. ([#8418](https://github.com/pypa/pip/issues/8418) <https://github.com/pypa/pip/issues/8418>
_)- Correctly uninstall script files (from setuptools'
scripts
argument), when installed with--user
. ([#8733](https://github.com/pypa/pip/issues/8733) <https://github.com/pypa/pip/issues/8733>
_)- New resolver: When a requirement is requested both via a direct URL (
req @ URL
) and via version specifier with extras (req[extra]
), the resolver will now be able to use the URL to correctly resolve the requirement with extras. ([#8785](https://github.com/pypa/pip/issues/8785) <https://github.com/pypa/pip/issues/8785>
_)- New resolver: Show relevant entries from user-supplied constraint files in the error message to improve debuggability. (
[#9300](https://github.com/pypa/pip/issues/9300) <https://github.com/pypa/pip/issues/9300>
_)- Avoid parsing version to make the version check more robust against lousily debundled downstream distributions. (
[#9348](https://github.com/pypa/pip/issues/9348) <https://github.com/pypa/pip/issues/9348>
_)--user
is no longer suggested incorrectly when pip fails with a permission error in a virtual environment. ([#9409](https://github.com/pypa/pip/issues/9409) <https://github.com/pypa/pip/issues/9409>
_)- Fix incorrect reporting on
Requires-Python
conflicts. ([#9541](https://github.com/pypa/pip/issues/9541) <https://github.com/pypa/pip/issues/9541>
_)
... (truncated)
2b2a268
Bump for releaseea761a6
Update AUTHORS.txt2edd3fd
Postpone a deprecation to 21.23cccfbf
Rename mislabeled news fragment21cd124
Fix NEWS.rst placeholder positione46bdda
Merge pull request #9827 from pradyunsg/fix-git-improper-tag-handling0e4938d
:newspaper:ca832b2
Don't split git references on unicode separators1320bac
Merge pull request #9814 from pradyunsg/revamp-ci-apr-2021-v2e9cc23f
Skip checks on PRs onlyDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Unable to import the library, though I installed torch v1.0 and pytorch-fast-elmo
File "/usr/local/lib/python3.7/site-packages/pytorch_fast_elmo/init.py", line 12, in
Train a new model base on this package.