PyVision:基于动态工具的具身智能体

论文地址:

[2507.07998v1] PyVision: Agentic Vision with Dynamic Tooling

1. 背景 

现有的智能体一般都是通过大模型规划调用已经预定义好的一些工具(具体来说也就是一些函数)来解决问题。这样就会导致在针对特征的任务上Agent去解决问题缺乏灵活性。所以这篇文章就提出了pyVision来在解决特定问题的时候,针对任务具体的生成一些工具(函数或者也这说是代码)来提高智能体解决问题的能力。

2.框架架构

从示意图中可以看到PyVision 使一个多语言大语言模型(MLLM) 能够在推理过程中动态生成并执行Python 代码。在每个会话中,MLLM 接收一个输入(Input),生成相应的Python 代码,并在一个隔离的Python 运行环境中执行它。生成的输出——文本、视觉或两者皆有——会反馈回MLLM 的上下文,使其能够在多轮中迭代和完善其推理,直到产生最终答案。 

其中:

  • code_block_i 指的是MLLM 在第i 轮生成的Python 代码。
  • mm_clue_i 指的是Python 解释器执行后的多模态输出。

3.具体推理案例

在文章中提到了针对几个不同领域特定的任务,来使用pyVsion来解决视觉推理的例子。

3.1 视觉搜索

3.2 医学图像分析

 3.3 符号视觉谜题

 3.4视觉草图绘制

 3.5 视觉差异比较

 3.6 视频理解

 4 论文结论

从图中可以看到选择的这几种的任务数据集上,其中:

MathVista和MathVision-mini其中主要是多模态数学。用于测试LLM在具有需要视觉感知和数值推理的数学问题的表现。

MMMU:其中主要是测试跨学科的特定领域推理。

VisualPUzzles和VLMAreBlind-mini:里面主要是符号视觉谜题组成,用于测试LLM探索对抽象、结构化视觉原语
进行解析和推理的极限。

V∗主要用于测试LLM精确识别微妙的视觉细节。

从图中可以看到,在GPT-4.1的使用了Pyvision之后的PyVision-GPT-4.1在 MathVista的测试上提升了1.8%(也就是从69.9%-71.7%)同样的也可以看到在其他任务上也得到了一些提升。但是相比于o1 o3这些模型上面,其实还是差了不少。也同样说明这个框架中所用的后端大模型对于整体在解决这些问题上也是很重要的。

5. 代码复现

项目源码:https://github.com/agents-x-project/PyVision

DEMO:https://huggingface.co/spaces/Agents-X/PyVision

源码解析:

1. 配置LLM的API配置

项目里面提供了三种LLM的配置,分别是openai, auzre和vllm。其中配置文件是放在:

./api_config_files/api_config_*

2. 提示词模版

#英文原版
{"retool": "Solve the following problem step by step. You now have the ability to selectively write executable Python code to enhance your reasoning process. The Python code will be executed by an external sandbox, and the output (wrapped in `<interpreter>output_str</interpreter>`) can be returned to aid your reasoning and help you arrive at the final answer. The Python code should be complete scripts, including necessary imports. \nEach code snippet is wrapped with `<code>\n```python\ncode snippet\n```\n</code>`.\nThe last part of your response should be in the following format:\n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>\n\n*user question:*\nAnswer the following Math Problem and put the answer in the format of \\boxed{{answer}}\n\n{query}\n\n\nRemember to place the final answer in the last part using the format: \n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>","vistool": "Solve the following problem step by step. You now have the ability to selectively write executable Python code to enhance your reasoning process. The Python code will be executed by an external sandbox.\n\nFor all the provided images, in order, the i-th image has already been read into the global variable `image_clue_i` using the PIL.Image.open() function. When writing Python code, you can directly use these variables without needing to read them again.\n\nSince you are dealing with the VQA task, you MUST use the python tool (e.g., matplotlib library) to analyze or transform images whenever it could improve your understanding or aid your reasoning. This includes but is not limited to zooming in, rotating, adjusting contrast, computing statistics, or isolating features. \n\nNote that when you use matplotlib to visualize data or further process images, you need to use plt.show() to display these images; there is no need to save them. Do not use image processing libraries like cv2 or PIL. If you want to check the value of a variable, you MUST use print() to check it.\n\nThe output (wrapped in `<interpreter>output_str</interpreter>`) can be returned to aid your reasoning and help you arrive at the final answer. The Python code should be complete scripts, including necessary imports. \nEach code snippet is wrapped with `<code>\n```python\ncode snippet\n```\n</code>`.\nThe last part of your response should be in the following format:\n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>\n\n*user question:*\nAnswer the following Problem with an image provided and put the answer in the format of \\boxed{{answer}}\n\n{query}\n\nRemember to place the final answer in the last part using the format: \n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>","vistool_with_img_info": "Solve the following problem step by step. You now have the ability to selectively write executable Python code to enhance your reasoning process. The Python code will be executed by an external sandbox.\n\nFor all the provided images, in order, the i-th image has already been read into the global variable `image_clue_i` using the PIL.Image.open() function. When writing Python code, you can directly use these variables without needing to read them again.\n\nSince you are dealing with the VQA task, you MUST use the python tool (e.g., matplotlib library) to analyze or transform images whenever it could improve your understanding or aid your reasoning. This includes but is not limited to zooming in, rotating, adjusting contrast, computing statistics, or isolating features. \n\nNote that when you use matplotlib to visualize data or further process images, you need to use plt.show() to display these images; there is no need to save them. Do not use image processing libraries like cv2 or PIL. If you want to check the value of a variable, you MUST use print() to check it.\n\nThe output (wrapped in `<interpreter>output_str</interpreter>`) can be returned to aid your reasoning and help you arrive at the final answer. The Python code should be complete scripts, including necessary imports. \nEach code snippet is wrapped with `<code>\n```python\ncode snippet\n```\n</code>`.\nThe last part of your response should be in the following format:\n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>\n\n*image resolution:*\n\nImage Width: {width}; Image Height: {height}\n\n*user question:*\nAnswer the following Problem with an image provided and put the answer in the format of \\boxed{{answer}}\n\n{query}\n\nRemember to place the final answer in the last part using the format: \n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>","vistool_with_img_info_multi_image": "Solve the following problem step by step. You now have the ability to selectively write executable Python code to enhance your reasoning process. The Python code will be executed by an external sandbox.\n\nFor all the provided images, in order, the i-th image has already been read into the global variable `image_clue_i` using the PIL.Image.open() function. When writing Python code, you can directly use these variables without needing to read them again.\n\nSince you are dealing with the VQA task, you MUST use the python tool (e.g., matplotlib library) to analyze or transform images whenever it could improve your understanding or aid your reasoning. This includes but is not limited to zooming in, rotating, adjusting contrast, computing statistics, or isolating features. \n\nNote that when you use matplotlib to visualize data or further process images, you need to use plt.show() to display these images; there is no need to save them. Do not use image processing libraries like cv2 or PIL. If you want to check the value of a variable, you MUST use print() to check it.\n\nThe output (wrapped in `<interpreter>output_str</interpreter>`) can be returned to aid your reasoning and help you arrive at the final answer. The Python code should be complete scripts, including necessary imports. \nEach code snippet is wrapped with `<code>\n```python\ncode snippet\n```\n</code>`.\nThe last part of your response should be in the following format:\n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>\n\n*image resolution:*\n\n{image_information}\n\n*user question:*\nAnswer the following Problem with an image provided and put the answer in the format of \\boxed{{answer}}\n\n{query}\n\nRemember to place the final answer in the last part using the format: \n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>","vistool_with_img_info_v2": "You are an agent - please keep going until the user’s query is completely resolved, before ending your turn and yielding back to the user. Only terminate your turn when you are sure that the problem is solved. \n\nSolve the following problem step by step. You now have the ability to selectively write executable Python code to enhance your reasoning process. The Python code will be executed by an external sandbox. \n\nYou MUST plan extensively before each function call, and reflect extensively on the outcomes of the previous function calls. DO NOT do this entire process by making function calls only, as this can impair your ability to solve the problem and think insightfully.\n\nFor all the provided images, in order, the i-th image has already been read into the global variable `image_clue_i` using the PIL.Image.open() function. When writing Python code, you can directly use these variables without needing to read them again.\n\nSince you are dealing with the vision-related question answering task, you MUST use the python tool (e.g., matplotlib library) to analyze or transform images whenever it could improve your understanding or aid your reasoning. This includes but is not limited to zooming in, rotating, adjusting contrast, computing statistics, or isolating features. \n\nNote that when you use matplotlib to visualize data or further process images, you need to use plt.show() to display these images; there is no need to save them. Do not use image processing libraries like cv2 or PIL. If you want to check the value of a variable, you MUST use print() to check it.\n\nThe output (wrapped in `<interpreter>output_str</interpreter>`) can be returned to aid your reasoning and help you arrive at the final answer. The Python code should be complete scripts, including necessary imports. \nEach code snippet is wrapped with `<code>\n```python\ncode snippet\n```\n</code>`.\nThe last part of your response should be in the following format:\n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>\n\n*image resolution:*\n\nImage Width: {width}; Image Height: {height}\n\n*user question:*\nAnswer the following Problem with an image provided and put the answer in the format of \\boxed{{answer}}\n\n{query}\n\nRemember to place the final answer in the last part using the format: \n<answer>\n\\boxed{{'The final answer goes here.'}}\n</answer>","no_tool": "You are a helpful assistant. And you are dealing with the VQA tasks. Solve the visual questions step by step and give the correct answer. Note: put your answer in the format of \"\\boxed{{the right answer here}}\"\n *user question*:\n{query}","no_tool_no_cot": "Question:\n{query}\nGive the correct answer directly, in the format of \"Final Answer:\\boxed{{the final answer here}}\"\n"
}#中文版
{"retool": "逐步解决以下问题。您现在有能力选择性地编写可执行的Python代码来增强您的推理过程。Python代码将由外部沙盒执行,输出(包装在`<interpreter>output_str</interpreter>`中)可以返回以帮助您的推理并帮助您得出最终答案。Python代码应该是完整的脚本,包括必要的导入。\n每个代码片段都用`<code>\n```python\n代码片段\n```\n</code>`包装。\n您回答的最后部分应该采用以下格式:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>\n\n*用户问题:*\n回答以下数学问题并将答案放在\\boxed{{answer}}格式中\n\n{query}\n\n\n记住在最后部分使用以下格式放置最终答案:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>","vistool": "逐步解决以下问题。您现在有能力选择性地编写可执行的Python代码来增强您的推理过程。Python代码将由外部沙盒执行。\n\n对于所有提供的图像,按顺序,第i个图像已经使用PIL.Image.open()函数读入全局变量`image_clue_i`中。在编写Python代码时,您可以直接使用这些变量,而无需再次读取它们。\n\n由于您正在处理VQA任务,每当可以改善您的理解或帮助您的推理时,您必须使用python工具(例如,matplotlib库)来分析或转换图像。这包括但不限于放大、旋转、调整对比度、计算统计信息或隔离特征。\n\n请注意,当您使用matplotlib可视化数据或进一步处理图像时,您需要使用plt.show()来显示这些图像;无需保存它们。不要使用cv2或PIL等图像处理库。如果您想检查变量的值,您必须使用print()来检查它。\n\n输出(包装在`<interpreter>output_str</interpreter>`中)可以返回以帮助您的推理并帮助您得出最终答案。Python代码应该是完整的脚本,包括必要的导入。\n每个代码片段都用`<code>\n```python\n代码片段\n```\n</code>`包装。\n您回答的最后部分应该采用以下格式:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>\n\n*用户问题:*\n回答以下提供图像的问题并将答案放在\\boxed{{answer}}格式中\n\n{query}\n\n记住在最后部分使用以下格式放置最终答案:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>","vistool_with_img_info": "逐步解决以下问题。您现在有能力选择性地编写可执行的Python代码来增强您的推理过程。Python代码将由外部沙盒执行。\n\n对于所有提供的图像,按顺序,第i个图像已经使用PIL.Image.open()函数读入全局变量`image_clue_i`中。在编写Python代码时,您可以直接使用这些变量,而无需再次读取它们。\n\n由于您正在处理VQA任务,每当可以改善您的理解或帮助您的推理时,您必须使用python工具(例如,matplotlib库)来分析或转换图像。这包括但不限于放大、旋转、调整对比度、计算统计信息或隔离特征。\n\n请注意,当您使用matplotlib可视化数据或进一步处理图像时,您需要使用plt.show()来显示这些图像;无需保存它们。不要使用cv2或PIL等图像处理库。如果您想检查变量的值,您必须使用print()来检查它。\n\n输出(包装在`<interpreter>output_str</interpreter>`中)可以返回以帮助您的推理并帮助您得出最终答案。Python代码应该是完整的脚本,包括必要的导入。\n每个代码片段都用`<code>\n```python\n代码片段\n```\n</code>`包装。\n您回答的最后部分应该采用以下格式:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>\n\n*图像分辨率:*\n\n图像宽度:{width};图像高度:{height}\n\n*用户问题:*\n回答以下提供图像的问题并将答案放在\\boxed{{answer}}格式中\n\n{query}\n\n记住在最后部分使用以下格式放置最终答案:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>","vistool_with_img_info_multi_image": "逐步解决以下问题。您现在有能力选择性地编写可执行的Python代码来增强您的推理过程。Python代码将由外部沙盒执行。\n\n对于所有提供的图像,按顺序,第i个图像已经使用PIL.Image.open()函数读入全局变量`image_clue_i`中。在编写Python代码时,您可以直接使用这些变量,而无需再次读取它们。\n\n由于您正在处理VQA任务,每当可以改善您的理解或帮助您的推理时,您必须使用python工具(例如,matplotlib库)来分析或转换图像。这包括但不限于放大、旋转、调整对比度、计算统计信息或隔离特征。\n\n请注意,当您使用matplotlib可视化数据或进一步处理图像时,您需要使用plt.show()来显示这些图像;无需保存它们。不要使用cv2或PIL等图像处理库。如果您想检查变量的值,您必须使用print()来检查它。\n\n输出(包装在`<interpreter>output_str</interpreter>`中)可以返回以帮助您的推理并帮助您得出最终答案。Python代码应该是完整的脚本,包括必要的导入。\n每个代码片段都用`<code>\n```python\n代码片段\n```\n</code>`包装。\n您回答的最后部分应该采用以下格式:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>\n\n*图像分辨率:*\n\n{image_information}\n\n*用户问题:*\n回答以下提供图像的问题并将答案放在\\boxed{{answer}}格式中\n\n{query}\n\n记住在最后部分使用以下格式放置最终答案:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>","vistool_with_img_info_v2": "您是一个代理 - 请继续直到用户的查询完全解决,在结束您的回合并让回给用户之前。只有在您确定问题已解决时才终止您的回合。\n\n逐步解决以下问题。您现在有能力选择性地编写可执行的Python代码来增强您的推理过程。Python代码将由外部沙盒执行。\n\n您必须在每次函数调用之前进行广泛规划,并对之前函数调用的结果进行广泛反思。不要仅通过进行函数调用来完成整个过程,因为这可能会损害您解决问题和深入思考的能力。\n\n对于所有提供的图像,按顺序,第i个图像已经使用PIL.Image.open()函数读入全局变量`image_clue_i`中。在编写Python代码时,您可以直接使用这些变量,而无需再次读取它们。\n\n由于您正在处理与视觉相关的问题回答任务,每当可以改善您的理解或帮助您的推理时,您必须使用python工具(例如,matplotlib库)来分析或转换图像。这包括但不限于放大、旋转、调整对比度、计算统计信息或隔离特征。\n\n请注意,当您使用matplotlib可视化数据或进一步处理图像时,您需要使用plt.show()来显示这些图像;无需保存它们。不要使用cv2或PIL等图像处理库。如果您想检查变量的值,您必须使用print()来检查它。\n\n输出(包装在`<interpreter>output_str</interpreter>`中)可以返回以帮助您的推理并帮助您得出最终答案。Python代码应该是完整的脚本,包括必要的导入。\n每个代码片段都用`<code>\n```python\n代码片段\n```\n</code>`包装。\n您回答的最后部分应该采用以下格式:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>\n\n*图像分辨率:*\n\n图像宽度:{width};图像高度:{height}\n\n*用户问题:*\n回答以下提供图像的问题并将答案放在\\boxed{{answer}}格式中\n\n{query}\n\n记住在最后部分使用以下格式放置最终答案:\n<answer>\n\\boxed{{'最终答案放在这里。'}}\n</answer>","no_tool": "您是一个有用的助手。您正在处理VQA任务。逐步解决视觉问题并给出正确答案。注意:将您的答案放在\"\\boxed{{正确答案在这里}}\"格式中\n*用户问题*:\n{query}","no_tool_no_cot": "问题:\n{query}\n直接给出正确答案,格式为\"最终答案:\\boxed{{最终答案在这里}}\"\n"
}

3. 启动main.py

from openai import OpenAI
from inference_engine.vis_inference_demo_gpt import evaluate_single_data, evaluate_single_with_cleanup
from inference_engine.safe_persis_shared_vis_python_exe import PythonExecutor......
# Run inference with safe execution
print(f"Processing image: {args.image_path}")
print(f"Question: {args.question}")
print("Running inference with safe execution...")# messages, final_response = evaluate_single_with_cleanup(eval_args, data, client)
executor = PythonExecutor()
messages, final_response = evaluate_single_data(eval_args, data, client, executor)# Save results
os.makedirs(args.output_dir, exist_ok=True)if args.save_messages:messages_path = os.path.join(args.output_dir, "test_messages.json")with open(messages_path, "w", encoding="utf-8") as f:json.dump(messages, f, indent=4, ensure_ascii=False)print(f"Messages saved to: {messages_path}")

这里整体的逻辑也很简单,就是配置好参数之后使用evaluate_single_data函数进行执行得到模型推理结果。

4. inference_engine 

这个模块是项目中最核心的代码,负责主要负责处理视觉问答(VQA)任务中的代码执行和推理过程。

evaluate_single_data

其中evaluate_single_data是整个系统的核心代码,实现了基于动态工具的具身视觉问答的完整流程。

# 参数提取和验证
prompt_template = args.prompt_template
prompt = args.prompt
exe_code = args.exe_code
max_tokens = args.max_tokens
temperature = args.temperature
api_name = args.api_name#提示模板选择逻辑
if "no_tool" in prompt:# 不使用工具的纯文本推理if len(image_path_list) == 1:messages = process_prompt_init(...)elif len(image_path_list) >= 2:messages = process_prompt_init_multi_images(...)
else:# 使用工具的推理if len(image_path_list) == 1:prompt = "vistool_with_img_info_v2"  # 单图像增强版messages = process_prompt_init(...)elif len(image_path_list) >= 2:prompt = "vistool_with_img_info_multi_image"  # 多图像messages = process_prompt_init_multi_images(...)
#迭代推理循环
while True:if exe_code and pred_stop_reason == "</code>":# 需要执行代码的情况# 1. 提取代码code_to_execute = response_text.split("```python")[-1].split("```")[0].strip()# 2. 执行代码exe_result = execute_codes([code_to_execute], messages, executor)[0][0]# 3. 处理执行结果if report == "Done":# 成功执行text_result = exe_result[0]['text']images_result = exe_result[0]['images']else:# 执行出错error_result = report# 4. 更新消息历史messages, new_image_clue_idx = update_messages_with_execute_content(...)# 5. 继续生成下一部分response_text, pred_stop_reason = call_chatgpt_api(...)else:# 不需要执行代码,完成推理final_response = response_textbreak

 call_chatgpt_api 函数 - API调用封装

#多API支持
if client_type == "openai" or client_type == "azure":# OpenAI/Azure APIresponse = client.chat.completions.create(...)
elif client_type == "anthropic":# Claude APImessage = client.messages.create(...)
elif client_type == "vllm":# VLLM APIresponse = client.chat.completions.create(...)
#停止条件检测
# 检测停止序列
if stop and any(s in response_text for s in stop):for s in stop:if s in response_text:stop_reason = sbreak# 特殊处理代码块
if "<code>" in response_text:stop_reason = "</code>"

process_prompt_init 函数 - 提示构建

#图像编码处理
if "claude" in api_name:img_result = encode_image_with_resize(image_path)  # Claude需要调整尺寸
else:img_result = encode_image(image_path)  # 其他API直接编码
#消息结构构件
# 对于工具模式,添加image_clue标签
content.append({"type": "text", "text": "<image_clue_0>"})
content.append({"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}})
content.append({"type": "text", "text": "</image_clue_0>\n\n"})

execute_codes 函数 - 代码执行管理

def execute_codes(codes, messages, executor: PythonExecutor):no_code_idx = []codes_use = []# 过滤空代码for i, code in enumerate(codes):if code == "":no_code_idx.append(i)else:codes_use.append(code)# 批量执行代码batch_results = executor.batch_apply(codes_use, messages)return batch_results, no_code_idx

update_messages_with_execute_content 函数 - 执行结果整合

#执行成功的情况
if error_result is None:# 构建解释器消息interpreter_message_text_prefix = [{"type": "text", "text": f"<interpreter>\nText Result:\n{text_result}\nImage Result:\n"}]# 处理生成的图像if images_result is not None:for image_base64_item in images_result:interpreter_message_images = [{"type": "text", "text": f"<image_clue_{image_clue_idx}>"},{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64_item}"}},{"type": "text", "text": f"</image_clue_{image_clue_idx}>"}]image_content += interpreter_message_imagesimage_clue_idx += 1
#执行失败的图像
else:interpreter_message_text_prefix = [{"type": "text", "text": f"<interpreter>{error_result}"}]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/diannao/90849.shtml
繁体地址,请注明出处:http://hk.pswp.cn/diannao/90849.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Higress 上架 KubeSphere Marketplace,助力企业构建云原生流量入口

随着企业数字化转型持续深化&#xff0c;云原生架构正逐渐成为构建现代应用的主流选择。而服务治理作为云原生落地的核心能力之一&#xff0c;急需更灵活、高效的解决方案。近日&#xff0c;AI 原生的 API 网关 Higress 正式上架 KubeSphere Marketplace&#xff0c;助力用户轻…

在LC480T上部署xapp1052

实验环境&#xff1a;LC480T加速卡 开发环境&#xff1a;windows11vivado2020 运行环境&#xff1a;ubuntu22.04 硬件电路&#xff1a;LC480T加速卡(xc7k480tffg1156-2) vivado工程文件下载&#xff1a;https://download.csdn.net/download/xiaolangyangyang/91349686 驱动及应…

TCP的socket编程

TCP客户端逻辑void Usage(const std::string & process) {std::cout << "Usage: " << process << " server_ip server_port" <<std::endl; } // ./tcp_client serverip serverport int main(int argc, char * argv[]) {if (ar…

【理念●体系】模板规范篇:打造可标准化复用的 AI 项目骨架

【理念●体系】从零打造 Windows WSL Docker Anaconda PyCharm 的 AI 全链路开发体系-CSDN博客 【理念●体系】Windows AI 开发环境搭建实录&#xff1a;六层架构的逐步实现与路径治理指南-CSDN博客 【理念●体系】路径治理篇&#xff1a;打造可控、可迁移、可复现的 AI 开…

Skia---渐变色着色器

今天介绍的是实际工作中最常用到的着色器&#xff1a;渐变色着色器。 渐变色着色器是一个从一种颜色平滑的过渡到另一种颜色的效果&#xff0c;渐变色着色器的作用主要是增强图形的视觉吸引力。 线性渐变 Skia 里的线性渐变色着色器是最简单的渐变色着色器&#xff0c;它用于…

2025.07.09华为机考真题解析-第二题200分

📌 点击直达笔试专栏 👉《大厂笔试突围》 💻 春秋招笔试突围在线OJ 👉 笔试突围OJ 02. 地铁线路故障预警系统 问题描述 LYA 负责管理一个城市的地铁网络系统。地铁网络由 n n n

数学建模:非线性规划:凸规划问题

一、定义凸集定义​​&#xff1a;设Ω是n维欧氏空间的一点集&#xff0c;若任意两点x₁∈Ω&#xff0c;x₂∈Ω&#xff0c;其连线上的所有点αx₁(1-α)x₂∈Ω&#xff0c;(0≤α≤1)&#xff0c;则称Ω为凸集。​​凸函数定义​​&#xff1a;给定函数f(x)(x∈D⊂Rⁿ)&…

ISIS | 广播网络中的 ISIS 伪节点 LSP

注&#xff1a;本文为 “ISIS | 伪节点 LSP” 相关合辑。 英文引文&#xff0c;机翻未校。 中文引文&#xff0c;略作重排。 如有内容异常&#xff0c;请看原文。 ISIS in Broadcast Network and Pseudonode LSP 广播网络中 的 ISIS 伪节点 LSP ISIS in broadcast network is…

ARIA UWB安全雷达主要产品型号与核心功能全解析

ARIA UWB雷达拥有LT系列与AHM系列两大产品线。LT103 XBT、LT102 V2、LT103 OEM等代表型号具备高精度定位、低功耗和强穿透能力&#xff0c;适用于工业自动化与物联网。AHM3D、AHM2D、AHM3DSC则专注三维检测和智能计算&#xff0c;广泛服务于医疗健康、安防监控等场景。Hydrogen…

NLP自然语言处理04 transformer架构模拟实现

总体架构输入部分代码实现:导包# -*-coding:utf-8-*- import matplotlib.pyplot as plt import numpy as np import torch import torch.nn as nn # -*-coding:utf-8-*- import copy import torch.nn.functional as F import math位置编码器部分词嵌入WordEmbedding# todo 作用…

记录一本书: Python机器学习:基于PyTorch和Scikit-Learn

记录一本书&#xff1a; Python机器学习&#xff1a;基于PyTorch和Scikit-Learn 作者&#xff1a;&#xff08;美&#xff09;塞巴斯蒂安拉施卡(Sebastian Raschka)&#xff08;美&#xff09;刘玉溪&#xff08;海登&#xff09;(Yuxi(Hayden)Liu) &#xff08;美&#xff09;…

Datomic数据库简介(TBC)

Datomic 数据库详细介绍 Datomic 是一个由 Rich Hickey&#xff08;Clojure 语言创始人&#xff09;设计的 不可变、时间感知、分布式数据库&#xff0c;专为现代应用程序设计&#xff0c;强调 数据不变性&#xff08;immutability&#xff09;、查询灵活性和可审计性。它结合…

xformers 完整安装教程【pip conda】(解决 conda 版本 pytorch 自适应安装 xformers)

我个人喜欢用 mamba&#xff08;conda&#xff09;创建环境&#xff0c;然后用 mamba 安装 pytorch CUDA&#xff08;如果需要使用 CUDA 编译&#xff09;&#xff0c;还有一些比如 gcc/g 等与 python 无关的一些工具。 但是最近我在扩充环境的时候&#xff0c;发现需要额外安…

VM虚拟机全版本网盘+免费本地网络穿透端口映射实时同步动态家庭IP教程

VM虚拟机全版本秘钥&#xff0c;文章末尾。 首先网络穿透的意义是让公网可以直接访问家庭电脑&#xff0c;这样本地电脑的硬件性能得以完全发挥&#xff0c;特别是在云服务器贵性能又没家庭电脑好&#xff0c;专线宽带又贵&#xff0c;第三方网络穿透贵的场景下。一般第三方网…

C++ - 仿 RabbitMQ 实现消息队列--项目介绍与环境搭建

目录 项目介绍 开发环境 技术选型 环境搭建 安装 wget(一般情况下默认会自带) 更换国内软件源 安装 lrzsz 传输工具 安装编译器 安装项目构建工具 make 安装调试器 安装 git 安装 cmake 安装 Protobuf 安装 Muduo 安装 SQLite3 安装 Gtest 项目介绍 首先说一下…

《目标检测模块实践手册:从原理到落地的尝试与分享》第一期

大家好&#xff0c;欢迎来到《目标检测模块实践手册》系列的第一篇。从今天开始&#xff0c;我想以一种 “实践记录者” 的身份&#xff0c;和大家聊聊在目标检测任务中那些形形色色的模块。这些内容没有权威结论&#xff0c;更多的是我在实际操作中的一些尝试、发现和踩过的坑…

C++11笑传之引用

C11前言列表初始化{}进行初始化initializer_list右值引用和移动语义左值与右值左值引用与右值引用引用延长生命周期右值引用和移动语义的使用场景左值引用移动构造和移动赋值右值引用在容器插入的提效引用折叠万能折叠完美转发前言 C11是C继98后的更新&#xff0c;其更新了许多…

瀚高数据库提交数据后,是否需要COMMIT(APP)

文章目录环境症状问题原因解决方案报错编码环境 系统平台&#xff1a; 版本&#xff1a;5.6.5,4.5 症状 瀚高数据库提交数据后&#xff0c;是否需要commit&#xff0c;瀚高数据库是否有配置项。 问题原因 瀚高数据库默认自动COMMIT&#xff08;提交数据&#xff09;&#…

深大计算机游戏开发实验三

主要步骤主角飞船的创建和移动边界设置以及护盾设置创建敌机自动生成敌机图层设置弹丸设置武器创建不同发射模式管理竞态条件击败敌机掉落升级道具不同敌机的生成分值显示实现退出游戏界面之后进入游戏的最高记录重置游戏界面失败后重新加载最记录不会重置任何时候在游戏界面按…

详解缓存淘汰策略:LRU

文章目录缓存淘汰策略LRU核心结构核心操作流程局限性源码走读AddGet缓存淘汰策略 缓存淘汰策略的存在是为了解决 缓存容量有限性 和 高缓存命中率 之间的矛盾。其核心目标是在有限的缓存空间内&#xff0c;尽可能提高缓存命中率 缓存容量有限性&#xff1a;缓存&#xff08;例…