Update README.md
Browse files
README.md
CHANGED
|
@@ -16,4 +16,32 @@ tags:
|
|
| 16 |
- art
|
| 17 |
widget:
|
| 18 |
- text: '笔底江山助磅礴'
|
| 19 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
- art
|
| 17 |
widget:
|
| 18 |
- text: '笔底江山助磅礴'
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Chinese Poem and Couplt small GPT2 Model
|
| 22 |
+
|
| 23 |
+
## Model description
|
| 24 |
+
|
| 25 |
+
The model is used to generate Chinese ancient poems and couplets. It is based on the [IDEA-CCNL/Wenzhong-GPT2-110M](https://huggingface.co/IDEA-CCNL/Wenzhong-GPT2-110M)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
## How to use
|
| 29 |
+
|
| 30 |
+
You can use the model directly with a pipeline for text generation:
|
| 31 |
+
|
| 32 |
+
When the parameter skip_special_tokens is True:
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
>>> from transformers import BertTokenizer, GPT2LMHeadModel,TextGenerationPipeline
|
| 36 |
+
>>> tokenizer = BertTokenizer.from_pretrained("snzhang/GPT2-Poem-Small")
|
| 37 |
+
>>> model = GPT2LMHeadModel.from_pretrained("snzhang/GPT2-Poem-Small")
|
| 38 |
+
>>> text_generator = TextGenerationPipeline(model, tokenizer)
|
| 39 |
+
>>> text_generator("笔底江山助磅礴", max_length=50, do_sample=True)
|
| 40 |
+
[{'generated_text':'笔底江山助磅礴,万卷诗书见成章。'}]
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
And you can add the prefix "(唐诗:your title)"、"(宋词:your title)" and "(对联)" to make generation more precise.
|
| 44 |
+
|
| 45 |
+
## Training data
|
| 46 |
+
|
| 47 |
+
Training data contains 71,334 Chinese ancient poems and couplets.
|