开发者社区> 问答> 正文

在LLM大语言模型如果我开多进程同时调用的话,对性能会有提升吗?

在LLM大语言模型如果我开多进程同时调用的话,对性能会有提升吗?

展开
收起
三分钟热度的鱼 2024-04-17 18:32:04 12 0
1 条回答
写回答
取消 提交回答
  • 多线程需要用CB模式:

    1. 模型加载qwen_model(model_path, tp_size, precision, enable_cb = True), 增加enable_cb = True
    2. 推理调用generate_cb_async函数(非async调用generate_cb)
      results_generator = model.generate_cb_async(intpu_id, generation_config=generation_config)
      response = ""
      total_tokens = 0
      async for request_output in results_generator:
      if(request_output == -1):
         response += streamer.end()
         total_tokens += 1
         break
      
      else:
         response += streamer.handel_str(request_output)
         total_tokens += 1  此回答整理自钉群“LLM大语言模型-阿里云支持”
      
    2024-04-17 18:53:20
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PAI灵骏智算 构建全链路LLM服务的最佳实践 立即下载
服务上云加速大家居产业C2M进程 立即下载
低代码开发师(初级)实战教程 立即下载