Skip to content

Commit 49e74be

Browse files
authored
Release 1.0.1
2 parents 1a59449 + c1c1441 commit 49e74be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+647
-868
lines changed

README.md

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DeepPavlov is designed for
1818
* Issues [*github/issues/*](https://github.com/deeppavlov/DeepPavlov/issues)
1919
* Forum [*forum.deeppavlov.ai*](https://forum.deeppavlov.ai/)
2020
* Blogs [*medium.com/deeppavlov*](https://medium.com/deeppavlov)
21-
* Tutorials [*examples/*](examples) and [extended colab tutorials](https://github.com/deeppavlov/dp_tutorials)
21+
* [Extended colab tutorials](https://github.com/deeppavlov/dp_tutorials)
2222
* Docker Hub [*hub.docker.com/u/deeppavlov/*](https://hub.docker.com/u/deeppavlov/)
2323
* Docker Images Documentation [*docs:docker-images/*](http://docs.deeppavlov.ai/en/master/intro/installation.html#docker-images)
2424

@@ -34,13 +34,9 @@ Please leave us [your feedback](https://forms.gle/i64fowQmiVhMMC7f9) on how we c
3434

3535
[Automatic Spelling Correction](http://docs.deeppavlov.ai/en/master/features/models/spelling_correction.html) | [Entity Linking](http://docs.deeppavlov.ai/en/master/features/models/entity_linking.html)
3636

37-
[Russian SuperGLUE](http://docs.deeppavlov.ai/en/master/features/models/superglue.html)
38-
39-
**Skills**
40-
41-
[Open Domain Questions Answering](http://docs.deeppavlov.ai/en/master/features/skills/odqa.html)
37+
[Open Domain Questions Answering](http://docs.deeppavlov.ai/en/master/features/models/odqa.html) | [Frequently Asked Questions Answering](http://docs.deeppavlov.ai/en/master/features/models/faq.html)
4238

43-
[Frequently Asked Questions Answering](http://docs.deeppavlov.ai/en/master/features/skills/faq.html)
39+
[Russian SuperGLUE](http://docs.deeppavlov.ai/en/master/features/models/superglue.html)
4440

4541
**Embeddings**
4642

@@ -97,24 +93,26 @@ evaluate and infer it:
9793

9894
#### GPU requirements
9995

100-
To run supported DeepPavlov models on GPU you should have [CUDA](https://developer.nvidia.com/cuda-toolkit) compatible
101-
with used GPU and [library PyTorch version](deeppavlov/requirements/pytorch.txt).
96+
By default, DeepPavlov installs models requirements from PyPI. PyTorch from PyPI could not support your device CUDA
97+
capability. To run supported DeepPavlov models on GPU you should have [CUDA](https://developer.nvidia.com/cuda-toolkit)
98+
compatible with used GPU and [PyTorch version](deeppavlov/requirements/pytorch.txt) required by DeepPavlov models.
99+
See [docs](https://docs.deeppavlov.ai/en/master/intro/quick_start.html#using-gpu) for details.
102100

103101
### Command line interface (CLI)
104102

105103
To get predictions from a model interactively through CLI, run
106104

107105
```bash
108-
python -m deeppavlov interact <config_path> [-d]
106+
python -m deeppavlov interact <config_path> [-d] [-i]
109107
```
110108

111-
* `-d` downloads required data -- pretrained model files and embeddings
112-
(optional).
109+
* `-d` downloads required data - pretrained model files and embeddings (optional).
110+
* `-i` installs model requirements (optional).
113111

114112
You can train it in the same simple way:
115113

116114
```bash
117-
python -m deeppavlov train <config_path> [-d]
115+
python -m deeppavlov train <config_path> [-d] [-i]
118116
```
119117

120118
Dataset will be downloaded regardless of whether there was `-d` flag or not.
@@ -126,10 +124,11 @@ The data format is specified in the corresponding model doc page.
126124
There are even more actions you can perform with configs:
127125

128126
```bash
129-
python -m deeppavlov <action> <config_path> [-d]
127+
python -m deeppavlov <action> <config_path> [-d] [-i]
130128
```
131129

132130
* `<action>` can be
131+
* `install` to install model requirements (same as `-i`),
133132
* `download` to download model's data (same as `-d`),
134133
* `train` to train the model on the data specified in the config file,
135134
* `evaluate` to calculate metrics on the same dataset,
@@ -140,6 +139,7 @@ python -m deeppavlov <action> <config_path> [-d]
140139
*<file_path>* if `-f <file_path>` is specified.
141140
* `<config_path>` specifies path (or name) of model's config file
142141
* `-d` downloads required data
142+
* `-i` installs model requirements
143143

144144

145145
### Python
@@ -149,33 +149,26 @@ To get predictions from a model interactively through Python, run
149149
```python
150150
from deeppavlov import build_model
151151

152-
model = build_model(<config_path>, download=True)
152+
model = build_model(<config_path>, install=True, download=True)
153153

154154
# get predictions for 'input_text1', 'input_text2'
155155
model(['input_text1', 'input_text2'])
156156
```
157-
158-
* where `download=True` downloads required data from web -- pretrained model
159-
files and embeddings (optional),
160-
* `<config_path>` is path to the chosen model's config file (e.g.
161-
`"deeppavlov/configs/ner/ner_ontonotes_bert_mult.json"`) or
162-
`deeppavlov.configs` attribute (e.g.
157+
where
158+
* `install=True` installs model requirements (optional),
159+
* `download=True` downloads required data from web - pretrained model files and embeddings (optional),
160+
* `<config_path>` is model name (e.g. `'ner_ontonotes_bert_mult'`), path to the chosen model's config file (e.g.
161+
`"deeppavlov/configs/ner/ner_ontonotes_bert_mult.json"`), or `deeppavlov.configs` attribute (e.g.
163162
`deeppavlov.configs.ner.ner_ontonotes_bert_mult` without quotation marks).
164163

165164
You can train it in the same simple way:
166165

167166
```python
168167
from deeppavlov import train_model
169168

170-
model = train_model(<config_path>, download=True)
169+
model = train_model(<config_path>, install=True, download=True)
171170
```
172171

173-
* `download=True` downloads pretrained model, therefore the pretrained
174-
model will be, first, loaded and then train (optional).
175-
176-
Dataset will be downloaded regardless of whether there was ``-d`` flag or
177-
not.
178-
179172
To train on your own data you need to modify dataset reader path in the
180173
[train config doc](http://docs.deeppavlov.ai/en/master/intro/config_description.html#train-config).
181174
The data format is specified in the corresponding model doc page.
@@ -185,12 +178,9 @@ You can also calculate metrics on the dataset specified in your config file:
185178
```python
186179
from deeppavlov import evaluate_model
187180

188-
model = evaluate_model(<config_path>, download=True)
181+
model = evaluate_model(<config_path>, install=True, download=True)
189182
```
190183

191-
192184
## License
193185

194186
DeepPavlov is Apache 2.0 - licensed.
195-
196-
##

deeppavlov/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626

2727

2828
# TODO: make better
29-
def train_model(config: [str, Path, dict], download: bool = False, recursive: bool = False) -> Chainer:
30-
train_evaluate_model_from_config(config, download=download, recursive=recursive)
29+
def train_model(config: [str, Path, dict], install: bool = False,
30+
download: bool = False, recursive: bool = False) -> Chainer:
31+
train_evaluate_model_from_config(config, install=install, download=download, recursive=recursive)
3132
return build_model(config, load_trained=True)
3233

3334

34-
def evaluate_model(config: [str, Path, dict], download: bool = False, recursive: bool = False) -> dict:
35-
return train_evaluate_model_from_config(config, to_train=False, download=download, recursive=recursive)
35+
def evaluate_model(config: [str, Path, dict], install: bool = False,
36+
download: bool = False, recursive: bool = False) -> dict:
37+
return train_evaluate_model_from_config(config, to_train=False, install=install,
38+
download=download, recursive=recursive)
3639

3740

3841
# check version

deeppavlov/_meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '1.0.0'
1+
__version__ = '1.0.1'
22
__author__ = 'Neural Networks and Deep Learning lab, MIPT'
33
__description__ = 'An open source library for building end-to-end dialog systems and training chatbots.'
44
__keywords__ = ['NLP', 'NER', 'SQUAD', 'Intents', 'Chatbot']

deeppavlov/core/commands/infer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import json
15-
import pickle
1615
import sys
1716
from itertools import islice
1817
from logging import getLogger
@@ -24,15 +23,18 @@
2423
from deeppavlov.core.common.params import from_params
2524
from deeppavlov.core.data.utils import jsonify_data
2625
from deeppavlov.download import deep_download
26+
from deeppavlov.utils.pip_wrapper import install_from_config
2727

2828
log = getLogger(__name__)
2929

3030

3131
def build_model(config: Union[str, Path, dict], mode: str = 'infer',
32-
load_trained: bool = False, download: bool = False) -> Chainer:
32+
load_trained: bool = False, install: bool = False, download: bool = False) -> Chainer:
3333
"""Build and return the model described in corresponding configuration file."""
3434
config = parse_config(config)
3535

36+
if install:
37+
install_from_config(config)
3638
if download:
3739
deep_download(config)
3840

deeppavlov/core/commands/train.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from deeppavlov.core.data.data_learning_iterator import DataLearningIterator
2525
from deeppavlov.core.data.utils import get_all_elems_from_json
2626
from deeppavlov.download import deep_download
27+
from deeppavlov.utils.pip_wrapper import install_from_config
2728

2829
log = getLogger(__name__)
2930

@@ -70,12 +71,15 @@ def train_evaluate_model_from_config(config: Union[str, Path, dict],
7071
iterator: Union[DataLearningIterator, DataFittingIterator] = None, *,
7172
to_train: bool = True,
7273
evaluation_targets: Optional[Iterable[str]] = None,
74+
install: bool = False,
7375
download: bool = False,
7476
start_epoch_num: Optional[int] = None,
7577
recursive: bool = False) -> Dict[str, Dict[str, float]]:
7678
"""Make training and evaluation of the model described in corresponding configuration file."""
7779
config = parse_config(config)
7880

81+
if install:
82+
install_from_config(config)
7983
if download:
8084
deep_download(config)
8185

deeppavlov/core/data/simple_vocab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def load(self):
109109
self.reset()
110110
if self.load_path:
111111
if self.load_path.is_file():
112-
log.info("[loading vocabulary from {}]".format(self.load_path))
112+
log.debug("[loading vocabulary from {}]".format(self.load_path))
113113
tokens, counts = [], []
114114
for ln in self.load_path.open('r', encoding='utf8'):
115115
token, cnt = self.load_line(ln)

deeppavlov/core/models/torch_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def __init__(self, device: str = "gpu",
9999
# we need to switch to eval mode here because by default it's in `train` mode.
100100
# But in case of `interact/build_model` usage, we need to have model in eval mode.
101101
self.model.eval()
102-
log.info(f"Model was successfully initialized! Model summary:\n {self.model}")
102+
log.debug(f"Model was successfully initialized! Model summary:\n {self.model}")
103103

104104
def init_from_opt(self, model_func: str) -> None:
105105
"""Initialize from scratch `self.model` with the architecture built in `model_func` method of this class
@@ -150,22 +150,22 @@ def load(self, fname: Optional[str] = None, *args, **kwargs) -> None:
150150
model_func = getattr(self, self.opt.get("model_name", ""), None)
151151

152152
if self.load_path:
153-
log.info(f"Load path {self.load_path} is given.")
153+
log.debug(f"Load path {self.load_path} is given.")
154154
if isinstance(self.load_path, Path) and not self.load_path.parent.is_dir():
155155
raise ConfigError("Provided load path is incorrect!")
156156

157157
weights_path = Path(self.load_path.resolve())
158158
weights_path = weights_path.with_suffix(f".pth.tar")
159159
if weights_path.exists():
160-
log.info(f"Load path {weights_path} exists.")
161-
log.info(f"Initializing `{self.__class__.__name__}` from saved.")
160+
log.debug(f"Load path {weights_path} exists.")
161+
log.debug(f"Initializing `{self.__class__.__name__}` from saved.")
162162

163163
# firstly, initialize with random weights and previously saved parameters
164164
if model_func:
165165
self.init_from_opt(model_func)
166166

167167
# now load the weights, optimizer from saved
168-
log.info(f"Loading weights from {weights_path}.")
168+
log.debug(f"Loading weights from {weights_path}.")
169169
checkpoint = torch.load(weights_path, map_location=self.device)
170170
model_state = checkpoint["model_state_dict"]
171171
optimizer_state = checkpoint["optimizer_state_dict"]
@@ -181,10 +181,10 @@ def load(self, fname: Optional[str] = None, *args, **kwargs) -> None:
181181
self.optimizer.load_state_dict(optimizer_state)
182182
self.epochs_done = checkpoint.get("epochs_done", 0)
183183
elif model_func:
184-
log.info(f"Init from scratch. Load path {weights_path} does not exist.")
184+
log.debug(f"Init from scratch. Load path {weights_path} does not exist.")
185185
self.init_from_opt(model_func)
186186
elif model_func:
187-
log.info(f"Init from scratch. Load path {self.load_path} is not provided.")
187+
log.debug(f"Init from scratch. Load path {self.load_path} is not provided.")
188188
self.init_from_opt(model_func)
189189

190190
@overrides

deeppavlov/core/trainers/fit_trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, chainer_config: dict, *, batch_size: int = -1,
6363
max_test_batches: int = -1,
6464
**kwargs) -> None:
6565
if kwargs:
66-
log.info(f'{self.__class__.__name__} got additional init parameters {list(kwargs)} that will be ignored:')
66+
log.warning(f'{self.__class__.__name__} got additional init parameters {list(kwargs)} that will be ignored:')
6767
self.chainer_config = chainer_config
6868
self._chainer = Chainer(chainer_config['in'], chainer_config['out'], chainer_config.get('in_y'))
6969
self.batch_size = batch_size

deeppavlov/deep.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
parser.add_argument("-b", "--batch-size", dest="batch_size", default=None, help="inference batch size", type=int)
4242
parser.add_argument("-f", "--input-file", dest="file_path", default=None, help="Path to the input file", type=str)
4343
parser.add_argument("-d", "--download", action="store_true", help="download model components")
44+
parser.add_argument("-i", "--install", action="store_true", help="install model requirements")
4445

4546
parser.add_argument("--folds", help="number of folds", type=int, default=5)
4647

@@ -67,6 +68,8 @@ def main():
6768
args = parser.parse_args()
6869
pipeline_config_path = find_config(args.config_path)
6970

71+
if args.install or args.mode == 'install':
72+
install_from_config(pipeline_config_path)
7073
if args.download or args.mode == 'download':
7174
deep_download(pipeline_config_path)
7275

@@ -95,8 +98,6 @@ def main():
9598
rabbit_virtualhost=args.rabbit_virtualhost)
9699
elif args.mode == 'predict':
97100
predict_on_stream(pipeline_config_path, args.batch_size, args.file_path)
98-
elif args.mode == 'install':
99-
install_from_config(pipeline_config_path)
100101
elif args.mode == 'crossval':
101102
if args.folds < 2:
102103
log.error('Minimum number of Folds is 2')

deeppavlov/download.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def download_resource(url: str, dest_paths: Iterable[Union[Path, str]], headers:
145145

146146
def download_resources(args: Namespace) -> None:
147147
if not args.all and not args.config:
148-
log.error('You should provide either skill config path or -all flag')
148+
log.error('You should provide either model config path or -all flag')
149149
sys.exit(1)
150150
elif args.all:
151151
downloads = get_configs_downloads()

0 commit comments

Comments
 (0)