{"id":2530,"date":"2025-06-25T10:42:22","date_gmt":"2025-06-25T02:42:22","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=2530"},"modified":"2025-06-25T10:45:18","modified_gmt":"2025-06-25T02:45:18","slug":"chunk%e5%88%86%e5%89%b2%e7%9a%84%e5%8e%9f%e7%90%86%e5%92%8coverlap%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2025\/06\/25\/chunk%e5%88%86%e5%89%b2%e7%9a%84%e5%8e%9f%e7%90%86%e5%92%8coverlap%e4%bc%98%e5%8c%96\/","title":{"rendered":"Chunk\u5206\u5272\u7684\u539f\u7406\u548c\u7b80\u5355\u4f18\u5316"},"content":{"rendered":"\n<p><strong>chunk\u5206\u5272<\/strong>\u7684\u539f\u7406\u548c\u4e00\u4e9b\u4f18\u5316\u8bb0\u5f55<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Chunk\u5206\u5272\u7684\u539f\u7406<\/h2>\n\n\n\n<p>\u5728\u4ee3\u7801\uff08<code>src\/core\/hybrid_retrieval_db.py<\/code>\uff09\u4e2d\uff0cchunk\u5206\u5272\u7684\u6838\u5fc3\u903b\u8f91\u5728 <code>_split_text<\/code> \u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def _split_text(self, text: str) -&gt; List&#91;str]:\n        \"\"\"\n        \u5c06\u6587\u672c\u6309\u53e5\u5b50\u5206\u5272\u6210\u6709\u91cd\u53e0\u7684\u5757\u3002\n        \u8fd9\u79cd\u65b9\u6cd5\u901a\u8fc7\u5728\u5757\u4e4b\u95f4\u4fdd\u7559\u91cd\u53e0\u7684\u53e5\u5b50\u6765\u786e\u4fdd\u4e0a\u4e0b\u6587\u7684\u8fde\u7eed\u6027\uff0c\n        \u6709\u6548\u907f\u514d\u4e86\u50cf\"\u5b89\u5168\u8d39\u7528\"\u548c\"30\u5143\"\u8fd9\u6837\u7684\u5173\u952e\u4fe1\u606f\u88ab\u5206\u5272\u5728\u4e0d\u540c\u5757\u4e2d\u800c\u4e22\u5931\u5173\u8054\u7684\u95ee\u9898\u3002\n        Args:\n            text: \u539f\u59cb\u6587\u672c\u3002\n        \"\"\"\n        chunk_overlap = self.chunk_overlap\n\n        # 1. \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6309\u53e5\u5b50\u5206\u5272\uff0c\u540c\u65f6\u4fdd\u7559\u5206\u9694\u7b26\u3002\n        if not text:\n            return &#91;]\n        \n        parts = re.split(r'(&#91;\u3002\uff01\uff1f\uff1b\\n])', text)\n        sentences = &#91;]\n        for i in range(0, len(parts), 2):\n            sentence = parts&#91;i]\n            if i + 1 &lt; len(parts):\n                sentence += parts&#91;i+1]\n            sentence = sentence.strip()\n            if sentence:\n                sentences.append(sentence)\n\n        if not sentences:\n            return &#91;]\n\n        # 2. \u5c06\u53e5\u5b50\u5408\u5e76\u6210\u5757\uff0c\u5e76\u521b\u5efa\u91cd\u53e0\u3002\n        chunks = &#91;]\n        current_chunk_sentences = &#91;]\n        current_len = 0\n\n        for i in range(len(sentences)):\n            sentence = sentences&#91;i]\n            sentence_len = len(sentence)\n            \n            # \u5982\u679c\u52a0\u4e0a\u65b0\u53e5\u5b50\u4f1a\u8d85\u957f\uff0c\u5c31\u5148\u5c06\u5f53\u524d\u5757\u4fdd\u5b58\n            # (+1 \u662f\u4e3a\u4e86\u7a7a\u683c)\n            if current_chunk_sentences and current_len + sentence_len + 1 &gt; self.chunk_size:\n                chunks.append(\" \".join(current_chunk_sentences))\n                \n                # \u521b\u5efa\u91cd\u53e0\uff1a\u4ece\u4e0a\u4e00\u4e2a\u5757\u7684\u672b\u5c3e\u53d6N\u4e2a\u53e5\u5b50\u4f5c\u4e3a\u65b0\u5757\u7684\u5f00\u5934\n                start_index = max(0, len(current_chunk_sentences) - chunk_overlap)\n                current_chunk_sentences = current_chunk_sentences&#91;start_index:]\n                current_len = sum(len(s) for s in current_chunk_sentences) + max(0, len(current_chunk_sentences) - 1)\n            \n            # \u5982\u679c\u5355\u4e2a\u53e5\u5b50\u5c31\u8d85\u957f\uff0c\u76f4\u63a5\u628a\u5b83\u4f5c\u4e3a\u4e00\u4e2a\u5757\n            if sentence_len &gt; self.chunk_size:\n                # \u5982\u679c\u524d\u9762\u8fd8\u6709\u5185\u5bb9\uff0c\u5148\u4fdd\u5b58\n                if current_chunk_sentences:\n                    chunks.append(\" \".join(current_chunk_sentences))\n                    current_chunk_sentences = &#91;]\n                    current_len = 0\n                chunks.append(sentence)\n            else:\n                current_chunk_sentences.append(sentence)\n                current_len += sentence_len\n                if len(current_chunk_sentences) &gt; 1:\n                    current_len += 1  # \u52a0\u7a7a\u683c\u7684\u957f\u5ea6\n\n        # \u4e0d\u8981\u5fd8\u8bb0\u6700\u540e\u4e00\u4e2a\u5757\n        if current_chunk_sentences:\n            chunks.append(\" \".join(current_chunk_sentences))\n        \n        return chunks<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u539f\u7406\u7b80\u8ff0<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6309\u53e5\u5b50\u5206\u5272<\/strong>\uff1a\u9996\u5148\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u5168\u6587\u672c\u6309\u201c\u53e5\u5b50\u201d\u5206\u5272\uff08\u5305\u62ec\u4e2d\u6587\u7684\u53e5\u53f7\u3001\u95ee\u53f7\u3001\u611f\u53f9\u53f7\u3001\u5206\u53f7\u3001\u6362\u884c\u7b49\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6ed1\u52a8\u7a97\u53e3+\u91cd\u53e0<\/strong>\uff1a\u5c06\u82e5\u5e72\u53e5\u5b50\u5408\u5e76\u6210\u4e00\u4e2a\u201c\u5757\u201d\uff08chunk\uff09\uff0c\u6bcf\u4e2a\u5757\u7684\u957f\u5ea6\u4e0d\u8d85\u8fc7\u8bbe\u5b9a\u7684<code>chunk_size<\/code>\u3002\u5757\u4e0e\u5757\u4e4b\u95f4\u6709\u91cd\u53e0\uff08overlap\uff09\uff0c\u5373\u6bcf\u4e2a\u65b0\u5757\u4f1a\u5305\u542b\u4e0a\u4e00\u4e2a\u5757\u7ed3\u5c3e\u7684\u82e5\u5e72\u53e5\u5b50\uff08\u7531<code>chunk_overlap<\/code>\u63a7\u5236\uff09\u3002<\/li>\n\n\n\n<li><strong>\u7279\u6b8a\u5904\u7406<\/strong>\uff1a\u5982\u679c\u67d0\u4e2a\u53e5\u5b50\u672c\u8eab\u5c31\u5f88\u957f\uff0c\u8d85\u8fc7\u4e86<code>chunk_size<\/code>\uff0c\u5219\u5355\u72ec\u4f5c\u4e3a\u4e00\u4e2a\u5757\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f2a\u4ee3\u7801\u6d41\u7a0b<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6309\u53e5\u5b50\u5206\u5272\u6587\u672c\uff0c\u5f97\u5230\u53e5\u5b50\u5217\u8868\u3002<\/li>\n\n\n\n<li>\u7528\u6ed1\u52a8\u7a97\u53e3\u5c06\u53e5\u5b50\u62fc\u63a5\u6210\u5757\uff0c\u6bcf\u4e2a\u5757\u957f\u5ea6\u4e0d\u8d85\u8fc7<code>chunk_size<\/code>\u3002<\/li>\n\n\n\n<li>\u6bcf\u4e2a\u65b0\u5757\u7684\u5f00\u5934\u4f1a\u5305\u542b\u4e0a\u4e00\u4e2a\u5757\u7ed3\u5c3e\u7684\u82e5\u5e72\u53e5\u5b50\uff08overlap\uff09\uff0c\u4fdd\u8bc1\u4e0a\u4e0b\u6587\u8fde\u7eed\u3002<\/li>\n\n\n\n<li>\u8fd4\u56de\u6240\u6709\u5757\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. Chunk\u5206\u5272\u7684\u597d\u5904<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u63d0\u5347\u68c0\u7d22\u7684\u7c92\u5ea6\u548c\u76f8\u5173\u6027<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u68c0\u7d22\u65f6\u4e0d\u662f\u4ee5\u6574\u7bc7\u6587\u6863\u4e3a\u5355\u4f4d\uff0c\u800c\u662f\u4ee5\u201c\u5757\u201d\u4e3a\u5355\u4f4d\uff0c\u80fd\u66f4\u7cbe\u7ec6\u5730\u5b9a\u4f4d\u5230\u76f8\u5173\u5185\u5bb9\u3002<\/li>\n\n\n\n<li>\u7528\u6237\u7684\u67e5\u8be2\u66f4\u5bb9\u6613\u547d\u4e2d\u5177\u4f53\u7684\u77e5\u8bc6\u70b9\u6216\u4e8b\u5b9e\uff0c\u800c\u4e0d\u662f\u8fd4\u56de\u6574\u7bc7\u5927\u6587\u6863\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u907f\u514d\u5173\u952e\u4fe1\u606f\u88ab\u5272\u88c2<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7\u201c\u91cd\u53e0\u201d\u673a\u5236\uff08overlap\uff09\uff0c\u53ef\u4ee5\u9632\u6b62\u5173\u952e\u4fe1\u606f\uff08\u5982\u201c\u5b89\u5168\u8d39\u7528\u201d\u4e0e\u201c30\u5143\u201d\uff09\u88ab\u5206\u5728\u4e0d\u540c\u5757\u800c\u4e22\u5931\u4e0a\u4e0b\u6587\u3002<\/li>\n\n\n\n<li>\u8fd9\u6837\u5373\u4f7f\u7528\u6237\u7684\u67e5\u8be2\u8de8\u8d8a\u4e86\u4e24\u4e2a\u5757\u7684\u8fb9\u754c\uff0c\u4e5f\u80fd\u5728\u91cd\u53e0\u533a\u57df\u5185\u88ab\u68c0\u7d22\u5230\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u63d0\u5347\u5411\u91cf\u68c0\u7d22\u7684\u6548\u679c<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5411\u91cf\u68c0\u7d22\u6a21\u578b\uff08\u5982embedding\uff09\u5bf9\u957f\u6587\u672c\u7684\u6548\u679c\u6709\u9650\uff0c\u5206\u5757\u540e\u6bcf\u4e2a\u5757\u957f\u5ea6\u9002\u4e2d\uff0c\u80fd\u66f4\u597d\u5730\u8868\u8fbe\u8bed\u4e49\u3002<\/li>\n\n\n\n<li>\u907f\u514d\u4e86\u957f\u6587\u672cembedding\u7a00\u91ca\u5173\u952e\u4fe1\u606f\u7684\u95ee\u9898\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u652f\u6301\u5927\u6587\u6863\u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u4e0e\u589e\u91cf\u66f4\u65b0<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5927\u6587\u6863\u88ab\u5206\u6210\u591a\u4e2a\u5757\uff0c\u53ef\u4ee5\u5206\u6279\u5b58\u50a8\u3001\u68c0\u7d22\u548c\u66f4\u65b0\uff0c\u63d0\u5347\u7cfb\u7edf\u7684\u53ef\u6269\u5c55\u6027\u548c\u6548\u7387\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u4fbf\u4e8e\u540e\u7eed\u7684\u9ad8\u9636\u5904\u7406<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5206\u5757\u540e\u53ef\u4ee5\u5bf9\u6bcf\u4e2a\u5757\u5355\u72ec\u505aembedding\u3001\u6253\u6807\u7b7e\u3001\u6458\u8981\u3001\u4e8b\u5b9e\u9a8c\u8bc1\u7b49\u64cd\u4f5c\uff0c\u7075\u6d3b\u6027\u66f4\u9ad8\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u76f4\u89c2\u4f8b\u5b50<\/h2>\n\n\n\n<p>\u5047\u8bbe\u6709\u5982\u4e0b\u6587\u672c\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u201c\u5b89\u5168\u8d39\u7528\u6309\u716730\u5143\/\u5428\u7684\u6807\u51c6\u63d0\u53d6\u3002\u6240\u6709\u8d39\u7528\u9700\u4e13\u6b3e\u4e13\u7528\u3002\u8fdd\u53cd\u89c4\u5b9a\u5c06\u8ffd\u8d23\u3002\u201d<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5206\u5272\u540e\u53ef\u80fd\u5f97\u5230\uff1a<\/li>\n\n\n\n<li>Chunk1: \u201c\u5b89\u5168\u8d39\u7528\u6309\u716730\u5143\/\u5428\u7684\u6807\u51c6\u63d0\u53d6\u3002\u201d<\/li>\n\n\n\n<li>Chunk2: \u201c\u5b89\u5168\u8d39\u7528\u6309\u716730\u5143\/\u5428\u7684\u6807\u51c6\u63d0\u53d6\u3002\u6240\u6709\u8d39\u7528\u9700\u4e13\u6b3e\u4e13\u7528\u3002\u201d<\/li>\n\n\n\n<li>Chunk3: \u201c\u6240\u6709\u8d39\u7528\u9700\u4e13\u6b3e\u4e13\u7528\u3002\u8fdd\u53cd\u89c4\u5b9a\u5c06\u8ffd\u8d23\u3002\u201d<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u6837\uff0c<strong>\u201c30\u5143\/\u5428\u201d<\/strong>\u548c<strong>\u201c\u4e13\u6b3e\u4e13\u7528\u201d<\/strong>\u7684\u4fe1\u606f\u90fd\u80fd\u5728\u81f3\u5c11\u4e00\u4e2achunk\u4e2d\u5b8c\u6574\u51fa\u73b0\uff0c\u67e5\u8be2\u65f6\u4e0d\u4f1a\u9057\u6f0f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u603b\u7ed3<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>chunk\u5206\u5272<\/strong>\u662f\u5c06\u957f\u6587\u672c\u6309\u53e5\u5b50\u6ed1\u52a8\u5206\u5757\uff0c\u5e76\u8bbe\u7f6e\u91cd\u53e0\uff0c\u4fdd\u8bc1\u6bcf\u4e2a\u5757\u65e2\u4e0d\u592a\u957f\u4e5f\u4e0d\u5272\u88c2\u5173\u952e\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong>\u597d\u5904<\/strong>\uff1a\u63d0\u5347\u68c0\u7d22\u76f8\u5173\u6027\u3001\u907f\u514d\u4fe1\u606f\u5272\u88c2\u3001\u4f18\u5316\u5411\u91cf\u8868\u8fbe\u3001\u652f\u6301\u5927\u6587\u6863\u5904\u7406\u3001\u4fbf\u4e8e\u540e\u7eed\u5206\u6790\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5176\u4ed6\u591a\u9879\u4f18\u5316\u63aa\u65bd\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong>\u5206\u6279\u5904\u7406\uff08Batching\uff09\u4e0e\u663e\u5b58\u4f18\u5316<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5206\u6279\u6dfb\u52a0\u6587\u6863\u5230\u5411\u91cf\u6570\u636e\u5e93<\/strong><br>\u5728 <code>add_documents_to_db<\/code> \u65b9\u6cd5\u4e2d\uff0c\u6587\u6863\u5757\u662f\u5206\u6279\uff08batch_size\uff0c\u9ed8\u8ba432\uff09\u5904\u7406\u7684\uff0c\u800c\u4e0d\u662f\u4e00\u6b21\u6027\u5168\u90e8\u5904\u7406\u3002\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u907f\u514d\u663e\u5b58\u6ea2\u51fa\uff0c\u63d0\u5347\u5927\u6279\u91cf\u6570\u636e\u5904\u7406\u7684\u7a33\u5b9a\u6027\u548c\u6548\u7387\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  for start in range(0, len(documents), batch_size):\n      ...\n      with torch.inference_mode():\n          embeddings = self.embedding_model.encode(batch_docs, is_query=False)\n      ...\n      self.collection.add(...)\n      # \u91ca\u653eMPS\u663e\u5b58\n      if torch.backends.mps.is_available():\n          torch.mps.empty_cache()<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u81ea\u52a8\u91ca\u653e\u663e\u5b58<\/strong><br>\u9488\u5bf9 Apple Silicon (MPS) \u8bbe\u5907\uff0c\u5904\u7406\u5b8c\u6bcf\u4e2abatch\u540e\u4e3b\u52a8\u8c03\u7528 <code>torch.mps.empty_cache()<\/code> \u91ca\u653e\u663e\u5b58\uff0c\u9632\u6b62\u5185\u5b58\u6cc4\u6f0f\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>\u8bbe\u5907\u81ea\u9002\u5e94\u4e0e\u6570\u636e\u7c7b\u578b\u4f18\u5316<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u81ea\u52a8\u9009\u62e9\u6700\u4f73\u8bbe\u5907<\/strong><br>Embedding \u548c Reranker \u6a21\u578b\u4f1a\u81ea\u52a8\u68c0\u6d4b\u5e76\u4f18\u5148\u4f7f\u7528 MPS\uff08Apple Silicon\uff09\u3001CUDA\uff08NVIDIA GPU\uff09\u6216CPU\uff0c\u5145\u5206\u5229\u7528\u786c\u4ef6\u52a0\u901f\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  if torch.backends.mps.is_available():\n      self.device = torch.device(\"mps\")\n  elif torch.cuda.is_available():\n      self.device = torch.device(\"cuda\")\n  else:\n      self.device = torch.device(\"cpu\")<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6839\u636e\u8bbe\u5907\u9009\u62e9\u6570\u636e\u7c7b\u578b<\/strong><br>GPU\/MPS\u4e0a\u4f7f\u7528 float16\uff0cCPU\u4e0a\u7528 float32\uff0c\u8fdb\u4e00\u6b65\u63d0\u5347\u63a8\u7406\u901f\u5ea6\u548c\u8282\u7701\u5185\u5b58\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. <strong>\u6587\u672c\u5206\u5757\uff08Chunk\uff09\u4e0e\u91cd\u53e0\u4f18\u5316<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6309\u53e5\u5b50\u5206\u5757+\u91cd\u53e0<\/strong><br>\u6587\u672c\u5206\u5757\u65f6\u91c7\u7528\u6ed1\u52a8\u7a97\u53e3+\u91cd\u53e0\uff08overlap\uff09\u7b56\u7565\uff0c\u65e2\u4fdd\u8bc1\u4e86\u68c0\u7d22\u7c92\u5ea6\uff0c\u53c8\u907f\u514d\u4e86\u5173\u952e\u4fe1\u606f\u88ab\u5272\u88c2\uff0c\u63d0\u9ad8\u4e86\u68c0\u7d22\u76f8\u5173\u6027\u548c\u53ec\u56de\u7387\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. <strong>\u63a8\u7406\u6a21\u5f0f\u4f18\u5316<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f7f\u7528 <code>torch.inference_mode()<\/code><\/strong><br>\u5728\u6240\u6709embedding\u548c\u63a8\u7406\u76f8\u5173\u64cd\u4f5c\u4e2d\uff0c\u4f7f\u7528 <code>torch.inference_mode()<\/code>\uff0c\u5173\u95ed\u68af\u5ea6\u8ba1\u7b97\uff0c\u51cf\u5c11\u5185\u5b58\u6d88\u8017\u548c\u63d0\u5347\u63a8\u7406\u901f\u5ea6\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. <strong>\u9ad8\u6548\u7684\u5411\u91cf\u5f52\u4e00\u5316<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Embedding\u5f52\u4e00\u5316<\/strong><br>\u5728 <code>Qwen3Embedding.encode<\/code> \u65b9\u6cd5\u4e2d\uff0c\u6240\u6709\u5411\u91cf\u90fd\u505a\u4e86L2\u5f52\u4e00\u5316\uff08<code>F.normalize<\/code>\uff09\uff0c\u4fdd\u8bc1\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7684\u6709\u6548\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6. <strong>\u589e\u91cf\u66f4\u65b0\u4e0e\u5206\u5e03\u5f0f\u5b58\u50a8\u53cb\u597d<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u652f\u6301\u6587\u6863\u7684\u589e\u91cf\u66f4\u65b0\u548c\u5206\u5757\u5b58\u50a8<\/strong><br>\u6587\u6863\u88ab\u5206\u5757\u540e\uff0c\u53ef\u4ee5\u5355\u72ec\u589e\u5220\u6539\u67e5\uff0c\u4fbf\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u7684\u5206\u5e03\u5f0f\u7ba1\u7406\u548c\u9ad8\u6548\u66f4\u65b0\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">7. <strong>\u65e5\u5fd7\u4e0e\u8fdb\u5ea6\u8f93\u51fa<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8be6\u7ec6\u7684\u8fdb\u5ea6\u548c\u72b6\u6001\u8f93\u51fa<\/strong><br>\u5173\u952e\u6b65\u9aa4\u5747\u6709\u8be6\u7ec6\u7684\u65e5\u5fd7\u8f93\u51fa\uff0c\u4fbf\u4e8e\u76d1\u63a7\u548c\u8c03\u8bd5\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p>\u4f18\u5316\u63aa\u65bd\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5206\u6279\u5904\u7406\u4e0e\u663e\u5b58\u7ba1\u7406<\/li>\n\n\n\n<li>\u8bbe\u5907\u81ea\u9002\u5e94\u4e0e\u6570\u636e\u7c7b\u578b\u4f18\u5316<\/li>\n\n\n\n<li>\u6587\u672c\u5206\u5757\u4e0e\u91cd\u53e0<\/li>\n\n\n\n<li>\u63a8\u7406\u6a21\u5f0f\u4f18\u5316<\/li>\n\n\n\n<li>\u5411\u91cf\u5f52\u4e00\u5316<\/li>\n\n\n\n<li>\u589e\u91cf\u66f4\u65b0\u4e0e\u5206\u5e03\u5f0f\u53cb\u597d<\/li>\n\n\n\n<li>\u8be6\u7ec6\u65e5\u5fd7\u8f93\u51fa<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>chunk\u5206\u5272\u7684\u539f\u7406\u548c\u4e00\u4e9b\u4f18\u5316\u8bb0&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2530","post","type-post","status-publish","format-standard","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=2530"}],"version-history":[{"count":4,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2530\/revisions"}],"predecessor-version":[{"id":2534,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/2530\/revisions\/2534"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=2530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=2530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=2530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}