Skip to main content

The pipy version of FastBERT

Project description

FastBERT_pypi

The pypi version of FastBERT.

Install

Install fastbert with pip.

$ pip install fastbert

Usage

Currently fastbert only supports single sentence classification. More function will be added later.

Chinese single sentence classification

from fastbert import FastBERT

# Loading your dataset
labels = ['T', 'F']
sents_train = [
    '你吃北京烤鸭吗?',
    '我吃宫爆鸡丁!',
    ...
]
labels_train = [
    'T',
    'F',
    ...
]

# Create and training model
model = FastBERT("google_bert_base_zh", labels=labels, device='cuda:0')
model.fit(
    sents_train,
    labels_train,
    model_saving_path='./fastbert.bin',
)

# Loading model and make inference
model.load_model('./fastbert.bin')
label, exec_layers = model('还是吃老干妈吧', speed=0.7)

English single sentence classification

...

# Create and training model
model = FastBERT("google_bert_base_en", labels=labels, device='cuda:0')
model.fit(
    sents_train,
    labels_train,
    model_saving_path='./fastbert.bin',
)

...

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

fastbert-0.0.5.tar.gz (198.8 kB view hashes)

Uploaded Source

Built Distribution

fastbert-0.0.5-py3-none-any.whl (215.6 kB view hashes)

Uploaded Python 3

Supported by

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