Skip to main content

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

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.5.tar.gz (25.7 kB view details)

Uploaded Source

File details

Details for the file keras-ernie-1.0.5.tar.gz.

File metadata

  • Download URL: keras-ernie-1.0.5.tar.gz
  • Upload date:
  • Size: 25.7 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

Hashes for keras-ernie-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f75ebb79d59b0f536005e88e0cedd71e1ae8e3ba17098531713f38da9301a534
MD5 fe543018220ffd1b4b89e7869a9145a4
BLAKE2b-256 002113c36a707940d45421c226b781255f7aea5d7d8eb21f659dc869396f4672

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page