LLM 的合成数据

Cosmopedia: 如何为预训练构建大规模合成数据集

本文档的专注点是如何将样本从 几千 扩展到 数百万,从而使其可用于 从头开始预训练 LLM。深入研究了创建数据集的方法、提示整编的方法及相应的技术栈。

Cosmopedia

Cosmopedia 的目的是重现 Phi-1.5 所使用的训练数据。

围绕在 Phi 数据集上的谜团除了我们对其如何创建的不甚了了之外,还有一个问题是其数据集的生成使用的是私有模型。为了解决这些问题,我们引入了 Cosmopedia,这是由 Mixtral-8x7B-Instruct-v0.1 生成的包含教科书、博文、故事、帖子以及 WikiHow 文章等各种体裁的合成数据集。其中有超过 3000 万个文件、250 亿个词元,是迄今为止最大的开放合成数据集。

实际上 Cosmopedia 的大部分时间都花在了细致的提示词工程上了。

Letta (fka MemGPT) 是用于创建有状态 LLM 服务的框架

Docker 部署

克隆代码

git clone https://github.com/cpacker/MemGPT

设置环境变量,编辑配置文件 .env

  • Ollama
LETTA_LLM_ENDPOINT=http://host.docker.internal:11434
LETTA_LLM_ENDPOINT_TYPE=ollama
LETTA_LLM_MODEL=qwen2.5:7b-q6_K
LETTA_LLM_CONTEXT_WINDOW=32000
LETTA_EMBEDDING_ENDPOINT=http://host.docker.internal:11434
LETTA_EMBEDDING_ENDPOINT_TYPE=ollama
LETTA_EMBEDDING_MODEL=bge-m3
LETTA_EMBEDDING_DIM=1024

在下载 Ollama 模型时,请确保使用标签!

不要执行 ollama pull dolphin2.2-mistral,而是执行 ollama pull dolphin2.2-mistral:7b-q6_K。

如果您没有指定标签,Ollama 可能会默认使用高度压缩的模型变体(例如 Q4)。

Qwen2 Technical Report

Abstract(摘要)

This report introduces the Qwen2 series, the latest addition to our large language models and large multimodal models. We release a comprehensive suite of foundational and instruction-tuned language models, encompassing a parameter range from 0.5 to 72 billion, featuring dense models and a Mixture-of-Experts model. Qwen2 surpasses most prior open-weight models, including its predecessor Qwen1.

Qwen2.5-Coder Technical Report

Abstract(摘要)

In this report, we introduce the Qwen2.5-Coder series, a significant upgrade from its predecessor, CodeQwen1.5. This series includes two models: Qwen2.5-Coder-1.5B and Qwen2.5-Coder-7B. As a code-specific model, Qwen2.5-Coder is built upon the Qwen2.5 architecture and continues pretrained on a vast corpus of over 5.5 trillion tokens. Through meticulous data cleaning, scalable synthetic data generation, and balanced data mixing, Qwen2.

Continue 源码分析 - 向量数据库存储位置

向量数据库存储位置

生成规则

LanceDB 存储位置:~/.continue/index/lancedb

  • UsersjunjianGitHubcontinuedevcontinue-0.9.191-vscodeextensionsvscodeNONEvectordb_OpenAIEmbeddingsProviderbge-base-zh-v1.5.lance
  • UsersjunjianGitHubcontinuedevcontinue-0.9.191-vscodeextensionsvscodeNONEvectordb_TransformersJsEmbeddingsProviderall-MiniLM-L6-v2.lance
  • UsersjunjianGitHubcontinuedevcontinue-0.9.191-vscodeextensionsvscodeNONEvectordb_TransformersJsEmbeddingsProviderbge-small-zh-v1.5.lance

向量数据库存储目录名字的组成部分: IndexTag.directory: /Users/junjian/GitHub/continuedev/continue-0.9.191-vscode/extensions/vscode IndexTag.branch: NONE IndexTag.

Langfuse: Open Source LLM Engineering Platform

Langfuse

LLM 可观察性(LLM Observability)、提示管理(Prompt Management)、LLM 评估(LLM Evaluations)、数据集(Datasets)、LLM 指标(LLM Metrics)和提示游乐场(Prompt Playground)

概述(Overview)

开发(Develop)

  • LLM Observability(可观察性):为您的应用程序进行仪表化,并开始将跟踪数据传输到 Langfuse(快速入门,集成跟踪)
  • Langfuse UI:检查和调试复杂的日志(演示,跟踪)
  • Prompt Management:从 Langfuse 中管理、版本化和部署提示(提示管理)
  • Prompt Engineering:使用 LLM 游乐场测试和迭代您的提示

监控(Monitor)

  • LLM Analytics(分析):跟踪指标(成本、延迟、质量)并从仪表板和数据导出中获得见解(分析)
  • LLM Evaluations(评估):为您的 LLM 完成收集和计算分数(分数和评估)
    • 在 Langfuse 中运行(基于模型的评估)和 LLM 作为评判
    • 收集用户反馈(用户反馈)
    • 在 Langfuse 中手动评分 LLM 输出(手动评分)

LiteLLM: [Python SDK] [Proxy Server (LLM Gateway)]

LiteLLM Proxy Server (LLM Gateway)

安装

pip install 'litellm[proxy]'

编辑配置文件:config.yaml

model_list:
  - model_name: qwen-coder
    litellm_params:
      model: ollama/qwen2.5-coder:7b
  - model_name: bge-m3
    litellm_params:
      model: ollama/bge-m3
  - model_name: llava
    litellm_params:
      model: ollama/llava:7b
      api_base: "http://localhost:11434"
      # api_base: http://127.0.0.1:11434/v1 # ❌ 500 Internal Server Error
  - model_name: gpt-4
    litellm_params:
      model: openai/gpt-4-32k
// ...

命令部署 # 集成 Langfuse LANGFUSE_PUBLIC_KEY=pk-lf-fd5d8fb

Kong AI Gateway

Kong

更快地构建生产就绪的 AI 应用程序(对于开发人员)

通过简单更改一行代码,使用现代基础设施构建具有多 LLM 支持和路由、高级 AI 负载均衡、LLM 可观察性、LLM 安全性和治理等功能的语义智能 AI 应用程序。

将语义智能注入到您的 AI 应用程序中(对于平台团队)

通过语义缓存加速每个 AI 应用程序,通过语义路由智能地跨多个模型路由,构建高级提示模板,检测和防止滥用,以及 AI 可观察性。

AI 流量的 L7 可观察性,用于成本监控和调优(AI 指标和可观察性)

获取应用程序发送的每个 AI 请求的见解,并捕获详细信息以了解和优化您的 AI 使用和成本,支持 10 多个日志摄取器。

安装(Docker)

PostgreSQL docker run -d --name kong-database \ -p 5432:5432 \ -e "POSTGRES_USER=kong" \ -e "POSTGRES_DB=kong" \ -e &q

SGLang 大模型服务框架

SGLang

SGLang is a fast serving framework for large language models and vision language models. It makes your interaction with models faster and more controllable by co-designing the backend runtime and frontend language.

SGLang 是用于大型语言模型和视觉语言模型的快速服务框架。通过协同设计后端运行时和前端语言,使您与模型的交互更快速、更可控。

The core features include:

核心功能包括: Fast Backend Runtime: Efficient serving with RadixAttention for prefix caching, jump-forward constrained decoding, continuous batching, token attention (paged attention), tensor parallelism, FlashInfer kernels, and quantization (AWQ/FP8/GPTQ/Marlin).

大模型推理需要多少显存?

计算加载模型需要的显存

模型参数(B) 参数使用的位数(bits) 加载需要显存(G)
0.5 16 1
1.5 16 3
7 16 14
9 16 18
22 16 44
72 16 144

计算支持不同长度的上下文需要的显存