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

云服务器ecs是什么seo专员是干嘛的

云服务器ecs是什么,seo专员是干嘛的,做线上兼职哪个网站比较靠谱,网站建设合同模板下载在 main() 函数的stream循环中,我们可以计算每秒钟生成的token数量,然后输出 it/s。在流式生成过程中,我们可以使用Python的time模块来计算速度。在测试时,生成速度会受到多个因素的影响,包括设备性能、模型大小、输入…

main() 函数的stream循环中,我们可以计算每秒钟生成的token数量,然后输出 it/s。在流式生成过程中,我们可以使用Python的time模块来计算速度。在测试时,生成速度会受到多个因素的影响,包括设备性能、模型大小、输入文本长度等。

import os
import torch
import platform
from colorama import Fore, Style
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.generation.utils import GenerationConfig
import timedef init_model():print("init model ...")model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-13B-Chat",torch_dtype=torch.float16,device_map="cuda",trust_remote_code=True)model.generation_config = GenerationConfig.from_pretrained("baichuan-inc/Baichuan-13B-Chat")tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-13B-Chat",use_fast=False,trust_remote_code=True)return model, tokenizerdef clear_screen():if platform.system() == "Windows":os.system("cls")else:os.system("clear")print(Fore.YELLOW + Style.BRIGHT + "欢迎使用百川大模型,输入进行对话,clear 清空历史,CTRL+C 中断生成,stream 开关流式生成,exit 结束。")return []def main(stream=True):model, tokenizer = init_model()messages = clear_screen()while True:prompt = input(Fore.GREEN + Style.BRIGHT + "\n用户:" + Style.NORMAL)if prompt.strip() == "exit":breakif prompt.strip() == "clear":messages = clear_screen()continueprint(Fore.CYAN + Style.BRIGHT + "\nBaichuan:" + Style.NORMAL, end='')if prompt.strip() == "stream":stream = not streamprint(Fore.YELLOW + "({}流式生成)\n".format("开启" if stream else "关闭"), end='')continuemessages.append({"role": "user", "content": prompt})if stream:position = 0try:start_time = time.time()total_tokens = 0for response in model.chat(tokenizer, messages, stream=True):print(response[position:], end='', flush=True)position = len(response)total_tokens += len(tokenizer(response, return_tensors='pt')['input_ids'][0])if torch.backends.mps.is_available():torch.mps.empty_cache()end_time = time.time()elapsed_time = end_time - start_timetokens_per_second = total_tokens / elapsed_timeprint(f"\n\n生成速度:{tokens_per_second:.2f} tokens/s")except KeyboardInterrupt:passprint()else:response = model.chat(tokenizer, messages)print(response)if torch.backends.mps.is_available():torch.mps.empty_cache()messages.append({"role": "assistant", "content": response})print(Style.RESET_ALL)if __name__ == "__main__":main()

http://www.dt0577.cn/news/45854.html

相关文章:

  • 沈阳企业自助建站网络营销策划案范本
  • 网站开发 实时更新业务推广平台
  • web网站开发能实现上传文件关键的近义词
  • 个人外贸公司网站免费换友情链接
  • 宁波网站建设设计百度快照优化的优势是什么
  • 做h5网站要多少钱百度退款客服电话
  • 顺义建站好的公司网站模板下载免费
  • 定制版网站建设详细报价友情链接交换的作用在于
  • 保定高端模板建站石家庄seo公司
  • 如果网站被攻击了快速排名软件seo系统
  • 江苏建设监理协会网站网站推广的基本方法有哪些
  • 河南郑州旅游网站制作淮北seo排名
  • 网站制作软件手机178软文网
  • 做企业内刊有哪些网站推荐国内搜索引擎有哪些
  • 网站如何做seo优化网站域名备案信息查询
  • 平面设计素材免费网站有哪些网站seo优化报告
  • wordpress非官方优化外包服务公司
  • 仿站小工具使用教程活动推广方式都有哪些
  • 医院互联网网站建设出售外链
  • wordpress评论qqseo关键词优化推广价格
  • 北京做企业网站的公司推广app平台
  • 做盗版电影网站问题网站关键词优化外包
  • 免费商城网站建设中公教育培训机构官网
  • 3d家装效果图制作软件短视频seo询盘获客系统
  • 3g网站建设移动网站如何优化排名
  • 游戏网站怎么赚钱seo优化顾问
  • 网站建设关于公司怎么写超级外链吧
  • 关于做代购网站的纳税知识深圳专业seo
  • 网站建立公司四川培训心得体会300字
  • 房产网站代运营百度信息流广告怎么投放