r""" Instantiate a pretrained LTP model from a pre-trained model configuration from huggingface-hub. The model is set in evaluation mode by default using `model.eval()` (Dropout modules are deactivated). To train the model, you should first set it
(
pretrained_model_name_or_path="LTP/small",
force_download: bool = False,
resume_download: bool = False,
proxies: Dict = None,
use_auth_token: Optional[str] = None,
cache_dir: Optional[str] = None,
local_files_only: bool = False,
**model_kwargs,
)
| 11 | |
| 12 | |
| 13 | def LTP( |
| 14 | pretrained_model_name_or_path="LTP/small", |
| 15 | force_download: bool = False, |
| 16 | resume_download: bool = False, |
| 17 | proxies: Dict = None, |
| 18 | use_auth_token: Optional[str] = None, |
| 19 | cache_dir: Optional[str] = None, |
| 20 | local_files_only: bool = False, |
| 21 | **model_kwargs, |
| 22 | ) -> Union[LTP_legacy, LTP_neural]: |
| 23 | r""" |
| 24 | Instantiate a pretrained LTP model from a pre-trained model |
| 25 | configuration from huggingface-hub. The model is set in |
| 26 | evaluation mode by default using `model.eval()` (Dropout modules |
| 27 | are deactivated). To train the model, you should first set it |
| 28 | back in training mode with `model.train()`. |
| 29 | |
| 30 | Parameters: |
| 31 | pretrained_model_name_or_path (`str` or `os.PathLike`): |
| 32 | Can be either: |
| 33 | - A string, the `model id` of a pretrained model |
| 34 | hosted inside a model repo on huggingface.co. |
| 35 | Valid model ids are [`LTP/tiny`, `LTP/small`, |
| 36 | `LTP/base`, `LTP/base1`, `LTP/base1`, `LTP/legacy` |
| 37 | ], the legacy model only support cws, pos and ner, |
| 38 | but more fast. |
| 39 | - You can add `revision` by appending `@` at the end |
| 40 | of model_id simply like this: |
| 41 | `dbmdz/bert-base-german-cased@main` Revision is |
| 42 | the specific model version to use. It can be a |
| 43 | branch name, a tag name, or a commit id, since we |
| 44 | use a git-based system for storing models and |
| 45 | other artifacts on huggingface.co, so `revision` |
| 46 | can be any identifier allowed by git. |
| 47 | - A path to a `directory` containing model weights |
| 48 | saved using |
| 49 | [`~transformers.PreTrainedModel.save_pretrained`], |
| 50 | e.g., `./my_model_directory/`. |
| 51 | - `None` if you are both providing the configuration |
| 52 | and state dictionary (resp. with keyword arguments |
| 53 | `config` and `state_dict`). |
| 54 | force_download (`bool`, *optional*, defaults to `False`): |
| 55 | Whether to force the (re-)download of the model weights |
| 56 | and configuration files, overriding the cached versions |
| 57 | if they exist. |
| 58 | resume_download (`bool`, *optional*, defaults to `False`): |
| 59 | Whether to delete incompletely received files. Will |
| 60 | attempt to resume the download if such a file exists. |
| 61 | proxies (`Dict[str, str]`, *optional*): |
| 62 | A dictionary of proxy servers to use by protocol or |
| 63 | endpoint, e.g., `{'http': 'foo.bar:3128', |
| 64 | 'http://hostname': 'foo.bar:4012'}`. The proxies are |
| 65 | used on each request. |
| 66 | use_auth_token (`str` or `bool`, *optional*): |
| 67 | The token to use as HTTP bearer authorization for remote |
| 68 | files. If `True`, will use the token generated when |
| 69 | running `transformers-cli login` (stored in |
| 70 | `~/.huggingface`). |
nothing calls this directly
no test coverage detected