A bert sentence encoding tool
Project description
This is a bert sentence encoding tool.
How to use it
install package
pip install --index-url https://pypi.python.org/simple/ bert-sent-encoding==0.1.1
or
git clone ssh://git@gitlab.leihuo.netease.com:32200/shaojianzhi/bert-sent-encoding.git
cd bert-sent-encoding
python setup.py install
then use it
from bert_sent_encoding import bert_sent_encoding
bse = bert_sent_encoding(model_path='bert_sent_encoding/model/chinese_L-12_H-768_A-12', seq_length=64, batch_size=8, word_vector=False, layer=-1)
vector = bse.get_vector('你好') # 1. get vector of string
vectors = bse.get_vector(['你好', '哈哈']) # 2. get vector list of strings
bse.write_txt2vector(input_file, output_file) # 3. get and write vectors of strings
for line:
bse = bert_sent_encoding(model_path='bert_sent_encoding/model/chinese_L-12_H-768_A-12', seq_length=64, batch_size=8)
model_path is required, seq_length, batch_size and word_vector are optional
for line:
bse.write_txt2vector(input_file, output_file) # 3. get and write vectors of strings
path of input_file and output_file are defined by user and below is content of input_file:
the first line text
the second line text
...
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
bert_sent_encoding-0.1.2.tar.gz
(45.4 kB
view hashes)
Built Distribution
Close
Hashes for bert_sent_encoding-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1846acd82a8728e479a7cdebdc7d037d0fc56a3908e8b2e2a32fb60abe650502 |
|
MD5 | ac77f14ef262d6cf51776ffa405a5a5a |
|
BLAKE2b-256 | fa6184b637405eb331e11a34bcb2f398858f6b04e7f62ae0d28e9d0abe4d0bbf |