Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions scripts/vi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
output_lang = "vi"

prompt = lambda content: f'''
You are a translator for the Vietnamese translation team. You are tasked with translating the following text into Vietnamese. You must follow these instructions:
- Translate the text into Vietnamese, while keeping the original formatting (either Markdown, MDX or HTML)
- Inside code blocks, translate the comments but leave the code as-is ; If the code block contains quite plain texts, you MUST provide the translation in <details> tag

You are a translator for the Vietnamese translation team. You are tasked with translating the following texts into Vietnamese. You must follow these instructions:
- Translate the texts into Vietnamese, while keeping the original formatting (either Markdown, MDX or HTML)
- Inside code blocks, translate the comments but leave the code as-is; If the code block contains quite plain texts, you MUST provide the translation in <details> tag
- Do not translate inline code, the URLs and file paths
- If the term is abbreviated, keep the original term and provide the translation in parentheses for the first time it appears in the text
- If there are any slag or funny joke in english, keep it (do not translate) and give an explanation so vietnamese reader can understand
- Use "ta", "chúng ta", "chúng mình", "các bạn" as pronouns
- If there are any slag or funny joke in english, keep it (do not translate) and give an explanation so Vietnamese reader can understand
- Use "ta", "mình, "chúng ta", "chúng mình", "các bạn" as pronouns

KEEP THESE TERMS (DO NOT TRANSLATE, do NOT add translation in parentheses): model, API, SDK, CLI, HTML, GGUF, AI, training, inference, server, client, notebook, python, Hugging Face, transformers, diffusion, diffuser, data, function, LangGraph, LangChain, Llama, Gemma, token, Unit, pretrain, Live (live stream), form, format, certificate, Space, CodeAgent
KEEP THESE TERMS (DO NOT TRANSLATE, do NOT add translation in parentheses): API, SDK, CLI, HTML, GGUF, AI, inference, server, client, notebook, python, Hugging Face, transformers, diffusion, diffuser, LangGraph, LangChain, Llama, Gemma, token, pretrain, Live (live stream), form, format, certificate, Space, CodeAgent

Also KEEP these terms but PROVIDE TRANSLATION in parentheses for the first time it appears in the text: alignment (cân chỉnh), LLM, RAG (tìm kiếm và tạo ra câu trả lời), Agent (tác nhân), Tools (công cụ), "Special Token" (token đặc biệt), "chain-of-thought" (luồng suy luận), fine-tuning (tinh chỉnh), Thought-Action-Observation (Tư duy-Hành động-Quan sát)

Expand All @@ -21,13 +22,16 @@
- Bonus Unit: Chương bổ trợ
- Module: Mô-đun
- Lesson ...: Bài ...
- Model: Mô hình
- Dataset: Tập dữ liệu
- Course: Khóa học
- state-of-the-art: hiện đại nhất
- Q&A: Hỏi và Đáp
- Dummy: ảo (or "giả", or "thử" depending on the context)
- onboarding: làm quen
- Hands-on: Thực hành
- Challenge: Bài tập lớn
- Training: Huấn luyện

Here is an example:
- Original text: To run the models, we will use [ollama](https://ollama.com), a command line tool that allows you to run LLMs and embedding models from Hugging Face. With ollama, you **don't need** to have access to a server or cloud service to run the models. You can run the models directly **on your computer**.
Expand Down Expand Up @@ -59,10 +63,26 @@
message = {{"user": "This is a test"}}
```

If the code block does not contain any plain texts or comments, leave it as it is. Example:
- Original text:
<iframe
src="https://huggingface.co/datasets/agents-course/unit3-invitees/embed/viewer/default/train"
frameborder="0"
width="100%"
height="560px"
></iframe>

- Translation:
<iframe
src="https://huggingface.co/datasets/agents-course/unit3-invitees/embed/viewer/default/train"
frameborder="0"
width="100%"
height="560px"
></iframe>

IMPORTANT: Only output the translated text and nothing else, no need explanation or instruction. The input text is between "=== BEGIN OF TEXT ===" and "=== END OF TEXT ===".
IMPORTANT: Only output the translated texts and nothing else, no need explaination or instruction. The input text is between "=== BEGIN OF TEXT ===" and "=== END OF TEXT ===".

Please translate the following text to vietnamese:
Please translate the following texts to Vietnamese:

=== BEGIN OF TEXT ===
{content}
Expand Down
96 changes: 95 additions & 1 deletion units/vi/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,110 @@
title: Bài kiểm tra cuối chương 1
- local: unit1/conclusion
title: Kết luận
- title: Chương 2. Các Framework cho AI Agent
sections:
- local: unit2/introduction
title: Các Framework cho AI Agent
- title: Chương 2.1 smolagents framework
sections:
- local: unit2/smolagents/introduction
title: Giới thiệu về smolagents
- local: unit2/smolagents/why_use_smolagents
title: Tại sao nên dùng smolagents?
- local: unit2/smolagents/quiz1
title: Kiểm tra nhanh 1
- local: unit2/smolagents/code_agents
title: Xây dựng các Agent sử dụng code
- local: unit2/smolagents/tool_calling_agents
title: Viết các hành động dưới dạng đoạn code hoặc JSON
- local: unit2/smolagents/tools
title: Công cụ
- local: unit2/smolagents/retrieval_agents
title: Xây dựng hệ thống Agentic RAG
- local: unit2/smolagents/quiz2
title: Kiểm tra nhanh 2
- local: unit2/smolagents/multi_agent_systems
title: Hệ thống Đa Agent
- local: unit2/smolagents/vision_agents
title: Các Agent thị giác
- local: unit2/smolagents/final_quiz
title: Bài kiểm tra cuối chương
- local: unit2/smolagents/conclusion
title: Kết luận
- title: Chương 2.2 The LlamaIndex framework
sections:
- local: unit2/llama-index/introduction
title: Giới thiệu về LLamaIndex
- local: unit2/llama-index/llama-hub
title: Giới thiệu về LlamaHub
- local: unit2/llama-index/components
title: Các thành phần trong LlamaIndex là gì?
- local: unit2/llama-index/tools
title: Sử dụng Tools trong LlamaIndex
- local: unit2/llama-index/quiz1
title: Kiểm tra nhanh 1
- local: unit2/llama-index/agents
title: Sử dụng Agents trong LlamaIndex
- local: unit2/llama-index/workflows
title: Tạo Agentic Workflow trong LlamaIndex
- local: unit2/llama-index/quiz2
title: Kiểm tra nhanh 2
- local: unit2/llama-index/conclusion
title: Kết luận
- title: Chương 2.3 LangGraph framework
sections:
- local: unit2/langgraph/introduction
title: Giới thiệu về LangGraph
- local: unit2/langgraph/when_to_use_langgraph
title: LangGraph là gì?
- local: unit2/langgraph/building_blocks
title: Các thành phần cơ bản của LangGraph
- local: unit2/langgraph/first_graph
title: Xây dựng LangGraph đầu tiên của bạn
- local: unit2/langgraph/document_analysis_agent
title: Đồ thị Phân tích Tài liệu
- local: unit2/langgraph/quiz1
title: Kiểm tra nhanh 1
- local: unit2/langgraph/conclusion
title: Kết luận
- title: Chương 3. Use Case cho Agentic RAG
sections:
- local: unit3/agentic-rag/introduction
title: Giới thiệu các Use Case cho Agentic RAG
- local: unit3/agentic-rag/agentic-rag
title: Tìm kiếm và tạo câu trả lời mang tính tác nhân (RAG)
# - local: unit3/agentic-rag/invitees
# title: Tạo ra công cụ RAG cho Thông tin Khách mời
# - local: unit3/agentic-rag/tools
# title: Xây dựng và Tích hợp Công cụ cho Agent của Bạn
# - local: unit3/agentic-rag/agent
# title: Tạo Agent Tổ Chức Gala Của Bạn
- local: unit3/agentic-rag/conclusion
title: Kết luận
- title: Chương bổ trợ 1. Fine-tune LLM cho Function-calling
sections:
- local: bonus-unit1/introduction
title: Giới thiệu
- local: bonus-unit1/what-is-function-calling
title: Function Calling là gì?
- local: bonus-unit1/fine-tuning
title: Hãy fine-tuning model cho Function-calling
title: Hãy fine-tuning mô hình cho Function-calling
- local: bonus-unit1/conclusion
title: Kết luận
- title: Khi nào các bước tiếp theo được công bố?
sections:
- local: communication/next-units
title: Các chương tiếp theo
- title: Bonus Unit 2. Agent Observability and Evaluation
sections:
- local: bonus-unit2/introduction
title: Giới thiệu
- local: bonus-unit2/what-is-agent-observability-and-evaluation
title: Khả năng quan sát và đánh giá agent là gì?
- local: bonus-unit2/monitoring-and-evaluating-agents-notebook
title: Giám sát và đánh giá agent
- local: bonus-unit2/quiz
title: Bài kiểm tra nhanh
- title: Khi nào các bước tiếp theo được công bố?
sections:
- local: communication/next-units
Expand Down
33 changes: 33 additions & 0 deletions units/vi/bonus-unit2/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Khả năng quan sát & Đánh giá AI Agent

![Chương bổ trợ 2 - Ảnh đại diện](https://langfuse.com/images/cookbook/huggingface-agent-course/agent-observability-and-evaluation.png)

Chào mừng bạn đến với **Chương bổ trợ 2**! Trong chương này, chúng ta sẽ khám phá các chiến lược nâng cao để quan sát, đánh giá và cải thiện hiệu suất của các Agent.

---

## 📚 Khi nào nên học chương này?

Chương bổ trợ này phù hợp nếu bạn:
- **Phát triển và triển khai AI Agent:** Bạn muốn đảm bảo Agent hoạt động ổn định trong môi trường production.
- **Cần thông tin chi tiết:** Bạn muốn chẩn đoán lỗi, tối ưu hiệu suất hoặc hiểu cách Agent vận hành.
- **Muốn giảm chi phí vận hành:** Theo dõi chi phí, độ trễ và chi tiết thực thi để quản lý tài nguyên hiệu quả.
- **Hướng đến cải tiến liên tục:** Bạn quan tâm việc tích hợp phản hồi người dùng thời gian thực và đánh giá tự động vào ứng dụng AI.

Tóm lại: dành cho tất cả những ai muốn đưa Agent tiếp cận người dùng thực tế!

---

## 🤓 Nội dung học

Trong chương này, bạn sẽ học cách:
- **Tích hợp công cụ quan sát:** Học cách tích hợp OpenTelemetry vào framework *smolagents* để theo dõi Agent.
- **Giám sát chỉ số:** Theo dõi các chỉ số như lượng token sử dụng (chi phí), độ trễ và lỗi.
- **Đánh giá thời gian thực:** Hiểu các kỹ thuật đánh giá live (live stream) như thu thập phản hồi người dùng và sử dụng LLM làm giám khảo.
- **Phân tích ngoại tuyến:** Sử dụng benchmark datasets (ví dụ: GSM8K) để kiểm tra và so sánh hiệu suất Agent.

---

## 🚀 Sẵn sàng bắt đầu chưa?

Trong phần tiếp theo, chúng ta sẽ học kiến thức cơ bản về Khả năng quan sát và Đánh giá Agent. Sau đó, ta sẽ cùng thực hành ngay!
85 changes: 85 additions & 0 deletions units/vi/bonus-unit2/monitoring-and-evaluating-agents-notebook.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<CourseFloatingBanner chapter={2}
classNames="absolute z-10 right-0 top-0"
notebooks={[
{label: "Google Colab", value: "https://colab.research.google.com/github/huggingface/agents-course/blob/main/notebooks/bonus-unit2/monitoring-and-evaluating-agents.ipynb"},
]} />

# Chương bổ trợ 2: Quan sát và đánh giá Agent

<Tip>
Bạn có thể theo dõi code trong <a href="https://huggingface.co/agents-course/notebooks/blob/main/bonus-unit2/monitoring-and-evaluating-agents-notebook.ipynb" target="_blank">notebook này</a> và chạy trên Google Colab.
</Tip>

Trong notebook này, chúng ta sẽ học cách **giám sát các bước nội bộ (traces) của AI Agent** và **đánh giá hiệu suất** bằng các công cụ quan sát mã nguồn mở.

Khả năng quan sát và đánh giá hành vi của Agent là cực kỳ quan trọng để:
- Gỡ lỗi khi tác vụ thất bại hoặc cho kết quả không tối ưu
- Theo dõi chi phí và hiệu suất theo thời gian thực
- Cải thiện độ tin cậy và an toàn thông qua phản hồi liên tục

## Yêu cầu trước khi thực hành 🏗️

Trước khi chạy notebook này, hãy đảm bảo bạn đã:

🔲 📚 **Học xong** [Giới thiệu về Agent](https://huggingface.co/learn/agents-course/unit1/introduction)

🔲 📚 **Học xong** [Framework smolagents](https://huggingface.co/learn/agents-course/unit2/smolagents/introduction)

## Bước 0: Cài đặt thư viện cần thiết

Chúng ta cần một số thư viện để chạy, giám sát và đánh giá Agent:

```python
%pip install 'smolagents[telemetry]'
%pip install opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents
%pip install langfuse datasets 'smolagents[gradio]'
```

## Bước 1: Thiết lập instrumentation cho Agent

Trong notebook này, chúng ta dùng [Langfuse](https://langfuse.com/) làm công cụ quan sát, nhưng bạn có thể dùng **bất kỳ dịch vụ tương thích OpenTelemetry nào**. Code dưới đây hướng dẫn cách thiết lập biến môi trường cho Langfuse (hoặc endpoint OTel khác) và cách instrumentation cho smolagent.

**Lưu ý:** Nếu dùng LlamaIndex hoặc LangGraph, bạn có thể xem tài liệu instrumentation [tại đây](https://langfuse.com/docs/integrations/llama-index/workflows) và [tại đây](https://langfuse.com/docs/integrations/langchain/example-python-langgraph).

Đầu tiên, hãy cấu hình biến môi trường để kết nối tới endpoint OpenTelemetry của Langfuse.

```python
import os
import base64

# Lấy key của bạn từ https://cloud.langfuse.com
LANGFUSE_PUBLIC_KEY = "pk-lf-..."
LANGFUSE_SECRET_KEY = "sk-lf-..."
os.environ["LANGFUSE_PUBLIC_KEY"] = LANGFUSE_PUBLIC_KEY
os.environ["LANGFUSE_SECRET_KEY"] = LANGFUSE_SECRET_KEY
os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # 🇪🇺 Ví dụ cho khu vực EU
# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # 🇺🇸 Ví dụ cho khu vực US

LANGFUSE_AUTH = base64.b64encode(
f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()
).decode()

os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = os.environ.get("LANGFUSE_HOST") + "/api/public/otel"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}"
```
Chúng ta cũng cần cấu hình Hugging Face token cho các lệnh inference.

```python
# Thiết lập Hugging Face token và các secret khác dưới dạng biến môi trường
os.environ["HF_TOKEN"] = "hf_..."
```
Tiếp theo, thiết lập tracer-provider cho OpenTelemetry đã cấu hình.

```python
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

# Tạo TracerProvider cho OpenTelemetry
trace_provider = TracerProvider()

# Thêm SimpleSpanProcessor với OTLPSpanExporter để gửi traces
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter()))

# Thiết lập tracer provider mặc định toàn cục
23 changes: 23 additions & 0 deletions units/vi/bonus-unit2/quiz.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kiểm tra: Đánh giá AI Agent

Hãy cùng kiểm tra hiểu biết của bạn về các khái niệm theo dõi và đánh giá Agent đã học trong Chương bổ trợ này.

Bài kiểm tra này không bắt buộc và không tính điểm.

### Q1: Khả năng quan sát trong AI Agent chủ yếu đề cập đến điều gì?
Phát biểu nào mô tả chính xác mục đích của khả năng quan sát cho AI Agent?

<Question
choices={[
{
text: "Nó liên quan đến việc theo dõi hoạt động nội bộ thông qua logs, metrics và spans để hiểu hành vi của agent.",
explain: "Chính xác! Khả năng quan sát nghĩa là sử dụng logs, metrics và spans để làm rõ cách thức hoạt động bên trong của agent.",
correct: true
},
{
text: "Nó chỉ tập trung vào việc giảm chi phí tài chính khi chạy agent.",
explain: "Khả năng quan sá bao gồm chi phí nhưng không giới hạn ở đó."
},
{
text: "Nó chỉ đề cập đến giao diện bên ngoài và UI của agent.",
explain: "Khả năng quan sá liên quan đến quy trình nội bộ
Loading
Loading