keras ERNIE
Pre-trained ERNIE models could be loaded for feature extraction and prediction.
Install
pip install keras-ernie
Usage
- Download pre-trained ERNIE models
- Load the pre-trained ERNIE models
- Convert pre-trained ERNIE model to Tensor model
Download Pre-trained ERNIE Models
Notes: Currently, only the following models are supported.
| Model | Description |
|---|---|
| ERNIE 1.0 Base for Chinese | with params, config and vocabs |
| ERNIE 1.0 Base for Chinese(max-len-512) | with params, config and vocabs |
| ERNIE 2.0 Base for English | with params, config and vocabs |
Load Pre-trained ERNIE Models
import os
from keras_ernie import load_from_checkpoint
ernie_path = "/root/ERNIE_stable-1.0.1"
init_checkpoint = os.path.join(ernie_path, 'params')
ernie_config_path = os.path.join(ernie_path, 'ernie_config.json')
ernie_vocab_path = os.path.join(ernie_path, 'vocab.txt')
ernie_version = "stable-1.0.1"
model = load_from_checkpoint(init_checkpoint, ernie_config_path, ernie_vocab_path, ernie_version,
max_seq_len=128, num_labels=2, use_fp16=False, training=False, seq_len=None, name='ernie')
model.summary()
Convert Pre-trained ERNIE Model To Tensor Model
import os
from keras_ernie import ErnieArgs
from keras_ernie import convert_paddle_to_tensor
ernie_path = "/root/ERNIE_stable-1.0.1"
init_checkpoint = os.path.join(ernie_path, 'params')
ernie_config_path = os.path.join(ernie_path, 'ernie_config.json')
ernie_vocab_path = os.path.join(ernie_path, 'vocab.txt')
tensor_checkpoints_dir = "/root/checkpoints"
args = ErnieArgs(init_checkpoint, ernie_config_path, ernie_vocab_path,
max_seq_len=128, num_labels=2, use_fp16=False)
convert_paddle_to_tensor(args, tensor_checkpoints_dir)
Release files for keras-ernie 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| keras-ernie-1.0.7.tar.gz | 25.2 kB | Details |
Release files / keras-ernie-1.0.7.tar.gz
| Download URL | keras-ernie-1.0.7.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68500366088f7f1ba477edc2e817419887607c6c369fdad757782c24cf9cb5d7
|
|
BLAKE2b-256 checksum How to use checksums |
c34990cc696045c50f162b087934e582e2bf036594ac50dcbd4f093166e09388
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|