[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79RSEZFXKPN56JHQ46239AV":3,"skill-same:01M79RSEZFXKPN56JHQ46239AV":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M79RSEZFXKPN56JHQ46239AV","chunking-embeddings",null,"Chunking, embeddings, and RAG pipeline integration","jamon8888\u002Fhacienda-engine","jamon8888","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F145190?v=4","01M79RNFE7K7JZ1AZG8TACAV98","Jamin Rubio","01M79RNFEV6ZC1SZ4K04SHDY8Z",2,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fchunking-embeddings\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\ndescription: \"Chunking, embeddings, and RAG pipeline integration\"\nname: chunking-embeddings\npriority: critical\n---\n\n# Chunking & Embeddings\n\n**Text splitting strategies, embedding generation with FastEmbed, RAG pipeline integration**\n\n## Chunking Architecture Overview\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002F`, `crates\u002Fxberg\u002Fsrc\u002Fembeddings.rs`\n\n```text\nExtracted Text\n    |\n[1. Normalization] -> Clean whitespace, remove control chars\n    |\n[2. Chunk Strategy Selection] -> Fixed-size, semantic, syntax-aware, recursive\n    |\n[3. Overlap Management] -> Control context window overlap\n    |\n[4. Optional Embedding] -> Generate vectors with FastEmbed\n    |\nOutput: Vec\u003CChunk> with text, vectors, metadata\n```\n\n## Chunking Strategies\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002Fmod.rs`\n\n| Strategy                          | Pattern                                                 | Best For                                                           |\n| --------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------ |\n| **Fixed-Size**                    | Sliding window with configurable overlap                | Uniform chunks for embedding models with fixed token limits        |\n| **Semantic**                      | Split by sentences, merge\u002Fsplit by similarity threshold | Smart context preservation for LLM consumption and semantic search |\n| **Syntax-Aware**                  | Split by paragraph\u002Fsection\u002Fheading\u002Fcode-block structure | Preserving document structure (sections, code blocks) in RAG       |\n| **Recursive** (LangChain pattern) | Try separators in order: `\\n\\n`, `\\n`, `,`              | Best general-purpose chunking; auto-finds optimal split points     |\n\nKey config fields per strategy (see struct definitions in `chunking\u002Fmod.rs`):\n\n- Fixed-Size: `chunk_size`, `overlap`, `trim_whitespace`\n- Semantic: `target_chunk_size`, `min\u002Fmax_chunk_size`, `semantic_threshold`, `use_sentence_boundaries`\n- Syntax-Aware: `chunk_by` (Paragraph\u002FSection\u002FHeading\u002FSentence\u002FCodeBlock), `max_chunk_size`, `respect_code_blocks`\n- Recursive: `separators[]`, `chunk_size`, `overlap`\n\n## Chunking Configuration Presets\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002Fmod.rs`\n\n| Preset       | Chunk Size  | Overlap | Strategy   | Use Case               |\n| ------------ | ----------- | ------- | ---------- | ---------------------- |\n| **Balanced** | 512 tokens  | 50      | Semantic   | RAG sweet spot         |\n| **Compact**  | 256 tokens  | 32      | Fixed-Size | Dense vectors          |\n| **Extended** | 1024 tokens | 100     | Recursive  | Full context           |\n| **Minimal**  | 128 tokens  | 16      | (default)  | Lightweight embeddings |\n\nUsage: set `config.chunking.preset = Some(\"balanced\")` in `ExtractionConfig`.\n\n## Embedding Generation with FastEmbed\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fembeddings.rs`\n\n### Model Selection\n\n| Model                               | Dimensions | Notes                            |\n| ----------------------------------- | ---------- | -------------------------------- |\n| `BAAI\u002Fbge-small-en-v1.5` (default)  | 384        | Fast, excellent for RAG          |\n| `BAAI\u002Fbge-small-zh-v1.5`            | 384        | Chinese optimized                |\n| `BAAI\u002Fbge-base-en-v1.5`             | 768        | Better quality, slower           |\n| `jinaai\u002Fjina-embeddings-v2-base-en` | 768        | Long context (up to 8192 tokens) |\n| `Custom(path)`                      | varies     | Custom ONNX model path           |\n\n### Embedding Pattern\n\n`TextEmbeddingManager` provides singleton-cached models per config. Pattern:\n\n1. `get_or_init_model()` -- lazy-loads ONNX model (downloads if needed), caches in `Arc\u003CRwLock\u003CHashMap>>`\n2. `embed_chunks()` -- collects chunk texts, calls `model.embed(texts, batch_size)`, zips results back to `ChunkWithEmbedding`\n\nDefault config: `batch_size=256`, `device=CPU`, `parallel_requests=4`.\n\n### ONNX Runtime Requirement\n\nEmbeddings require ONNX Runtime. Feature-gated via:\n\n```toml\n[features]\nembeddings = [\"dep:fastembed\", \"dep:ort\"]\n```\n\nInstall: `brew install onnxruntime` (macOS) \u002F `apt install libonnxruntime libonnxruntime-dev` (Linux). Verify: `echo $ORT_DYLIB_PATH`.\n\n## RAG Integration Pattern\n\nThe full extraction-to-RAG pipeline:\n\n1. **Extract**: `extract(ExtractInput::from_uri(path), config)` -> `ExtractionResult`\n2. **Chunk**: Apply preset strategy to `output.results[0].content` -> `Vec\u003CChunk>`\n3. **Embed**: If embedding config present, `TextEmbeddingManager::embed_chunks()` -> `Vec\u003CChunkWithEmbedding>`\n4. **Output**: `RagDocument { file_path, metadata, chunks }` ready for vector DB ingestion\n\nSee `ChunkWithEmbedding` struct in `types.rs`: contains `text`, `embedding: Vec\u003Cf32>`, `dimensions`, `norm`, `metadata`.\n\n## Critical Rules\n\n1. **Chunking is preprocessing** - Always apply before embedding to ensure consistent vector sizes\n2. **Overlap prevents information loss** - Set overlap to 15-20% of chunk size\n3. **Embedding models are stateful** - Lazy load and cache to avoid repeated initialization\n4. **ONNX Runtime is required** - Gracefully degrade if not available (skip embeddings)\n5. **Batch embedding for performance** - Never embed single chunks; batch 50-1000 chunks\n6. **Normalize embeddings for search** - Use L2 norm for cosine similarity\n7. **Cache embedding results** - Don't re-embed identical text chunks\n8. **Model selection impacts quality** - bge-small (384) for speed, bge-base (768) for quality\n\n## Related Skills\n\n- **extraction-pipeline-patterns** - Text extraction preceding chunking\n- **api-server-mcp** - Endpoint for chunking + embedding operations\n- **ocr-backend-management** - OCR text quality affects chunking success\n","# Chunking & Embeddings\n\n**Text splitting strategies, embedding generation with FastEmbed, RAG pipeline integration**\n\n## Chunking Architecture Overview\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002F`, `crates\u002Fxberg\u002Fsrc\u002Fembeddings.rs`\n\n```text\nExtracted Text\n    |\n[1. Normalization] -> Clean whitespace, remove control chars\n    |\n[2. Chunk Strategy Selection] -> Fixed-size, semantic, syntax-aware, recursive\n    |\n[3. Overlap Management] -> Control context window overlap\n    |\n[4. Optional Embedding] -> Generate vectors with FastEmbed\n    |\nOutput: Vec\u003CChunk> with text, vectors, metadata\n```\n\n## Chunking Strategies\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002Fmod.rs`\n\n| Strategy                          | Pattern                                                 | Best For                                                           |\n| --------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------------ |\n| **Fixed-Size**                    | Sliding window with configurable overlap                | Uniform chunks for embedding models with fixed token limits        |\n| **Semantic**                      | Split by sentences, merge\u002Fsplit by similarity threshold | Smart context preservation for LLM consumption and semantic search |\n| **Syntax-Aware**                  | Split by paragraph\u002Fsection\u002Fheading\u002Fcode-block structure | Preserving document structure (sections, code blocks) in RAG       |\n| **Recursive** (LangChain pattern) | Try separators in order: `\\n\\n`, `\\n`, `,`              | Best general-purpose chunking; auto-finds optimal split points     |\n\nKey config fields per strategy (see struct definitions in `chunking\u002Fmod.rs`):\n\n- Fixed-Size: `chunk_size`, `overlap`, `trim_whitespace`\n- Semantic: `target_chunk_size`, `min\u002Fmax_chunk_size`, `semantic_threshold`, `use_sentence_boundaries`\n- Syntax-Aware: `chunk_by` (Paragraph\u002FSection\u002FHeading\u002FSentence\u002FCodeBlock), `max_chunk_size`, `respect_code_blocks`\n- Recursive: `separators[]`, `chunk_size`, `overlap`\n\n## Chunking Configuration Presets\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fchunking\u002Fmod.rs`\n\n| Preset       | Chunk Size  | Overlap | Strategy   | Use Case               |\n| ------------ | ----------- | ------- | ---------- | ---------------------- |\n| **Balanced** | 512 tokens  | 50      | Semantic   | RAG sweet spot         |\n| **Compact**  | 256 tokens  | 32      | Fixed-Size | Dense vectors          |\n| **Extended** | 1024 tokens | 100     | Recursive  | Full context           |\n| **Minimal**  | 128 tokens  | 16      | (default)  | Lightweight embeddings |\n\nUsage: set `config.chunking.preset = Some(\"balanced\")` in `ExtractionConfig`.\n\n## Embedding Generation with FastEmbed\n\n**Location**: `crates\u002Fxberg\u002Fsrc\u002Fembeddings.rs`\n\n### Model Selection\n\n| Model                               | Dimensions | Notes                            |\n| ----------------------------------- | ---------- | -------------------------------- |\n| `BAAI\u002Fbge-small-en-v1.5` (default)  | 384        | Fast, excellent for RAG          |\n| `BAAI\u002Fbge-small-zh-v1.5`            | 384        | Chinese optimized                |\n| `BAAI\u002Fbge-base-en-v1.5`             | 768        | Better quality, slower           |\n| `jinaai\u002Fjina-embeddings-v2-base-en` | 768        | Long context (up to 8192 tokens) |\n| `Custom(path)`                      | varies     | Custom ONNX model path           |\n\n### Embedding Pattern\n\n`TextEmbeddingManager` provides singleton-cached models per config. Pattern:\n\n1. `get_or_init_model()` -- lazy-loads ONNX model (downloads if needed), caches in `Arc\u003CRwLock\u003CHashMap>>`\n2. `embed_chunks()` -- collects chunk texts, calls `model.embed(texts, batch_size)`, zips results back to `ChunkWithEmbedding`\n\nDefault config: `batch_size=256`, `device=CPU`, `parallel_requests=4`.\n\n### ONNX Runtime Requirement\n\nEmbeddings require ONNX Runtime. Feature-gated via:\n\n```toml\n[features]\nembeddings = [\"dep:fastembed\", \"dep:ort\"]\n```\n\nInstall: `brew install onnxruntime` (macOS) \u002F `apt install libonnxruntime libonnxruntime-dev` (Linux). Verify: `echo $ORT_DYLIB_PATH`.\n\n## RAG Integration Pattern\n\nThe full extraction-to-RAG pipeline:\n\n1. **Extract**: `extract(ExtractInput::from_uri(path), config)` -> `ExtractionResult`\n2. **Chunk**: Apply preset strategy to `output.results[0].content` -> `Vec\u003CChunk>`\n3. **Embed**: If embedding config present, `TextEmbeddingManager::embed_chunks()` -> `Vec\u003CChunkWithEmbedding>`\n4. **Output**: `RagDocument { file_path, metadata, chunks }` ready for vector DB ingestion\n\nSee `ChunkWithEmbedding` struct in `types.rs`: contains `text`, `embedding: Vec\u003Cf32>`, `dimensions`, `norm`, `metadata`.\n\n## Critical Rules\n\n1. **Chunking is preprocessing** - Always apply before embedding to ensure consistent vector sizes\n2. **Overlap prevents information loss** - Set overlap to 15-20% of chunk size\n3. **Embedding models are stateful** - Lazy load and cache to avoid repeated initialization\n4. **ONNX Runtime is required** - Gracefully degrade if not available (skip embeddings)\n5. **Batch embedding for performance** - Never embed single chunks; batch 50-1000 chunks\n6. **Normalize embeddings for search** - Use L2 norm for cosine similarity\n7. **Cache embedding results** - Don't re-embed identical text chunks\n8. **Model selection impacts quality** - bge-small (384) for speed, bge-base (768) for quality\n\n## Related Skills\n\n- **extraction-pipeline-patterns** - Text extraction preceding chunking\n- **api-server-mcp** - Endpoint for chunking + embedding operations\n- **ocr-backend-management** - OCR text quality affects chunking success\n",{"name":5,"priority":24,"description":7},"critical","main","613e6deee7a2f31f95bac8beec31dd5171193c8d",".ai-rulez\u002Fskills\u002Fchunking-embeddings",0,"https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine","https:\u002F\u002Fhacienda-engine-hacienda-studio.vercel.app","https:\u002F\u002Fgithub.com\u002Fjamon8888","hacienda.diy","Maker","2026-11-15 05:01:55",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add jamon8888\u002Fhacienda-engine --skill chunking-embeddings",{"tool":41,"command":42},"bunx","bunx skills add jamon8888\u002Fhacienda-engine --skill chunking-embeddings",{"tool":44,"command":45},"pnpm","pnpm dlx skills add jamon8888\u002Fhacienda-engine --skill chunking-embeddings","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fchunking-embeddings\u002FSKILL.md",true,[],[50,57,64,71,78,85],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M79RTKG5HB5PQ251W7J9C4S6","impeccable","Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fimpeccable\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M79RTFDA4MAD9PPF3N15B68Y","wasm-constraints","WASM build constraints for the crates\u002Fxberg-wasm crate — the wasm-target feature set, no-tokio sync-only internal APIs, the mandatory SyncExtractor trait for WASM-compatible extractors, the 2 MB HTML size limit, size-optimized build config (opt-level=\"z\"), and the async-wrapper\u002Fsync-internal API pattern. Load when building for wasm32, adding or modifying a WASM-compatible extractor, or debugging WASM build\u002Fruntime failures.","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fwasm-constraints\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M79RTC4SV7NENKJXK2PSHK7H","release-versioning","How xberg versions are synced and released — Cargo.toml is the single source of truth, `task version:sync` propagates it to alef-managed binding manifests AND the integrations under integrations\u002F, which are versioned and published in lockstep with core (including -rc.N). Load before bumping a version, editing the version-sync task, or touching an integration's version\u002Fxberg dependency.","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Frelease-versioning\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M79RT94KWTS5R5T61S71H1AD","plugin-architecture-patterns","Plugin architecture, registration, and trait patterns","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fplugin-architecture-patterns\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M79RT3X076QPZYK10QF6Q22X","mime-detection-routing","MIME type detection and extractor routing in core\u002Fmime.rs and core\u002Fextractor\u002Fbytes.rs — the extension→EXT_TO_MIME→validate→registry→extractor flow, key detection functions, the 118+ case-insensitive extension map, priority-based registry selection, wildcard MIME families, and how to add a new MIME type. Load when adding a format, wiring an extractor to a MIME type, or debugging why a file routes to the wrong (or no) extractor.","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fmime-detection-routing\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M79RSZYWZ6RSAM31N2Y0TXMN","format-specific-extraction","Format-specific document extraction workflows","https:\u002F\u002Fgithub.com\u002Fjamon8888\u002Fhacienda-engine\u002Fblob\u002Fmain\u002F.ai-rulez\u002Fskills\u002Fformat-specific-extraction\u002FSKILL.md",[],[]]