https://github.com/4ai/bert-encoder
Encode text to BERT representations from pretrained BERT model
https://github.com/4ai/bert-encoder
Last synced: 3 days ago
JSON representation
Encode text to BERT representations from pretrained BERT model
- Host: GitHub
- URL: https://github.com/4ai/bert-encoder
- Owner: 4AI
- License: mit
- Created: 2019-06-17T10:26:32.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T04:26:47.000Z (almost 7 years ago)
- Last Synced: 2025-02-24T15:19:52.720Z (over 1 year ago)
- Language: Python
- Size: 64.5 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bert-encoder
# Usage
```python
from bert_encoder import BertEncoder
be = BertEncoder("/path/to/pretrain_bert_model")
be.encode(["你好", "你在哪"])
```
output
```
[array([[-0.43364248, 0.41179657, -0.32683408, ..., 0.2388876 ,
0.2813817 , -0.12212703],
[-0.3853165 , 0.30760592, -0.3487961 , ..., -0.02057578,
-0.21075164, -0.4568899 ]], dtype=float32), array([[-0.43364248, 0.41179657, -0.32683408, ..., 0.2388876 ,
0.2813817 , -0.12212703],
[-0.1804257 , 0.7799143 , -0.19864915, ..., -0.26258343,
0.01706939, -0.6424839 ],
[-0.45424426, 0.5611929 , 0.1049192 , ..., 0.31221464,
0.19015062, -0.10684527]], dtype=float32)]
```
# Environment
```
python 3.5+
```
# Installation
```bash
cd bert-encoder
python setup install
```