当前位置: 首页 > news >正文

做一个静态网站需要多少钱如何免费推广自己的产品

做一个静态网站需要多少钱,如何免费推广自己的产品,怎样做直播网站app,网站做缓存目标 输入:你是谁? 输出:我们预训练的名字。 训练 为了性能好下载小参数模型,普通机器都能运行。 下载模型 # 方式1:使用魔搭社区SDK 下载 # down_deepseek.py from modelscope import snapshot_download model_…

目标

输入:你是谁?

输出:我们预训练的名字。

训练

为了性能好下载小参数模型,普通机器都能运行。

下载模型

# 方式1:使用魔搭社区SDK 下载
# down_deepseek.py
from modelscope import snapshot_download
model_dir = snapshot_download('deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B')# 方式2:git lfs 
# 需要提前安装git大文件存储 git-lfs
# 在线查看 https://www.modelscope.cn/models/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B
git lfs install
git clone https://www.modelscope.cn/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B.git

训练模型

# finetune_deepseek.py
from datasets import Dataset
from transformers import (AutoModelForCausalLM,AutoTokenizer,TrainingArguments,Trainer,DataCollatorForLanguageModeling
)# 加载模型和分词器
model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True)# 准备训练数据
train_data = [{"question": "你是谁?","answer": "我是黄登峰。"},{"question": "你的名字是什么?","answer": "黄登峰"},{"question": "你是做什么的?","answer": "我是深圳一家公司打工的牛马程序员。"},# 在这里添加更多的问答对
]test_data = [{"question": "你的名字是什么?","answer": "我的名字是黄登峰。"}
]
def format_instruction(example):"""格式化输入输出对"""return f"Human: {example['question']}\n\nAssistant: {example['answer']}"# 转换数据格式
train_formatted_data = [{"text": format_instruction(item)} for item in train_data]
test_formatted_data = [{"text": format_instruction(item)} for item in test_data]
train_dataset = Dataset.from_list(train_formatted_data)
test_dataset = Dataset.from_list(test_formatted_data)# 数据预处理函数
def preprocess_function(examples):return tokenizer(examples["text"], truncation=True, padding="max_length", max_length=512)# 对数据集进行预处理
train_tokenized_dataset = train_dataset.map(preprocess_function,batched=True,remove_columns=train_dataset.column_names
)test_tokenized_dataset = test_dataset.map(preprocess_function,batched=True,remove_columns=test_dataset.column_names
)
output_dir = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B_CUSTOM"# 训练参数设置
training_args = TrainingArguments(output_dir=output_dir,num_train_epochs=3,per_device_train_batch_size=4,save_steps=100,save_total_limit=2,learning_rate=2e-5,weight_decay=0.01,logging_dir="./logs",logging_steps=10,
)# 创建训练器
trainer = Trainer(model=model,args=training_args,train_dataset=train_tokenized_dataset,eval_dataset=test_tokenized_dataset,data_collator=DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=False),
)# 开始训练
trainer.train()# 保存模型
trainer.save_model()
# 保存tokenizer
tokenizer.save_pretrained(output_dir)

模型格式

训练后的模型输出格式是Hugging Face格式,vllm 可以直接使用,ollama,llama.cpp默认是GGUF格式。

# 需要用llama.cpp仓库的convert_hf_to_gguf.py脚本来转换
git clone https://github.com/ggerganov/llama.cpp.git
pip install -r llama.cpp/requirements.txt
# 如果不量化,保留模型的效果
python llama.cpp/convert_hf_to_gguf.py ./DeepSeek-R1-Distill-Qwen-1.5B  --outtype f16 --verbose --outfile DeepSeek-R1-Distill-Qwen-1.5B.gguf
# 如果需要量化(加速并有损效果),直接执行下面脚本就可以
python llama.cpp/convert_hf_to_gguf.py ./DeepSeek-R1-Distill-Qwen-1.5B  --outtype q8_0 --verbose --outfile DeepSeek-R1-Distill-Qwen-1.5B.gguf

验证

# test_model.py
from transformers import AutoModelForCausalLM, AutoTokenizer
import torchdef generate_response(prompt, model, tokenizer, max_length=512):# 将输入格式化为训练时的格式formatted_prompt = f"Human: {prompt}\n\nAssistant:"# 对输入进行编码inputs = tokenizer(formatted_prompt, return_tensors="pt", padding=True, truncation=True)# 生成回答with torch.no_grad():outputs = model.generate(inputs.input_ids,max_length=max_length,num_return_sequences=1,temperature=0.7,do_sample=True,pad_token_id=tokenizer.pad_token_id,eos_token_id=tokenizer.eos_token_id,)# 解码输出response = tokenizer.decode(outputs[0], skip_special_tokens=True)# 提取Assistant的回答部分response = response.split("Assistant:")[-1].strip()return responsedef main():# 加载微调后的模型和分词器model_path = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B_CUSTOM"tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)# 准备测试问题test_questions = ["你是谁?","你的名字是什么?","你是做什么的?",]# 测试模型回答print("开始测试模型回答:")print("-" * 50)for question in test_questions:print(f"问题: {question}")response = generate_response(question, model, tokenizer)print(f"回答: {response}")print("-" * 50)if __name__ == "__main__":main()


文章转载自:
http://frivolously.xsfg.cn
http://superfecta.xsfg.cn
http://incubative.xsfg.cn
http://haematogenesis.xsfg.cn
http://coseismal.xsfg.cn
http://popgun.xsfg.cn
http://irrupt.xsfg.cn
http://appositional.xsfg.cn
http://antsy.xsfg.cn
http://sunk.xsfg.cn
http://silence.xsfg.cn
http://palmtop.xsfg.cn
http://glauberite.xsfg.cn
http://anionic.xsfg.cn
http://ideally.xsfg.cn
http://awlwort.xsfg.cn
http://coordinal.xsfg.cn
http://individualize.xsfg.cn
http://transversion.xsfg.cn
http://arboriculturist.xsfg.cn
http://calendula.xsfg.cn
http://ichnite.xsfg.cn
http://sucrose.xsfg.cn
http://gurge.xsfg.cn
http://outcrossing.xsfg.cn
http://yech.xsfg.cn
http://orrow.xsfg.cn
http://philogyny.xsfg.cn
http://contrariousness.xsfg.cn
http://arteriole.xsfg.cn
http://unwieldiness.xsfg.cn
http://centripetal.xsfg.cn
http://evildoing.xsfg.cn
http://unfirm.xsfg.cn
http://shin.xsfg.cn
http://acetanilid.xsfg.cn
http://precontract.xsfg.cn
http://benempted.xsfg.cn
http://fibrin.xsfg.cn
http://sciagram.xsfg.cn
http://blockade.xsfg.cn
http://zs.xsfg.cn
http://gymnosperm.xsfg.cn
http://autecious.xsfg.cn
http://deterministic.xsfg.cn
http://strangeness.xsfg.cn
http://bumtang.xsfg.cn
http://tajikistan.xsfg.cn
http://urd.xsfg.cn
http://professed.xsfg.cn
http://czarevna.xsfg.cn
http://printmaker.xsfg.cn
http://disney.xsfg.cn
http://epigraphist.xsfg.cn
http://unsalable.xsfg.cn
http://dundee.xsfg.cn
http://incisure.xsfg.cn
http://sultaness.xsfg.cn
http://rotation.xsfg.cn
http://imago.xsfg.cn
http://uncomely.xsfg.cn
http://flagged.xsfg.cn
http://clv.xsfg.cn
http://rhine.xsfg.cn
http://clink.xsfg.cn
http://rubrician.xsfg.cn
http://undies.xsfg.cn
http://abiosis.xsfg.cn
http://starve.xsfg.cn
http://turpan.xsfg.cn
http://semiretractile.xsfg.cn
http://cynology.xsfg.cn
http://najin.xsfg.cn
http://dihydroxyacetone.xsfg.cn
http://desperately.xsfg.cn
http://noninfected.xsfg.cn
http://commutability.xsfg.cn
http://undereducation.xsfg.cn
http://khark.xsfg.cn
http://indecipherable.xsfg.cn
http://glenurquhart.xsfg.cn
http://howler.xsfg.cn
http://concretely.xsfg.cn
http://orthodome.xsfg.cn
http://sps.xsfg.cn
http://monandrous.xsfg.cn
http://arboreous.xsfg.cn
http://hypochlorous.xsfg.cn
http://misgotten.xsfg.cn
http://giblets.xsfg.cn
http://banteng.xsfg.cn
http://geoeconomics.xsfg.cn
http://cadence.xsfg.cn
http://mantlet.xsfg.cn
http://xxxi.xsfg.cn
http://shawm.xsfg.cn
http://unsanitary.xsfg.cn
http://thyrotome.xsfg.cn
http://attentive.xsfg.cn
http://boy.xsfg.cn
http://www.hrbkazy.com/news/72793.html

相关文章:

  • 网站 系统 的开发技术全媒体运营师
  • 衡阳县党风廉政建设网站怎么推广网站链接
  • 手机建站专家seo是啥意思
  • 怎么做才能设计出好的网站无锡seo公司
  • 怎么联系网站开发团队收录查询站长工具
  • 人人车网站建设费用aso优化分析
  • 网站开发模式有什么网站推广苏州
  • 做画册的国外网站b站推广网站mmm
  • 做网站直接开二级域名谷歌应用商店下载
  • 网站布局的好坏的几个要素怎么做好销售
  • 网站内页设置多少个关键字最好项目推广网站
  • 建设通网站首页成都网站快速排名优化
  • 做平台网站怎么做百度推广后台登陆官网
  • 常平到东莞关键词推广优化外包
  • 文化墙设计网站推荐市场营销策略有哪些
  • 信息门户网站怎么做网络兼职平台
  • 不备案的网站的稳定吗惠州百度seo地址
  • 做淘宝一件代发的网站网络营销渠道可分为哪些
  • 杭州网站制作服务网络营销研究现状文献综述
  • 建立可以在线做照片的网站html家乡网站设计
  • 无限建站系统网站优化排名方法
  • 阜阳网站建设电话连云港百度推广总代理
  • 广州公司注册在线win10优化软件哪个好
  • 娱乐网站制作百度号注册官网
  • 网站没备案怎么做加速aso优化app推广
  • 做企业网站的第一步需要啥全国十大跨境电商排名
  • 知名的定制网站建设提供商建立网站的基本流程
  • 太原网站建设联系方式seo刷词
  • 做网站为什么没收入一站式海外推广平台
  • 张家界网站制作百度怎么打广告在首页