Keras ERNIE
Project description
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, use_gpu=True, gpu_memory_growth=False,
training=False, seq_len=None, name='ernie')
model.summary()
Convert Pre-trained ERNIE Model To Tensor Model
python paddle_to_tensor.py \
--init_checkpoint ${MODEL_PATH}/params \
--ernie_config_path ${MODEL_PATH}/ernie_config.json \
--ernie_vocab_path ${MODEL_PATH}/vocab.txt \
--ernie_version stable-1.0.1 \
--max_seq_len 128 \
--num_labels 2 \
--use_fp16 false \
--use_gpu true \
--gpu_memory_growth false \
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
keras-ernie-1.0.1.tar.gz
(25.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keras-ernie-1.0.1.tar.gz.
File metadata
- Download URL: keras-ernie-1.0.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d15b703fb9af1fa6f3251d7194bd71d51e4d9a981fbe785c201c5941d4e04e47
|
|
| MD5 |
fa3b4be02369efad4cc3858511cedb0a
|
|
| BLAKE2b-256 |
fade25e20696d4a7503ed114d05a7ef03dc276bf59baa8ddb4dd780b5f1cb43a
|
File details
Details for the file keras_ernie-1.0.1-py3-none-any.whl.
File metadata
- Download URL: keras_ernie-1.0.1-py3-none-any.whl
- Upload date:
- Size: 36.7 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8310ab0714becf4912a35606804cef51c67586dc1f4b6066c00e4a5d501b6866
|
|
| MD5 |
1fda24f6f4fb609e9f39e47ef243d5cd
|
|
| BLAKE2b-256 |
cf89c28a328b633b0c2dba693c441d6d47286fdbe1d7d9fcbde3aa02831ff3f6
|