Lộ trình đang học Current learning path

Developer Platform Developer Platform

Build và deploy apps trên Cloudflare. Build and deploy apps on Cloudflare.

Về trang lộ trình Track home

Phần 5: AI trên Developer Platform Part 5: AI on the Developer Platform · Bài 4/5 Lesson 4/5

RAG với Vectorize và storage RAG with Vectorize and storage

Tách luồng ingest và query: lưu tài liệu trong R2, tạo embeddings vào Vectorize, retrieve context có nguồn trước khi gọi model. Đừng coi vector search là quyền truy cập dữ liệu. Separate ingestion from queries: store documents in R2, create embeddings in Vectorize, and retrieve sourced context before calling the model. Do not treat vector search as data authorization.

RAG with Vectorize and storage
Minh họa từ Cloudflare Reference Architecture (developers.cloudflare.com) Illustration from Cloudflare Reference Architecture (developers.cloudflare.com)

Các bước thực hiện Step-by-step

  1. Xác định document nào được ingest và ACL nào áp dụng cho từng user/tenant trước khi tạo embedding. Define which documents are ingested and which ACL applies to every user or tenant before creating embeddings.
  2. Lưu original documents trong R2; chunk document có metadata source, version và access scope. Store original documents in R2; chunk documents with source, version, and access-scope metadata.
  3. Tạo embeddings và upsert vào Vectorize; tách ingestion job khỏi query path. Create embeddings and upsert them to Vectorize; keep ingestion jobs separate from the query path.
  4. Ở query time: authorize user trước, retrieve only allowed chunks, đưa sources vào prompt và đánh giá grounded answer. At query time: authorize the user first, retrieve only allowed chunks, put sources in the prompt, and evaluate grounded answers.

Giải thích chi tiết Detailed explanation

RAG tăng chất lượng câu trả lời nhưng không thay thế authorization hoặc data lifecycle. Embedding có thể tiết lộ semantic information, nên enforce tenant/ACL filter trước retrieval và có retention/deletion plan. RAG improves answer quality but does not replace authorization or a data lifecycle. Embeddings can reveal semantic information, so enforce tenant or ACL filters before retrieval and have a retention and deletion plan.

Lưu ý (best practices) Note (best practices)

Dùng metadata tenant/ACL để filter retrieval và giữ source document tách khỏi vector index. Retrieval phù hợp không đồng nghĩa người gọi được phép đọc document đó. Use tenant or ACL metadata to filter retrieval and keep source documents separate from the vector index. A relevant retrieval does not mean the caller is allowed to read that document.

Nguồn: Source: Vectorize — Get started Vectorize — Get started

Ví dụ triển khai (Cloudflare Resources) Deployment examples (Cloudflare Resources)

Ví dụ chính thức từ Cloudflare Resources — gợi ý theo chủ đề bài học trong lộ trình này. Official examples from Cloudflare Resources — matched to this lesson within this path.

Tutorial Tutorial Developer Platform Developer Platform

Xây dựng Retrieval Augmented Generation (RAG) AI Build a Retrieval Augmented Generation (RAG) AI

Tóm tắt thực hành: Xây dựng Retrieval Augmented Generation (RAG) AI trên Workers AI. Build your first AI app with Cloudflare AI. This guide uses Workers AI, Vectorize, D1, and Cloudflare Workers.

Build your first AI app with Cloudflare AI. This guide uses Workers AI, Vectorize, D1, and Cloudflare Workers.

Tìm hiểu thêm Learn more
Sơ đồ kiến trúc Reference architecture diagram Chung / đa lĩnh vực Cross-cutting

Retrieval Augmented Generation (RAG)

/reference-architecture/diagrams/ai/ai-rag

Tìm hiểu thêm Learn more
Tutorial Tutorial Developer Platform Developer Platform

Sử dụng R2 as static asset storage với Cloudflare Pages Use R2 as static asset storage with Cloudflare Pages

Tóm tắt thực hành: Sử dụng R2 as static asset storage với Cloudflare Pages trên Cloudflare Pages. This tutorial will teach you how to use R2 as a static asset storage bucket for your Pages app.

This tutorial will teach you how to use R2 as a static asset storage bucket for your Pages app.

Tìm hiểu thêm Learn more

Xem thêm ví dụ trong lộ trình → More examples in this path →

Tài liệu Cloudflare Developers Cloudflare Developer docs

Sơ đồ kiến trúc (Cloudflare Docs) Architecture diagrams (Cloudflare Docs)

Figure 1: Knowledge seeding

Retrieval Augmented Generation (RAG) Retrieval Augmented Generation (RAG)

RAG kết hợp retrieval (Vectorize/KV) với Workers AI để chatbot trả lời chính xác hơn — seeding knowledge và query path tách biệt. RAG combines retrieval with generative models for better text. It uses external knowledge to create factual, relevant responses, improving coherence and accuracy in NLP tasks like chatbots.

Thuật ngữ: Concepts: RAG · Vectorize · Workers AI · Knowledge seeding · Embeddings

Sơ đồ chính thức ↗ Official diagram ↗ · AI Artificial Intelligence (AI)

Sản phẩm liên quan Related products

Học xong hoặc muốn đổi hướng? Finished or want a different path?

Ba lộ trình độc lập — mỗi lộ trình chỉ gồm bài học và tài liệu trong phạm vi đó. Chọn lộ trình khác khi sẵn sàng, không cần học song song. Three independent paths — each includes only lessons and materials for that scope. Switch when you are ready; no need to study paths in parallel.

Chưa chắc — làm bài chọn lộ trình Not sure — use the path selector · So sánh cả ba lộ trình Compare all three paths