rasa-pro 3.11.11__py3-none-any.whl → 3.11.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/keys +1 -0
- rasa/nlu/extractors/crf_entity_extractor.py +69 -19
- rasa/version.py +1 -1
- {rasa_pro-3.11.11.dist-info → rasa_pro-3.11.12.dist-info}/METADATA +1 -1
- {rasa_pro-3.11.11.dist-info → rasa_pro-3.11.12.dist-info}/RECORD +8 -7
- {rasa_pro-3.11.11.dist-info → rasa_pro-3.11.12.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.11.dist-info → rasa_pro-3.11.12.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.11.dist-info → rasa_pro-3.11.12.dist-info}/entry_points.txt +0 -0
rasa/keys
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"segment": "CcvVD1I68Nkkxrv93cIqv1twIwrwG8nz", "sentry": "a283f1fde04347b099c8d729109dd450@o251570"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from collections import OrderedDict
|
|
4
|
-
from enum import Enum
|
|
5
3
|
import logging
|
|
4
|
+
import shutil
|
|
6
5
|
import typing
|
|
7
|
-
from
|
|
6
|
+
from collections import OrderedDict
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type
|
|
8
10
|
|
|
9
11
|
import numpy as np
|
|
10
12
|
|
|
@@ -43,6 +45,10 @@ if typing.TYPE_CHECKING:
|
|
|
43
45
|
|
|
44
46
|
CONFIG_FEATURES = "features"
|
|
45
47
|
|
|
48
|
+
TAGGERS_DIR = "taggers"
|
|
49
|
+
CRFSUITE_MODEL_FILE_NAME = "model.crfsuite"
|
|
50
|
+
PLAIN_CRF_MODEL_FILE_NAME = "model.txt"
|
|
51
|
+
|
|
46
52
|
|
|
47
53
|
class CRFToken:
|
|
48
54
|
def __init__(
|
|
@@ -419,19 +425,11 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
419
425
|
"""Loads trained component (see parent class for full docstring)."""
|
|
420
426
|
try:
|
|
421
427
|
with model_storage.read_from(resource) as model_dir:
|
|
422
|
-
dataset = rasa.shared.utils.io.read_json_file(
|
|
423
|
-
model_dir / "crf_dataset.json"
|
|
424
|
-
)
|
|
425
428
|
crf_order = rasa.shared.utils.io.read_json_file(
|
|
426
429
|
model_dir / "crf_order.json"
|
|
427
430
|
)
|
|
428
431
|
|
|
429
|
-
|
|
430
|
-
[CRFToken.create_from_dict(token_data) for token_data in sub_list]
|
|
431
|
-
for sub_list in dataset
|
|
432
|
-
]
|
|
433
|
-
|
|
434
|
-
entity_taggers = cls.train_model(dataset, config, crf_order)
|
|
432
|
+
entity_taggers = cls._load_taggers(model_dir, config)
|
|
435
433
|
|
|
436
434
|
entity_extractor = cls(config, model_storage, resource, entity_taggers)
|
|
437
435
|
entity_extractor.crf_order = crf_order
|
|
@@ -443,19 +441,71 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
|
|
|
443
441
|
)
|
|
444
442
|
return cls(config, model_storage, resource)
|
|
445
443
|
|
|
444
|
+
@classmethod
|
|
445
|
+
def _load_taggers(
|
|
446
|
+
cls, model_dir: Path, config: Dict[Text, Any]
|
|
447
|
+
) -> Dict[str, "CRF"]:
|
|
448
|
+
"""
|
|
449
|
+
Load taggers from model directory that persists trained binary
|
|
450
|
+
`model.crfsuite` files.
|
|
451
|
+
"""
|
|
452
|
+
|
|
453
|
+
import pycrfsuite
|
|
454
|
+
import sklearn_crfsuite
|
|
455
|
+
|
|
456
|
+
# Get tagger directories
|
|
457
|
+
taggers_base = model_dir / TAGGERS_DIR
|
|
458
|
+
if not taggers_base.exists():
|
|
459
|
+
return {}
|
|
460
|
+
|
|
461
|
+
taggers_dirs = [
|
|
462
|
+
directory for directory in taggers_base.iterdir() if directory.is_dir()
|
|
463
|
+
]
|
|
464
|
+
|
|
465
|
+
entity_taggers: Dict[str, "CRF"] = {}
|
|
466
|
+
|
|
467
|
+
for tagger_dir in taggers_dirs:
|
|
468
|
+
# Instantiate sklearns CRF wrapper for the pycrfsuite's Tagger
|
|
469
|
+
entity_tagger = sklearn_crfsuite.CRF(
|
|
470
|
+
algorithm="lbfgs",
|
|
471
|
+
# coefficient for L1 penalty
|
|
472
|
+
c1=config["L1_c"],
|
|
473
|
+
# coefficient for L2 penalty
|
|
474
|
+
c2=config["L2_c"],
|
|
475
|
+
# stop earlier
|
|
476
|
+
max_iterations=config["max_iterations"],
|
|
477
|
+
# include transitions that are possible, but not observed
|
|
478
|
+
all_possible_transitions=True,
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
# Load pycrfsuite tagger from the persisted binary model.crfsuite file
|
|
482
|
+
entity_tagger._tagger = pycrfsuite.Tagger()
|
|
483
|
+
entity_tagger._tagger.open(str(tagger_dir / CRFSUITE_MODEL_FILE_NAME))
|
|
484
|
+
|
|
485
|
+
entity_taggers[tagger_dir.name] = entity_tagger
|
|
486
|
+
|
|
487
|
+
return entity_taggers
|
|
488
|
+
|
|
446
489
|
def persist(self, dataset: List[List[CRFToken]]) -> None:
|
|
447
490
|
"""Persist this model into the passed directory."""
|
|
448
491
|
with self._model_storage.write_to(self._resource) as model_dir:
|
|
449
|
-
data_to_store = [
|
|
450
|
-
[token.to_dict() for token in sub_list] for sub_list in dataset
|
|
451
|
-
]
|
|
452
|
-
|
|
453
|
-
rasa.shared.utils.io.dump_obj_as_json_to_file(
|
|
454
|
-
model_dir / "crf_dataset.json", data_to_store
|
|
455
|
-
)
|
|
456
492
|
rasa.shared.utils.io.dump_obj_as_json_to_file(
|
|
457
493
|
model_dir / "crf_order.json", self.crf_order
|
|
458
494
|
)
|
|
495
|
+
if self.entity_taggers is not None:
|
|
496
|
+
for tag_name, entity_tagger in self.entity_taggers.items():
|
|
497
|
+
# Create the directories for storing the CRF model
|
|
498
|
+
tagger_dir = model_dir / TAGGERS_DIR / tag_name
|
|
499
|
+
tagger_dir.mkdir(parents=True, exist_ok=True)
|
|
500
|
+
# Create a plain text version of the CRF model
|
|
501
|
+
entity_tagger.tagger_.dump(
|
|
502
|
+
str(tagger_dir / PLAIN_CRF_MODEL_FILE_NAME)
|
|
503
|
+
)
|
|
504
|
+
# Persist binary version of the model.crfsuite
|
|
505
|
+
shutil.copy2(
|
|
506
|
+
src=entity_tagger.modelfile.name,
|
|
507
|
+
dst=tagger_dir / CRFSUITE_MODEL_FILE_NAME,
|
|
508
|
+
)
|
|
459
509
|
|
|
460
510
|
@classmethod
|
|
461
511
|
def _crf_tokens_to_features(
|
rasa/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: rasa-pro
|
|
3
|
-
Version: 3.11.
|
|
3
|
+
Version: 3.11.12
|
|
4
4
|
Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
|
|
5
5
|
Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
|
|
6
6
|
Author: Rasa Technologies GmbH
|
|
@@ -495,6 +495,7 @@ rasa/graph_components/validators/default_recipe_validator.py,sha256=BHrF6NTfJz42
|
|
|
495
495
|
rasa/graph_components/validators/finetuning_validator.py,sha256=38AcwmV8cF5TIlWhUIzh98wtZf934ix04HcczCJiWkU,12863
|
|
496
496
|
rasa/hooks.py,sha256=3nsfCA142V56mBQ7ktBXhD_RyaSrfj7fY3t7HnsD4Pc,3709
|
|
497
497
|
rasa/jupyter.py,sha256=x_GF9PK2zMhltb48GEIV9YZ4pRhCto8nV5SioYSCljI,1782
|
|
498
|
+
rasa/keys,sha256=2Stg1fstgJ203cOoW1B2gGMY29fhEnjIfTVxKv_fqPo,101
|
|
498
499
|
rasa/llm_fine_tuning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
499
500
|
rasa/llm_fine_tuning/annotation_module.py,sha256=wFmW3d6lI5o49OWmdbYQlgr24rqHDgA0T0hLM1pSb9U,8578
|
|
500
501
|
rasa/llm_fine_tuning/conversations.py,sha256=iW2hoR23Km5wnMC7t8pOXH2Zj3LVcA62xrx2aKDRP78,5208
|
|
@@ -544,7 +545,7 @@ rasa/nlu/emulators/luis.py,sha256=AWMGI17Su1q6PcE8l1S1mDJpwfVtx7ibY9rwBmg3Maw,30
|
|
|
544
545
|
rasa/nlu/emulators/no_emulator.py,sha256=tLJ2DyWhOtaIBudVf7mJGsubca9Vunb6VhJB_tWJ8wU,334
|
|
545
546
|
rasa/nlu/emulators/wit.py,sha256=0eMj_q49JGj0Z6JZjR7rHIABNF-F3POX7s5W5OkANyo,1930
|
|
546
547
|
rasa/nlu/extractors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
547
|
-
rasa/nlu/extractors/crf_entity_extractor.py,sha256=
|
|
548
|
+
rasa/nlu/extractors/crf_entity_extractor.py,sha256=pLiM6vEybqSW4refbBRr68QbE-9haxyHQo7vslymyI0,29400
|
|
548
549
|
rasa/nlu/extractors/duckling_entity_extractor.py,sha256=XooWjw6eDC0sxZ-T1YgDnrLcRTBx6B40SFGLjHTHg-w,7686
|
|
549
550
|
rasa/nlu/extractors/entity_synonyms.py,sha256=WShheUF7wbP7VWfpCNw3J4NouAcFjAupDsT4oAj_TUc,7148
|
|
550
551
|
rasa/nlu/extractors/extractor.py,sha256=m6p07GDBZi1VhgYCkYJrWs_Zk87okV77hvoiwG_1xxA,17539
|
|
@@ -779,9 +780,9 @@ rasa/utils/train_utils.py,sha256=f1NWpp5y6al0dzoQyyio4hc4Nf73DRoRSHDzEK6-C4E,212
|
|
|
779
780
|
rasa/utils/url_tools.py,sha256=JQcHL2aLqLHu82k7_d9imUoETCm2bmlHaDpOJ-dKqBc,1218
|
|
780
781
|
rasa/utils/yaml.py,sha256=KjbZq5C94ZP7Jdsw8bYYF7HASI6K4-C_kdHfrnPLpSI,2000
|
|
781
782
|
rasa/validator.py,sha256=O1wjCeV7ITJ0luvb3GCWy8x1fGgzWVbClEMlPnLBowQ,67265
|
|
782
|
-
rasa/version.py,sha256=
|
|
783
|
-
rasa_pro-3.11.
|
|
784
|
-
rasa_pro-3.11.
|
|
785
|
-
rasa_pro-3.11.
|
|
786
|
-
rasa_pro-3.11.
|
|
787
|
-
rasa_pro-3.11.
|
|
783
|
+
rasa/version.py,sha256=CgppFzIc7-kYA4G-bTW0JQ0GGCnzxv9tadLtKLUPrfE,118
|
|
784
|
+
rasa_pro-3.11.12.dist-info/METADATA,sha256=-Zu3BDmQMQHVhndlAJPOMyf-SNU7Oa_GqCjAvs6CyvY,10729
|
|
785
|
+
rasa_pro-3.11.12.dist-info/NOTICE,sha256=7HlBoMHJY9CL2GlYSfTQ-PZsVmLmVkYmMiPlTjhuCqA,218
|
|
786
|
+
rasa_pro-3.11.12.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
787
|
+
rasa_pro-3.11.12.dist-info/entry_points.txt,sha256=ckJ2SfEyTPgBqj_I6vm_tqY9dZF_LAPJZA335Xp0Q9U,43
|
|
788
|
+
rasa_pro-3.11.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|