使用fastchat实现大模型高并发对话

手动执行脚本

python3 -m fastchat.serve.controller
CUDA_VISIBLE_DEVICES=0 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory "44GiB" --port 31001 --worker http://localhost:31001 --load-8bit
CUDA_VISIBLE_DEVICES=0 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory "44GiB" --port 31002 --worker http://localhost:31002 --load-8bit
CUDA_VISIBLE_DEVICES=1 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory "44GiB" --port 31003 --worker http://localhost:31003 --load-8bit
CUDA_VISIBLE_DEVICES=1 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory "44GiB" --port 31004 --worker http://localhost:31004 --load-8bit
python3 -m fastchat.serve.gradio_web_server --concurrency-count=150

脚本一键启动

import subprocess
import multiprocessing
import time
import fastchat.serve.gradio_web_server

def execute_command(command):
    # Execute the command
    try:
        subprocess.run(command, shell=True, check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error executing command: {e}")

if __name__ == "__main__":
    scripts = [
        "python3 -m fastchat.serve.controller",
        "CUDA_VISIBLE_DEVICES=0 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory 44GiB --port 31001 --worker http://localhost:31001 --load-8bit",
        "CUDA_VISIBLE_DEVICES=0 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory 44GiB --port 31002 --worker http://localhost:31002 --load-8bit",
        "CUDA_VISIBLE_DEVICES=1 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory 44GiB --port 31003 --worker http://localhost:31003 --load-8bit",
        "CUDA_VISIBLE_DEVICES=1 python3 -m fastchat.serve.model_worker --model-path /home/NLP/LLM/pretrained_model/LanguageModels/ChatGLM2_6B --limit-worker-concurrency 100 --max-gpu-memory 44GiB --port 31004 --worker http://localhost:31004 --load-8bit",
        "python3 -m fastchat.serve.gradio_web_server --concurrency-count=150"
    ]
    processes = []
    start_time = 10
    add_time = 5
    for script in scripts:
        # Create a new process for each command
        p = multiprocessing.Process(target=execute_command, args=(script,))
        processes.append(p)

    for p in processes:
        p.start()
        # Wait for 5 seconds before starting the next process
        time.sleep(start_time)
        start_time += add_time

    for p in processes:
        p.join()
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
FastChat是一个文本嵌入模型,它可以用于文本相似度计算和文本匹配任务。FastChat通过学习将文本映射到低维向量空间中的嵌入表示,从而捕捉文本之间的语义信息。 FastChat模型主要由两个组成部分构成:句子嵌入的编码器和相似度计算的度量方法。 首先,FastChat使用编码器将句子嵌入到低维向量空间中。编码器通常是基于深度学习的模型,如卷积神经网络(CNN)或循环神经网络(RNN)。编码器网络将输入文本进行特征提取,并将其转换为固定长度的向量表示。这个向量表示能够保留文本的语义信息,并能够被用来计算文本之间的相似度。 其次,FastChat采用一种度量方法来计算文本之间的相似度。一种常见的度量方法是余弦相似度。余弦相似度度量了两个向量之间的夹角,夹角越小,表示两个向量越相似。因此,通过计算两个文本向量的余弦相似度,就可以得到它们之间的相似度分数。 FastChat的优势在于它能够快速且准确地计算文本之间的相似度。由于FastChat使用了低维的向量表示,计算相似度的复杂度相对较低。这使得FastChat在实际应用中具有高效性和实用性。 总而言之,FastChat是一个重要的文本嵌入模型,它通过将文本转换为低维向量表示,并通过度量方法计算文本相似度。这个模型在很多自然语言处理任务中都有广泛的应用,如文本匹配、问答系统、推荐系统等。它为我们提供了一种有效的方式来捕捉和比较文本之间的语义信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

羊城迷鹿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值