YC W22 孵化的开源项目,提供分布式模型训练和推理的完整工程框架。适合有分布式 AI 系统需求的团队。
在你自己的硬件上获得企业级 AI 能力。无需云服务。
LlamaFarm 是一个完全运行在你自有硬件上的开源 AI 平台。你可以构建 RAG 应用、训练自定义分类器、检测异常并运行文档处理——一切都在本地完成,隐私得到完全保障。
🔒 完全隐私——你的数据永远不会离开设备
💰 无 API 成本——使用开源模型,无需支付按 token 计费的费用
🌐 支持离线——模型下载完成后,无需联网即可使用
⚡ 针对硬件优化——在 Apple Silicon、NVIDIA 和 AMD 硬件上自动启用 GPU/NPU 加速
立即开始使用——无需命令行:
视频演示(90 秒):https://youtu.be/W7MHGyN0MdQ
下载上方的桌面应用并运行即可。无需任何额外配置。
安装 CLI:
macOS / Linux:curl -fsSL https://raw.githubusercontent.com/llama-farm/llamafarm/main/install.sh | bash
Windows(PowerShell):irm https://raw.githubusercontent.com/llama-farm/llamafarm/main/install.ps1 | iex
也可以直接从 releases 下载。
curl -fsSL https://raw.githubusercontent.com/llama-farm/llamafarm/main/install.sh | bash
Windows(PowerShell):
irm https://raw.githubusercontent.com/llama-farm/llamafarm/main/install.ps1 | iex
也可以直接从 releases 下载。
创建并运行项目:lf init my-project # Generates llamafarm.yaml lf start # Starts services and opens Designer UI
创建并运行项目:
lf init my-project # Generates llamafarm.yaml
lf start # Starts services and opens Designer UI
与你的 AI 对话:lf chat # Interactive chat lf chat "Hello, LlamaFarm!" # One-off message
lf chat # Interactive chat
lf chat "Hello, LlamaFarm!" # One-off message
Designer Web 界面位于 http://localhost:14345。
git clone https://github.com/llama-farm/llamafarm.git
cd llamafarm
# Install Nx globally and initialize the workspace
npm install -g nx
nx init --useDotNxInstallation --interactive=false # Required on first clone
# Start all services (run each in a separate terminal)
nx start server # FastAPI server (port 14345)
nx start rag # RAG worker for document processing
nx start universal-runtime # ML models, OCR, embeddings (port 11540)
LlamaFarm 由三项主要服务组成:
所有配置都集中在 llamafarm.yaml 中——不存在散落各处的设置或隐藏的默认值。
Universal Runtime 让你能够使用 HuggingFace 模型以及各种专业 ML 能力:
runtime:
models:
default:
provider: universal
model: Qwen/Qwen2.5-1.5B-Instruct
base_url: http://127.0.0.1:11540/v1
通过简单配置,即可让 GGUF 模型获得 CPU/GPU 加速:
runtime:
models:
default:
provider: ollama
model: qwen3:8b
base_url: http://localhost:11434/v1
支持 vLLM、Together、Mistral API,以及任何与 OpenAI 兼容的 endpoint:
runtime:
models:
default:
provider: openai
model: gpt-4o
base_url: https://api.openai.com/v1
api_key: ${OPENAI_API_KEY}
创建一个与处理策略和数据库关联的数据集。
上传文件(PDF、DOCX、Markdown、TXT)——除非传入 --no-process,否则系统会自动执行处理。
只有在你有意跳过自动处理时(例如需要上传大批量文件),才需要手动执行处理。
使用语义搜索进行查询,并可选择使用元数据过滤。
lf datasets create -s default -b main_db research
lf datasets upload research ./papers/*.pdf # auto-processes by default
# For large batches:
# lf datasets upload research ./papers/*.pdf --no-process
# lf datasets process research
lf rag query --database main_db "What are the key findings?"
位于 http://localhost:14345 的 Designer 提供以下功能:
详情请参阅 Designer Features Guide。
llamafarm.yaml 是每个项目唯一可信的配置来源:
version: v1
name: my-assistant
namespace: default
# Multi-model configuration
runtime:
default_model: fast
models:
fast:
description: "Fast local model"
provider: universal
model: Qwen/Qwen2.5-1.5B-Instruct
base_url: http://127.0.0.1:11540/v1
powerful:
description: "More capable model"
provider: universal
model: Qwen/Qwen2.5-7B-Instruct
base_url: http://127.0.0.1:11540/v1
# System prompts
prompts:
- name: default
messages:
- role: system
content: You are a helpful assistant.
# RAG configuration
rag:
databases:
- name: main_db
type: ChromaStore
default_embedding_strategy: default_embeddings
default_retrieval_strategy: semantic_search
embedding_strategies:
- name: default_embeddings
type: UniversalEmbedder
config:
model: sentence-transformers/all-MiniLM-L6-v2
base_url: http://127.0.0.1:11540/v1
retrieval_strategies:
- name: semantic_search
type: BasicSimilarityStrategy
config:
top_k: 5
data_processing_strategies:
- name: default
parsers:
- type: PDFParser_LlamaIndex
config:
chunk_size: 1000
chunk_overlap: 100
- type: MarkdownParser_Python
config:
chunk_size: 1000
extractors: []
# Dataset definitions
datasets:
- name: research
data_processing_strategy: default
database: main_db
使用 ${VAR} 语法从 .env 文件中注入 secret:
runtime:
models:
openai:
api_key: ${OPENAI_API_KEY}
# With default: ${OPENAI_API_KEY:-sk-default}
# From specific file: ${file:.env.production:API_KEY}
完整参考信息请参阅 Configuration Guide。
LlamaFarm 提供与 OpenAI 兼容的 REST API:
curl -X POST http://localhost:14345/v1/projects/default/my-project/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Hello"}],
"stream": false,
"rag_enabled": true
}'
curl -X POST http://localhost:14345/v1/projects/default/my-project/rag/query \
-H "Content-Type: application/json" \
-d '{
"query": "What are the requirements?",
"database": "main_db",
"top_k": 5
}'
所有 endpoint 请参阅 API Reference。
Universal Runtime 提供聊天之外的其他 endpoint:
curl -X POST http://localhost:14345/v1/vision/ocr \
-F "file=@document.pdf" \
-F "model=surya"
LlamaFarm 通过 PyOD 支持 12 种以上的异常检测算法,并同时支持批处理和流式模式。
# Train on normal data
curl -X POST http://localhost:14345/v1/ml/anomaly/fit \
-H "Content-Type: application/json" \
-d '{"model": "sensor-detector", "backend": "ecod", "data": [[22.1], [23.5], ...]}'
# Detect anomalies
curl -X POST http://localhost:14345/v1/ml/anomaly/detect \
-H "Content-Type: application/json" \
-d '{"model": "sensor-detector", "data": [[22.0], [100.0], [23.0]], "threshold": 0.5}'
# Streaming detection (handles cold start, auto-retraining, sliding windows)
curl -X POST http://localhost:14345/v1/ml/anomaly/stream \
-H "Content-Type: application/json" \
-d '{"model": "live-sensor", "data": {"temperature": 72.5}, "backend": "ecod"}'
可用 backend:ecod(推荐)、isolation_forest、one_class_svm、local_outlier_factor、autoencoder、hbos、copod、knn、mcd、cblof、suod、loda
完整文档请参阅 Models Guide。
通过 Model Context Protocol,让模型能够访问外部工具:
# In llamafarm.yaml
mcp:
servers:
- name: filesystem
transport: stdio
command: npx
args: ['-y', '@modelcontextprotocol/server-filesystem', '/data']
runtime:
models:
- name: assistant
provider: ollama
model: llama3.1:8b
mcp_servers: [filesystem]
LlamaFarm 还会将自己的 API 暴露为 MCP 工具,供 Claude Desktop、Cursor 及其他 MCP client 使用。请参阅 Tool Calling Guide。
有关配置说明和完整列表,请参阅 examples/README.md。
LlamaFarm 已应用于多个行业的文档分析、监控和欺诈检测:
# Python server tests
cd server && uv sync && uv run --group test python -m pytest
# CLI tests
cd cli && go test ./...
# RAG tests
cd rag && uv sync && uv run pytest tests/
# Universal Runtime tests
cd runtimes/universal && uv sync && uv run pytest tests/
# Build docs
nx build docs
通过实现 provider 支持并更新 schema 来添加 runtime。
通过实现存储 backend 来添加向量数据库(Chroma、Qdrant 等)。
为新的文件格式添加 parser(PDF、DOCX、HTML、CSV 等)。
添加 extractor,以提取自定义元数据。
在 cli/cmd/ 下添加 CLI 命令。
分步说明请参阅 Extending Guide。
Discord——与团队和社区交流
GitHub Issues——提交 bug 报告和功能请求
Discussions——交流想法和提案
Contributing Guide——代码风格和贡献流程
本项目采用 Apache 2.0 License。致谢信息请参阅 CREDITS。
在本地构建,部署到任何地方,真正拥有你的 AI。