---
title: GenPoem
canonical_url: "https://www.modelscope.cn/models/KeanuX/GenPoem"
md_url: "https://www.modelscope.cn/models/KeanuX/GenPoem.md"
repository: KeanuX/GenPoem
chinese_name: PoemGenerater
last_updated: 2024-08-12
license: "Apache License 2.0"
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - bert
architectures:
  - BertLMHeadModel
parameters: 64.4M
tensor_type:
  - F32
library_name:
  - pytorch
  - transformer
  - safetensors
downloads: 205
stars: 1
---

# GenPoem

> GenPoem - KeanuX 在 ModelScope 开源的模型。此模型用于生成古诗词，喜爱古诗的小伙伴可自由使用。

KeanuX/GenPoem 是 ModelScope 魔搭社区上的 64.4M 参数text-generation模型，采用 Apache License 2.0 许可。

- **Repository**: KeanuX/GenPoem
- **License**: Apache License 2.0
- **Tasks**: text-generation
- **Parameters**: 64.4M
- **Downloads**: 205
- **Stars**: 1
- **Last updated**: 2024-08-12

Source: https://www.modelscope.cn/models/KeanuX/GenPoem

---

# GenPoem诗词模型介绍

此模型用于古诗词生成，喜爱中国古诗词的小伙伴可以使用此模型根据自身描述生成你喜爱的古诗词

```
frame：transformers&pytorch
model dtype：float32
padding：max_length
train device：NVIDIA RTX A4000 X2
```


## 部署示例
```
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

if __name__ == '__main__':
    # 模型路径
    model_path = "./models/GenPoem_v1.0.0/"
    
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    
    model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True).to(device)
    
    tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
    
    # 用户输入
    prompt = "高山流水"
    
    # 编码输入
    inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
    
    # 模型推理
    outputs = model.generate(inputs, max_length=150, do_sample=True, top_k=10, top_p=0.95, temperature=0.8)
    
    # 编码输出
    model_res = tokenizer.decode(outputs[0], skip_special_tokens=True)
    
    # 打印输出
    print(f"model_res: {model_res}")
```

------
## 训练数据
| Model | train acc | val acc | train loss | val loss | max_length | LR | train_batch | val_batch |
|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| base v1.0.0 | 0.924 | 0.918 | 5.36 | 5.1 | 512 | 5e-5 | 16 | 8 |
| wait to update | —— | —— | —— | —— | —— | —— | —— | —— |
| wait to update | —— | —— | —— | —— | —— | —— | —— | —— |

此模型不涉及任何费用收取，公开大家使用，喜欢的小伙伴自取，使用transformers框架结合pytorch框架可实现快速部署使用，详细模型参数，词汇列表等请参考相关json配置文件，祝大家生活愉快！
