128 篇文章带有标签 “LLM”

Cline: 自主编程助手

git clone https://github.com/cline/cline.git
code cline
npm run install:all

如果构建项目时遇到问题,请安装 esbuild problem matchers 扩展。

Activating task providers npm
错误: problemMatcher 引用无效: $esbuild-watch

打开 运行和调试 侧边栏,运行 Run Extension,或者按 F5 键启动调试,打开一个新的 VSCode 窗口,加载扩展。

构建自主答题的智能体

这里想探索使用多模态大模型答题的技术方案,包含单选题、多选题、判断题,最终构建自主答题的智能体。

工作流程:🏞️ -> MLM(多模态大模型)-> 答案

直接使用多模态大模型读题(转成文字),然后检索答案,把题和答案组合的提示词输入给语言大模型。

我使用了 Ollama 调用多模态大模型 minicpm-v:8b 来生成文字。llava:7b 的效果不好。

代码示例:

import ollama

response = ollama.chat(
	model="minicpm-v:8b",
	messages=[
		{
			'role': 'user',
			'content': '读取图像中的题。',
			'images': ['ti.png']
		}
	]
)

print(response['message']['content'])

沐曦 MXC500 训练 GPU 的大模型推理性能压测

曦云®C500是沐曦面向通用计算的旗舰产品,提供强大高精度及多精度混合算力,配备大规格高带宽显存,片间互联MetaXLink无缝链接多GPU系统,自主研发的MXMACA®软件栈可兼容主流GPU生态,能够全面满足数字经济建设和产业数字化的算力需求。

2023 年 6 月 14 日,沐曦官宣 AI 训练 GPU MXC500 完成芯片功能测试,MXMACA 2.0 计算平台基础测试完成,意味着公司首款 AI 训练芯片 MXC500成功点亮,该芯片采用 7nm 制程,GPGPU 架构,能够兼容 CUDA,目标对标英伟达 A100/A800 芯片。

沐曦主要有三大产品线:

  1. 用于 AI 推理的 MXN 系列;
  2. 用于 AI 训练及通用计算的 MXC 系列;
  3. 用于图形渲染的 MXG 系列。

研发实力强大,软件生态布局完善。沐曦的研发团队阵容豪华,三位创始人均在 AMD 拥有 20 年左右的 GPU 研发经验,其中两位为 AMD 科学家(Fellow)。沐曦采用了完全自主研发的 GPU IP,有效提高了产品的开发效率,同时拥有完全自主知识产权的指令集和架构,可以对每个独立的计算实例进行灵活配置,从而优化数据中心计算资源的效率。

SWE-bench: Can Language Models Resolve Real-World GitHub Issues?

Language models have outpaced our ability to evaluate them effectively, but for their future development it is essential to study the frontier of their capabilities. We find real-world software engineering to be a rich, sustainable, and challenging testbed for evaluating the next generation of language models. To this end, we introduce SWE-bench, an evaluation framework consisting of 2,294 software engineering problems drawn from real GitHub issues and corresponding pull requests across 12 popular Python repositories. Given a codebase along with a description of an issue to be resolved, a language model is tasked with editing the codebase to address the issue. Resolving issues in SWE-bench frequently requires understanding and coordinating changes across multiple functions, classes, and even files simultaneously, calling for models to interact with execution environments, process extremely long contexts and perform complex reasoning that goes far beyond traditional code generation tasks. Our evaluations show that both state-ofthe-art proprietary models and our fine-tuned model SWE-Llama can resolve only the simplest issues. The best-performing model, Claude 2, is able to solve a mere 1.96% of the issues. Advances on SWE-bench represent steps towards LMs that are more practical, intelligent, and autonomous.

Claude: Developing a computer use model

Claude can now use computers. The latest version of Claude 3.5 Sonnet can, when run through the appropriate software setup, follow a user’s commands to move a cursor around their computer’s screen, click on relevant locations, and input information via a virtual keyboard, emulating the way people interact with their own computer.

Claude现在可以使用计算机了。最新版本的Claude 3.5 Sonnet可以在通过适当的软件设置后,按照用户的命令在计算机屏幕上移动光标,单击相关位置,并通过虚拟键盘输入信息,模拟人们与自己的计算机交互的方式。

We think this skill—which is currently in public beta—represents a significant breakthrough in AI progress.

UI-TARS: Pioneering Automated GUI Interaction with Native Agents

UI-TARS: Pioneering Automated GUI Interaction with Native Agents(与本地代理进行自动化 GUI 交互的先驱)

This paper introduces UI-TARS, a native GUI agent model that solely perceives the screenshots as input and performs human-like interactions (e.g., keyboard and mouse operations). Unlike prevailing agent frameworks that depend on heavily wrapped commercial models (e.g., GPT-4o) with expert-crafted prompts and workflows, UI-TARS is an end-to-end model that outperforms these sophisticated frameworks.

Computer-Using Agent

A universal interface for AI to interact with the digital world. AI 与数字世界交互的通用接口。

Today we introduced a research preview of Operator⁠, an agent that can go to the web to perform tasks for you. Powering Operator is Computer-Using Agent (CUA), a model that combines GPT-4o's vision capabilities with advanced reasoning through reinforcement learning. CUA is trained to interact with graphical user interfaces (GUIs)—the buttons, menus, and text fields people see on a screen—just as humans do.

DeepSeek-V3 Technical Report

We present DeepSeek-V3, a strong Mixture-of-Experts (MoE) language model with 671B total parameters with 37B activated for each token. To achieve efficient inference and cost-effective training, DeepSeek-V3 adopts Multi-head Latent Attention (MLA) and DeepSeekMoE architec- tures, which were thoroughly validated in DeepSeek-V2. Furthermore, DeepSeek-V3 pioneers an auxiliary-loss-free strategy for load balancing and sets a multi-token prediction training objective for stronger performance. We pre-train DeepSeek-V3 on 14.

DeepSeek R1: 通过强化学习激励 LLM 的推理能力

We introduce our first-generation reasoning models, DeepSeek-R1-Zero and DeepSeek-R1. DeepSeek-R1-Zero, a model trained via large-scale reinforcement learning (RL) without super- vised fine-tuning (SFT) as a preliminary step, demonstrates remarkable reasoning capabilities. Through RL, DeepSeek-R1-Zero naturally emerges with numerous powerful and intriguing reasoning behaviors. However, it encounters challenges such as poor readability, and language mixing.

CodeGate - 让 AI 编码助手更安全

CodeGate 是位于 AI 编码助手和 LLM 之间的本地提示网关,用于增强隐私和安全性。

  • 执行代码安全审查
  • 识别包依赖项中的漏洞
  • 防止敏感数据(如机密)与 AI 模型共享

CodeGate 是位于 AI 编码助手和 LLM 之间的本地代理。CodeGate 会审查您的提示是否存在任何潜在的机密泄露 — 在机密离开您的桌面之前对其进行加密,并在响应中对其进行解密。CodeGate 使用 RAG 来更新任何 LLM 的知识库,并提供相关的风险洞察。

ollama pull qwen2.5-coder:7b
ollama pull qwen2.5-coder:1.5b

编辑配置文件:~/.continue/config.json

华为 Atlas A2 上使用 LLaMA-Factory 模型微调

  • 云资源
    • ModelArts
      • 开发环境
        • Notebook
  • 自定义镜像:llama2
  • 类型:ASCEND
  • 规格:Ascend: 8*Ascend910 ARM: 192核 768GB
  • 存储配置:云硬盘EVS
    • 磁盘规格:200GB

工作目录:/home/ma-user/work

pip install --upgrade modelscope

编辑 download.py 文件

#模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('Qwen/Qwen1.5-7B-Chat')
export MODELSCOPE_CACHE=/home/ma-user/work
python download.py
ll /home/ma-user/work/hub/Qwen/Qwen1___5-7B-Chat

修改配置文件:Qwen/Qwen1___5-7B-Chat/config.json

{
  "torch_dtype": "float16",
}

NPU 不支持 bfloat16,模型配置文件需要修改为 float16

git clone https://github.com/hiyouga/LLaMA-Factory

❌ 网络不稳定,多试几次。

LangChain Blog: In the Loop

“什么是代理?”

几乎每天都会有人问我这个问题。在 LangChain,我们构建工具来帮助开发者构建 LLM 应用程序,特别是那些充当推理引擎并与外部数据和计算源交互的应用程序。这包括通常被称为“代理”的系统。

每个人似乎对代理都有稍微不同的定义。我的定义可能比大多数人更技术性:

💡 代理是一个使用 LLM 来决定应用程序控制流的系统。

即使在这里,我也承认我的定义并不完美。人们通常认为代理是高级的、自主的、类人的——但如果是一个简单的系统,LLM 在两个不同路径之间进行路由呢?这符合我的技术定义,但不符合人们对代理应具备能力的普遍看法。很难准确定义什么是代理!

这就是为什么我非常喜欢 Andrew Ng 上周的推文。在推文中,他建议“与其争论哪些工作应被包括或排除为真正的代理,我们可以承认系统可以有不同程度的代理性。”就像自动驾驶汽车有不同的自动化级别一样,我们也可以将代理能力视为一个光谱。我非常同意这个观点,我认为 Andrew 表达得很好。将来,当有人问我什么是代理时,我会转而讨论什么是“代理性”。

去年我在 TED 演讲中谈到了 LLM 系统,并使用下面的幻灯片讨论了 LLM 应用程序中存在的不同自主级别。

一个系统越“代理性”,LLM 决定系统行为的程度就越高。

使用 LLM 将输入路由到特定的下游工作流中具有一些小的“代理性”行为。这将属于上图中的路由器类别。

华为 Atlas 800I A2 服务器的大模型推理性能压测

--stream 不要加,经常出问题。

  • --read-timeout: 网络读取超时
  • --parallel: 并发数
  • -n: 请求数

压测命令

evalscope perf \
    --api openai \
    --url 'http://127.0.0.1:1025/v1/chat/completions' \
    --model 'qwen' \
    --dataset openqa \
    --dataset-path './datasets/open_qa.jsonl' \
    --max-prompt-length 8000 \
    --stop '<|im_end|>' \
    --read-timeout=120 \
    --parallel 1 \
    -n 1

压测命令 evalscope perf \ --api openai \ --url 'http://127.0.0.1:1025/v1/chat/completions&#39; \ --model 'qwen' \ --dataset openqa \ --dataset-path './datasets/Codefuse-Evol-Instruct-Clean-data.

在华为 Atlas 800I A2 服务器上搭建大模型推理服务

NPU GPU
CANN CUDA
MindSpore PyTorch
MindFormer Transformers
MindIE vLLM
  • Qwen1.5-7B
git clone https://www.modelscope.cn/Qwen/Qwen1.5-7B-Chat.git
  • Qwen2-7B ❌
git clone https://www.modelscope.cn/Qwen/Qwen2-7B-Instruct.git
  • Qwen2-72B
git clone https://www.modelscope.cn/Qwen/Qwen2-72B-Instruct.git
  • DeepSeek-Coder-6.7B
git clone https://www.modelscope.cn/deepseek-ai/deepseek-coder-6.7b-instruct.git
  • StarCoder2-15B ❌
git clone https://www.modelscope.cn/AI-ModelScope/starcoder2-15b.git
  • CodeGeeX2-6B ❌
git clone https://www.modelscope.cn/ZhipuAI/codegeex2-6b.git

缺少软件包 sentencepiece

因为 MindIE 不支持 bin 格式的模型,需要将模型转换为

OpenAI API Compatibility

  • Ollama: 11434
  • LiteLLM: 4000
  • XInference: 9997
  • MindIE: 1025
  • curl -s: -s 选项表示静默模式,不输出进度信息。
  • jq -r: -r 选项表示以原始格式输出,去掉了引号。

在 Bash 中,单引号和双引号的使用有一些重要的区别:

  • 单引号 (')
    • 完全字面值:单引号内的内容被视为字面值,不会对其中的任何字符进行扩展或解析。
    • 变量不扩展:在单引号内,变量不会被解析。例如,'LITELLMAPIKEY会被视为字符LITELLM_API_KEY' 会被视为字符串 'LITELLM_API_KEY',而不是变量的值。
    echo '$LITELLM_API_KEY'  # 输出: $LITELLM_API_KEY
    
  • 双引号 (")
    • 允许扩展:双引号内的内容会进行解析和扩展。
    • 变量扩展:在双引号内,变量会被解析。例如,"$LITELLM_API_KEY" 会被替换为该变量的值。
    • 特殊字符处理:某些字符(如 $ 和 \)在双引号内需要用反斜杠转义。
    echo "$LITELLM_API_KEY"  # 输出: 变量的实际值(例如: sk-1234)
    

部署 LLM 多 LoRA 适配器的推理服务

conda create -n text-generation-inference python=3.9
conda activate text-generation-inference

git clone https://github.com/huggingface/text-generation-inference.git && cd text-generation-inference
BUILD_EXTENSIONS=True make install
conda create -n vllm python=3.10 -y
conda activate vllm
pip install vllm
cd ~/HuggingFace/mistralai/Mistral-7B-v0.1
git clone https://huggingface.co/predibase/magicoder adapters/magicoder

vllm - Using LoRA adapters mistralai/Mistral-7B-v0.

推测解码 (Speculative Decoding)

  1. 初步生成:使用一个小而快速的模型(称为Mq),生成一系列初步的 tokens。这个模型很高效,所以能快速得到结果。
  2. 并行评估:接着,使用一个更大的目标模型(称为Mp)来同时评估Mq生成的所有 tokens。Mp会判断每个 token 的概率,选择那些可能性高的结果。
  3. 修正输出:对于那些被Mq生成但被Mp拒绝的低概率 token,Mp会提供新的替代 token。这一步确保了输出的质量,同时提高了生成的速度。
  • Serving AI models faster with speculative decoding
    1. 生成多个猜测候选: 使用一个更小更高效的"草稿"模型或者是主模型本身的最后一层,生成多个可能的下一个token作为猜测。
    2. 并行评估猜测: 利用主要的大型语言模型(LLM)并行地对这些猜测进行评估,计算每个猜测的概率分布。
    3. 接受或拒绝猜测: 通过比较每个猜测在 LLM 和草稿模型下的概率,以及生成一个随机数进行判断,决定是否接受该猜测。
    4. 调整并重采样: 如果所有猜测都被接受,则直接从 LLM 采样下一个token。如果有猜测被拒绝,则从调整后的概率分布中重新采样被拒绝的猜测。
    5. 输出结果: 最终输出包括所有被接受的猜测以及从 LLM 采样或重采样得到的token。

Text Generation Inference - Speculation 推测解码:在不降低准确性