Skip to content

Commit 834fd46

Browse files
authored
Merge pull request #81 from rust-tieng-viet/claude/llm-rust-posts-011CUVavVA3L8AjsHfZvGXyt
feat: Add LLM and Rust
2 parents c1d061c + 3dc78ff commit 834fd46

File tree

7 files changed

+2231
-0
lines changed

7 files changed

+2231
-0
lines changed

src/SUMMARY.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@
179179

180180
---
181181

182+
# AI và Large Language Models (LLM)
183+
184+
- [Rust và LLM Overview](./llm/README.md)
185+
- [Rig - LLM Application Framework](./llm/rig.md)
186+
- [llm - Unified LLM Interface](./llm/llm-crate.md)
187+
- [Candle - Minimalist ML Framework](./llm/candle.md)
188+
- [Building AI Agents và Workflows](./llm/ai-agents-workflows.md)
189+
- [Recent Updates 2025](./llm/recent-updates-2025.md)
190+
191+
---
192+
182193
# Rust Idioms
183194

184195
- [Functional programming](./idioms/functional-programming.md)

src/llm/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# AI và Large Language Models (LLM) với Rust
2+
3+
Rust đang ngày càng trở thành một lựa chọn mạnh mẽ cho việc xây dựng các ứng dụng AI và làm việc với Large Language Models (LLM). Với performance vượt trội, tính an toàn về bộ nhớ, và khả năng xử lý đồng thời hiệu quả, Rust mang đến những ưu điểm độc đáo cho lĩnh vực này.
4+
5+
## Tại sao sử dụng Rust cho LLM?
6+
7+
### 1. Performance Cao
8+
9+
Rust cung cấp performance tương đương C/C++ nhờ vào:
10+
- **Zero-cost abstractions**: Không có overhead khi sử dụng các abstractions
11+
- **Không có garbage collector**: Quản lý bộ nhớ thông qua ownership system
12+
- **Tối ưu hóa compiler**: LLVM backend cho phép tối ưu hóa mạnh mẽ
13+
14+
Điều này đặc biệt quan trọng khi:
15+
- Chạy inference với models lớn
16+
- Xử lý batch requests với throughput cao
17+
- Triển khai trên edge devices với tài nguyên hạn chế
18+
19+
### 2. Memory Safety
20+
21+
Rust's ownership system ngăn chặn:
22+
- Memory leaks
23+
- Data races
24+
- Null pointer dereferences
25+
- Buffer overflows
26+
27+
Tính năng này cực kỳ quan trọng khi xây dựng production systems xử lý sensitive data hoặc chạy 24/7.
28+
29+
### 3. Concurrency và Parallelism
30+
31+
Rust cung cấp:
32+
- **Fearless concurrency**: Compiler đảm bảo thread-safety tại compile time
33+
- **async/await**: Xử lý I/O-bound operations hiệu quả
34+
- **Rayon**: Data parallelism dễ dàng
35+
36+
Điều này giúp xử lý multiple requests đồng thời và tận dụng tối đa hardware.
37+
38+
## Ecosystem LLM trong Rust
39+
40+
Rust có một ecosystem ngày càng phát triển cho AI/ML và LLM:
41+
42+
### Frameworks và Libraries
43+
44+
1. **[Rig](./rig.md)** - Framework hoàn chỉnh để xây dựng LLM applications
45+
2. **[llm crate](./llm-crate.md)** - Unified API cho nhiều LLM providers
46+
3. **[Candle](./candle.md)** - ML framework nhẹ với hỗ trợ CPU/GPU
47+
48+
### Use Cases Phổ Biến
49+
50+
- **LLM Inference**: Chạy models như GPT, Claude, Llama trực tiếp
51+
- **RAG Systems**: Retrieval-Augmented Generation với vector databases
52+
- **Multi-agent Systems**: Orchestrate nhiều LLM agents
53+
- **API Wrappers**: Tích hợp với OpenAI, Anthropic, Groq, etc.
54+
- **Model Serving**: REST APIs với performance cao
55+
56+
## So sánh với Python
57+
58+
| Đặc điểm | Rust | Python |
59+
|----------|------|--------|
60+
| Performance | ⚡ Rất cao (gần C/C++) | 🐌 Chậm hơn (interpreted) |
61+
| Memory Safety | ✅ Compile-time guarantees | ⚠️ Runtime errors possible |
62+
| Concurrency | ✅ Fearless concurrency | ⚠️ GIL limitations |
63+
| Development Speed | 📚 Steep learning curve | 🚀 Rapid prototyping |
64+
| Ecosystem Size | 📦 Đang phát triển | 📦 Rất lớn (mature) |
65+
| Deployment | 📦 Single binary | 🐍 Requires runtime + deps |
66+
67+
## Khi nào nên dùng Rust?
68+
69+
**Nên dùng Rust khi:**
70+
- Performance là critical (inference latency, throughput)
71+
- Cần deploy trên resource-constrained environments
72+
- Xây dựng production systems yêu cầu high reliability
73+
- Muốn single binary deployment (không cần Python runtime)
74+
- Xử lý sensitive data (memory safety quan trọng)
75+
76+
**Có thể dùng Python khi:**
77+
- Rapid prototyping và experimentation
78+
- Ecosystem phong phú của Python là bắt buộc
79+
- Team đã thành thạo Python
80+
- Model training (Rust tốt hơn cho inference)
81+
82+
## Getting Started
83+
84+
Để bắt đầu với LLM trong Rust, bạn có thể:
85+
86+
1. Học các libraries chính: [Rig](./rig.md), [llm crate](./llm-crate.md)
87+
2. Xem [Recent Updates 2025](./recent-updates-2025.md) để biết tin tức mới nhất
88+
3. Thử các examples từ [awesome-rust-llm](https://github.com/jondot/awesome-rust-llm)
89+
90+
## Resources
91+
92+
- [Rust for Large Language Model Operations (LLMOps) - Coursera](https://www.coursera.org/learn/rust-llmops)
93+
- [awesome-rust-llm - GitHub](https://github.com/jondot/awesome-rust-llm)
94+
- [Rust and LLM AI Infrastructure](https://betterprogramming.pub/rust-and-llm-ai-infrastructure-embracing-the-power-of-performance-c72bb705a96c)

0 commit comments

Comments
 (0)