-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
116 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 asahi417 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
from setuptools import setup, find_packages | ||
|
||
VERSION = '0.0.0' | ||
NAME = 'tner' | ||
IS_RELEASED = False | ||
|
||
with open('README.md') as f: | ||
with open('README.md', 'r') as f: | ||
readme = f.read() | ||
|
||
setup( | ||
name=NAME, | ||
version=VERSION, | ||
description='A library for language model finetuning on named entity recognition and model evaluation over cross-domain datasets.', | ||
name='tner', | ||
packages=find_packages(exclude=["asset", "examples", "static", "templates", "tests"]), | ||
version='0.0.0', | ||
license='MIT', | ||
description='Transformer-based named entity recognition', | ||
url='https://github.com/asahi417/tner', | ||
download_url="https://github.com/asahi417/tner/archive/0.0.0.tar.gz", | ||
keywords=['ner', 'nlp', 'language-model'], | ||
long_description=readme, | ||
long_description_content_type="text/markdown", | ||
author='Asahi Ushio', | ||
author_email='[email protected]', | ||
packages=find_packages(), | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package | ||
'Intended Audience :: Developers', # Define that your audience are developers | ||
'Intended Audience :: Science/Research', | ||
'Topic :: Scientific/Engineering', | ||
'License :: OSI Approved :: MIT License', # Again, pick a license | ||
'Programming Language :: Python :: 3', #Specify which pyhton versions that you want to support | ||
], | ||
include_package_data=True, | ||
test_suite='tests', | ||
install_requires=[ | ||
'Pillow>=7.1.0', | ||
'mecab-python3==0.996.5', # this version can only work | ||
'uvicorn==0.11.8', | ||
'jinja2==2.11.2', | ||
'aiofiles==0.5.0', | ||
'fastapi==0.61.0', | ||
'matplotlib==3.3.1', | ||
'toml', | ||
'tensorboard', | ||
'torch', | ||
'transformers', | ||
'seqeval', | ||
'segtok' | ||
] | ||
) | ||
'Pillow>=7.1.0', | ||
# 'mecab-python3==0.996.5', # this version can only work | ||
'mecab-python3', # this version can only work | ||
'uvicorn==0.11.8', | ||
'jinja2==2.11.2', | ||
'aiofiles==0.5.0', | ||
'fastapi==0.61.0', | ||
'matplotlib==3.3.1', | ||
'toml', | ||
'tensorboard', | ||
'torch', | ||
'transformers', | ||
'seqeval', | ||
'segtok' | ||
], | ||
python_requires='>=3.6', | ||
entry_points={ | ||
'console_scripts': [ | ||
'tner-train = tner_cl.train:main', | ||
'tner-test = tner_cl.test:main', | ||
'tner-predict = tner_cl.predict:main' | ||
], | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" Fine-tune transformers on NER dataset """ | ||
import argparse | ||
from tner import TrainTransformersNER | ||
|
||
|
||
def get_options(): | ||
parser = argparse.ArgumentParser(description='Fine-tune transformers on NER dataset') | ||
parser.add_argument('-c', '--checkpoint', help='checkpoint to load', default=None, type=str) | ||
parser.add_argument('--checkpoint-dir', help='checkpoint directory', default=None, type=str) | ||
parser.add_argument('--lower-case', help='lower case all the data', action='store_true') | ||
parser.add_argument('--test-data', help='test dataset (if not specified, use trained set)', default=None, type=str) | ||
parser.add_argument('--test-lower-case', help='lower case all the test data', action='store_true') | ||
parser.add_argument('--test-entity-span', help='evaluate entity span', action='store_true') | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
opt = get_options() | ||
# train model | ||
trainer = TrainTransformersNER( | ||
checkpoint=opt.checkpoint, | ||
checkpoint_dir=opt.checkpoint_dir | ||
) | ||
if not trainer.is_trained: | ||
raise ValueError('checkpoints not found at {}'.format(trainer.checkpoint)) | ||
test_data = [None] if opt.test_data is None else opt.test_data.split(',') | ||
for i in test_data: | ||
trainer.test(test_dataset=i, entity_span_prediction=opt.test_entity_span, lower_case=opt.test_lower_case) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters