40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
import os
|
||
定义 README.md 的内容
|
||
readme_content = """---
|
||
library: transformers
|
||
pipeline_tag: text-generation
|
||
tags:
|
||
- hebei-tourism
|
||
- deepseek
|
||
- llama
|
||
Hebei Tourism Deepseek Model
|
||
This is a fine-tuned model based on deepseek-ai/deepseek-coder-1.3b-base for providing information about tourism in Hebei, China. The model is fine-tuned using the transformers library and supports text generation tasks.
|
||
Usage
|
||
You can use this model with the transformers library:
|
||
python
|
||

|
||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||
|
||
model = AutoModelForCausalLM.from_pretrained("jinv2/hebei-tourism-deepseek")
|
||
tokenizer = AutoTokenizer.from_pretrained("jinv2/hebei-tourism-deepseek")
|
||
|
||
input_text = "介绍一下河北的旅游景点"
|
||
inputs = tokenizer(input_text, return_tensors="pt")
|
||
outputs = model.generate(**inputs, max_length=200)
|
||
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
||
"""
|
||
定义保存路径
|
||
save_path = "/home/mmm/桌面/deepseek/hebei_model_merged/README.md"
|
||
写入 README.md 文件
|
||
try:
|
||
with open(save_path, "w", encoding="utf-8") as f:
|
||
f.write(readme_content)
|
||
print(f"Successfully generated README.md at {save_path}")
|
||
except Exception as e:
|
||
print(f"Failed to generate README.md: {e}")
|
||
验证文件内容
|
||
if os.path.exists(save_path):
|
||
with open(save_path, "r", encoding="utf-8") as f:
|
||
print("\nGenerated README.md content:")
|
||
print(f.read())
|