{"id":269,"date":"2025-05-10T08:31:49","date_gmt":"2025-05-10T00:31:49","guid":{"rendered":"http:\/\/52.76.12.94\/?p=269"},"modified":"2026-06-04T11:22:42","modified_gmt":"2026-06-04T03:22:42","slug":"%e5%88%a9%e7%94%a8-amazon-bedrock-data-automation%ef%bc%88bda%ef%bc%89%e5%af%b9%e8%a7%86%e9%a2%91%e6%95%b0%e6%8d%ae%e8%bf%9b%e8%a1%8c%e8%87%aa%e5%8a%a8%e5%8c%96%e5%a4%84%e7%90%86%e4%b8%8e%e6%a3%80","status":"publish","type":"post","link":"https:\/\/flycloud.io\/en\/2025\/05\/10\/%e5%88%a9%e7%94%a8-amazon-bedrock-data-automation%ef%bc%88bda%ef%bc%89%e5%af%b9%e8%a7%86%e9%a2%91%e6%95%b0%e6%8d%ae%e8%bf%9b%e8%a1%8c%e8%87%aa%e5%8a%a8%e5%8c%96%e5%a4%84%e7%90%86%e4%b8%8e%e6%a3%80\/","title":{"rendered":"\u5229\u7528 Amazon Bedrock Data Automation\uff08BDA\uff09\u5bf9\u89c6\u9891\u6570\u636e\u8fdb\u884c\u81ea\u52a8\u5316\u5904\u7406\u4e0e\u68c0\u7d22"},"content":{"rendered":"<p>\u5f53\u524d\u70b9\u64ad\u89c6\u9891\u5e73\u53f0\u641c\u7d22\u529f\u80fd\u4e3b\u8981\u662f\u57fa\u4e8e\u89c6\u9891\u6807\u9898\u7684\u5173\u952e\u5b57\u68c0\u7d22\u3002\u5bf9\u4e8e\u70b9\u64ad\u5e73\u53f0\u800c\u8a00\uff0c\u6211\u4eec\u5e0c\u671b\u53ef\u4ee5\u901a\u8fc7\u4f18\u5316\u89c6\u9891\u641c\u7d22\u4f53\u9a8c\u6ee1\u8db3\u7528\u6237\u901a\u8fc7\u6a21\u7cca\u63cf\u8ff0\u67e5\u627e\u89c6\u9891\u7684\u9700\u6c42\uff0c\u4ece\u800c\u63d0\u9ad8\u7528\u6237\u7684\u641c\u7d22\u4f53\u9a8c\u3002\u501f\u52a9 Amazon Bedrock Data Automation\uff08BDA\uff09\u6280\u672f\uff0c\u8fd0\u7528 AI \u81ea\u52a8\u5256\u6790\u89c6\u9891\u5185\u5bb9\uff0c\u63d0\u53d6\u5173\u952e\u4fe1\u606f\uff0c\u901a\u8fc7\u5411\u91cf\u641c\u7d22\u8fbe\u6210\u8bed\u4e49\u667a\u80fd\u5339\u914d\uff0c\u5b9e\u73b0\u591a\u89d2\u5ea6\uff08\u89c6\u9891\u5173\u952e\u5b57\u3001\u53f0\u8bcd\u3001\u573a\u666f\u63cf\u8ff0\uff09\u89c6\u9891\u68c0\u7d22\uff0c\u6709\u5229\u4e8e\u63d0\u5347\u7528\u6237\u641c\u7d22\u6548\u7387\uff0c\u589e\u52a0\u5e73\u53f0\u6d3b\u8dc3\u5ea6\uff0c\u4e5f\u4e3a\u89c6\u9891\u521b\u4f5c\u8005\u521b\u9020\u66f4\u591a\u66dd\u5149\u673a\u9047\u3002 \u5728\u4e0b\u6587\u4e2d\uff0c\u6211\u4eec\u4f1a\u57fa\u4e8e Amazon Bedrock Data Automation\uff08BDA\uff09\u5b9e\u73b0\u89c6\u9891\u5904\u7406\u4e0e\u53cc\u8def\u53ec\u56de\u7684\u89e3\u51b3\u65b9\u6848\u8fdb\u884c\u63cf\u8ff0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Amazon Bedrock Data Automation \u529f\u80fd\u6982\u8ff0<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/xie.infoq.cn\/link?target=https%3A%2F%2Fdocs.aws.amazon.com%2Fzh_cn%2Fbedrock%2Flatest%2Fuserguide%2Fbda.html\">Bedrock Data Automation\uff08BDA\uff09<\/a>\u662f\u57fa\u4e8e\u4e91\u7684\u670d\u52a1\uff0c\u501f\u52a9\u751f\u6210\u5f0f AI\uff0c\u80fd\u5c06\u6587\u6863\u3001\u56fe\u50cf\u3001\u89c6\u9891\u548c\u97f3\u9891\u7b49\u975e\u7ed3\u6784\u5316\u5185\u5bb9\uff0c\u9ad8\u6548\u8f6c\u5316\u4e3a\u7ed3\u6784\u5316\u683c\u5f0f\uff0c\u81ea\u52a8\u63d0\u53d6\u3001\u751f\u6210\u5173\u952e\u4fe1\u606f\uff0c\u52a9\u529b\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\uff0c\u6267\u884c\u590d\u6742\u5de5\u4f5c\u6d41\u7a0b\u3002\u76ee\u524d\u652f\u6301 us-east-1 \u548c us-west-2 \u4e24\u4e2a\u5730\u533a\u3002<\/p>\n\n\n\n<p>\u4ece\u8f93\u51fa\u7ed3\u679c\u89d2\u5ea6\uff0cBDA \u652f\u6301\u6807\u51c6\u7ed3\u679c\u548c\u81ea\u5b9a\u4e49\u7ed3\u679c\u7684\u8f93\u51fa\uff0c\u5f53\u7528\u6237\u9009\u62e9\u81ea\u5b9a\u4e49\u7ed3\u679c\u7684\u8f93\u51fa\u65f6\uff0c\u53ef\u4ee5\u7528 prompt \u7684\u65b9\u5f0f\u53bb\u751f\u6210\u60f3\u8981\u7684\u7ed3\u679c\u3002\u81ea\u5b9a\u4e49\u7684\u7ed3\u6784\u53ef\u4ee5\u4fdd\u5b58\u4e3a\u84dd\u56fe\u4e3a BDA \u9879\u76ee\u6240\u4f7f\u7528\u3002\u76ee\u524d\u81ea\u5b9a\u4e49\u7ed3\u679c\u7684\u8f93\u51fa\u652f\u6301\u6587\u6863\u548c\u56fe\u7247\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/e7\/e7a8f1471bab87358413b87e12bbb856.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6807\u51c6\u7ed3\u679c\u7684\u8f93\u51fa\u5219\u5bf9\u56db\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u6e90\u505a\u4e86\u9884\u5b9a\u4e49\u7684\u8f93\u51fa\u7ed3\u6784\uff0c\u4f8b\u5982\u5bf9\u4e8e\u6587\u6863\u6570\u636e\uff0c\u6807\u51c6\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u4ece\u800c\u53ef\u4ee5\u4e3a\u4e0d\u540c\u4e0b\u6e38\u5e94\u7528\u6240\u7528\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/90\/9024d8f48c4a4bf409d4c54c4876fd80.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u624b\u52a8\u5728\u64cd\u4f5c\u53f0\u4e0a\u6d4b\u8bd5 DBA \u7684\u5404\u79cd\u529f\u80fd\u5305\u62ec\u6587\u6863\uff0c\u56fe\u7247\uff0c\u89c6\u9891\u548c\u97f3\u9891\u7b49\uff0c\u4ee5\u4e0b\u6211\u4eec\u4ee5\u89c6\u9891 Demo \u4e3a\u4f8b\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u627e\u5230 Amazon Bedrock \u5728\u63a7\u5236\u53f0\u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u70b9\u51fb\u5de6\u4fa7\u5de5\u5177\u680f\u4e2d Data Automation \u4e0b\u7684 Demo\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/35\/35a8e3ad8c6eeebecf75ae7f2dba07a2.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5728\u5de5\u5177\u680f\u4e2d\u7684 Demo \u4e2d\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u7528\u5df2\u5b58\u5728 Demo \u4e0a\u7684\u6570\u636e\uff0c\u6216\u4ece\u672c\u5730\/Amazon S3 \u4e2d\u4e0a\u4f20\u7684\u6570\u636e\u505a\u4e3a\u6e90\u6570\u636e\u8fdb\u884c\u6d4b\u8bd5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/63\/63a0527ac57b966b2c937fd01826be84.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6700\u540e\u70b9\u51fb Generate result\uff0c\u4fbf\u53ef\u4ee5\u5728\u5de6\u4fa7\u8f93\u51fa\u76f8\u5173\u7ed3\u679c\uff0c\u5e76\u53ef\u4ee5\u9009\u62e9\u6807\u51c6\u6570\u636e\u7ed3\u679c\u6216\u524d\u9762\u84dd\u56fe\u5236\u5b9a\u597d\u7684\u81ea\u5b9a\u4e49\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>\u5728\u89c6\u9891\u5904\u7406\u4e2d\uff0cBDA \u53ef\u4ee5\u751f\u6210\u5b8c\u6574\u89c6\u9891\u6458\u8981\u3001\u7ae0\u8282\u6458\u8981\u3001\u63d0\u53d6 IAB \u5206\u7c7b\u6cd5\u3001\u5b8c\u6574\u97f3\u9891\u811a\u672c\u3001\u89c6\u9891\u6587\u5b57\u3001\u8fdb\u884c\u5fbd\u6807\u68c0\u6d4b\u548c\u5185\u5bb9\u5ba1\u6838\u7b49\u3002\u5728\u63a8\u51fa BDA \u4e4b\u524d\uff0c\u4f20\u7edf\u5bf9\u89c6\u9891\u7684 RAG \u8fd8\u662f\u57fa\u4e8e\u624b\u5de5\u5bf9\u5207\u7247\u5904\u7406\uff0c\u5e76\u624b\u5de5\u901a\u8fc7 SaaS \u6216\u5927\u6a21\u578b\u5bf9\u89c6\u9891\u58f0\u97f3\u6458\u5f55\uff0c\u6587\u5b57\u63d0\u53d6\u3002BDA \u7b80\u5316\u4e86\u8fd9\u4e00\u6d41\u7a0b\uff0c\u8f93\u51fa\u7684\u5185\u5bb9\u4ee5 Json \u6587\u6863\u7684\u5f62\u5f0f\u5448\u73b0\u3002<\/p>\n\n\n\n<p>Json \u6587\u6863\u7ed3\u6784\u76ee\u524d\u7248\u672c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1aMetadata\u3001shots\u3001chapters\u3001video\u3001statistics<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Metadata \u5305\u542b\u89c6\u9891\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5982\u8d44\u4ea7 ID\u3001\u683c\u5f0f\u3001\u5e27\u7387\u3001\u7f16\u7801\u3001\u65f6\u957f\u3001\u5206\u8fa8\u7387\u7b49\u3002<\/li>\n\n\n\n<li>Shots \u662f DBA \u81ea\u52a8\u5c06\u89c6\u9891\u5206\u5272\u6210\u591a\u4e2a\u955c\u5934\uff0c\u6bcf\u4e2a\u955c\u5934\u5305\u62ec\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u65f6\u95f4\u7801\uff0c\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u65f6\u95f4\u6233\uff08\u6beb\u79d2\uff09\uff0c\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u5e27\u7d22\u5f15\uff0c\u6301\u7eed\u65f6\u95f4\uff0c\u7f6e\u4fe1\u5ea6\uff0c\u6240\u5c5e\u7ae0\u8282\u7d22\u5f15\u3002<\/li>\n\n\n\n<li>Chapters \u662f DBA \u81ea\u52a8\u5c06\u89c6\u9891\u5206\u5272\u6210\u591a\u4e2a\u7ae0\u8282\uff0c\u6bcf\u4e2a\u7ae0\u8282\u5305\u542b\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u65f6\u95f4\u7801\uff0c\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u65f6\u95f4\u6233\uff08\u6beb\u79d2\uff09\uff0c\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u5e27\u7d22\u5f15\uff0c\u6301\u7eed\u65f6\u95f4\uff0c\u5305\u542b\u7684\u955c\u5934\u7d22\u5f15\uff0c\u7ae0\u8282\u6458\u8981\uff0c\u8f6c\u5f55\u6587\u672c\uff0cIAB \u5206\u7c7b\uff0c\u5185\u5bb9\u5ba1\u6838\u7b49\u3002\u5176\u4e2d\uff0cIAB \u5206\u7c7b\u53ef\u4ee5\u5e2e\u52a9\u5e7f\u544a\u627e\u5230\u89c6\u9891\u4e2d\u53ef\u4ee5\u5207\u5165\u7684\u70b9\uff0c\u8ba9\u5e7f\u544a\u7684\u5f15\u5165\u53ef\u4ee5\u66f4\u52a0\u6d41\u7545\u3002<\/li>\n\n\n\n<li>Video \u91cc\u9762\u5305\u542b\u4e86\u89c6\u9891\u603b\u7ed3\u548c\u89c6\u9891\u6574\u4f53\u7684\u8f6c\u5f55\u6587\u672c\u3002\u89c6\u9891\u6574\u4f53\u7684\u8f6c\u5f55\u6587\u672c\u5305\u542b\u4e86\u6bcf\u4e2a\u7ae0\u8282\u7684\u8f6c\u5f55\u6587\u672c\u3002<\/li>\n\n\n\n<li>Statistics \u4e3b\u8981\u662f\u5bf9\u89c6\u9891\u6570\u636e\u7684\u7edf\u8ba1\uff0c\u5305\u542b\u4e86\u955c\u5934\u6570\u91cf\u7edf\u8ba1\uff0c\u7ae0\u8282\u7edf\u8ba1\u548c\u89c6\u9891\u4e2d\u53d1\u8a00\u4eba\u7684\u6570\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4e3b\u8981\u7528\u5230\u4e86 DBA \u89c6\u9891\u5904\u7406\u7684\u5904\u7406\u624b\u6bb5\uff0c\u6765\u5c06\u89c6\u9891\u6570\u636e\u8f6c\u5316\u6210 json \u7ed3\u6784\u6570\u636e\u4e3a\u7528\u6237\u63d0\u4f9b\u6587\u5b57\u641c\u7d22\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u76f8\u5173\u67b6\u6784\u7684\u4ecb\u7ecd\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u76f8\u5173\u67b6\u6784\u8bf4\u660e<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u67b6\u6784\u603b\u89c8<\/strong><\/h4>\n\n\n\n<p>\u6574\u4e2a\u89c6\u9891\u5904\u7406\u4e0e\u68c0\u7d22\u7cfb\u7edf\u4e3b\u8981\u7531 Amazon S3\u3001Amazon EventBridge\u3001Amazon Lambda\u3001Amazon Bedrock\u3001Amazon DocumentDB\u3001Amazon API Gateway \u548c Amazon CloudFront \u7b49\u7ec4\u4ef6\u6784\u6210\uff0c\u5404\u7ec4\u4ef6\u534f\u540c\u5de5\u4f5c\uff0c\u5b9e\u73b0\u89c6\u9891\u6570\u636e\u7684\u81ea\u52a8\u5316\u5904\u7406\u4e0e\u9ad8\u6548\u68c0\u7d22\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u76f8\u5173\u6280\u672f\u7ec4\u4ef6<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Amazon S3\uff1a\u4f5c\u4e3a\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0c\u8d1f\u8d23\u5b58\u50a8\u89c6\u9891\u6587\u4ef6\u548c\u5904\u7406\u540e\u7684 json \u6587\u4ef6\u3002\u5b83\u5177\u6709\u9ad8\u53ef\u9760\u6027\u3001\u9ad8\u6269\u5c55\u6027\u548c\u4f4e\u6210\u672c\u7b49\u4f18\u52bf\uff0c\u4e3a\u89c6\u9891\u6570\u636e\u7684\u5b58\u50a8\u63d0\u4f9b\u4e86\u7a33\u5b9a\u7684\u57fa\u7840\u3002<\/li>\n\n\n\n<li>Amazon EventBridge\uff1a\u4f5c\u4e3a\u7cfb\u7edf\u4e2d\u5173\u952e\u7684\u4e8b\u4ef6\u89e6\u53d1\u4e2d\u67a2\uff0c\u8d1f\u8d23\u76d1\u6d4b\u7279\u5b9a\u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u4e00\u65e6\u68c0\u6d4b\u5230\u89c6\u9891\u6587\u4ef6\u4e0a\u4f20\u81f3 S3 \u6216 S3 \u8def\u5f84\u4e2d\u6587\u4ef6\u751f\u6210\uff0c\u5b83\u4fbf\u8fc5\u901f\u54cd\u5e94\uff0c\u7cbe\u51c6\u89e6\u53d1\u76f8\u5e94\u7684 Lambda \u51fd\u6570\u8c03\u7528\u3002<\/li>\n\n\n\n<li>Amazon Lambda\uff1a\u57fa\u4e8e\u65e0\u670d\u52a1\u5668\u8ba1\u7b97\u67b6\u6784\uff0c\u5141\u8bb8\u7528\u6237\u76f4\u63a5\u901a\u8fc7\u4ee3\u7801\u5b9e\u73b0\u5404\u79cd\u529f\u80fd\u3002\u5728\u672c\u7cfb\u7edf\u4e2d\uff0cLambda \u627f\u62c5\u4e86\u591a\u9879\u91cd\u8981\u4efb\u52a1\uff0c\u5982\u8c03\u7528 Bedrock API \u5904\u7406\u89c6\u9891\uff0c\u5c06\u975e\u7ed3\u6784\u5316\u7684\u89c6\u9891\u6570\u636e\u8f6c\u5316\u4e3a\u7ed3\u6784\u5316\u7684 json \u6587\u4ef6\uff1b\u8c03\u7528 Bedrock \u4e0a\u7684\u6a21\u578b\uff08\u5982 titan-embed-text-v2:0\uff09\u4e3a json \u6587\u4ef6\u5185\u5bb9\u751f\u6210 embedding\uff0c\u4ee5\u4fbf\u540e\u7eed\u8fdb\u884c\u5411\u91cf\u68c0\u7d22\u3002<\/li>\n\n\n\n<li>Amazon Bedrock\uff1aAmazon \u7684 AI \u4e00\u7ad9\u5f0f\u5e73\u53f0\uff0c\u96c6\u6210\u4e86\u5404\u79cd\u5148\u8fdb\u7684 AI \u6a21\u578b\uff0c\u4e3a\u7cfb\u7edf\u63d0\u4f9b\u5f3a\u5927\u7684 AI \u5904\u7406\u80fd\u529b\u3002\u5728\u672c\u6848\u4f8b\u4e2d\uff0c\u5176\u4e3b\u8981\u63d0\u4f9b\u4e86 BDA \u7684\u89c6\u9891\u5904\u7406\u529f\u80fd\u548c Titan \u6a21\u578b\u4e0e Cohere \u6a21\u578b\u7684\u8c03\u7528\u3002\u5176\u4e2d\uff0c\u5bf9 BDA \u7684\u8c03\u7528\u9700\u8981\u4f9d\u8d56 BDA \u9879\u76ee\u5bf9\u4e8e\u8f93\u51fa\u7684\u9884\u5b9a\u4e49\u3002\u5728\u6848\u4f8b\u4e2d\uff0c\u6211\u4eec\u9009\u62e9\u4ee5\u4e0b\u8f93\u51fa\u4f5c\u4e3a\u6570\u636e\u6e90\u8fdb\u884c\u5904\u7406\uff0c\u5bf9\u4e8e\u5176\u4ed6\u9879\u76ee\uff0c\u5177\u4f53\u8f93\u51fa\u53ef\u4ee5\u6309\u7167\u9700\u8981\u81ea\u884c\u52fe\u9009\uff1a<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/5a\/5a7c9ccd0d49b649fa468829f5104e0d.png\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Amazon DocumentDB\uff1a\u5b58\u50a8\u7531 BDA \u751f\u6210\u7684 json \u6587\u6863\u3002Amazon DocumentDB \u517c\u5bb9 Mongo DB\uff0c\u662f\u539f\u751f\u7684\u5b8c\u5168\u6258\u7ba1 json \u6587\u6863\u6570\u636e\u5e93\uff0c\u652f\u6301\u5411\u91cf\u3001\u6587\u672c\u7684\u5b58\u50a8\u3001\u7d22\u5f15\u548c\u805a\u5408\u3002DocumentDB \u5177\u5907\u5f3a\u5927\u7684\u6027\u80fd\u548c\u6269\u5c55\u6027\uff0c\u80fd\u591f\u540c\u65f6\u6ee1\u8db3\u64cd\u4f5c\u578b\u548c\u5206\u6790\u578b\u5de5\u4f5c\u8d1f\u8f7d\u7684\u9700\u6c42\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u63d0\u9ad8\u6570\u636e\u68c0\u7d22\u7684\u6548\u7387\uff0c\u5728\u6587\u5b57\u6570\u636e\u548c\u5411\u91cf\u6570\u636e\u7684\u5904\u7406\u4e2d\u90fd\u6709\u7740\u91cd\u8981\u4f5c\u7528\u3002\u6211\u4eec\u5728 Amazon DocumentDB \u4e2d\u521b\u5efa\u4e86\u6587\u5b57\u5012\u6392\u7d22\u5f15\u548c\u5411\u91cf\u7d22\u5f15\u4e3a\u540e\u7eed\u68c0\u7d22\u505a\u51c6\u5907\u3002\u7531\u4e8e\u662f\u6587\u672c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\uff0c\u6211\u4eec\u9009\u7528\u4f59\u5f26\u76f8\u4f3c\u5ea6\uff08cosine\uff09\u6765\u7528\u4e8e\u5411\u91cf\u7d22\u5f15\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>[<\/code><code>  { v: 4, key: { _id: 1 }, name: '_id_', ns: 'VideoData.videodata' },<\/code><code>  {<\/code><code>    v: 1,<\/code><code>    key: { _fts: 'text', _ftsx: 1 },<\/code><code>    name: 'text_index',<\/code><code>    ns: 'VideoData.videodata',<\/code><code>    default_language: 'english',<\/code><code>    weights: { text: 1 },<\/code><code>    textIndexVersion: 1<\/code><code>  },<\/code><code>  {<\/code><code>    v: 4,<\/code><code>    key: { embedding: 'vector' },<\/code><code>    name: 'vector_index',<\/code><code>    vectorOptions: {<\/code><code>      type: 'ivfflat',<\/code><code>      dimensions: 1024,<\/code><code>      similarity: 'cosine',<\/code><code>      lists: 1000<\/code><code>    },<\/code><code>    ns: 'VideoData.videodata'<\/code><code>  }<\/code><code>]<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Amazon API Gateway\uff1a\u4f5c\u4e3a API \u7ba1\u7406\u63a5\u53e3\uff0c\u8fde\u63a5\u524d\u7aef\u7528\u6237\u4e0e\u540e\u7aef\u670d\u52a1\u3002\u5b83\u8d1f\u8d23\u63a5\u6536\u524d\u7aef\u7528\u6237\u7684\u641c\u7d22\u8bf7\u6c42\uff0c\u5e76\u5c06\u5176\u8f6c\u53d1\u7ed9\u540e\u7aef\u7684 Lambda \u51fd\u6570\u8fdb\u884c\u5904\u7406\uff0c\u540c\u65f6\u5c06\u540e\u7aef\u5904\u7406\u7ed3\u679c\u8fd4\u56de\u7ed9\u524d\u7aef\u7528\u6237\uff0c\u4fdd\u969c\u4e86\u524d\u540e\u7aef\u6570\u636e\u4ea4\u4e92\u7684\u5b89\u5168\u548c\u9ad8\u6548\u3002<\/li>\n\n\n\n<li>Amazon CloudFront\uff1a\u4e3b\u8981\u7528\u4e8e\u52a0\u901f\u89c6\u9891\u5185\u5bb9\u7684\u5206\u53d1\u548c\u53ec\u56de\u3002\u901a\u8fc7\u5728\u5168\u7403\u8303\u56f4\u5185\u90e8\u7f72\u8fb9\u7f18\u8282\u70b9\uff0c\u5b83\u80fd\u591f\u5feb\u901f\u5c06\u89c6\u9891\u5185\u5bb9\u4f20\u9012\u7ed9\u7528\u6237\uff0c\u51cf\u5c11\u7528\u6237\u7b49\u5f85\u65f6\u95f4\uff0c\u63d0\u5347\u7528\u6237\u89c2\u770b\u89c6\u9891\u7684\u6d41\u7545\u5ea6\u548c\u4f53\u9a8c\u611f\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">\u67b6\u6784\u56fe<\/h4>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/ff\/ffc7a339fbf6d881019d4a383e8a29f3.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u89c6\u9891\u68c0\u7d22\u6d41\u7a0b<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u524d\u7f6e\u8fc7\u7a0b<\/strong><\/h4>\n\n\n\n<p>\u4e3a\u4e86\u66f4\u52a0\u65b9\u4fbf\u5feb\u901f\u5730\u90e8\u7f72\u548c\u4f7f\u7528\u672c\u65b9\u6848\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u57fa\u4e8e AWS CDK \u7684\u5168\u81ea\u52a8\u5316\u90e8\u7f72\u65b9\u6cd5: \uff1a<a href=\"https:\/\/xie.infoq.cn\/link?target=https%3A%2F%2Fgithub.com%2FJJJingjing%2Fsample-for-video-search\">sample-for-video-search<\/a>\u3002\u60a8\u53ef\u4ee5\u6309\u7167 README \u6765\u5c06\u6574\u5957\u73af\u5883\u8d44\u6e90\u5feb\u901f\u90e8\u7f72\u5728\u81ea\u5df1\u7684\u4e9a\u9a6c\u900a\u4e91\u79d1\u6280\u73af\u5883\u4e2d\uff0c\u968f\u540e\u4fbf\u53ef\u4ee5\u5f00\u59cb\u4ee5\u4e0b\u68c0\u7d22\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<p><strong>1. \u6570\u636e\u4e0a\u4f20<\/strong><\/p>\n\n\n\n<p>\u5728\u6211\u4eec\u7684\u6848\u4f8b\u4e2d\uff0c\u5e73\u53f0\u53ef\u4ee5\u5c06\u89c6\u9891\u6587\u4ef6\uff08mp4\/mov \u683c\u5f0f\uff09\u4e0a\u4f20\u81f3 Amazon S3 \u8def\u5f84\u4e2d\uff0c\u4f8b\u5982 s3:\/\/&lt;bucket-name&gt;\/video-input\/\uff0c\u4f5c\u4e3a\u540e\u7eed\u5904\u7406\u7684\u6e90\u6570\u636e\u3002<\/p>\n\n\n\n<p><strong>2. \u89c6\u9891\u5904\u7406\u4e0e\u89c6\u9891 Json \u6587\u4ef6\u751f\u6210<\/strong><\/p>\n\n\n\n<p>\u5f53 Amazon S3 \u8def\u5f84\u4e2d\u6709\u6587\u4ef6\u4e0a\u4f20\u5b8c\u6bd5\u65f6\uff0cAmazon EventBridge \u4f1a\u76d1\u6d4b\u5230\u76f8\u5173\u4e8b\u4ef6\u5e76\u89e6\u53d1 Amazon Lambda \u8c03\u7528 Amazon Bedrock API \u5bf9\u89c6\u9891\u6587\u4ef6\u6309\u7167\u5b9e\u73b0\u521b\u5efa\u7684 DBA \u9879\u76ee\u8fdb\u884c\u5904\u7406\u3002DBA \u9879\u76ee\u662f\u5229\u7528 Lambda \u5728\u89c6\u9891\u5904\u7406\u6d41\u7a0b\u524d\u521b\u5efa\u3002\u89c6\u9891\u5904\u7406\u5b8c\u6210\u540e\uff0c\u751f\u6210\u76f8\u5e94\u7684 json \u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4f20\u56de Amazon S3 \u5b58\u50a8 s3:\/\/&lt;bucket-name&gt;\/video-output\/\u3002\u76f8\u5173\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code># invokes bda by async approach with a given input file<\/code><code>def invoke_insight_generation_async(<\/code><code>        input_s3_uri,<\/code><code>        output_s3_uri,<\/code><code>        data_project_arn, blueprints = None):<\/code><code><br><\/code><code>    # Extract account ID from project ARN<\/code><code>    account_id = data_project_arn.split(':')[4]<\/code><code>    <\/code><code>    # Construct default Profile ARN using fixed us-west-2 region\uff0cwhich currently supports the 2 models required in the following process<\/code><code>    profile_arn = f\"arn:aws:bedrock:us-west-2:{account_id}:data-automation-profile\/us.data-automation-v1\"<\/code><code><br><\/code><code>    payload = {<\/code><code>        \"inputConfiguration\": {<\/code><code>            \"s3Uri\": input_s3_uri<\/code><code>        },<\/code><code>        \"outputConfiguration\": {<\/code><code>            \"s3Uri\": output_s3_uri<\/code><code>        },<\/code><code>        \"dataAutomationConfiguration\": {<\/code><code>            \"dataAutomationProjectArn\": data_project_arn,<\/code><code>            \"stage\": \"LIVE\"<\/code><code>        },<\/code><code>        \"dataAutomationProfileArn\": profile_arn,<\/code><code>        \"notificationConfiguration\": {<\/code><code>            \"eventBridgeConfiguration\": {\"eventBridgeEnabled\": True},<\/code><code>        }<\/code><code>    }<\/code><code><br><\/code><code>    try:<\/code><code>        response = bda_client_runtime.invoke_data_automation_async(**payload)<\/code><code>        print(f\"Successfully invoked data automation: {response}\")<\/code><code>        return response<\/code><code>    except Exception as e:<\/code><code>        print(f\"Error invoking data automation: {str(e)}\")<\/code><code>        raise<\/code><\/pre>\n\n\n\n<p><strong>3. \u57fa\u4e8e\u89c6\u9891 Json \u6587\u4ef6\u7684 Embedding \u5904\u7406<\/strong><\/p>\n\n\n\n<p>\u4e4b\u540e\uff0cAmazon S3 \u6587\u4ef6\u751f\u6210\u7684\u89c4\u5219\u4f1a\u518d\u6b21\u89e6\u53d1\u7684 Amazon EventBridge\uff0c\u4f7f\u5176\u542f\u52a8 Amazon Lambda \u8c03\u7528 Amazon Bedrock \u96c6\u6210\u7684 amazon.titan-embed-text-v2:0 \u6a21\u578b\uff0c\u4e3a Json \u6587\u4ef6\u5185\u5bb9\u505a \u5411\u91cf\u5316\u7528\u4e8e\u540e\u7eed\u67e5\u8be2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>try:<\/code><code>        response = bedrock_client.invoke_model(<\/code><code>            modelId=\"amazon.titan-embed-text-v2:0\",<\/code><code>            contentType=\"application\/json\",<\/code><code>            accept=\"application\/json\",<\/code><code>            body=json.dumps({<\/code><code>                \"inputText\": text<\/code><code>            })<\/code><code>        )<\/code><\/pre>\n\n\n\n<p>\u7531\u4e8e\u6bcf\u4e2a chapter \u5185\u7684 transcripts \u8f83\u957f\uff0c\u4e3a\u8fbe\u5230\u66f4\u597d\u7684\u68c0\u7d22\u6548\u679c\uff0c\u4f1a\u5bf9\u5176\u8fdb\u884c\u5207\u7247\u5904\u7406\uff0c\u6700\u540e\u5c06\u6574\u7406\u597d\u7684\u6570\u636e\u7ed3\u6784\u5b58\u5165 DocumentDB\u3002\u7531\u4e8e\u662f\u7b80\u6613\u73af\u5883\uff0c\u6211\u4eec\u57fa\u4e8e\u5b57\u7b26\u957f\u5ea6\u505a\u4e86\u7b80\u5355\u7684\u5207\u7247\u5904\u7406\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>def split_transcript_into_chunks(self, transcript_text, max_chunk_size=500, min_chunk_size=100):<\/code><code>        if not transcript_text:<\/code><code>            return []<\/code><code><br><\/code><code>        # \u5982\u679c\u8f93\u5165\u662f\u5b57\u5178\uff0c\u5c1d\u8bd5\u63d0\u53d6\u6587\u672c<\/code><code>        if isinstance(transcript_text, dict):<\/code><code>            if 'text' in transcript_text:<\/code><code>                transcript_text = transcript_text['text']<\/code><code>            elif 'representation' in transcript_text and 'text' in transcript_text['representation']:<\/code><code>                transcript_text = transcript_text['representation']['text']<\/code><code>            else:<\/code><code>                transcript_text = json.dumps(transcript_text)<\/code><code><br><\/code><code>        # \u786e\u4fdd\u8f93\u5165\u662f\u5b57\u7b26\u4e32<\/code><code>        if not isinstance(transcript_text, str):<\/code><code>            transcript_text = str(transcript_text)<\/code><code><br><\/code><code>        # \u6309\u53e5\u5b50\u5206\u5272\uff08\u53e5\u53f7\u3001\u95ee\u53f7\u3001\u611f\u53f9\u53f7\u540e\u8ddf\u7a7a\u683c\uff09<\/code><code>        # \u4f7f\u7528\u66f4\u5bbd\u677e\u7684\u6a21\u5f0f\uff0c\u5141\u8bb8\u53e5\u5b50\u7ed3\u675f\u540e\u6709\u4efb\u4f55\u6570\u91cf\u7684\u7a7a\u683c<\/code><code>        sentences = re.split(r'([.!?])\\s*', transcript_text)<\/code><code><br><\/code><code>        # \u5904\u7406\u5206\u5272\u7ed3\u679c\uff0c\u5c06\u6807\u70b9\u7b26\u53f7\u91cd\u65b0\u9644\u52a0\u5230\u53e5\u5b50<\/code><code>        processed_sentences = []<\/code><code>        i = 0<\/code><code>        while i &lt; len(sentences):<\/code><code>            sentence = sentences[i]<\/code><code><br><\/code><code>            # \u5982\u679c\u662f\u6807\u70b9\u7b26\u53f7\uff0c\u9644\u52a0\u5230\u524d\u4e00\u4e2a\u53e5\u5b50<\/code><code>            if i &gt; 0 and sentence in ['.', '!', '?']:<\/code><code>                processed_sentences[-1] += sentence<\/code><code>            else:<\/code><code>                processed_sentences.append(sentence)<\/code><code><br><\/code><code>            i += 1<\/code><code><br><\/code><code>        # \u5c06\u53e5\u5b50\u7ec4\u5408\u6210\u5757<\/code><code>        chunks = []<\/code><code>        current_chunk = \"\"<\/code><code><br><\/code><code>        for sentence in processed_sentences:<\/code><code>            # \u8df3\u8fc7\u7a7a\u53e5\u5b50<\/code><code>            if not sentence.strip():<\/code><code>                continue<\/code><code><br><\/code><code>            # \u5982\u679c\u5f53\u524d\u5757\u52a0\u4e0a\u65b0\u53e5\u5b50\u4f1a\u8d85\u8fc7\u6700\u5927\u5927\u5c0f\uff0c\u4fdd\u5b58\u5f53\u524d\u5757<\/code><code>            if current_chunk and len(current_chunk) + len(sentence) + 1 &gt; max_chunk_size:<\/code><code>                if len(current_chunk) &gt;= min_chunk_size:<\/code><code>                    chunks.append(current_chunk.strip())<\/code><code>                current_chunk = sentence<\/code><code>            else:<\/code><code>                if current_chunk:<\/code><code>                    current_chunk += \" \" + sentence<\/code><code>                else:<\/code><code>                    current_chunk = sentence<\/code><code><br><\/code><code>        # \u6dfb\u52a0\u6700\u540e\u4e00\u4e2a\u5757<\/code><code>        if current_chunk and len(current_chunk) &gt;= min_chunk_size:<\/code><code>            chunks.append(current_chunk.strip())<\/code><code><br><\/code><code>        return chunks<\/code><\/pre>\n\n\n\n<p>\u5c06 Json \u6587\u4ef6\u5411\u91cf\u5316\u540e\uff0c\u6211\u4eec\u5c06 Json \u6587\u4ef6\u7684\u6570\u636e\u683c\u5f0f\u8fdb\u884c\u4e86\u5904\u7406\uff0c\u4f7f\u5176\u5728 Amazon DocumentDB \u4e2d\u80fd\u66f4\u597d\u5730\u505a\u68c0\u7d22\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/static001.geekbang.org\/infoq\/ea\/ea5d9e6e387130466b4d86ec357648cf.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>def flatten_video_data(self, video_data, video_name):<\/code><code>        flattened_data = []<\/code><code>        <\/code><code>        # \u5904\u7406\u7ae0\u8282<\/code><code>        chapters = video_data.get('chapters', [])<\/code><code>        for chapter in chapters:<\/code><code>            chapter_summary = chapter.get('chapter_summary', {})<\/code><code>            flattened_chapter_summary = {<\/code><code>                \"video_name\": video_name,<\/code><code>                \"source\": f\"chapter_{chapter.get('chapter_index', 0)}_summary\",<\/code><code>                \"text\": chapter_summary.get('text', \"\"),<\/code><code>                \"embedding\": chapter_summary.get('embedding', []),<\/code><code>                \"start_timestamp_millis\": chapter.get('start_timestamp_millis'),<\/code><code>                \"end_timestamp_millis\": chapter.get('end_timestamp_millis')<\/code><code>            }<\/code><code>            flattened_data.append(flattened_chapter_summary)<\/code><code><br><\/code><code>            # \u5904\u7406\u7ae0\u8282\u8f6c\u5f55\u5757<\/code><code>            transcript_chunks = chapter.get('transcript_chunks', [])<\/code><code>            for chunk in transcript_chunks:<\/code><code>                flattened_chunk = {<\/code><code>                    \"video_name\": video_name,<\/code><code>                    \"source\": f\"chapter_{chapter.get('chapter_index', 0)}_transcript_chunk_{chunk.get('chunk_index', 0)}\",<\/code><code>                    \"text\": chunk.get('text', \"\"),<\/code><code>                    \"embedding\": chunk.get('embedding', []),<\/code><code>                    \"start_timestamp_millis\": chapter.get('start_timestamp_millis'),<\/code><code>                    \"end_timestamp_millis\": chapter.get('end_timestamp_millis')<\/code><code>                }<\/code><code>                flattened_data.append(flattened_chunk)<\/code><code><br><\/code><code>        return flattened_data<\/code><\/pre>\n\n\n\n<p>\u5bf9\u89c6\u9891\u751f\u6210\u7684\u6587\u5b57\u505a\u5b8c\u5411\u91cf\u5316\u548c\u6570\u636e\u683c\u5f0f\u7684\u6574\u7406\u540e\uff0c\u4fbf\u53ef\u4ee5\u5c06\u5176\u5b58\u5165 Amazon DocumentDB \u4e3a\u7528\u6237\u7684\u68c0\u7d22\u505a\u51c6\u5907\u4e86\u3002<\/p>\n\n\n\n<p><strong>4. \u7528\u6237\u641c\u7d22\u6587\u5b57\u7684 Embedding \u8f6c\u6362<\/strong><\/p>\n\n\n\n<p>\u5c06\u5411\u91cf\u548c\u6587\u5b57\u5b58\u5165 Amazon DocumentDB \u540e\uff0c\u7528\u6237\u4fbf\u53ef\u4ee5\u4ece\u524d\u7aef\u8f93\u5165\u641c\u7d22\u6587\u5b57\u5e76\u9009\u62e9\u641c\u7d22\u6a21\u5f0f\uff08\u6587\u672c\u641c\u7d22\u6216\u573a\u666f\u641c\u7d22\uff09\uff0c\u7cfb\u7edf\u4f1a\u4f7f\u7528 amazon.titan \u2013 embed \u2013 text \u2013 v2:0 \u6a21\u578b\u5bf9\u641c\u7d22\u6587\u5b57\u8fdb\u884c\u5411\u91cf\u5316\uff0c\u4ee5\u4fbf\u540e\u7eed\u8fdb\u884c\u5411\u91cf\u5339\u914d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>flowchart LR<\/code><code><br><\/code><code>  A([\u63a5\u6536\u641c\u7d22\u8bf7\u6c42])--&gt;B[\u89e3\u6790\u67e5\u8be2\u53c2\u6570]<\/code><code>  B--&gt;C{\u6267\u884c\u6df7\u5408\u641c\u7d22}<\/code><code>  C--&gt;D[\u5411\u91cf\u641c\u7d22]<\/code><code>  C--&gt;E[\u6587\u672c\u641c\u7d22]<\/code><code>  D--&gt;F([\u5408\u5e76\u641c\u7d22\u7ed3\u679c])<\/code><code><br><\/code><code>  E--&gt;F<\/code><code>  F--&gt;G([\u4f7f\u7528Cohere\u91cd\u6392\u5e8f])<\/code><code>  G--&gt;H([\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c])<\/code><\/pre>\n\n\n\n<p><strong>\u53cc\u8def\u53ec\u56de\u4e0e\u7ed3\u679c\u91cd\u6392\u5e8f<\/strong>\uff1aAmazon Lambda \u5229\u7528\u8f6c\u6362\u540e\u7684\u5411\u91cf\uff0c\u540c\u65f6\u8fdb\u884c\u6587\u5b57\u548c\u5411\u91cf\u7684\u53cc\u8def\u53ec\u56de\u3002\u5728\u5411\u91cf\u68c0\u7d22\u4e2d\uff0c\u4f7f\u7528 Amazon Document DB \u7684\u805a\u5408 pipeline \u5bf9\u5411\u91cf\u76f8\u4f3c\u5ea6\u8fdb\u884c\u641c\u7d22\uff0c\u6839\u636e\u641c\u7d22\u6a21\u5f0f\u8fc7\u6ee4\u7ed3\u679c\uff0c\u6700\u540e\u901a\u8fc7 project \u8fd4\u56de\u76f8\u5e94\u5b57\u6bb5\uff1b<\/p>\n\n\n\n<p>$project\uff1a\u8fd4\u56de\u76f8\u5e94\u5b57\u6bb5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>text: \"&lt;sample_text&gt;\"<\/code><code>video_name: \"&lt;sample_name&gt;.mov\" <\/code><code>source: \"chapter_6_summary\"<\/code><code>start_timestamp_millis: 181666<\/code><code>end_timestamp_millis: 227100<\/code><\/pre>\n\n\n\n<p>similarity\uff1a\u4e0e\u5411\u91cf\u7d22\u5f15\u4e00\u6837\uff0c\u6211\u4eec\u9009\u62e9\u4f59\u5f26\u76f8\u4f3c\u5ea6\uff08cosine\uff09\u6765\u8861\u91cf\u67e5\u8be2\u5411\u91cf\u548c\u6587\u6863\u5411\u91cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002<\/p>\n\n\n\n<p>top_k\uff1a\u8fd4\u56de\u7684\u89c6\u9891\u6570<\/p>\n\n\n\n<p>filter_condition\uff1a\u7531\u4e8e\u6211\u4eec\u7684\u641c\u7d22\u5206\u4e3a\u573a\u666f\u641c\u7d22\u548c\u53f0\u8bcd\u6587\u672c\u641c\u7d22\uff0c\u4fbf\u4ee5\u6b64\u4e3a\u7b5b\u9009\uff0c\u4ece\u800c\u7528\u6237\u53ef\u4ee5\u81ea\u884c\u9009\u62e9\u641c\u7d22\u573a\u666f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pipeline = [<\/code><code>                {<\/code><code>                    \"$search\": {<\/code><code>                        \"vectorSearch\": {<\/code><code>                            \"vector\": query_embedding,<\/code><code>                            \"path\": \"embedding\",<\/code><code>                            \"similarity\": \"cosine\",<\/code><code>                            \"k\": top_k * 3,  # Fetch more results since we'll filter them<\/code><code>                            \"efSearch\": 64<\/code><code>                        }<\/code><code>                    }<\/code><code>                },<\/code><code>                # Add a $match stage to filter results based on search mode (scene\/transcripts)<\/code><code>                {<\/code><code>                    \"$match\": filter_condition<\/code><code>                },<\/code><code>                # Limit to top_k results after filtering<\/code><code>                {<\/code><code>                    \"$limit\": top_k<\/code><code>                },<\/code><code>                {<\/code><code>                    \"$project\": {<\/code><code>                        \"text\": 1,<\/code><code>                        \"video_name\": 1,<\/code><code>                        \"source\": 1,<\/code><code>                        \"start_timestamp_millis\": 1,<\/code><code>                        \"end_timestamp_millis\": 1<\/code><code>                    }<\/code><code>                }<\/code><code>            ] <\/code><\/pre>\n\n\n\n<p>\u6587\u5b57\u68c0\u7d22\u5219\u57fa\u4e8e\u6e90\u6587\u4ef6\u4e3a json \u6587\u672c\u7684\u7279\u70b9\uff0c\u901a\u8fc7 <code>$text<\/code> \u64cd\u4f5c\u7b26\u5229\u7528\u5012\u6392\u7d22\u5f15\u8fdb\u884c\u6587\u672c\u641c\u7d22\u3002\u5012\u6392\u7d22\u5f15\u662f\u4e00\u79cd\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u5305\u542b\u7279\u5b9a\u5355\u8bcd\u6216\u77ed\u8bed\u7684\u6587\u6863\u7684\u6570\u636e\u7ed3\u6784\u3002\u4e0e\u4f20\u7edf\u7684\u6b63\u5411\u7d22\u5f15\uff08\u4ece\u6587\u6863\u5230\u5355\u8bcd\u7684\u6620\u5c04\uff09\u4e0d\u540c\uff0c\u5012\u6392\u7d22\u5f15\u662f\u4ece\u5355\u8bcd\u5230\u6587\u6863\u7684\u6620\u5c04\u3002<\/p>\n\n\n\n<p>\u68c0\u7d22\u5b8c\u6210\u540e\uff0c\u7531\u4e8e\u540c\u4e00\u4e2a source \u53ef\u80fd\u4f1a\u540c\u65f6\u88ab\u5411\u91cf\u68c0\u7d22\u548c\u6587\u5b57\u68c0\u7d22\u51fa\u6765\uff0c\u4ece\u800c\u5728\u5408\u5e76\u7ed3\u679c\u65f6\u505a\u4e86\u53bb\u91cd\u5904\u7406\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>all_results = processed_vector_results + processed_text_results<\/code><code>            # Remove duplicates based on '_id' and prefer text search results<\/code><code>            unique_results = []<\/code><code>            seen_ids = set()<\/code><code>            for result in reversed(all_results):  # Reverse the list to process text results first<\/code><code>                result_id = result['_id']<\/code><code>                if result_id not in seen_ids:<\/code><code>                    seen_ids.add(result_id)<\/code><code>                    unique_results.append(result)<\/code><code>            unique_results.reverse()  # Reverse the list back to original order<\/code><code>            # Return unique results directly<\/code><code>            return {\"results\": unique_results}<\/code><\/pre>\n\n\n\n<p>\u6700\u540e\u901a\u8fc7 Amazon Bedrock \u96c6\u6210\u7684 cohere.rerank \u2013 v3 \u2013 5:0 \u6a21\u578b\u5bf9\u53ec\u56de\u7ed3\u679c\u8fdb\u884c\u91cd\u6392\u5e8f\uff0c\u5e76\u5bf9\u8f93\u51fa\u7ed3\u679c\u8fdb\u884c\u4e86\u6574\u7406\uff0c\u800c\u540e\u6309\u7167\u76f8\u5173\u5ea6\u5206\u6570\u8fd4\u56de\u6700\u7b26\u5408\u7528\u6237\u9700\u6c42\u7684\u89c6\u9891\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>response = self.bedrock_client.invoke_model(<\/code><code>            modelId=\"cohere.rerank-v3-5:0\",<\/code><code>            contentType=\"application\/json\",<\/code><code>            accept=\"application\/json\",<\/code><code>            body=json.dumps({<\/code><code>                \"api_version\": 2,<\/code><code>                \"query\": query,<\/code><code>                \"documents\": documents,<\/code><code>                \"top_n\": len(documents)<\/code><code>            })<\/code><code>        )<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<p>\u5c06 BDA \u4f5c\u4e3a\u5904\u7406\u89c6\u9891\u7684\u624b\u6bb5\u4e4b\u4e00\u51cf\u5c11\u4e86\u624b\u5de5\u5206\u955c\uff0c\u53d6\u5e27\u7b49\u7684\u5de5\u5e8f\u3002\u65e0\u670d\u52a1\u5668\u7684\u67b6\u6784\u4e3a\u6574\u4f53\u7684\u8bbe\u8ba1\u63d0\u4f9b\u4e86\u4f4e\u6210\u672c\u7684\u8ba1\u7b97\u8d44\u6e90\uff0c\u540e\u7eed\u7684\u6570\u636e\u7684\u5b58\u50a8\u9009\u7528 DocumentDB \u4e5f\u662f\u5e0c\u671b\u53ef\u4ee5\u7528\u7075\u6d3b\u5730\u624b\u6bb5\u505a Json \u6570\u636e\u5904\u7406\u3002\u5728 AI \u6a21\u578b\u7684\u52a0\u6301\u4e0b\uff0c\u5e0c\u671b\u672c\u6587\u80fd\u591f\u4e3a AI \u4e0e\u89c6\u9891\u641c\u7d22\u63d0\u4f9b\u4e86\u4e00\u79cd\u65b0\u601d\u8def\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u6301\u7eed\u6539\u8fdb<\/strong><\/h3>\n\n\n\n<p>\u4f5c\u4e3a\u65b0\u529f\u80fd\uff0c\u76ee\u524d BDA \u7684\u89c6\u9891\u5904\u7406\u529f\u80fd\u4ec5\u9650\u4e8e\u6807\u51c6\u8f93\u51fa\uff0c\u53ef\u4ee5\u8003\u8651\u540e\u7eed\u52a0\u5165 Amazon Nova \u6a21\u578b\u6765\u4e30\u5bcc\u89c6\u9891\u573a\u666f\u63cf\u8ff0\u6570\u636e\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u63d0\u5347\u89c6\u9891\u5185\u5bb9\u5206\u6790\u7684\u7cbe\u7ec6\u5ea6\u3002Amazon Nova \u6a21\u578b\u80fd\u591f\u5bf9\u89c6\u9891\u8fdb\u884c\u62bd\u5e27\u7406\u89e3\uff0c\u4ece\u6bcf\u4e00\u5e27\u56fe\u50cf\u4e2d\u63d0\u53d6\u66f4\u4e30\u5bcc\u7684\u4fe1\u606f\uff0c\u4f8b\u5982\u89c6\u9891\u573a\u666f\u4e2d\u7684\u7269\u4f53\u7ec6\u8282\u3001\u53d8\u5316\u7b49\u3002\u8fd9\u4e9b\u989d\u5916\u7684\u4fe1\u606f\u5c06\u88ab\u6574\u5408\u5230\u89c6\u9891\u68c0\u7d22\u7cfb\u7edf\u4e2d\uff0c\u4f7f\u5f97\u7528\u6237\u5728\u641c\u7d22\u89c6\u9891\u65f6\uff0c\u80fd\u591f\u83b7\u5f97\u66f4\u7cbe\u51c6\u3001\u66f4\u4e30\u5bcc\u7684\u641c\u7d22\u7ed3\u679c\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u70b9\u64ad\u89c6\u9891\u5e73\u53f0\u641c\u7d22\u529f\u80fd\u4e3b\u8981\u662f\u57fa\u4e8e\u89c6\u9891\u6807\u9898\u7684\u5173\u952e\u5b57\u68c0\u7d22\u3002\u5bf9\u4e8e\u70b9\u64ad\u5e73\u53f0\u800c\u8a00\uff0c\u6211\u4eec\u5e0c\u671b\u53ef\u4ee5\u901a\u8fc7\u4f18\u5316\u89c6\u9891\u641c\u7d22\u4f53\u9a8c\u6ee1\u8db3\u7528\u6237\u901a\u8fc7\u6a21\u7cca\u63cf\u8ff0\u67e5\u627e\u89c6\u9891\u7684\u9700\u6c42\uff0c\u4ece\u800c\u63d0\u9ad8\u7528\u6237\u7684\u641c\u7d22\u4f53\u9a8c\u3002\u501f\u52a9 Amazon Bedrock Data Automation\uff08BDA\uff09\u6280\u672f\uff0c\u8fd0\u7528 AI \u81ea\u52a8\u5256\u6790\u89c6\u9891\u5185\u5bb9\uff0c\u63d0\u53d6\u5173\u952e\u4fe1\u606f\uff0c\u901a\u8fc7\u5411\u91cf\u641c\u7d22\u8fbe\u6210\u8bed\u4e49\u667a\u80fd\u5339\u914d\uff0c\u5b9e\u73b0\u591a\u89d2\u5ea6\uff08\u89c6\u9891\u5173\u952e\u5b57\u3001\u53f0\u8bcd\u3001\u573a\u666f\u63cf\u8ff0\uff09\u89c6\u9891\u68c0\u7d22\uff0c\u6709\u5229\u4e8e\u63d0\u5347\u7528\u6237\u641c\u7d22\u6548\u7387\uff0c\u589e\u52a0&hellip;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-ai","category-aws"],"_links":{"self":[{"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/posts\/269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":3,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/posts\/269\/revisions\/287"}],"wp:attachment":[{"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flycloud.io\/en\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}