33 lines
1.2 KiB
Markdown
33 lines
1.2 KiB
Markdown
---
|
||
language: zh
|
||
datasets:
|
||
- clue
|
||
widget:
|
||
- text: 这是很久之前的事情了
|
||
pipeline_tag: text-generation
|
||
license: apache-2.0
|
||
---
|
||
|
||
|
||
# Chinese GPT2 Model
|
||
|
||
## Model description
|
||
|
||
The model is used to generate Chinese texts.
|
||
## How to use
|
||
|
||
You can use the model directly with a pipeline for text generation:
|
||
|
||
```python
|
||
>>> from transformers import BertTokenizer, GPT2LMHeadModel, TextGenerationPipeline
|
||
>>> tokenizer = BertTokenizer.from_pretrained("uer/gpt2-chinese-cluecorpussmall")
|
||
>>> model = GPT2LMHeadModel.from_pretrained("uer/gpt2-chinese-cluecorpussmall")
|
||
>>> text_generator = TextGenerationPipeline(model, tokenizer)
|
||
>>> text_generator("这是很久之前的事情了", max_length=100, do_sample=True)
|
||
[{'generated_text': '这是很久之前的事情了 。 至 今 仍 留 在 我 身 上 , 我 记 忆 犹 新 。 在 接 受 记 者 采 访 时 , 杨 杰 表 白 了 , 当 初 有 没 有 见 过 我 , 我 不 认 为 他 们 是 不 合 适 的 人 。 虽 然 当 时 他 们 不 信 我 , 但 杨 杰 表 示 , 感 觉 那 个 时 候 感 觉 是 好 想 听 他 们 说 话 ,'}]
|
||
|
||
```
|
||
|
||
## Training data
|
||
|
||
[CLUECorpusSmall](https://github.com/CLUEbenchmark/CLUECorpus2020/) is used as training data. |