Emaoso commited on
Commit
e68736f
·
verified ·
1 Parent(s): 33146b7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +48 -7
README.md CHANGED
@@ -1,11 +1,52 @@
1
- # my-qwen2.5-tangshi-ollama-model
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- Ollama model wrapper pointing to the GGUF produced from `my-qwen2.5-tangshi-model`.
 
4
 
5
- Modelfile:
 
 
 
 
 
6
 
7
- ```
8
- FROM ../my-qwen2.5-tangshi-model/Model-494M-F16.gguf
9
- ```
 
10
 
11
- Place this folder under Ollama's models directory or use `ollama pull` / `ollama import` as needed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - zh
4
+ license: apache-2.0
5
+ base_model: Qwen/Qwen2.5-0.5B
6
+ pipeline_tag: text-generation
7
+ tags:
8
+ - 唐诗
9
+ - 古诗生成
10
+ - chinese-poetry
11
+ - qwen2.5
12
+ ---
13
 
14
+ # Tangshi|中文唐诗生成模型
15
+ 基于Qwen2.5-0.5B微调的古诗专用大模型,擅长自动生成五言/七言绝句、律诗,专为古典诗词创作优化。训练数据为57000首唐诗全参数。
16
 
17
+ ## 仓库信息
18
+ Huggingface地址:`Emaoso/Tangshi`
19
+ 包含两类权重:
20
+ 1. `model.safetensors`:原生transformers权重,用于Python代码调用
21
+ 2. `model-ollama.gguf`:GGUF量化权重,用于Ollama本地部署
22
+ 附带:Ollama一键构建配置 Modelfile
23
 
24
+ ## 一、Python Transformers调用(推荐)
25
+ ### 1.安装依赖
26
+ ```bash
27
+ pip install torch transformers
28
 
29
+
30
+ ====================================
31
+ 代码示例
32
+ from transformers import AutoTokenizer, AutoModelForCausalLM
33
+
34
+ model_name = "Emaoso/Tangshi"
35
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
36
+ model = AutoModelForCausalLM.from_pretrained(model_name)
37
+
38
+ # 写诗指令
39
+ prompt = "写一首春日五言绝句"
40
+ inputs = tokenizer(prompt, return_tensors="pt")
41
+ outputs = model.generate(**inputs, max_new_tokens=80)
42
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
43
+
44
+ # 清洗多余注释
45
+ import re
46
+ result = re.sub(r'(.*|〖.*|见卷.*','',result)
47
+ print(result)
48
+
49
+ ======================================
50
+ ollama 使用
51
+ ollama create tangshi https://huggingface.co/Emaoso/Tangshi/resolve/main/Modelfile
52
+ ollama run tangshi