File size: 716 Bytes
9bcff91 9866627 9bcff91 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
---
tags:
- text-generation
language: zh
license: apache-2.0
---
## Usage (HuggingFace Transformers)
```
pip install transformers
```
```python
from transformers import CPMAntTokenizer, CPMAntModel
texts = ["今天天气真好!"]
model = CPMAntModel.from_pretrained("openbmb/cpm-ant-10b")
tokenizer = CPMAntTokenizer.from_pretrained("openbmb/cpm-ant-10b")
input_ids = tokenizer.get_model_input(texts)
logits, hidden = model(**input_ids)
print(logits.shape)
print(hidden.shape)
```
## pipeline
```python
texts = ["昨天多云转阴,", "今天天气不错,"]
generator = pipeline("text-generation", model="openbmb/cpm-ant-10b", tokenizer="openbmb/cpm-ant-10b")
result = generator(texts)
print(result)
``` |