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

自己怎么做一个企业官网电商网站如何优化

自己怎么做一个企业官网,电商网站如何优化,3000元网站建设三年,合肥网站建设 毅耘在 main() 函数的stream循环中#xff0c;我们可以计算每秒钟生成的token数量#xff0c;然后输出 it/s。在流式生成过程中#xff0c;我们可以使用Python的time模块来计算速度。在测试时#xff0c;生成速度会受到多个因素的影响#xff0c;包括设备性能、模型大小、输入…在 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_dtypetorch.float16,device_mapcuda,trust_remote_codeTrue)model.generation_config GenerationConfig.from_pretrained(baichuan-inc/Baichuan-13B-Chat)tokenizer AutoTokenizer.from_pretrained(baichuan-inc/Baichuan-13B-Chat,use_fastFalse,trust_remote_codeTrue)return model, tokenizerdef clear_screen():if platform.system() Windows:os.system(cls)else:os.system(clear)print(Fore.YELLOW Style.BRIGHT 欢迎使用百川大模型输入进行对话clear 清空历史CTRLC 中断生成stream 开关流式生成exit 结束。)return []def main(streamTrue):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, streamTrue):print(response[position:], end, flushTrue)position len(response)total_tokens len(tokenizer(response, return_tensorspt)[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.hkea.cn/news/14571782/

相关文章:

  • 住房和城乡建设部政务服务门户网站国家企业信息公示网(广东)
  • 肇庆 网站建设公司有哪些专业做室内设计的网站有哪些内容
  • 做网站用什么系统wordpress注册报名
  • 做网站用dw的多吗青岛网站建设方案优化
  • 成都市建设工程施工安监站网站西安建设网站的公司哪家好
  • 网站设计公司 北京中企动力做的 石子厂网站
  • 购买网站空间的方法如何查询网站备案信息
  • 国内大宗商品交易平台镇江网站排名优化公司
  • 网站风格主要包括哪些英文案例网站
  • dede网站模板客官网网站开发框架
  • 网站建设的上市公司淄博网站建设淄博
  • 网站建设与管理的通知如何建立网站教材
  • php网站开发 招聘网站 not found
  • 免费网站空间申请asp网站设置
  • 广州 环保 凡人网站建设国内重大新闻2021
  • 湖南建设教育网站wordpress建立数据库时出错
  • 织梦网站熊掌号改造怎么做wordpress附件详情
  • 深圳品牌网站网站充值平台怎么做的
  • 网站策划win8式网站后台模板
  • 合肥国际网站建设正规平台江苏网站建设
  • 做网站的图片需要多少钱郑州最新防疫进展
  • 南昌大学作风建设网站中国最大的网站制作公司
  • 外贸网站推广和建站怎样设计一个网站
  • 江苏企业建站自己没有货源怎么开网店
  • 开源门户网站iis v6 新建网站
  • 建设电子商务网站总结ui设计在线网站
  • 制造业外贸营销网站建设wordpress默认安装目录
  • 哈尔滨网站建设论坛家在深圳光明业主论坛
  • 重庆网站设计定制一般网站的建设步骤有哪些
  • 女鞋网站建设策划方案网站推广和优化的原因网络营销