metadata
tags:
- text-generation
language: zh
Note
This repo is under development.
Usage
pip install transformers
from transformers import CPMAntTokenizer, CPMAntForCausalLM
texts = "今天天气不错,"
model = CPMAntForCausalLM.from_pretrained("openbmb/cpm-ant-10b")
tokenizer = CPMAntTokenizer.from_pretrained("openbmb/cpm-ant-10b")
input_ids = tokenizer(texts, return_tensors="pt")
outputs = model.generate(**input_ids)
output_texts = tokenizer.batch_decode(outputs)
print(output_texts)
pipeline
texts = ["今天天气不错,","新年快乐,万事如意,"]
generator = pipeline("text-generation", model="openbmb/cpm-ant-10b", tokenizer="openbmb/cpm-ant-10b")
result = generator(texts)
print(result)