Logo Rag Architect

Rag Architect

Tổ chức
mega-edo
rag-architect

RAG Architect - POWERFUL

Tổng quan

Nhà phát hànhmega-edo
Kho mãmega-tron
Tên kỹ năngrag-architect
Sao
27
Bản fork
2
Tệp đi kèm
3
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được mega-edo công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Rag Architect trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/mega-edo/mega-tron/tree/main/benchmarks/feedback_loop/pool/noise/engineering/rag-architect
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mega-edo/mega-tron.git /tmp/mega-tron
mkdir -p .claude/skills
cp -r /tmp/mega-tron/benchmarks/feedback_loop/pool/noise/engineering/rag-architect .claude/skills/rag-architect
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Rag Architect trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Rag Architect ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Rag Architect không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

RAG Architect - POWERFUL

Overview

The RAG (Retrieval-Augmented Generation) Architect skill provides comprehensive tools and knowledge for designing, implementing, and optimizing production-grade RAG pipelines. This skill covers the entire RAG ecosystem from document chunking strategies to evaluation frameworks, enabling you to build scalable, efficient, and accurate retrieval systems.

Core Competencies

1. Document Processing & Chunking Strategies

Fixed-Size Chunking
  • Character-based chunking: Simple splitting by character count (e.g., 512, 1024, 2048 chars)
  • Token-based chunking: Splitting by token count to respect model limits
  • Overlap strategies: 10-20% overlap to maintain context continuity
  • Pros: Predictable chunk sizes, simple implementation, consistent processing time
  • Cons: May break semantic units, context boundaries ignored
  • Best for: Uniform documents, when consistent chunk sizes are critical
Sentence-Based Chunking
  • Sentence boundary detection: Using NLTK, spaCy, or regex patterns
  • Sentence grouping: Combining sentences until size threshold is reached
  • Paragraph preservation: Avoiding mid-paragraph splits when possible
  • Pros: Preserves natural language boundaries, better readability
  • Cons: Variable chunk sizes, potential for very short/long chunks
  • Best for: Narrative text, articles, books
Paragraph-Based Chunking
  • Paragraph detection: Double newlines, HTML tags, markdown formatting
  • Hierarchical splitting: Respecting document structure (sections, subsections)
  • Size balancing: Merging small paragraphs, splitting large ones
  • Pros: Preserves logical document structure, maintains topic coherence
  • Cons: Highly variable sizes, may create very large chunks
  • Best for: Structured documents, technical documentation
Semantic Chunking
  • Topic modeling: Using TF-IDF, embeddings similarity for topic detection
  • Heading-aware splitting: Respecting document hierarchy (H1, H2, H3)
  • Content-based boundaries: Detecting topic shifts using semantic similarity
  • Pros: Maintains semantic coherence, respects document structure
  • Cons: Complex implementation, computationally expensive
  • Best for: Long-form content, technical manuals, research papers
Recursive Chunking
  • Hierarchical approach: Try larger chunks first, recursively split if needed
  • Multi-level splitting: Different strategies at different levels
  • Size optimization: Minimize number of chunks while respecting size limits
  • Pros: Optimal chunk utilization, preserves context when possible
  • Cons: Complex logic, potential performance overhead
  • Best for: Mixed content types, when chunk count optimization is important
Document-Aware Chunking
  • File type detection: PDF pages, Word sections, HTML elements
  • Metadata preservation: Headers, footers, page numbers, sections
  • Table and image handling: Special processing for non-text elements
  • Pros: Preserves document structure and metadata
  • Cons: Format-specific implementation required
  • Best for: Multi-format document collections, when metadata is important

2. Embedding Model Selection

Dimension Considerations
  • 128-256 dimensions: Fast retrieval, lower memory usage, suitable for simple domains
  • 512-768 dimensions: Balanced performance, good for most applications
  • 1024-1536 dimensions: High quality, better for complex domains, higher cost
  • 2048+ dimensions: Maximum quality, specialized use cases, significant resources
Speed vs Quality Tradeoffs
  • Fast models: sentence-transformers/all-MiniLM-L6-v2 (384 dim, ~14k tokens/sec)
  • Balanced models: sentence-transformers/all-mpnet-base-v2 (768 dim, ~2.8k tokens/sec)
  • Quality models: text-embedding-ada-002 (1536 dim, OpenAI API)
  • Specialized models: Domain-specific fine-tuned models
Model Categories
  • General purpose: all-MiniLM, all-mpnet, Universal Sentence Encoder
  • Code embeddings: CodeBERT, GraphCodeBERT, CodeT5
  • Scientific text: SciBERT, BioBERT, ClinicalBERT
  • Multilingual: LaBSE, multilingual-e5, paraphrase-multilingual

3. Vector Database Selection

Pinecone
  • Managed service: Fully hosted, auto-scaling
  • Features: Metadata filtering, hybrid search, real-time updates
  • Pricing: $70/month for 1M vectors (1536 dim), pay-per-use scaling
  • Best for: Production applications, when managed service is preferred
  • Cons: Vendor lock-in, costs can scale quickly
Weaviate
  • Open source: Self-hosted or cloud options available
  • Features: GraphQL API, multi-modal search, automatic vectorization
  • Scaling: Horizontal scaling, HNSW indexing
  • Best for: Complex data types, when GraphQL API is preferred
  • Cons: Learning curve, requires infrastructure management
Qdrant
  • Rust-based: High performance, low memory footprint
  • Features: Payload filtering, clustering, distributed deployment
  • API: REST and gRPC interfaces
  • Best for: High-performance requirements, resource-constrained environments
  • Cons: Smaller community, fewer integrations
Chroma
  • Embedded database: SQLite-based, easy local development
  • Features: Collections, metadata filtering, persistence
  • Scaling: Limited, suitable for prototyping and small deployments
  • Best for: Development, testing, small-scale applications
  • Cons: Not suitable for production scale
pgvector (PostgreSQL)
  • SQL integration: Leverage existing PostgreSQL infrastructure
  • Features: ACID compliance, joins with relational data, mature ecosystem
  • Performance: ivfflat and HNSW indexing, parallel query processing
  • Best for: When you already use PostgreSQL, need ACID compliance
  • Cons: Requires PostgreSQL expertise, less specialized than purpose-built DBs

4. Retrieval Strategies

Dense Retrieval
  • Semantic similarity: Using embedding cosine similarity
  • Advantages: Captures semantic meaning, handles paraphrasing well
  • Limitations: May miss exact keyword matches, requires good embeddings
  • Implementation: Vector similarity search with k-NN or ANN algorithms
Sparse Retrieval
  • Keyword-based: TF-IDF, BM25, Elasticsearch
  • Advantages: Exact keyword matching, interpretable results
  • Limitations: Misses semantic similarity, vulnerable to vocabulary mismatch
  • Implementation: Inverted indexes, term frequency analysis
Hybrid Retrieval
  • Combination approach: Dense + sparse retrieval with score fusion
  • Fusion strategies: Reciprocal Rank Fusion (RRF), weighted combination
  • Benefits: Combines semantic understanding with exact matching
  • Complexity: Requires tuning fusion weights, more complex infrastructure
Reranking
  • Two-stage approach: Initial retrieval followed by reranking
  • Reranking models: Cross-encoders, specialized reranking transformers
  • Benefits: Higher precision, can use more sophisticated models for final ranking
  • Tradeoff: Additional latency, computational cost

5. Query Transformation Techniques

HyDE (Hypothetical Document Embeddings)
  • Approach: Generate hypothetical answer, embed answer instead of query
  • Benefits: Improves retrieval by matching document style rather than query style
  • Implementation: Use LLM to generate hypothetical document, embed that
  • Use cases: When queries and documents have different styles
Multi-Query Generation
  • Approach: Generate multiple query variations, retrieve for each, merge results
  • Benefits: Increases recall, handles query ambiguity
  • Implementation: LLM generates 3-5 query variations, deduplicate results
  • Considerations: Higher cost and latency due to multiple retrievals
Step-Back Prompting
  • Approach: Generate broader, more general version of specific query
  • Benefits: Retrieves more general context that helps answer specific questions
  • Implementation: Transform "What is the capital of France?" to "What are European capitals?"
  • Use cases: When specific questions need general context

6. Context Window Optimization

Dynamic Context Assembly
  • Relevance-based ordering: Most relevant chunks first
  • Diversity optimization: Avoid redundant information
  • Token budget management: Fit within model context limits
  • Hierarchical inclusion: Include summaries before detailed chunks
Context Compression
  • Summarization: Compress less relevant chunks while preserving key information
  • Key information extraction: Extract only relevant facts/entities
  • Template-based compression: Use structured formats to reduce token usage
  • Selective inclusion: Include only chunks above relevance threshold

7. Evaluation Frameworks

Faithfulness Metrics
  • Definition: How well generated answers are grounded in retrieved context
  • Measurement: Fact verification against source documents
  • Implementation: NLI models to check entailment between answer and context
  • Threshold: >90% for production systems
Relevance Metrics
  • Context relevance: How relevant retrieved chunks are to the query
  • Answer relevance: How well the answer addresses the original question
  • Measurement: Embedding similarity, human evaluation, LLM-as-judge
  • Targets: Context relevance >0.8, Answer relevance >0.85
Context Precision & Recall
  • Precision@K: Percentage of top-K results that are relevant
  • Recall@K: Percentage of relevant documents found in top-K results
  • Mean Reciprocal Rank (MRR): Average of reciprocal ranks of first relevant result
  • NDCG@K: Normalized Discounted Cumulative Gain at K
End-to-End Metrics
  • RAGAS: Comprehensive RAG evaluation framework
  • Correctness: Factual accuracy of generated answers
  • Completeness: Coverage of all relevant aspects
  • Consistency: Consistency across multiple runs with same query

8. Production Patterns

Caching Strategies
  • Query-level caching: Cache results for identical queries
  • Semantic caching: Cache for semantically similar queries
  • Chunk-level caching: Cache embedding computations
  • Multi-level caching: Redis for hot queries, disk for warm queries
Streaming Retrieval
  • Progressive loading: Stream results as they become available
  • Incremental generation: Generate answers while still retrieving
  • Real-time updates: Handle document updates without full reprocessing
  • Connection management: Handle client disconnections gracefully
Fallback Mechanisms
  • Graceful degradation: Fallback to simpler retrieval if primary fails
  • Cache fallbacks: Serve stale results when retrieval is unavailable
  • Alternative sources: Multiple vector databases for redundancy
  • Error handling: Comprehensive error recovery and user communication

9. Cost Optimization

Embedding Cost Management
  • Batch processing: Batch documents for embedding to reduce API costs
  • Caching strategies: Cache embeddings to avoid recomputation
  • Model selection: Balance cost vs quality for embedding models
  • Update optimization: Only re-embed changed documents
Vector Database Optimization
  • Index optimization: Choose appropriate index types for use case
  • Compression: Use quantization to reduce storage costs
  • Tiered storage: Hot/warm/cold data strategies
  • Resource scaling: Auto-scaling based on query patterns
Query Optimization
  • Query routing: Route simple queries to cheaper methods
  • Result caching: Avoid repeated expensive retrievals
  • Batch querying: Process multiple queries together when possible
  • Smart filtering: Use metadata filters to reduce search space

10. Guardrails & Safety

Content Filtering
  • Toxicity detection: Filter harmful or inappropriate content
  • PII detection: Identify and handle personally identifiable information
  • Content validation: Ensure retrieved content meets quality standards
  • Source verification: Validate document authenticity and reliability
Query Safety
  • Injection prevention: Prevent malicious query injection attacks
  • Rate limiting: Prevent abuse and ensure fair usage
  • Query validation: Sanitize and validate user inputs
  • Access controls: Ensure users can only access authorized content
Response Safety
  • Hallucination detection: Identify when model generates unsupported claims
  • Confidence scoring: Provide confidence levels for generated responses
  • Source attribution: Always provide sources for factual claims
  • Uncertainty handling: Gracefully handle cases where answer is uncertain

Implementation Best Practices

Development Workflow

  1. Requirements gathering: Understand use case, scale, and quality requirements
  2. Data analysis: Analyze document corpus characteristics
  3. Prototype development: Build minimal viable RAG pipeline
  4. Chunking optimization: Test different chunking strategies
  5. Retrieval tuning: Optimize retrieval parameters and thresholds
  6. Evaluation setup: Implement comprehensive evaluation metrics
  7. Production deployment: Scale-ready implementation with monitoring

Monitoring & Observability

  • Query analytics: Track query patterns and performance
  • Retrieval metrics: Monitor precision, recall, and latency
  • Generation quality: Track faithfulness and relevance scores
  • System health: Monitor database performance and availability
  • Cost tracking: Monitor embedding and vector database costs

Maintenance & Updates

  • Document refresh: Handle new documents and updates
  • Index maintenance: Regular vector database optimization
  • Model updates: Evaluate and migrate to improved models
  • Performance tuning: Continuous optimization based on usage patterns
  • Security updates: Regular security assessments and updates

Common Pitfalls & Solutions

Poor Chunking Strategy

  • Problem: Chunks break mid-sentence or lose context
  • Solution: Use boundary-aware chunking with overlap

Low Retrieval Precision

  • Problem: Retrieved chunks are not relevant to query
  • Solution: Improve embedding model, add reranking, tune similarity threshold

High Latency

  • Problem: Slow retrieval and generation
  • Solution: Optimize vector indexing, implement caching, use faster embedding models

Inconsistent Quality

  • Problem: Variable answer quality across different queries
  • Solution: Implement comprehensive evaluation, add quality scoring, improve fallbacks

Scalability Issues

  • Problem: System doesn't scale with increased load
  • Solution: Implement proper caching, database sharding, and auto-scaling

Conclusion

Building effective RAG systems requires careful consideration of each component in the pipeline. The key to success is understanding the tradeoffs between different approaches and choosing the right combination of techniques for your specific use case. Start with simple approaches and gradually add sophistication based on evaluation results and production requirements.

This skill provides the foundation for making informed decisions throughout the RAG development lifecycle, from initial design to production deployment and ongoing maintenance.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Rag Architect làm được gì?

RAG Architect - POWERFUL

Vì sao nên dùng Rag Architect trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Rag Architect là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Rag Architect trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/mega-edo/mega-tron/tree/main/benchmarks/feedback_loop/pool/noise/engineering/rag-architect. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Rag Architect?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Rag Architect với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Rag Architect với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Rag Architect có miễn phí không?

Có. Kỹ năng này được mega-edo phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇