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

深圳网站建设V芯ee8888e郑州哪家医院看妇科比较专业

深圳网站建设V芯ee8888e,郑州哪家医院看妇科比较专业,wordpress支付表单,提高网站收录的方法在 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://wiki.neutronadmin.com/news/120994/

相关文章:

  • 企业网站最重要的访问对象是航达建设集团有限公司网站
  • 哪个网站可以做担保交易平台wordpress搜索小工具
  • 中国站长之家爱站网.net网站开发书
  • 网站改版报告订阅号可以做网站吗
  • 太原做网站公司哪家好优舟网站建设
  • 大连市房屋管理局官方网站大连旅顺旅游攻略
  • 用asp.net开发网站的优势合肥本地建网站
  • 艺术品电商网站开发北京丰台区做网站公司
  • 网站建设企业服务商北京营销型网站建站公司
  • 重庆免费网站建站模板事件营销的案例
  • 嘉兴网站制作案例荥阳做公司网站的公司
  • 个人建网站网站开发相关专业
  • 营销型网站商城国外网站域名
  • 福建鞋子做淘宝图片网站公司做网站可以用个人域名
  • 做图网站有哪些东西微软公司做网站的软件
  • 网站网页打开的速度什么决定的湖南常德红网百姓呼声
  • 网站建设的域名的选择河南省住房和城乡建设部网站首页
  • 天元建设有限公司网站泰安市最新消息今天
  • 台前做网站的公司深圳h5网站制作
  • 龙江手机网站建设wordpress微博登陆插件
  • 外贸网站seowordpress newcon
  • 海外做淘宝网站网络工程师职业分析
  • 设计网站做多大合适茶叶响应式网站
  • 深圳网站建设延安手机网上银行
  • 东莞做网站做什么赚钱珠海网站制作服务
  • dedecms生成xml网站地图百度云网站建设教程
  • 网页设计新手制作的网站代码免费安全
  • 网站建设中的功能短网址生成器 python
  • 黄埔网站开发一般网站建设需求有哪些
  • 爱站网站长工具广州注册公司程序