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

网站报名照片怎么做网络营销的50种方法

网站报名照片怎么做,网络营销的50种方法,福田做网站,关于我市政府网站建设的讲话在 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.tj-hxxt.cn/news/78029.html

相关文章:

  • 如何建立公司网站模块百度网页入口官网
  • 网站制作开发的步骤和方法营销网点机构号
  • 做网站风险四川百度推广排名查询
  • 仿淘宝网站疫情最新数据消息
  • 福州网站制作系统关键词优化外包
  • 品牌营销模式搜索引擎优化叫什么
  • 请公司建网站公关
  • 企业网站网址举例百度登录页面
  • 广州做网站信科分公司百度培训
  • 怎样做汽车网站建设爱站权重查询
  • 哈尔滨网站开发公司电话十大外贸电商平台
  • 批发网站建设平台百度人工客服24小时
  • 青岛网站建设服务新闻头条今天最新消息
  • 综合b2b网站有哪些百度第三季度财报2022
  • 网站建设 中企动力上海网络营销工作内容和职责
  • 河南建设人才信息网王通seo教程
  • oa连接到网站的链接怎么做网站建设一般多少钱
  • 做免费网站安全吗比较火的推广软件
  • 郑州网站建设信息如何优化seo
  • wordpress免费电子商务插件游戏优化是什么意思?
  • 做视频直播网站做个公司网站一般需要多少钱
  • 免费网页空间代码seo优化网站网页教学
  • 昆明网站建设推荐seo海外推广
  • 网店怎么做seo最强
  • 大连网站开发 选领超科技企业营销策划论文
  • 如何做建材团购网站江西seo推广
  • 美食城网站建设策划书品牌推广方案案例
  • 网站等级保护如何做市场调研表模板
  • 扬州网站建设制作爱站网关键词怎么挖掘
  • 网站开发就是ssh吗销售网站有哪些