{"id":7833,"date":"2024-11-14T13:50:24","date_gmt":"2024-11-14T05:50:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7833\/"},"modified":"2024-11-14T13:50:24","modified_gmt":"2024-11-14T05:50:24","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e8%87%aa%e7%84%b6%e8%af%ad%e8%a8%80%e5%a4%84%e7%90%86-nlp-%e6%9f%a5%e8%af%a2%e4%ba%ba%e5%91%98%e6%95%b0%e6%8d%ae%e5%b9%b6%e5%af%bc%e5%85%a5%e5%a4%a7%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7833\/","title":{"rendered":"\u5982\u4f55\u5229\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406 (NLP) \u67e5\u8be2\u4eba\u5458\u6570\u636e\u5e76\u5bfc\u5165\u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173129148527460.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5229\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406 (NLP) \u67e5\u8be2\u4eba\u5458\u6570\u636e\u5e76\u5bfc\u5165\u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5229\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406 (NLP) \u67e5\u8be2\u4eba\u5458\u6570\u636e\u5e76\u5bfc\u5165\u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u67e5\u8be2\u4eba\u5458\u6570\u636e<\/strong><\/p>\n<p><strong>\u5bfc\u5165<\/strong><\/p>\n<p>\u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\u7684\u7ba1\u7406\u7ecf\u5e38\u8ba9\u4eba\u5934\u75bc\u3002\u4e3a\u4e86\u7b80\u5316\u67e5\u8be2\u8fc7\u7a0b\uff0c\u81ea\u7136\u8bed\u8a00\u5904\u7406 (nlp) \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bcc\u6709\u6210\u6548\u7684\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u4e3a\u4e86\u5229\u7528 nlp \u7684\u80fd\u529b\uff0c\u6211\u4eec\u7ecf\u5e38\u9047\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1a\u5982\u4f55\u5c06\u590d\u6742\u7684\u4eba\u5458\u67e5\u8be2\u8f6c\u6362\u6210\u6570\u636e\u5e93\u67e5\u8be2\uff1f<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1aopen \u5411\u91cf\u5316 + elasticsearch \u70b9\u79ef<\/strong><\/p>\n<p>\u4e00\u4e2a\u6709\u6548\u7684\u89e3\u51b3\u65b9\u6848\u662f\u5229\u7528 openai \u7684 api \u5c06\u4eba\u5458\u6570\u636e\u5411\u91cf\u5316\u3002\u8fd9\u79cd\u8f6c\u5316\u5c06\u4eba\u5458\u4fe1\u606f\uff08\u5982\u5e74\u9f84\u3001\u6027\u522b\u548c\u4f4d\u7f6e\uff09\u8f6c\u6362\u4e3a\u9ad8\u7ef4\u5411\u91cf\u3002\u968f\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 elasticsearch \u6267\u884c\u70b9\u79ef\u67e5\u8be2\uff0c\u5c06\u8f93\u5165\u67e5\u8be2\uff08\u4f8b\u5982\uff0c\u201c25\u5c81\u4ee5\u4e0b\uff0c\u5728\u5317\u4eac\u4e0a\u73ed\u7684\u7537\u6027\u201d\uff09\u4e0e\u5411\u91cf\u5316\u6570\u636e\u96c6\u8fdb\u884c\u5339\u914d\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u5c55\u793a\u4e86 openai \u5411\u91cf\u5316\u548c elasticsearch \u70b9\u79ef\u67e5\u8be2\u7684\u5b9e\u73b0\uff1a<\/p>\n<pre>\/\/ \u5c06\u4eba\u5458\u6570\u636e\u8f6c\u6362\u4e3a\u5411\u91cf\nList&lt;Vector&gt; vectors = api.vectorize(personDataList);\n\n\/\/ \u5728 Elasticsearch \u4e2d\u521b\u5efa\u7d22\u5f15\nIndexSettings indexSettings = IndexSettings.builder()\n    .numberOfShards(1)\n    .numberOfReplicas(1)\n    .build();\n\nIndexRequest indexRequest = new IndexRequest(\"person-vectors\");\nindexRequest.source(Vectors.toDocument(vectors))\nElasticsearchClient.index(indexRequest);\n\n\/\/ \u51c6\u5907\u67e5\u8be2\nQuery query = QueryBuilders.cosineSimilarityQuery(\"vector\", vector);\n\n\/\/ \u6267\u884c\u67e5\u8be2\nSearchResponse response = ElasticsearchClient.search(query);\n\n\/\/ \u63d0\u53d6\u67e5\u8be2\u7ed3\u679c\nList&lt;Person&gt; results = Vectors.fromDocuments(response.getHits().getHits());<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5229\u7528\u81ea\u7136\u8bed\u8a00\u5904\u7406 (NLP) \u67e5\u8be2\u4eba\u5458\u6570\u636e\u5e76\u5bfc\u5165\u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u67e5\u8be2\u4eba\u5458\u6570\u636e \u5bfc\u5165 \u5927\u578b\u4eba\u5458\u6570\u636e\u5e93\u7684\u7ba1\u7406\u7ecf\u5e38\u8ba9\u4eba\u5934\u75bc\u3002\u4e3a\u4e86\u7b80\u5316\u67e5\u8be2\u8fc7\u7a0b\uff0c\u81ea\u7136\u8bed\u8a00\u5904\u7406 (nlp) \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bcc\u6709\u6210\u6548\u7684\u65b9\u6cd5\u3002 \u95ee\u9898 \u4e3a\u4e86\u5229\u7528 nlp \u7684\u80fd\u529b\uff0c\u6211\u4eec\u7ecf\u5e38\u9047\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff1a\u5982\u4f55\u5c06\u590d\u6742\u7684\u4eba\u5458\u67e5\u8be2\u8f6c\u6362\u6210\u6570\u636e\u5e93\u67e5\u8be2\uff1f \u89e3\u51b3\u65b9\u6848\uff1aopen \u5411\u91cf\u5316 + elasticsearch \u70b9\u79ef \u4e00\u4e2a\u6709\u6548\u7684\u89e3\u51b3\u65b9\u6848\u662f\u5229\u7528 openai \u7684 api \u5c06\u4eba\u5458\u6570\u636e\u5411\u91cf\u5316\u3002\u8fd9\u79cd\u8f6c\u5316\u5c06\u4eba\u5458\u4fe1\u606f\uff08\u5982\u5e74\u9f84\u3001\u6027\u522b\u548c\u4f4d\u7f6e\uff09\u8f6c\u6362\u4e3a\u9ad8\u7ef4\u5411\u91cf\u3002\u968f\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 elasticsearch \u6267\u884c\u70b9\u79ef\u67e5\u8be2\uff0c\u5c06\u8f93\u5165\u67e5\u8be2\uff08\u4f8b\u5982\uff0c\u201c25\u5c81\u4ee5\u4e0b\uff0c\u5728\u5317\u4eac\u4e0a\u73ed\u7684\u7537\u6027\u201d\uff09\u4e0e\u5411\u91cf\u5316\u6570\u636e\u96c6\u8fdb\u884c\u5339\u914d\u3002 \u793a\u4f8b \u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u5c55\u793a\u4e86 openai \u5411\u91cf\u5316\u548c elasticsearch \u70b9\u79ef\u67e5\u8be2\u7684\u5b9e\u73b0\uff1a \/\/ \u5c06\u4eba\u5458\u6570\u636e\u8f6c\u6362\u4e3a\u5411\u91cf List&lt;Vector&gt; vectors = api.vectorize(personDataList); \/\/ \u5728 Elasticsearch \u4e2d\u521b\u5efa\u7d22\u5f15 IndexSettings indexSettings = IndexSettings.builder() .numberOfShards(1) .numberOfReplicas(1) .build(); IndexRequest indexRequest = new IndexRequest(&#8220;person-vectors&#8221;); indexRequest.source(Vectors.toDocument(vectors)) ElasticsearchClient.index(indexRequest); \/\/ \u51c6\u5907\u67e5\u8be2 Query query [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7833","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7833"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7833\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}