Skip to content

Commit

Permalink
merge dev for release 0.9.7 (#195)
Browse files Browse the repository at this point in the history
* merge python3_10 integration

* improve codecov script

* improve codecov script with test verbosity

* improve codecov script with test verbosity

* add script to run tests on all python version supported

* fix path management

* change mod of executable file

* add interactive shell to handle conda

* remove shebang arg

* fix contributing and minor typo in tests script

* improv example code and remove dead example

* squash handling from url branch

* cleanup dead file

* improve speed test code

* add num_workers test fasttext under windows os condition

* add tests case for num_workers test in parser

* simplified tests case windows

* update changelog

* fix windows os failing test due to num workers gt 0

* fix missing lower cassing windows os name

* add missing downlaod_from_url deprecated message and redirect to new refactored function

* add major release todo list to track function to remove

* update changelog

* add pragma no cover to skip codecovv

* improve variable naming

* refactor position of non protected method

* bump pylint and add django for codacy

* fix deepparse tools pylint

* fix network pylint

* fix vectorizer modules

* fix torch member and parser modules

* refactor arguments init in cli and cycling import

* fix circular import

* fix last pylint errors

* fix error in csv column names versus column name

* fix list csv column names missing nargs

* remove duplicate detection and fix with statement for temporary directory

* fix oylint on test

* push to 0.8.1

* simplification skipif test testing

* bug fix issue 141

* fix missing csv dataset in test for csv integration test

* merge improvement for error handling of retrain and test API

* linting yml file

* improve run all tests script

* improve run tests python envs

* fix naming of tests and some typos

* add save_model_eights method (#147)

* bumb actions version (checkout and setup-python

* fixed actions/checkout setted to 4 instead of 3

* add dependabot

* bump stale to v5

* add python 3.11 in linting

* remove python 3.11 since not supported for now and add 3.10 in windows test to see if still fails

* revert windoes python 3.10 since still fail

* Add codeql (#148)

* Create FUNDING.yml

* Update README.md

* Update FUNDING.yml

* Create codeql-analysis.yml

* add deprecated warnings class type on deprecated download_from_url_fn

* refactored dataset containter creation into a factory

* fix errors for parsing cases

* moved arguments in dataset factory

* add tests case for new factory tool fn

* added val dataset handling

* fixed tests and remove major release todo

* added cleaning conda env

* improved scirpt with warmup training

* remove fine_tuning script since in branch

* fixed tests

* fixed test without clear num_workers arg

* remove fn download_from_url

* removed unecessary retrain in test api tests

* added verbose for test and improved tests for retrain test integration

* updated changelog

* fixed missing hint typing, improved internal doc, fixed train_ratio arg error in code examples and in doc

* add pylint step on code examples

* added missing typing, uniformization of assertFileExist fn, added integration test and improved doc

* remove comment in linting ci to bug fix if failling problem

* fix dead verbose retrain api flag

* add ini option for django

* remove linting of code example since fail due to pylint-django and I am unable to make it work

* fixed django settings

* add steps to install depparse for code examples linting

* remove install -e

* reinstaller install -e .

* add skip=no-member since it is mostly flase positive

* removed no-member pylint disable

* add docker image

* formating

* formated README

* update changelog

* merge uk example and fixes to doc

* hot-fix choices handling in cli.download

* linting and security template mv

* improved deepparse server error handling

* merge offline parsing

* fix typo in all test run

* fixed error in module name and refactored errors module

* fixed reference packaging other deepparse module

* added missing hint typing

* add missing urllib3 dependancies

* improve workflow

* improve doc

* add download_models, fix bug in cache path handling and fixed examples

* update changelog

* refactored test and add download_models tests

* merge refactoring of download cli fn

* moved code for licensing

* fixed typo in doc

* Update CHANGELOG.md

* added factories and tests

* added offline argument to model factory

* added data padders & tests

* black formatting

* added data padder factory & tests

* added docstring & preparing to refactor padder

* refactored data padder to solve LSP issue

* refactored vectorizer factory & temporarily removed type hinting from TrainVectorizer due to cyclic import

* adjusted docstring

* Hotfix `SSLError` when downloading model weights of model type: `bpemb` (#157)

* ✨ add `no_ssl_verification()` context manager

disables SSL for requests library within context

* 🐛 hotfix model factory for `model_type="bpemb"`

Co-authored-by: David Beauchemin <[email protected]>

* moved context wrapper in bpemb embedding model

* removed unused as err

* added pylint skip for broad except to hotfix code

* added pylint skip for broad except to hotfix code

* bump version and changelog

* added DataPadder docstring

* applied refurb (#160)

* wip - added DataProcessor and tests

* tweaked process_for_training method

* finished DataProcessor and tests

* removed obsolete tests

* added DataProcessor docstring

* Bump docker/metadata-action from 4.0.1 to 4.1.1 (#161)

Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.0.1 to 4.1.1.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@69f6fc9...5739616)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump docker/login-action from 2.0.0 to 2.1.0 (#162)

Bumps [docker/login-action](https://github.com/docker/login-action) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@49ed152...f4ef78c)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump pylint from 2.15.3 to 2.15.5 (#163)

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.3 to 2.15.5.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](pylint-dev/pylint@v2.15.3...v2.15.5)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump docker/build-push-action from 3.1.1 to 3.2.0 (#164)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3.1.1 to 3.2.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@c84f382...c56af95)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump black from 22.8.0 to 22.10.0 (#165)

Bumps [black](https://github.com/psf/black) from 22.8.0 to 22.10.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@22.8.0...22.10.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Beauchemin <[email protected]>

* fix black dependancy pyproject.toml

* added DataProcessorFactory and tests

* fix error in arg train ratio example and added assert in deepparse.retrain to be more verbose

* added error handling for macos and improved windows for case of num_worker and multiprocessing

* fixed failling test and improved test for test_api

* fixed windows tests

* Update CHANGELOG.md

* Feat/add new tags to retrain cli (#167)

* add missing import in init

* add feature to allow new_prediction_tags in retrain CLI API

* bump version and changelog

* fix typo in doc retrain CLI

* fixed errors due to model naming conventions

* added final docstring

* fixed broken tests

* removed broken test patching

* cleaned-up parser after new changes integration

* black formatting

* remove accidental unused import

* fixed linting

* black formatting

* removed unnecessary args

* patching factories in AddressParser tests to memory optimise

* fixed brocken tests

* removed unused import

* fixed windows tests

* fixed windows test

* removed unused modules after refactor

* removed imports for removed modules

* add tensorboard dependancies in test/requirements since it make test fail due to missing tensorboard for Poutyne import

* Update deepparse/parser/address_parser.py

Co-authored-by: David Beauchemin <[email protected]>

* added error handling to data processor factory

* fixed linting

* Update deepparse/converter/data_processor_factory.py

* fixed broken tests

* fixed broken test

* Update CHANGELOG.md

* Bump docker/metadata-action from 4.1.1 to 4.3.0 (#173)

Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.1.1 to 4.3.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@5739616...507c2f2)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Beauchemin <[email protected]>

* Bump pylint from 2.15.9 to 2.15.10 (#174)

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.9 to 2.15.10.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](pylint-dev/pylint@v2.15.9...v2.15.10)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Beauchemin <[email protected]>

* Bump docker/build-push-action from 3.2.0 to 4.0.0 (#175)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 3.2.0 to 4.0.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](docker/build-push-action@c56af95...3b5e802)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Beauchemin <[email protected]>

* Bump black from 22.12.0 to 23.1.0 (#176)

* Bump black from 22.12.0 to 23.1.0

Bumps [black](https://github.com/psf/black) from 22.12.0 to 23.1.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@22.12.0...23.1.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* bump pyproject.toml

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Beauchemin <[email protected]>

* bump version

* black formatting

* fixed missing update of tag converter in data processor

* jupyter notebook formating

* fix typo in test

* bump version

* improve documentation of codecov_push.sh

* run docker ci monthly instead of weekly

* Bump pylint from 2.15.10 to 2.16.2 (#180)

* Bump pylint from 2.15.10 to 2.16.2

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.10 to 2.16.2.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](pylint-dev/pylint@v2.15.10...v2.16.2)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump actions/checkout from 2 to 3 (#181)

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix warnings and new error

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: davebulaval <[email protected]>

* add target to dev instead of main

* Python311 (#182)

* Bump pylint from 2.15.10 to 2.16.2

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.10 to 2.16.2.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](pylint-dev/pylint@v2.15.10...v2.16.2)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix warnings and new error

* add python 3.11

* add doc in script to run tests

* remove 3.10 and 3.11 tests for Windows since pip install fail

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add missing with_hyphen_split argument in __call__

* Pre process address call argument (#183)

* add missing with_hyphen_split argument in __call__

* reworked DataCleaning into a more flexible approach

* fix tests, improve doc and add more pre-processors

* Various minor improvements (#185)

* minor improvements to doc, code and tests

* add multithreads tests in worker and fixed missing .to removal

* improve contributing and changelog

* fix typo in doc

* fix typo in doc

* drop python 3.7 (#187)

* Bug fix retrain model loading (#188)

* improve error handling

* improve error handling with retrain model and test a test case with new error raise if no metadata

* fix tests and improve new fix with a better getter

* fix error message and improve tests

* fix pylint

* fix skipif to allow runner to run tests and fix call to prepare pretrained in locality of test to allow runner to run tests

* add fake ckpt creation in not integration tests

* fix setup class related to pre trained init

* fix setupclass error in some tests

* normalization of hint typing in doc

* Lengths as list (#189)

* merge lengths as vector to lengths as list

* fix tests

* fix tests

* fix tests

* fix tests

* fix tests

* minor doc corrections

* fix pylint

* fix doc

* bump version and changelog

* improve documentation

* improve ckpt error message and fix typos

* improve error handling cache

* Aws s3 uri (#193)

* add first version of uri implementation using s3path

* changed to cloudpath since support more s3 provider

* improve cloudpathlib handling and doc

* add fn to handle weights download over URI, add new dependencies, add tests and fix setup.py

* add code to upload wieghts properly, add some tests, add model version release

* add release version

* fixed tests, add changelog and start docs

* add examples

* fix changelog typos, fix parse and testing tests and code, improve cli doc and add integration test uri

* fix tests and fix error in tool infer model type

* fix error in cli.test

* fix error in base case

* fix data processor error and improve test to catch this kind of error

* fix missing element in changelog

* add override and better verbose handling in retrain

* update changelog

* fix error in test

* fix tests

* Bug fix fasttext build (#194)

* add build-system like pr 1292 in fasttext repo

* add pybind11 in build steps since broken with new pip tool

* switch to fasttext-wheel to fix the build problem

* update changelog

* improve error handling weights load and fix broken tests

* bump version and changelog

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Marouane Yassine <[email protected]>
Co-authored-by: Ajinkya Indulkar <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marouane Yassine <[email protected]>
  • Loading branch information
5 people authored May 22, 2023
1 parent fdf1a8e commit dfbab27
Show file tree
Hide file tree
Showing 42 changed files with 609 additions and 112 deletions.
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ We love your input! We want to make contributing to this project as easy and tra
- Proposing new features
- Becoming a maintainer

## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
## We Develop with GitHub
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
## We Use [GitHub Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:

1. Fork the repo and create your branch from the **`dev` branch**.
2. If you've added code that should be tested, you **must** ensure it is properly tested.
3. If you've changed APIs, update the documentation.
4. Ensure the Travis test suite passes.
4. Ensure the CI/CD test suite passes.
5. Make sure your code lints.
6. Submit that pull request!

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -Ur requirements.txt
pip install -Ur docs/requirements.txt
pip install -e .
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -Ur requirements.txt
pip install -Ur styling_requirements.txt
pip install -Ur tests/requirements.txt
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -Ur requirements.txt
pip install -Ur tests/requirements.txt
python setup.py develop
Expand All @@ -38,6 +39,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -Ur requirements.txt
pip install -Ur tests/requirements.txt
python setup.py develop
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ deepparse/version.py
*.ckpt

*mlruns/

*model/
1 change: 1 addition & 0 deletions .release/bpemb.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aa32fa918494b461202157c57734c374
1 change: 1 addition & 0 deletions .release/bpemb_attention.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cfb190902476376573591c0ec6f91ece
1 change: 1 addition & 0 deletions .release/fasttext.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f67a0517c70a314bdde0b8440f21139d
1 change: 1 addition & 0 deletions .release/fasttext_attention.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a2b688bdfa2aa7c009bb7d980e352978
5 changes: 5 additions & 0 deletions .release/model_version_release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How to Create a New Model's Version

1. `md5sum <model.ckpt> > model.version`
2. Remove the model.cpkt text in `model.version` file
3. Update latests BPEMB and FastText hash in `tests/test_tools.py`
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,17 @@
suggested in the [documentation](https://pytorch.org/tutorials//intermediate/torch_compile_tutorial.html). It
increases the performance by about 1/100.

## 0.9.7

- New models release with more meta-data.
- Add a feature to use an AddressParser from a URI.
- Add a feature to upload the trained model to a URI.
- Add an example of how to use URI for parsing from and uploading to.
- Improve error handling of `path_to_retrain_model`.
- Bug-fix pre-processor error.
- Add verbose override and improve verbosity handling in retrain.
- Bug-fix the broken FastText installation using `fasttext-wheel` instead of `fasttext` (
see [here](https://github.com/facebookresearch/fastText/issues/512#issuecomment-1534519551)
and [here](https://github.com/facebookresearch/fastText/pull/1292)).

## dev
2 changes: 1 addition & 1 deletion deepparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .fasttext_tools import *
from .tools import *
from .version import __version__
from .weights_init import *
from .weights_tools import *
2 changes: 1 addition & 1 deletion deepparse/cli/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main(args=None) -> None:
.. code-block:: sh
parse fasttext ./dataset.csv parsed_address.pckl --path_to_retrained_model ./path
parse fasttext ./dataset.csv parsed_address.pckl --path_to_model_weights ./path
"""
if args is None: # pragma: no cover
Expand Down
2 changes: 1 addition & 1 deletion deepparse/cli/parser_arguments_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def add_batch_size_arg(parser: ArgumentParser) -> None:
def add_path_to_retrained_model_arg(parser: ArgumentParser) -> None:
parser.add_argument(
"--path_to_retrained_model",
help=wrap("A path to a retrained model to use for testing."),
help=wrap("A path to a retrained model to use. It can be an S3-URI."),
type=str,
default=None,
)
Expand Down
2 changes: 1 addition & 1 deletion deepparse/network/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from torch import nn

from ..weights_init import weights_init
from .. import weights_init


class Decoder(nn.Module):
Expand Down
2 changes: 1 addition & 1 deletion deepparse/network/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torch import nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence

from ..weights_init import weights_init
from .. import weights_init


class Encoder(nn.Module):
Expand Down
19 changes: 10 additions & 9 deletions deepparse/network/seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import random
import warnings
from abc import ABC
from collections import OrderedDict
from typing import Tuple, Union, List

import torch
from torch import nn

from .decoder import Decoder
from .encoder import Encoder
from .. import handle_weights_upload
from ..tools import download_weights, latest_version


Expand Down Expand Up @@ -113,20 +113,21 @@ def _load_pre_trained_weights(self, model_type: str, cache_dir: str, offline: bo
)
download_weights(model_type, cache_dir, verbose=self.verbose)

all_layers_params = torch.load(model_path, map_location=self.device)
self.load_state_dict(all_layers_params)
self._load_weights(path_to_model_torch_archive=model_path)

def _load_weights(self, path_to_retrained_model: str) -> None:
def _load_weights(self, path_to_model_torch_archive: str) -> None:
"""
Method to load (into the network) the weights.
Args:
path_to_retrained_model (str): The path to the fine-tuned model.
path_to_model_torch_archive (str): The path to the fine-tuned model Torch archive.
"""
all_layers_params = torch.load(path_to_retrained_model, map_location=self.device)
if isinstance(all_layers_params, dict) and not isinstance(all_layers_params, OrderedDict):
# Case where we have a retrained model with a different tagging space
all_layers_params = all_layers_params.get("address_tagger_model")
all_layers_params = handle_weights_upload(
path_to_model_to_upload=path_to_model_torch_archive, device=self.device
)

# All the time, our torch archive include meta-data along with the model weights
all_layers_params = all_layers_params.get("address_tagger_model")
self.load_state_dict(all_layers_params)

def _encoder_step(self, to_predict: torch.Tensor, lengths: List, batch_size: int) -> Tuple:
Expand Down
Loading

0 comments on commit dfbab27

Please sign in to comment.