:py:mod:`medcat.ner.transformers_ner` ===================================== .. py:module:: medcat.ner.transformers_ner Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: medcat.ner.transformers_ner.TransformersNER Functions ~~~~~~~~~ .. autoapisummary:: medcat.ner.transformers_ner.func_has_kwarg Attributes ~~~~~~~~~~ .. autoapisummary:: medcat.ner.transformers_ner.logger .. py:data:: logger .. py:class:: TransformersNER(cdb, config = None, training_arguments=None) Bases: :py:obj:`object` TODO: Add documentation .. py:attribute:: name :value: 'transformers_ner' .. py:method:: __init__(cdb, config = None, training_arguments=None) .. py:method:: create_eval_pipeline() .. py:method:: get_hash() A partial hash trying to catch differences between models. :Returns: **str** -- The hex hash. .. py:method:: _prepare_dataset(json_path, ignore_extra_labels, meta_requirements, file_name='data.json') .. py:method:: train(json_path = None, ignore_extra_labels=False, dataset=None, meta_requirements=None, trainer_callbacks = None) Train or continue training a model give a json_path containing a MedCATtrainer export. It will continue training if an existing model is loaded or start new training if the model is blank/new. :param json_path: Path/Paths to a MedCATtrainer export containing the meta_annotations we want to train for. :type json_path: str or list :param ignore_extra_labels: Makes only sense when an existing deid model was loaded and from the new data we want to ignore labels that did not exist in the old model. :param dataset: Defaults to None. :param meta_requirements: Defaults to None :param trainer_callbacks: A list of trainer callbacks for collecting metrics during the training at the client side. The transformers Trainer object will be passed in when each callback is called. :type trainer_callbacks: List[Callable[[Trainer], TrainerCallback]]] :raises ValueError: If something went wrong with model save path. :Returns: **Tuple** -- The dataframe, examples, and the dataset .. py:method:: eval(json_path = None, dataset=None, ignore_extra_labels=False, meta_requirements=None) .. py:method:: save(save_dir_path) Save all components of this class to a file :param save_dir_path: Path to the directory where everything will be saved. :type save_dir_path: str .. py:method:: expand_model_with_concepts(cui2preferred_name, use_avg_init = True) Expand the model with new concepts and their preferred names, which requires subsequent retraining on the model. :param cui2preferred_name: Dictionary where each key is the literal ID of the concept to be added and each value is its preferred name. :type cui2preferred_name: Dict[str, str] :param use_avg_init: Whether to use the average of existing weights or biases as the initial value for the new concept. Defaults to True. :type use_avg_init: bool .. py:method:: load(save_dir_path, config_dict = None) :classmethod: Load a meta_cat object. :param save_dir_path: The directory where all was saved. :type save_dir_path: str :param config_dict: This can be used to overwrite saved parameters for this meta_cat instance. Why? It is needed in certain cases where we autodeploy stuff. :type config_dict: dict :Returns: **meta_cat** (`medcat.MetaCAT`) -- You don't say .. py:method:: batch_generator(stream, batch_size_chars) :staticmethod: .. py:method:: pipe(stream, *args, **kwargs) Process many documents at once. :param stream: List of spacy documents. :type stream: Iterable[spacy.tokens.Doc] :param \*args: Extra arguments (not used here). :param \*\*kwargs: Extra keyword arguments (not used here). :Yields: *Doc* -- The same document. :Returns: **Iterator[Doc]** -- If the stream is None or empty. .. py:method:: _process(stream, batch_size_chars) .. py:method:: __call__(doc) Process one document, used in the spacy pipeline for sequential document processing. :param doc: A spacy document :type doc: Doc :Returns: **Doc** -- The same spacy document. .. py:function:: func_has_kwarg(func, keyword)