书生·浦语 大模型实战营(第三期) 进阶岛 第6关 MindSearch 快速部署

(第三期)书生大模型实战营——LMDeploy量化部署进阶实践 教程原文在。 阅读详情

文档Tutorial/docs/L2/MindSearch/readme_github.md at camp3 · InternLM/Tutorial 

把internstudio换成了github codespace

1. 创建开发机 & 环境配置 

Codespaces (github.com)

 浏览器会自动在新的页面打开一个web版的vscode。  神奇 Edge浏览器一直白网络错误

求助大佬呢  说代理出错 花钱换了代理 不好用  vs code codespace插件直连也不好用 百度说:DNS问题 控制面板 —手动设置/ 使用工具   DnsJumper 都不好用 前前后后大约五天时间浪费,
最后 发现是地域不能选择东南亚 要选择其特 无语。。。。

ps: 选择其他可以

 新建一个目录用于存放 MindSearch 的相关代码,并把 MindSearch 仓库 clone 下来。在终端中运行下面的命令:

mkdir -p /workspaces/mindsearch
cd /workspaces/mindsearch
git clone https://github.com/InternLM/MindSearch.git
cd MindSearch && git checkout b832275 && cd ..

 接下来,我们创建一个 conda 环境来安装相关依赖。

# 创建环境
conda create -n mindsearch python=3.10 -y
# 激活环境
conda activate mindsearch
# 安装依赖
pip install -r /workspaces/mindsearch/MindSearch/requirements.txt

 2. 获取硅基流动 API Key

完成注册后,打开 硅基流动统一登录 来准备 API Key。首先创建新 API 密钥,然后点击密钥进行复制,以备后续使用。

3. 启动 MindSearch

3.1 启动后端

由于硅基流动 API 的相关配置已经集成在了 MindSearch 中,所以我们可以直接执行下面的代码来启动 MindSearch 的后端。

export SILICON_API_KEY=第二步中复制的密钥
conda activate mindsearch
cd /workspaces/mindsearch/MindSearch
python -m mindsearch.app --lang cn --model_format internlm_silicon --search_engine DuckDuckGoSearch
 3.2 启动前端

在后端启动完成后,我们打开新终端运行如下命令来启动 MindSearch 的前端。

conda activate mindsearch
cd /workspaces/mindsearch/MindSearch
python frontend/mindsearch_gradio.py

前后端都启动后,我们应该可以看到github自动为这两个进程做端口转发。

 终于可以体验了

4. 部署到 HuggingFace Space 

打开 https://huggingface.co/spaces ,并点击 Create new Space,输入 Space name 并选择 License 后,选择配置如下所示 如下图所示。 

 打开qq邮箱认证

然后,我们进入 Settings,配置硅基流动的 API Key, 选择 New secrets,name 一栏输入 SILICON_API_KEY,value 一栏输入你的 API Key 的内容。 

 最后,我们先新建一个目录,准备提交到 HuggingFace Space 的全部文件

# 创建新目录
mkdir -p /workspaces/mindsearch/mindsearch_deploy
# 准备复制文件
cd /workspaces/mindsearch
cp -r /workspaces/mindsearch/MindSearch/mindsearch /workspaces/mindsearch/mindsearch_deploy
cp /workspaces/mindsearch/MindSearch/requirements.txt /workspaces/mindsearch/mindsearch_deploy
# 创建 app.py 作为程序入口
touch /workspaces/mindsearch/mindsearch_deploy/app.py

其中,app.py 的内容如下:

import json
import os

import gradio as gr
import requests
from lagent.schema import AgentStatusCode

os.system("python -m mindsearch.app --lang cn --model_format internlm_silicon &")

PLANNER_HISTORY = []
SEARCHER_HISTORY = []


def rst_mem(history_planner: list, history_searcher: list):
    '''
    Reset the chatbot memory.
    '''
    history_planner = []
    history_searcher = []
    if PLANNER_HISTORY:
        PLANNER_HISTORY.clear()
    return history_planner, history_searcher


def format_response(gr_history, agent_return):
    if agent_return['state'] in [
            AgentStatusCode.STREAM_ING, AgentStatusCode.ANSWER_ING
    ]:
        gr_history[-1][1] = agent_return['response']
    elif agent_return['state'] == AgentStatusCode.PLUGIN_START:
        thought = gr_history[-1][1].split('```')[0]
        if agent_return['response'].startswith('```'):
            gr_history[-1][1] = thought + '\n' + agent_return['response']
    elif agent_return['state'] == AgentStatusCode.PLUGIN_END:
        thought = gr_history[-1][1].split('```')[0]
        if isinstance(agent_return['response'], dict):
            gr_history[-1][
                1] = thought + '\n' + f'```json\n{json.dumps(agent_return["response"], ensure_ascii=False, indent=4)}\n```'  # noqa: E501
    elif agent_return['state'] == AgentStatusCode.PLUGIN_RETURN:
        assert agent_return['inner_steps'][-1]['role'] == 'environment'
        item = agent_return['inner_steps'][-1]
        gr_history.append([
            None,
            f"```json\n{json.dumps(item['content'], ensure_ascii=False, indent=4)}\n```"
        ])
        gr_history.append([None, ''])
    return


def predict(history_planner, history_searcher):

    def streaming(raw_response):
        for chunk in raw_response.iter_lines(chunk_size=8192,
                                             decode_unicode=False,
                                             delimiter=b'\n'):
            if chunk:
                decoded = chunk.decode('utf-8')
                if decoded == '\r':
                    continue
                if decoded[:6] == 'data: ':
                    decoded = decoded[6:]
                elif decoded.startswith(': ping - '):
                    continue
                response = json.loads(decoded)
                yield (response['response'], response['current_node'])

    global PLANNER_HISTORY
    PLANNER_HISTORY.append(dict(role='user', content=history_planner[-1][0]))
    new_search_turn = True

    url = 'http://localhost:8002/solve'
    headers = {'Content-Type': 'application/json'}
    data = {'inputs': PLANNER_HISTORY}
    raw_response = requests.post(url,
                                 headers=headers,
                                 data=json.dumps(data),
                                 timeout=20,
                                 stream=True)

    for resp in streaming(raw_response):
        agent_return, node_name = resp
        if node_name:
            if node_name in ['root', 'response']:
                continue
            agent_return = agent_return['nodes'][node_name]['detail']
            if new_search_turn:
                history_searcher.append([agent_return['content'], ''])
                new_search_turn = False
            format_response(history_searcher, agent_return)
            if agent_return['state'] == AgentStatusCode.END:
                new_search_turn = True
            yield history_planner, history_searcher
        else:
            new_search_turn = True
            format_response(history_planner, agent_return)
            if agent_return['state'] == AgentStatusCode.END:
                PLANNER_HISTORY = agent_return['inner_steps']
            yield history_planner, history_searcher
    return history_planner, history_searcher


with gr.Blocks() as demo:
    gr.HTML("""<h1 align="center">MindSearch Gradio Demo</h1>""")
    gr.HTML("""<p style="text-align: center; font-family: Arial, sans-serif;">MindSearch is an open-source AI Search Engine Framework with Perplexity.ai Pro performance. You can deploy your own Perplexity.ai-style search engine using either closed-source LLMs (GPT, Claude) or open-source LLMs (InternLM2.5-7b-chat).</p>""")
    gr.HTML("""
    <div style="text-align: center; font-size: 16px;">
        <a href="https://github.com/InternLM/MindSearch" style="margin-right: 15px; text-decoration: none; color: #4A90E2;">🔗 GitHub</a>
        <a href="https://arxiv.org/abs/2407.20183" style="margin-right: 15px; text-decoration: none; color: #4A90E2;">📄 Arxiv</a>
        <a href="https://huggingface.co/papers/2407.20183" style="margin-right: 15px; text-decoration: none; color: #4A90E2;">📚 Hugging Face Papers</a>
        <a href="https://huggingface.co/spaces/internlm/MindSearch" style="text-decoration: none; color: #4A90E2;">🤗 Hugging Face Demo</a>
    </div>
    """)
    with gr.Row():
        with gr.Column(scale=10):
            with gr.Row():
                with gr.Column():
                    planner = gr.Chatbot(label='planner',
                                         height=700,
                                         show_label=True,
                                         show_copy_button=True,
                                         bubble_full_width=False,
                                         render_markdown=True)
                with gr.Column():
                    searcher = gr.Chatbot(label='searcher',
                                          height=700,
                                          show_label=True,
                                          show_copy_button=True,
                                          bubble_full_width=False,
                                          render_markdown=True)
            with gr.Row():
                user_input = gr.Textbox(show_label=False,
                                        placeholder='帮我搜索一下 InternLM 开源体系',
                                        lines=5,
                                        container=False)
            with gr.Row():
                with gr.Column(scale=2):
                    submitBtn = gr.Button('Submit')
                with gr.Column(scale=1, min_width=20):
                    emptyBtn = gr.Button('Clear History')

    def user(query, history):
        return '', history + [[query, '']]

    submitBtn.click(user, [user_input, planner], [user_input, planner],
                    queue=False).then(predict, [planner, searcher],
                                      [planner, searcher])
    emptyBtn.click(rst_mem, [planner, searcher], [planner, searcher],
                   queue=False)

demo.queue()
demo.launch(server_name='0.0.0.0',
            server_port=7860,
            inbrowser=True,
            share=True)

 在最后,将 /root/mindsearch/mindsearch_deploy 目录下的文件(使用 git)提交到 HuggingFace Space 即可完成部署了。将代码提交到huggingface space的流程如下:

首先创建一个有写权限的token。 进入主页 找到创建的space点击

 

 一些权限勾上

 然后从huggingface把空的代码仓库clone到codespace。

/workspaces/codespaces-blank
git clone https://huggingface.co/spaces/<你的名字>/<仓库名称>
# 把token挂到仓库上,让自己有写权限
git remote set-url space https://<你的名字>:<上面创建的token>@huggingface.co/spaces/<你的名字>/<仓库名称>



##需要先创建/workspaces/codespaces-blank
之后切到 cd /workspaces/codespaces-blank

多了一个空格

现在codespace就是本地仓库,huggingface space是远程仓库,接下来使用方法就和常规的git一样了。 

cd <仓库名称>
# 把刚才准备的文件都copy进来
cp /workspaces/mindsearch/mindsearch_deploy/* .

## cd Mindsearch001

 

注意mindsearch文件夹其实是Mindsearch项目中的一个子文件夹,如果把这个Mindsearch的整个目录copy进来会有很多问题(git submodule无法提交代码,space中项目启动失败等)。

 最后把代码提交到huggingface space会自动启动项目。

git add .
git commit -m "update"
git push

 测试啦。

 

5.美化 Gradio 的界面 

小结:刚开始做这关,不断愈挫,灰心丧气,试了一些方法,最终发现是地域选择,无语。。。。

but,做事要细心。

huggingface的app链接:

Mindsearch001 - a Hugging Face Space by shuli007

https://huggingface.co/spaces/shuli007/Mindsearch001

手把手复现金蝶云星空V8.1文件上传漏洞(附完整POC与修复方案) 本文深度解析金蝶云星空V8.1文件上传漏洞,提供详细的漏洞复现步骤与完整POC,涵盖技术原理、测试环境搭建及验证流程。同时给出多维防护方案,包括官方补丁部署、临时缓解措施和长期安全加固建议,帮助企业有效防范任意文件上传风险。 阅读详情

相关推荐

Python批量注册脚本开发详细

开发一个Python批量注册脚本需要考虑多个方面,包括目标网站的注册流程、验证码处理、请求发送、数据存储等。以下是一个详细的开发流程和代码示例,用于实现基本的批量注册功能。

nsp202505的博客 3358

书生·浦语大模型完成3个模型的部署

Lagent 是一个轻量级、开源的基于大语言模型的智能体(agent)框架,支持用户快速地将一个大语言模型转变为多种类型的智能体,并提供了一些典型工具为大语言模型赋能。通过 Lagent 框架可以更好的发挥 InternLM 的全部性能。

weixin_50256876的博客 1199

最新Mamba环境配置教程:从CUDA到causal-conv1d的完整安装流程

本文提供最新Mamba环境配置教程,涵盖从CUDA到causal-conv1d的完整安装流程。针对深度学习领域的长序列处理需求,详细指导如何正确配置CUDA工具链、安装PyTorch及关键依赖causal-conv1d,解决常见报错问题,并验证mamba-ssm集成效果。

bush的博客 420

大模型实战营第二期——1. 书生·浦语大模型全链路开源开放体系

B站-书生·浦语大模型全链路开源体系数据:汇聚 5400+ 数据集,涵盖多种模态与任务,更多数据集预训练:并行训练,极致优化,速度达到 3600 tokens/sec/gpu微调:全面的微调能力,支持SFT,RLHF和通用工具调用部署:全链路部署,性能领先,每秒生成 2000+ tokens评测:全方位评测,性能可复现,50 套评测集,30 万道题目。

啷个哩个啷 1415

FoundationPose复现及Realsense应用

FoundationPose是一个统一的基础模型,用于6D对象姿态估计和跟踪,支持基于模型和无模型的设置。在测试时可以立即应用于未见过的新对象,无需微调,只要给出其CAD模型,或者捕获少量RGBD参考图像。得益于统一框架,下游姿态估计模块在两种3D模型设置中都是相同的,当没有CAD模型时,使用神经隐式表示进行高效的新视角合成。通过大规模合成训练,辅以大型语言模型(LLM)、一种基于transformer的新架构和对比学习公式,实现了强大的泛化能力。

m0_56661101的博客 1万+

GStreamer —— 2.1、Windows搭建GStreamer环境,Qt加载GStreamer库后运行 - “教程1:Hello world!“(附:完整源码)

GStreamer —— 2、Windows搭建GStreamer环境,Qt加载GStreamer库后运行"教程1:Hello world!"

805

书生·浦语大模型 笔记+作业 LMDeploy 大模型量化部署实践

将训练好的模型在特定软硬件环境中启动的过程,使模型能够接收输入并返回预测结果。为了满足性能和效率的需求,常常需要对模型进行优化,例如模型压缩和硬件加速项目地址: https://github.com/InternLM/lmdeployInternLM 实现在Nvidia设备(服务端)上部署LLM的全流程解决方案turbomind。

kuangkaiming的博客 1045

Python爬虫实战:基于最新技术栈的政府招标采购数据抓取与分析

对于企业、研究人员和数据分析师来说,能够高效地获取这些数据意味着可以获得宝贵的商业洞察和市场先机。随着反爬技术的不断升级和网站结构的日益复杂,传统的爬虫方法已经难以满足需求。我们将采用Selenium、Playwright等现代浏览器自动化工具,结合Scrapy框架和异步请求库,构建一个能够应对各种反爬措施的强大爬虫系统。Playwright是微软开发的浏览器自动化工具,支持Chromium、WebKit和Firefox,比Selenium更快速、更稳定。

2201_76125261的博客 1316

InternVL 多模态模型部署微调实践-进阶

让我们一起修改XTuner下 InternVL的config,文件在: /root/InternLM/code/XTuner/xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_qlora_finetune.py。在这里,我们微调InterenVL使用xtuner。之后我们使用lmdeploy自带的pipeline工具进行开箱即用的推理流程,首先我们新建一个文件。推理后我们发现直接使用2b模型不能很好的讲出梗,现在我们要对这个2b模型进行微调。

wtt88的专栏 800

手把手教你学PCIE-- 热插拔电路设计与实现方案

PCIe热插拔(Hot-Plug)技术允许用户在系统运行时安全地插入或移除设备,而无需重启系统。本文将深入讲解热插拔电路的设计要点、关键器件选型及信号协议规范,涵盖机械结构、电气保护和电源管理三大核心模块。​。

MHD0815的博客 446

[Bug已解决] CUDA error 尽管 CUDA 可用且 GPU 受支持-通用排查 RuntimeError 解决方案

[Bug已解决] CUDA error 尽管 CUDA 可用且 GPU 受支持-通用排查 RuntimeError 解决方案

一键难忘的博客 2419

书生大模型实战营(暑假场)进阶岛关卡六——MindSearch 快速部署

书生大模型实战营(暑假场)进阶岛关卡六——MindSearch 快速部署按照教程,将 MindSearch 部署到 HuggingFace 并美化 Gradio 的界面,并提供截图和 Hugging Face 的Space的链接。解决了一些报错问题总结下git push 遇到的错误: 1.一直说没有给token令牌 美化 Gradio 的界面

HJL1228的博客 2181

热红外图像小目标检测算法综述

热红外小目标检测算法综述,着重介绍基于深度学习的小目标检测算法

Littro Innovations 4251

【书生大模型实战营】进阶岛 第6关 MindSearch 快速部署

随着硅基流动提供了免费的 InternLM2.5-7B-Chat 服务(免费的 InternLM2.5-7B-Chat 真的很香),MindSearch 的部署与使用也就迎来了纯 CPU 版本,进一步降低了部署门槛。打开codespace主页,选择blank template,浏览器会自动在新的页面打开一个web版的vscode。在最后,将 /root/mindsearch/mindsearch_deploy 目录下的文件(使用 git)提交到 HuggingFace Space 即可完成部署了。

人生不是轨道,是旷野。希望每天都有好心情。 1168

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

书生大模型实战营(第三期)-MindSearch 快速部署

书生大模型实战营(第三期)-MindSearch 快速部署

weixin_54561434的博客 1293

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

四期书生大模型实战营(【进阶岛】- 第6关 | MindSearch 快速部署)

闯关任务需要在关键步骤当中截图!任务描述部署MindSearch到 hugging face Spaces上部署MindSearch到 hugging face Spaces上 在官方的MindSearch页面复制Spaces应用到自己的Spaces下,Space 名称中需要包含 MindSearch 关键词,请在必要的步骤以及成功的对话测试结果当中请将作业发布到知乎、CSDN等任一社交媒体,将作业链接提交到以下问卷,助教老师批改后将获得 100 算力点奖励!!!

ban102055的博客 1288

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

书生进阶岛第六关:MindSearch 快速部署

1 MindSearch 简介MindSearch 是一个开源的 AI 搜索引擎框架,具有与 Perplexity.ai Pro 相同的性能。

qq_75269600的博客 2425

第三期书生大模型实战营 进阶岛第6关 MindSearch 快速部署

打开主页,选择blank template。接下来的操作就和我们使用vscode基本没差别了。然后我们新建一个目录用于存放 MindSearch 的相关代码,并把 MindSearch 仓库 clone 下来。接下来,我们创建一个 conda 环境来安装相关依赖。

qq_29983883的博客 1149

进阶岛-第6关-【MindSearch 快速部署】

【代码】进阶岛-第6关-【MindSearch 快速部署】

huixinci的专栏 1032

进阶岛第6关:MindSearch 快速部署

进阶岛第6关:MindSearch 快速部署

weixin_62549128的博客 1584

书生大模型实训营第4期进阶岛第六关:MindSearch 快速部署

书生大模型实训营第4期进阶岛第六关任务笔记

weixin_54052852的博客 1296

书生大模型-进阶岛第6关:MindSearch 快速部署

MindSearch 是一个开源的 AI 搜索引擎框架,具有与 Perplexity.ai Pro 相同的性能。MindSearch 通过搜索解决你在生活中遇到的各种问题MindSearch 通过数百个网页的浏览,提供更广泛、深层次的答案MindSearch 提供了思考路径、搜索关键词等完整的内容,提高回复的可信度和可用性。为 用户提供各种接口,包括 React、Gradio、Streamlit 和本地调试。根据需要选择任意类型。

qq_27520611的博客 777

书生第三期实战营-进阶岛

基础任务使用 Lagent 自定义一个智能体,并使用 Lagent Web Demo 成功部署与调用,记录复现过程并截图。使用 LMDeploy 部署 InternLM2.5-7B-Chat,并启动一个 API Server。在另一个窗口中启动 Lagent 的 Web Demo端口映射后,在本地浏览器中打开地址,并修改模型名称一栏为,修改模型 ip一栏为。插件选择一栏选择,输入指令,帮我搜索一下 MindSearch 论文使用 Lagent 自定义工具主要分为以下几步:继承。

Goodman_____的博客 1072

[InternLM 大模型开源社区]大模型实战营第三期@202408-彩蛋岛-第1关-MindSearch 快速部署

在下面输入问题,点summit。

维克的博客 905

L2G6000书生大模型实战营第4期——3.6 MindSearch 快速部署

使用硅基流动的API来使用和部署MindSearch到 hugging face Spaces上。

wuzipl的博客 2307

第四期书生大模型实战营【进阶岛】—— MindSearch 快速部署

MindSearch是一个开源的 AI 搜索引擎框架,具有与 Perplexity.ai Pro 相同的性能。🤔 任何你想知道的问题:MindSearch 通过搜索解决你在生活中遇到的各种问题。📚 深度知识探索:MindSearch 通过数百个网页的浏览,提供更广泛、深层次的答案。🔍 透明的解决方案路径:MindSearch 提供了思考路径、搜索关键词等完整的内容,提高回复的可信度和可用性。💻 多种用户界面:为用户提供各种接口,包括 React、Gradio、Streamlit 和本地调试。

weixin_45730545的博客 937
上一篇: 书生·浦语 大模型实战营(第三期) 进阶岛 第5关 茴香豆:企业级知识库问答工具
下一篇: 社区共建任务 在 MindSearch 中支持新的搜索 API
毛克卜唠嗑
博客等级 码龄3年 301粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址