{"id":9007,"date":"2024-09-25T13:17:07","date_gmt":"2024-09-25T04:17:07","guid":{"rendered":"https:\/\/www.prime-strategy.co.jp\/column\/?p=9007"},"modified":"2026-02-17T01:24:58","modified_gmt":"2026-02-16T16:24:58","slug":"dspy%e3%82%92%e7%94%a8%e3%81%84%e3%81%9f%e3%82%b7%e3%83%b3%e3%83%97%e3%83%ab%e3%81%aarag%e3%82%b7%e3%82%b9%e3%83%86%e3%83%a0%e3%81%ae%e6%a7%8b%e7%af%89","status":"publish","type":"post","link":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007","title":{"rendered":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9"},"content":{"rendered":"\n<p>\u524d\u56de\u306fDSPy\u306b\u3064\u3044\u3066\u306e\u57fa\u672c\u7684\u306a\u7d39\u4ecb\u3092\u81f4\u3057\u307e\u3057\u305f\u3002<br>\u4eca\u56de\u306f\u3001\u5b9f\u969b\u306bDSPy\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3055\u305b\u3001\u305d\u308c\u306b\u3064\u3044\u3066\u306e\u56de\u7b54\u3092ChatGPT-3.5\u306b\u3055\u305b\u308b\u3001\u3068\u3044\u3046\u5c11\u3057\u5177\u4f53\u7684\u306a\u4f7f\u7528\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u3064\u3064\u3001DSPy\u306b\u3064\u3044\u3066\u306e\u7406\u89e3\u3092\u6df1\u3081\u3066\u884c\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u304b\u3089\u51fa\u3066\u304f\u308b\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3001JupyterNotebook\u3067\u306e\u9010\u6b21\u5b9f\u884c\u5f62\u5f0f\u3067\u306e\u5b9f\u884c\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<br>\u4f46\u3057\u3001\u6700\u521d\u304b\u3089\u6700\u5f8c\u307e\u3067\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4e00\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4fdd\u5b58\u3057\u3066\u5b9f\u884c\u3057\u3066\u3082ColBERTv2\u306e\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\u306b\u6642\u9593\u304c\u304b\u304b\u308b\u5834\u5408\u3001\u8aad\u8fbc\u90e8\u5206\u306e\u540c\u671f\u51e6\u7406\u306a\u3069\u3092\u884c\u308f\u306a\u3044\u3068\u30a8\u30e9\u30fc\u3067\u843d\u3061\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001\u4e00\u5de5\u592b\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002<br>Google Colab\u306e\u7121\u6599\u67a0\u306a\u3069\u3067\u3082\u52d5\u304f\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u74b0\u5883\u304c\u624b\u5143\u306b\u7121\u3044\u65b9\u306f\u305d\u3061\u3089\u3092\u8a66\u3057\u3066\u898b\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"RAG%E3%81%A8%E3%81%AF%EF%BC%9F\"><\/span>RAG\u3068\u306f\uff1f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Retrieval-augmented generation\uff08RAG\uff09\u3068\u306f\u3001\u5927\u898f\u6a21\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LLM\uff09\u304c\u4e0e\u3048\u3089\u308c\u305f\u5927\u898f\u6a21\u306a\u77e5\u8b58\u30b3\u30fc\u30d1\u30b9\uff08\u793e\u5185\u6587\u7ae0\u3084\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306a\u3069\uff09\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001\u305d\u306e\u6587\u7ae0\u3092\u691c\u7d22\u3057\u3066\u95a2\u9023\u3059\u308b\u6bb5\u843d\u3084\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u898b\u3064\u3051\u3001\u81ea\u5206\u3067\u306f\u4e8b\u524d\u306b\u77e5\u308a\u5f97\u306a\u3044\u77e5\u8b58\u306b\u5bfe\u3057\u3066\u306e\u56de\u7b54\u3092\u751f\u6210\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u30a2\u30d7\u30ed\u30fc\u30c1\u3067\u3059\u3002<\/p>\n\n\n\n<p>RAG\u306f\u3001LLM\u304c\u5143\u3005\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3055\u308c\u3066\u3044\u306a\u3044\u77e5\u8b58\u306b\u3064\u3044\u3066\u3082\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306e\u77e5\u8b58\u3092\u52d5\u7684\u306b\u6d3b\u7528\u3057\u3001\u7cbe\u5ea6\u306e\u9ad8\u3044\u56de\u7b54\u3092\u63d0\u4f9b\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u6d17\u7df4\u3055\u308c\u305fRAG\u30b7\u30b9\u30c6\u30e0\u306b\u306f\u3001LLM\u304c\u77e5\u308a\u5f97\u306a\u3044\u77e5\u8b58\u3092\u53c2\u7167\u30fb\u691c\u7d22\u3059\u308b\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u304c\u5fc5\u8981\u3067\u3001\u69cb\u7bc9\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u306b\u306f\u8907\u96d1\u3055\u304c\u4f34\u3044\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u8907\u96d1\u3055\u3092\u8efd\u6e1b\u3059\u308b\u305f\u3081\u306b\u3001\u79c1\u305f\u3061\u306fDSPy\u306b\u6ce8\u76ee\u3057\u307e\u3059\u3002DSPy\u306f\u3001\u4e0a\u8a18\u306e\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u30b7\u30b9\u30c6\u30e0\u3092\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3059\u308b\u65b9\u6cd5\u3092\u63d0\u4f9b\u3057\u3066\u304f\u308c\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A8%80%E8%AA%9E%E3%83%A2%E3%83%87%E3%83%AB%EF%BC%88LM%EF%BC%89%E3%81%A8%E6%A4%9C%E7%B4%A2%E3%83%A2%E3%83%87%E3%83%AB%EF%BC%88RM%EF%BC%89%E3%81%AE%E8%A8%AD%E5%AE%9A\"><\/span>\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LM\uff09\u3068\u691c\u7d22\u30e2\u30c7\u30eb\uff08RM\uff09\u306e\u8a2d\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u307e\u305a\u3001\u8a00\u8a9e\u30e2\u30c7\u30eb\uff08LM\uff09\u3068\u691c\u7d22\u30e2\u30c7\u30eb\uff08RM\uff09\u3092\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3057\u307e\u3059\u3002DSPy\u306f\u8907\u6570\u306eLM\u3068RM\u306eAPI\u3068\u30ed\u30fc\u30ab\u30eb\u30e2\u30c7\u30eb\u306e\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u4f8b\u3067\u306f\u3001GPT-3.5\uff08gpt-3.5-turbo\uff09\u3068ColBERTv2\u691c\u7d22\u5668\uff082017\u5e74\u306eWikipedia\u306e\u300c\u8981\u7d04\u300d\u691c\u7d22\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u7121\u6599\u3067\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u3067\u3059\uff09\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002LM\u3068RM\u3092DSPy\u5185\u3067\u8a2d\u5b9a\u3057\u3001DSPy\u304c\u751f\u6210\u3084\u691c\u7d22\u306e\u305f\u3081\u306b\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5185\u90e8\u7684\u306b\u547c\u3073\u51fa\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import dspy\n\nturbo = dspy.OpenAI(model='gpt-3.5-turbo')\ncolbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http:\/\/20.102.90.50:2017\/wiki17_abstracts')\n\ndspy.settings.configure(lm=turbo, rm=colbertv2_wiki17_abstracts)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%87%E3%83%BC%E3%82%BF%E3%82%BB%E3%83%83%E3%83%88%E3%81%AE%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%81%BF\"><\/span>\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306e\u8aad\u307f\u8fbc\u307f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001DSPy\u306b\u6a19\u6e96\u3067\u7528\u610f\u3055\u308c\u3066\u308bHotPotQA\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u901a\u5e38\u3001\u30de\u30eb\u30c1\u30db\u30c3\u30d7\u65b9\u5f0f\u3068\u3044\u3046\u8907\u96d1\u306a\u8cea\u554f\u3068\u56de\u7b54\u306e\u30da\u30a2\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u3059\u3002DSPy\u304c\u63d0\u4f9b\u3059\u308b\u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306f\u3001HotPotQA\u30af\u30e9\u30b9\u3092\u901a\u3058\u3066\u8aad\u307f\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from dspy.datasets import HotPotQA\n\n# \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\ndataset = HotPotQA(train_seed=1, train_size=20, eval_seed=2023, dev_size=50, test_size=0)\n\n# DSPy\u306b'question'\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u5165\u529b\u3067\u3042\u308b\u3053\u3068\u3092\u4f1d\u3048\u307e\u3059\u3002\u4ed6\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306f\u30e9\u30d9\u30eb\u3084\u30e1\u30bf\u30c7\u30fc\u30bf\u3067\u3059\u3002\ntrainset = &#91;x.with_inputs('question') for x in dataset.train]\ndevset = &#91;x.with_inputs('question') for x in dataset.dev]\n\nlen(trainset), len(devset)<\/code><\/pre>\n\n\n\n<p>\u4e0a\u8a18\u306e\u5b9f\u884c\u7d50\u679c\u306f\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(20, 50)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%82%B7%E3%82%B0%E3%83%8D%E3%83%81%E3%83%A3%E3%81%AE%E6%A7%8B%E7%AF%89\"><\/span>\u30b7\u30b0\u30cd\u30c1\u30e3\u306e\u69cb\u7bc9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3093\u3060\u306e\u3067\u3001\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u30b5\u30d6\u30bf\u30b9\u30af\u306e\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<br>\u30b7\u30f3\u30d7\u30eb\u306a\u5165\u529b\u8cea\u554f\u3068\u51fa\u529b\u56de\u7b54\u3092\u8b58\u5225\u3067\u304d\u307e\u3059\u304c\u3001RAG\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u69cb\u7bc9\u3057\u3066\u3044\u308b\u305f\u3081\u3001ColBERT\u30b3\u30fc\u30d1\u30b9\u304b\u3089\u306e\u6587\u8108\u60c5\u5831\u3092\u5229\u7528\u3059\u308b\u4e8b\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class GenerateAnswer(dspy.Signature):\n    \"\"\"Answer questions with short factoid answers.\"\"\"\n\n    context = dspy.InputField(desc=\"may contain relevant facts\")\n    question = dspy.InputField()\n    answer = dspy.OutputField(desc=\"often between 1 and 5 words\")<\/code><\/pre>\n\n\n\n<p>context\u3068answer\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u5c0f\u3055\u306a\u8aac\u660e\u3092\u542b\u3081\u3066\u3001\u30e2\u30c7\u30eb\u304c\u53d7\u3051\u53d6\u308b\u3082\u306e\u3068\u751f\u6210\u3059\u3079\u304d\u3082\u306e\u306b\u3064\u3044\u3066\u5805\u7262\u306a\u30ac\u30a4\u30c9\u30e9\u30a4\u30f3\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E6%A7%8B%E7%AF%89\"><\/span>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u69cb\u7bc9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>RAG\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092DSPy\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u69cb\u7bc9\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u306f2\u3064\u306e\u95a2\u6570\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>__init__<\/code>\u95a2\u6570\u306f\u3001\u5fc5\u8981\u306a\u30b5\u30d6\u30e2\u30b8\u30e5\u30fc\u30eb\uff08dspy.Retrieve\u3068dspy.ChainOfThought\uff09\u3092\u5358\u7d14\u306b\u5ba3\u8a00\u3057\u307e\u3059\u3002\u5f8c\u8005\u306fGenerateAnswer\u30b7\u30b0\u30cd\u30c1\u30e3\u3092\u5b9f\u88c5\u3059\u308b\u3088\u3046\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>forward<\/code>\u95a2\u6570\u306f\u3001\u8cea\u554f\u306b\u7b54\u3048\u308b\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5236\u5fa1\u30d5\u30ed\u30fc\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\u8cea\u554f\u304c\u4e0e\u3048\u3089\u308c\u305f\u3089\u3001\u4e0a\u4f4d3\u3064\u306e\u95a2\u9023\u3059\u308b\u6bb5\u843d\u3092\u691c\u7d22\u3057\u3001\u305d\u308c\u3089\u3092\u6587\u8108\u3068\u3057\u3066\u56de\u7b54\u751f\u6210\u306b\u4f9b\u7d66\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>class RAG(dspy.Module):\n    def __init__(self, num_passages=3):\n        super().__init__()\n\n        self.retrieve = dspy.Retrieve(k=num_passages)\n        self.generate_answer = dspy.ChainOfThought(GenerateAnswer)\n    \n    def forward(self, question):\n        context = self.retrieve(question).passages\n        prediction = self.generate_answer(context=context, question=question)\n        return dspy.Prediction(context=context, answer=prediction.answer)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E6%9C%80%E9%81%A9%E5%8C%96\"><\/span>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u6700\u9069\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>RAG\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u5b9a\u7fa9\u3057\u305f\u306e\u3067\u3001\u6b21\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3068\u3001\u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002\u4eca\u56de\u306e\u8a2d\u5b9a\u3067\u306f\u3001\u4e3b\u306b\u30d7\u30ed\u30f3\u30d7\u30c8\u5185\u306b\u542b\u3081\u308b\u305f\u3081\u306e\u826f\u3044\u30c7\u30e2\u30f3\u30b9\u30c8\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u53ce\u96c6\u3057\u9078\u629e\u3059\u308b\u5f62\u3067\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u306f3\u3064\u306e\u8981\u7d20\u306b\u4f9d\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30bb\u30c3\u30c8\u3002\u4e0a\u8a18\u306etrainset\u304b\u308920\u306e\u8cea\u554f-\u56de\u7b54\u306e\u4f8b\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u691c\u8a3c\u306e\u305f\u3081\u306e\u30e1\u30c8\u30ea\u30c3\u30af\u3002\u4e88\u6e2c\u3055\u308c\u305f\u56de\u7b54\u304c\u6b63\u3057\u3044\u3053\u3068\u3001\u304a\u3088\u3073\u691c\u7d22\u3055\u308c\u305f\u6587\u8108\u304c\u5b9f\u969b\u306b\u305d\u306e\u56de\u7b54\u3092\u542b\u3093\u3067\u3044\u308b\u3053\u3068\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u7c21\u5358\u306avalidate_context_and_answer\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li>\u7279\u5b9a\u306e\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u3002DSPy\u30b3\u30f3\u30d1\u30a4\u30e9\u306b\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6700\u9069\u5316\u3067\u304d\u308b\u591a\u6570\u306e\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>from dspy.teleprompt import BootstrapFewShot\n\n# \u691c\u8a3c\u30ed\u30b8\u30c3\u30af\uff1a\u4e88\u6e2c\u3055\u308c\u305f\u56de\u7b54\u304c\u6b63\u3057\u3044\u3053\u3068\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\n# \u307e\u305f\u3001\u691c\u7d22\u3055\u308c\u305f\u6587\u8108\u304c\u5b9f\u969b\u306b\u305d\u306e\u56de\u7b54\u3092\u542b\u3093\u3067\u3044\u308b\u3053\u3068\u3082\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002\ndef validate_context_and_answer(example, pred, trace=None):\n    answer_EM = dspy.evaluate.answer_exact_match(example, pred)\n    answer_PM = dspy.evaluate.answer_passage_match(example, pred)\n    return answer_EM and answer_PM\n\n# RAG\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u57fa\u672c\u7684\u306a\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\nteleprompter = BootstrapFewShot(metric=validate_context_and_answer)\n\n# \u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002\ncompiled_rag = teleprompter.compile(RAG(), trainset=trainset)<\/code><\/pre>\n\n\n\n<p>\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u306b\u3064\u3044\u3066\u306f\u3001DSPy\u516c\u5f0f\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304b\u3089\u306e\u5f15\u7528\u3092\u4e0b\u8a18\u306b\u88dc\u8db3\u8aac\u660e\u3068\u3057\u3066\u8a18\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u306f\u3001\u4efb\u610f\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u53d6\u308a\u3001\u305d\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u52b9\u679c\u7684\u306a\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u30d6\u30fc\u30c8\u30b9\u30c8\u30e9\u30c3\u30d7\u3057\u9078\u629e\u3059\u308b\u3053\u3068\u3092\u5b66\u7fd2\u3067\u304d\u308b\u5f37\u529b\u306a\u6700\u9069\u5316\u30c4\u30fc\u30eb\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u300c\u9060\u9694\u3067\u306e\u30d7\u30ed\u30f3\u30d7\u30c6\u30a3\u30f3\u30b0\u300d\u3092\u610f\u5473\u3059\u308b\u540d\u524d\u304c\u4ed8\u3051\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7570\u306a\u308b\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u306f\u3001\u30b3\u30b9\u30c8\u3068\u54c1\u8cea\u306e\u6700\u9069\u5316\u306a\u3069\u306e\u89b3\u70b9\u3067\u3055\u307e\u3056\u307e\u306a\u30c8\u30ec\u30fc\u30c9\u30aa\u30d5\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002\u4e0a\u306e\u4f8b\u3067\u306f\u3001\u5358\u7d14\u306a\u30c7\u30d5\u30a9\u30eb\u30c8\u306eBootstrapFewShot\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30a2\u30ca\u30ed\u30b8\u30fc\u304c\u597d\u304d\u306a\u65b9\u306b\u306f\u3001\u3053\u308c\u3092\u6a19\u6e96\u7684\u306aDNN\u6559\u5e2b\u3042\u308a\u5b66\u7fd2\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u306b\u304a\u3051\u308b\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30c7\u30fc\u30bf\u3001\u640d\u5931\u95a2\u6570\u3001\u6700\u9069\u5316\u5668\u3068\u8003\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002SGD\u304c\u57fa\u672c\u7684\u306a\u6700\u9069\u5316\u5668\u3067\u3042\u308b\u4e00\u65b9\u3067\u3001Adam\u3084RMSProp\u306e\u3088\u3046\u306a\u3088\u308a\u6d17\u7df4\u3055\u308c\u305f\uff08\u305d\u3057\u3066\u3088\u308a\u9ad8\u4fa1\u306a\uff09\u6700\u9069\u5316\u5668\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E5%AE%9F%E8%A1%8C\"><\/span>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u5b9f\u884c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>RAG\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u3053\u306e\u5358\u7d14\u306aRAG\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u597d\u304d\u306a\u8cea\u554f\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002\nmy_question = \"What castle did David Gregory inherit?\"\n\n# \u4e88\u6e2c\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u3053\u308c\u306b\u306f`pred.context`\u3068`pred.answer`\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\npred = compiled_rag(my_question)\n\n# \u6587\u8108\u3068\u56de\u7b54\u3092\u51fa\u529b\u3057\u307e\u3059\u3002\nprint(f\"Question: {my_question}\")\nprint(f\"Predicted Answer: {pred.answer}\")\nprint(f\"Retrieved Contexts (truncated): {&#91;c&#91;:200] + '...' for c in pred.context]}\")\n<\/code><\/pre>\n\n\n\n<p>\u51fa\u529b\u306f\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Question: What castle did David Gregory inherit?\n\nPredicted Answer: Kinnairdy Castle\n\nRetrieved Contexts (truncated): &#91;'David Gregory (physician) | David Gregory (20 December 1625 \u2013 1720) was a Scottish physician and inventor. His surname is sometimes spelt as Gregorie, the original Scottish spelling. He inherited Kinn...', 'Gregory Tarchaneiotes | Gregory Tarchaneiotes (Greek: \u0393\u03c1\u03b7\u03b3\u03cc\u03c1\u03b9\u03bf\u03c2 \u03a4\u03b1\u03c1\u03c7\u03b1\u03bd\u03b5\u03b9\u03ce\u03c4\u03b7\u03c2 , Italian: \"Gregorio Tracanioto\" or \"Tracamoto\" ) was a \"protospatharius\" and the long-reigning catepan of Italy from 998 t...', 'David Gregory (mathematician) | David Gregory (originally spelt Gregorie) FRS (? 1659 \u2013 10 October 1708) was a Scottish mathematician and astronomer. He was professor of mathematics at the University ...']<\/code><\/pre>\n\n\n\n<p>\u3067\u306f\u3001\u3069\u306e\u3088\u3046\u306a\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u751f\u6210\u3055\u308c\u5b9f\u884c\u3055\u308c\u305f\u306e\u304b\uff1f\u3092\u898b\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>turbo.inspect_history(n=1)<\/code><\/pre>\n\n\n\n<p>\u51fa\u529b\u306f\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002\u304b\u306a\u308a\u9577\u3044\u30d7\u30ed\u30f3\u30d7\u30c8\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nAnswer questions with short factoid answers.\n\n---\n\nQuestion: At My Window was released by which American singer-songwriter?\nAnswer: John Townes Van Zandt\n\nQuestion: \"Everything Has Changed\" is a song from an album released under which record label ?\nAnswer: Big Machine Records\n\nQuestion: The Victorians - Their Story In Pictures is a documentary series written by an author born in what year?\nAnswer: 1950\n\nQuestion: Which Pakistani cricket umpire who won 3 consecutive ICC umpire of the year awards in 2009, 2010, and 2011 will be in the ICC World Twenty20?\nAnswer: Aleem Sarwar Dar\n\nQuestion: Having the combination of excellent foot speed and bat speed helped Eric Davis, create what kind of outfield for the Los Angeles Dodgers?\nAnswer: \"Outfield of Dreams\"\n\nQuestion: Who is older, Aleksandr Danilovich Aleksandrov or Anatoly Fomenko?\nAnswer: Aleksandr Danilovich Aleksandrov\n\nQuestion: The Organisation that allows a community to influence their operation or use and to enjoy the benefits arisingwas founded in what year?\nAnswer: 2010\n\nQuestion: Tombstone stared an actor born May 17, 1955 known as who?\nAnswer: Bill Paxton\n\nQuestion: In what year was the club founded that played Manchester City in the 1972 FA Charity Shield\nAnswer: 1874\n\nQuestion: which American actor was Candace Kita guest starred with\nAnswer: Bill Murray\n\nQuestion: Which is taller, the Empire State Building or the Bank of America Tower?\nAnswer: The Empire State Building\n\nQuestion: Which company distributed this 1977 American animated film produced by Walt Disney Productions for which Sherman Brothers wrote songs?\nAnswer: Buena Vista Distribution\n\n---\n\nFollow the following format.\n\nContext: may contain relevant facts\n\nQuestion: ${question}\n\nReasoning: Let's think step by step in order to ${produce the answer}. We ...\n\nAnswer: often between 1 and 5 words\n\n---\n\nContext:\n&#91;1] \u00abTae Kwon Do Times | Tae Kwon Do Times is a magazine devoted to the martial art of taekwondo, and is published in the United States of America. While the title suggests that it focuses on taekwondo exclusively, the magazine also covers other Korean martial arts. \"Tae Kwon Do Times\" has published articles by a wide range of authors, including He-Young Kimm, Thomas Kurz, Scott Shaw, and Mark Van Schuyver.\u00bb\n&#91;2] \u00abKwon Tae-man | Kwon Tae-man (born 1941) was an early Korean hapkido practitioner and a pioneer of the art, first in Korea and then in the United States. He formed one of the earliest dojang's for hapkido in the United States in Torrance, California, and has been featured in many magazine articles promoting the art.\u00bb\n&#91;3] \u00abHee Il Cho | Cho Hee Il (born October 13, 1940) is a prominent Korean-American master of taekwondo, holding the rank of 9th \"dan\" in the martial art. He has written 11 martial art books, produced 70 martial art training videos, and has appeared on more than 70 martial arts magazine covers. Cho won several national and international competitions as a taekwondo competitor, and has appeared in several films, including \"Fight to Win\", \"Best of the Best\", \"Bloodsport II\", and \"Bloodsport III\". He founded the Action International Martial Arts Association (AIMAA) in 1980, and is its President. Cho is a member of both \"Black Belt\" magazine's Hall of Fame and \"Tae Kwon Do Times\" magazine's Hall of Fame.\u00bb\n\nQuestion: Which magazine has published articles by Scott Shaw, Tae Kwon Do Times or Southwest Art?\n\nReasoning: Let's think step by step in order to produce the answer. We know that \"Tae Kwon Do Times\" has published articles by Scott Shaw, as mentioned in the context.\n\nAnswer: Tae Kwon Do Times\n\n---\n\nContext:\n&#91;1] \u00abRosario Dawson | Rosario Isabel Dawson (born May 9, 1979) is an American actress, producer, singer, comic book writer, and political activist. She made her film debut in the 1995 teen drama \"Kids\". Her subsequent film roles include \"He Got Game\", \"Men in Black II\", \"25th Hour\", \"Rent\", \"Sin City\", \"Death Proof\", \"Seven Pounds\", \"\", and \"Top Five\". Dawson has also provided voice-over work for Disney and DC.\u00bb\n&#91;2] \u00abSarai Gonzalez | Sarai Isaura Gonzalez (born 2005) is an American Latina child actress who made her professional debut at the age of 11 on the Spanish-language \"\"Soy Yo\"\" (\"That's Me\") music video by Bomba Est\u00e9reo. Cast as a \"nerdy\" tween with a \"sassy\" and \"confident\" attitude, her performance turned her into a \"Latina icon\" for \"female empowerment, identity and self-worth\". She subsequently appeared in two get out the vote videos for Latinos in advance of the 2016 United States elections.\u00bb\n&#91;3] \u00abGabriela (2001 film) | Gabriela is a 2001 American romance film, starring Seidy Lopez in the title role alongside Jaime Gomez as her admirer Mike. The film has been cited as an inspiration behind the Premiere Weekend Club, which supports Latino film-making.\u00bb\n\nQuestion: Which American actress who made their film debut in the 1995 teen drama \"Kids\" was the co-founder of Voto Latino?\n\nReasoning: Let's think step by step in order to produce the answer. We know that Rosario Dawson made her film debut in the 1995 teen drama \"Kids\" and is also known for her political activism.\n\nAnswer: Rosario Dawson\n\n---\n\nContext:\n&#91;1] \u00abBattle of Kursk | The Battle of Kursk was a Second World War engagement between German and Soviet forces on the Eastern Front near Kursk (450 km south-west of Moscow) in the Soviet Union during July and August 1943. The battle began with the launch of the German offensive, Operation Citadel (German: \"Unternehmen Zitadelle\" ), on 5 July, which had the objective of pinching off the Kursk salient with attacks on the base of the salient from north and south simultaneously. After the German offensive stalled on the northern side of the salient, on 12 July the Soviets commenced their Kursk Strategic Offensive Operation with the launch of Operation Kutuzov (Russian: \u041a\u0443\u0442\u0443\u0437\u043e\u0432 ) against the rear of the German forces in the northern side. On the southern side, the Soviets also launched powerful counterattacks the same day, one of which led to a large armoured clash, the Battle of Prokhorovka. On 3 August, the Soviets began the second phase of the Kursk Strategic Offensive Operation with the launch of Operation Polkovodets Rumyantsev (Russian: \u041f\u043e\u043b\u043a\u043e\u0432\u043e\u0434\u0435\u0446 \u0420\u0443\u043c\u044f\u043d\u0446\u0435\u0432 ) against the German forces in the southern side of the Kursk salient.\u00bb\n&#91;2] \u00abOperation Mars | Operation Mars, also known as the Second Rzhev-Sychevka Offensive Operation (Russian: \u0412\u0442\u043e\u0440\u0430\u044f \u0420\u0436\u0435\u0432\u0441\u043a\u043e-\u0421\u044b\u0447\u0451\u0432\u0441\u043a\u0430\u044f \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f), was the codename for an offensive launched by Soviet forces against German forces during World War II. It took place between 25 November and 20 December 1942 around the Rzhev salient in the vicinity of Moscow.\u00bb\n&#91;3] \u00abKholm Pocket | The Kholm Pocket (German: \"Kessel von Cholm\" ; Russian: \u0425\u043e\u043b\u043c\u0441\u043a\u0438\u0439 \u043a\u043e\u0442\u0451\u043b ) was the name given for the encirclement of German troops by the Red Army around Kholm south of Leningrad, during World War II on the Eastern Front, from 23 January 1942 until 5 May 1942. A much larger pocket was simultaneously surrounded in Demyansk, about 100 km to the northeast. These were the results of German retreat following their defeat during the Battle of Moscow.\u00bb\n\nQuestion: What is the code name for the German offensive that started this Second World War engagement on the Eastern Front (a few hundred kilometers from Moscow) between Soviet and German forces, which included 102nd Infantry Division?\n\nReasoning: Let's think step by step in order to produce the answer. We know that the German offensive that started the Battle of Kursk was called Operation Citadel (German: \"Unternehmen Zitadelle\").\n\nAnswer: Operation Citadel\n\n---\n\nContext:\n&#91;1] \u00abKerry Condon | Kerry Condon (born 4 January 1983) is an Irish television and film actress, best known for her role as Octavia of the Julii in the HBO\/BBC series \"Rome,\" as Stacey Ehrmantraut in AMC's \"Better Call Saul\" and as the voice of F.R.I.D.A.Y. in various films in the Marvel Cinematic Universe. She is also the youngest actress ever to play Ophelia in a Royal Shakespeare Company production of \"Hamlet.\"\u00bb\n&#91;2] \u00abCorona Riccardo | Corona Riccardo (c. 1878October 15, 1917) was an Italian born American actress who had a brief Broadway stage career before leaving to become a wife and mother. Born in Naples she came to acting in 1894 playing a Mexican girl in a play at the Empire Theatre. Wilson Barrett engaged her for a role in his play \"The Sign of the Cross\" which he took on tour of the United States. Riccardo played the role of Ancaria and later played Berenice in the same play. Robert B. Mantell in 1898 who struck by her beauty also cast her in two Shakespeare plays, \"Romeo and Juliet\" and \"Othello\". Author Lewis Strang writing in 1899 said Riccardo was the most promising actress in America at the time. Towards the end of 1898 Mantell chose her for another Shakespeare part, Ophelia im Hamlet. Afterwards she was due to join Augustin Daly's Theatre Company but Daly died in 1899. In 1899 she gained her biggest fame by playing Iras in the first stage production of Ben-Hur.\u00bb\n&#91;3] \u00abJudi Dench | Dame Judith Olivia \"Judi\" Dench, {'1': \", '2': \", '3': \", '4': \"} (born 9 December 1934) is an English actress and author. Dench made her professional debut in 1957 with the Old Vic Company. Over the following few years, she performed in several of Shakespeare's plays in such roles as Ophelia in \"Hamlet\", Juliet in \"Romeo and Juliet\", and Lady Macbeth in \"Macbeth\". Although most of her work during this period was in theatre, she also branched into film work and won a BAFTA Award as Most Promising Newcomer. She drew strong reviews for her leading role in the musical \"Cabaret\" in 1968.\u00bb\n\nQuestion: Who acted in the shot film The Shore and is also the youngest actress ever to play Ophelia in a Royal Shakespeare Company production of \"Hamlet.\" ?\n\nReasoning: Let's think step by step in order to produce the answer. We know that the actress in question played Ophelia in a Royal Shakespeare Company production of \"Hamlet\" and appeared in the short film \"The Shore.\"\n\nAnswer: Kerry Condon\n\n---\n\nContext:\n&#91;1] \u00abDavid Gregory (physician) | David Gregory (20 December 1625 \u2013 1720) was a Scottish physician and inventor. His surname is sometimes spelt as Gregorie, the original Scottish spelling. He inherited Kinnairdy Castle in 1664. Three of his twenty-nine children became mathematics professors. He is credited with inventing a military cannon that Isaac Newton described as \"being destructive to the human species\". Copies and details of the model no longer exist. Gregory's use of a barometer to predict farming-related weather conditions led him to be accused of witchcraft by Presbyterian ministers from Aberdeen, although he was never convicted.\u00bb\n&#91;2] \u00abGregory Tarchaneiotes | Gregory Tarchaneiotes (Greek: \u0393\u03c1\u03b7\u03b3\u03cc\u03c1\u03b9\u03bf\u03c2 \u03a4\u03b1\u03c1\u03c7\u03b1\u03bd\u03b5\u03b9\u03ce\u03c4\u03b7\u03c2 , Italian: \"Gregorio Tracanioto\" or \"Tracamoto\" ) was a \"protospatharius\" and the long-reigning catepan of Italy from 998 to 1006. In December 999, and again on February 2, 1002, he reinstituted and confirmed the possessions of the abbey and monks of Monte Cassino in Ascoli. In 1004, he fortified and expanded the castle of Dragonara on the Fortore. He gave it three circular towers and one square one. He also strengthened Lucera.\u00bb\n&#91;3] \u00abDavid Gregory (mathematician) | David Gregory (originally spelt Gregorie) FRS (? 1659 \u2013 10 October 1708) was a Scottish mathematician and astronomer. He was professor of mathematics at the University of Edinburgh, Savilian Professor of Astronomy at the University of Oxford, and a commentator on Isaac Newton's \"Principia\".\u00bb\n\nQuestion: What castle did David Gregory inherit?\n\nReasoning: Let's think step by step in order to produce the answer. We know that David Gregory inherited Kinnairdy Castle.\n\nAnswer: Kinnairdy Castle<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306a\u8a73\u7d30\u306a\u30c7\u30e2\u30f3\u30b9\u30c8\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u66f8\u3044\u3066\u3044\u306a\u3044\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u3001DSPy\u306f\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u306b\u66f8\u304b\u308c\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u5185\u3067\u30013,000\u30c8\u30fc\u30af\u30f3\u306e\u30d7\u30ed\u30f3\u30d7\u30c8\u30923\u30b7\u30e7\u30c3\u30c8\u306e\u691c\u7d22\u62e1\u5f35\u751f\u6210\u7528\u306b\u30d6\u30fc\u30c8\u30b9\u30c8\u30e9\u30c3\u30d7\u3057\u3001Chain-of-Thought\u306e\u7406\u7531\u3065\u3051\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u305f\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u3001\u69cb\u6210\u3068\u5b66\u7fd2\u306e\u529b\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002\u305f\u3060\u3001\u3053\u308c\u306f\u7279\u5b9a\u306e\u30c6\u30ec\u30d7\u30ed\u30f3\u30d7\u30bf\u30fc\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u305f\u3060\u3051\u3067\u3042\u308a\u3001\u5404\u8a2d\u5b9a\u3067\u5b8c\u74a7\u3067\u3042\u308b\u3068\u306f\u9650\u308a\u307e\u305b\u3093\u3002DSPy\u3067\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u54c1\u8cea\u3068\u30b3\u30b9\u30c8\u306b\u95a2\u3057\u3066\u6700\u9069\u5316\u304a\u3088\u3073\u691c\u8a3c\u3059\u308b\u305f\u3081\u306e\u5927\u898f\u6a21\u3060\u304c\u4f53\u7cfb\u7684\u306a\u9078\u629e\u80a2\u304c\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5b66\u7fd2\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u81ea\u4f53\u3082\u7c21\u5358\u306b\u8abf\u3079\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for name, parameter in compiled_rag.named_predictors():\n    print(name)\n    print(parameter.demos&#91;0])<\/code><\/pre>\n\n\n\n<p>\u51fa\u529b\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>generate_answer\nExample({'augmented': True, 'context': &#91;'Tae Kwon Do Times | Tae Kwon Do Times is a magazine devoted to the martial art of taekwondo, and is published in the United States of America. While the title suggests that it focuses on taekwondo exclusively, the magazine also covers other Korean martial arts. \"Tae Kwon Do Times\" has published articles by a wide range of authors, including He-Young Kimm, Thomas Kurz, Scott Shaw, and Mark Van Schuyver.', \"Kwon Tae-man | Kwon Tae-man (born 1941) was an early Korean hapkido practitioner and a pioneer of the art, first in Korea and then in the United States. He formed one of the earliest dojang's for hapkido in the United States in Torrance, California, and has been featured in many magazine articles promoting the art.\", 'Hee Il Cho | Cho Hee Il (born October 13, 1940) is a prominent Korean-American master of taekwondo, holding the rank of 9th \"dan\" in the martial art. He has written 11 martial art books, produced 70 martial art training videos, and has appeared on more than 70 martial arts magazine covers. Cho won several national and international competitions as a taekwondo competitor, and has appeared in several films, including \"Fight to Win\", \"Best of the Best\", \"Bloodsport II\", and \"Bloodsport III\". He founded the Action International Martial Arts Association (AIMAA) in 1980, and is its President. Cho is a member of both \"Black Belt\" magazine\\'s Hall of Fame and \"Tae Kwon Do Times\" magazine\\'s Hall of Fame.'], 'question': 'Which magazine has published articles by Scott Shaw, Tae Kwon Do Times or Southwest Art?', 'rationale': 'produce the answer. We know that \"Tae Kwon Do Times\" has published articles by Scott Shaw, as mentioned in the context.', 'answer': 'Tae Kwon Do Times'}) (input_keys=None)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%AE%E8%A9%95%E4%BE%A1\"><\/span>\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306e\u8a55\u4fa1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u305fRAG\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8a55\u4fa1\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u5f53\u7136\u3067\u3059\u304c\u3001\u3053\u306e\u308f\u305a\u304b\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306f\u4fe1\u983c\u6027\u306e\u3042\u308b\u30d9\u30f3\u30c1\u30de\u30fc\u30af\u3068\u306a\u308b\u3053\u3068\u3092\u610f\u5473\u3057\u3066\u3044\u307e\u305b\u3093\u3002\u3057\u304b\u3057\u3001\u8aac\u660e\u306e\u305f\u3081\u306b\u4f7f\u7528\u3059\u308b\u306e\u306f\u6709\u76ca\u3067\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u3001\u4e88\u6e2c\u3055\u308c\u305f\u56de\u7b54\u306e\u6b63\u78ba\u6027\uff08\u5b8c\u5168\u4e00\u81f4\uff09\u3092\u8a55\u4fa1\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from dspy.evaluate.evaluate import Evaluate\n\n# `evaluate_on_hotpotqa`\u95a2\u6570\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u4ee5\u4e0b\u3067\u4f55\u5ea6\u3082\u4f7f\u7528\u3057\u307e\u3059\u3002\nevaluate_on_hotpotqa = Evaluate(devset=devset, num_threads=1, display_progress=False, display_table=5)\n\n# `compiled_rag`\u30d7\u30ed\u30b0\u30e9\u30e0\u3092`answer_exact_match`\u30e1\u30c8\u30ea\u30c3\u30af\u3067\u8a55\u4fa1\u3057\u307e\u3059\u3002\nmetric = dspy.evaluate.answer_exact_match\nevaluate_on_hotpotqa(compiled_rag, metric=metric)<\/code><\/pre>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4e0b\u8a18\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Average Metric: 27 \/ 50  (54.0%)<\/code><\/pre>\n\n\n\n<p>\u7cbe\u5ea6\u3068\u3057\u3066\u306f\u5c0f\u3055\u306a\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3067\u8a13\u7df4\u3057\u305f\u306b\u3082\u95a2\u308f\u3089\u305a\u826f\u3044\u7d50\u679c\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E3%83%AA%E3%83%88%E3%83%AA%E3%83%BC%E3%83%90%E3%83%AB%EF%BC%88%E6%A4%9C%E7%B4%A2%E8%83%BD%E5%8A%9B%EF%BC%89%E3%81%AE%E8%A9%95%E4%BE%A1\"><\/span>\u30ea\u30c8\u30ea\u30fc\u30d0\u30eb\uff08\u691c\u7d22\u80fd\u529b\uff09\u306e\u8a55\u4fa1<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u691c\u7d22\u306e\u7cbe\u5ea6\u3092\u898b\u308b\u4e8b\u3082\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u306f\u8907\u6570\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u5358\u7d14\u306b\u691c\u7d22\u3055\u308c\u305f\u6bb5\u843d\u304c\u56de\u7b54\u3092\u542b\u3093\u3067\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u958b\u767a\u30bb\u30c3\u30c8\u306b\u306f\u691c\u7d22\u3055\u308c\u308b\u3079\u304d\u30b4\u30fc\u30eb\u30c9\u30bf\u30a4\u30c8\u30eb\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def gold_passages_retrieved(example, pred, trace=None):\n    gold_titles = set(map(dspy.evaluate.normalize_text, example&#91;'gold_titles']))\n    found_titles = set(map(dspy.evaluate.normalize_text, &#91;c.split(' | ')&#91;0] for c in pred.context]))\n\n    return gold_titles.issubset(found_titles)\n\ncompiled_rag_retrieval_score = evaluate_on_hotpotqa(compiled_rag, metric=gold_passages_retrieved)<\/code><\/pre>\n\n\n\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4e0b\u8a18\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Average Metric: 13 \/ 50  (26.0%)<\/code><\/pre>\n\n\n\n<p>\u3053\u3061\u3089\u3082\u3042\u307e\u308a\u826f\u3044\u7cbe\u5ea6\u3068\u306f\u8a00\u3048\u307e\u305b\u3093\u3002<br>\u3053\u306e\u30b7\u30f3\u30d7\u30eb\u306a<code>compiled_rag<\/code>\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u8cea\u554f\u306e\u304b\u306a\u308a\u306e\u5272\u5408\u3092\u9069\u5207\u306b\u56de\u7b54\u3067\u304d\u3066\u3044\u307e\u3059\u304c(\u3053\u306e\u5c0f\u898f\u6a21\u30bb\u30c3\u30c8\u306750%\u4ee5\u4e0a)\u3001\u30ea\u30c8\u30ea\u30fc\u30d0\u30eb\u306e\u7cbe\u5ea6\u306f\u306f\u308b\u304b\u306b\u4f4e\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f\u3001LM\u304c\u591a\u304f\u306e\u5834\u5408\u3001\u8cea\u554f\u306b\u56de\u7b54\u3059\u308b\u305f\u3081\u306b\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u306e\u904e\u7a0b\u3067\u8a18\u61b6\u3055\u308c\u305f\u77e5\u8b58\u306b\u4f9d\u5b58\u3059\u308b\u3053\u3068\u3092\u6f5c\u5728\u7684\u306b\u793a\u3057\u3066\u3044\u308b\u4e8b\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001DSPy\u3092\u4f7f\u7528\u3059\u308b\u4e8b\u3067\u3001\u672c\u6765\u306f\u958b\u767a\u8005\u304c\u8a66\u884c\u932f\u8aa4\u3059\u3079\u304d\u30d7\u30ed\u30f3\u30d7\u30c8\u306e\u8a13\u7df4\u306a\u3069\u3082\u81ea\u52d5\u5b9f\u884c\u3059\u308b\u4e8b\u304c\u51fa\u6765\u3001\u66f4\u306b\u306f\u8a55\u4fa1\u3059\u308b\u4e8b\u3082\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br>\u4eca\u56de\u306fColBEART\u306e\u516c\u958bWiki\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u304c\u3001\u3053\u306e\u8a18\u4e8b\u306e\u8a55\u4fa1\u304c\u826f\u3051\u308c\u3070\u3001Chroma\u3084Qdrant\u3068\u3044\u3063\u305f\u30d9\u30af\u30bf\u30fcDB\u3092\u30ea\u30c8\u30ea\u30fc\u30d0\u30fc\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u3001RAG\u3067\u691c\u7d22\u5bfe\u8c61\u3068\u3059\u3079\u304d\u6587\u7ae0\u3092\u8aad\u307f\u8fbc\u307e\u305b\u308b\u3001\u3088\u308a\u5b9f\u8df5\u7684\u306a\u65b9\u6cd5\u306e\u7d39\u4ecb\u3092\u884c\u3063\u3066\u884c\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306fDSPy\u306b\u3064\u3044\u3066\u306e\u57fa\u672c\u7684\u306a\u7d39\u4ecb\u3092\u81f4\u3057\u307e\u3057\u305f\u3002\u4eca\u56de\u306f\u3001\u5b9f\u969b\u306bDSPy\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3055\u305b\u3001\u305d\u308c\u306b\u3064\u3044\u3066\u306e\u56de\u7b54\u3092ChatGPT-3.5\u306b\u3055\u305b ... <a title=\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9\" class=\"read-more\" href=\"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007\" aria-label=\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 \u306b\u3064\u3044\u3066\u3055\u3089\u306b\u8aad\u3080\">Read more<\/a><\/p>\n","protected":false},"author":36,"featured_media":9009,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[74],"tags":[110],"series":[73],"journey":[100],"product":[],"class_list":["post-9007","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","tag-technical-guides","series-generative-ai","journey-deep","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column\" \/>\n<meta property=\"og:description\" content=\"\u524d\u56de\u306fDSPy\u306b\u3064\u3044\u3066\u306e\u57fa\u672c\u7684\u306a\u7d39\u4ecb\u3092\u81f4\u3057\u307e\u3057\u305f\u3002\u4eca\u56de\u306f\u3001\u5b9f\u969b\u306bDSPy\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3055\u305b\u3001\u305d\u308c\u306b\u3064\u3044\u3066\u306e\u56de\u7b54\u3092ChatGPT-3.5\u306b\u3055\u305b ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007\" \/>\n<meta property=\"og:site_name\" content=\"KUSANAGI Tech Column\" \/>\n<meta property=\"article:published_time\" content=\"2024-09-25T04:17:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-16T16:24:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1218\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"\u4e95\u5143\u525b\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@kusanagi_saya\" \/>\n<meta name=\"twitter:site\" content=\"@kusanagi_saya\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007\"},\"author\":{\"name\":\"\u4e95\u5143\u525b\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#\\\/schema\\\/person\\\/00d808ed1edcd0c4d44ad11941ae4966\"},\"headline\":\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9\",\"datePublished\":\"2024-09-25T04:17:07+00:00\",\"dateModified\":\"2026-02-16T16:24:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007\"},\"wordCount\":80,\"publisher\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/9de945479d466c7ca5a59cc6ac64a9cc.png\",\"keywords\":[\"\u6280\u8853\u89e3\u8aac\"],\"articleSection\":[\"AI\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007\",\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007\",\"name\":\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/9de945479d466c7ca5a59cc6ac64a9cc.png\",\"datePublished\":\"2024-09-25T04:17:07+00:00\",\"dateModified\":\"2026-02-16T16:24:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#primaryimage\",\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/9de945479d466c7ca5a59cc6ac64a9cc.png\",\"contentUrl\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/09\\\/9de945479d466c7ca5a59cc6ac64a9cc.png\",\"width\":2400,\"height\":1218},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_9007#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#website\",\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/\",\"name\":\"KUSANAGI Tech Column\",\"description\":\"\u901f\u3055\u306e\u7406\u7531\u3092\u77e5\u308b\u3002\u5b89\u5168\u306e\u4ed5\u7d44\u307f\u3092\u77e5\u308b\u3002WordPress\u904b\u7528\u306e\u300c\u306a\u305c\uff1f\u300d\u3092\u89e3\u304f\u6280\u8853\u30b3\u30e9\u30e0\",\"publisher\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#organization\",\"name\":\"KUSANAGI Tech Column\",\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/logo-tc.png\",\"contentUrl\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/wp-content\\\/uploads\\\/2024\\\/07\\\/logo-tc.png\",\"width\":716,\"height\":57,\"caption\":\"KUSANAGI Tech Column\"},\"image\":{\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/kusanagi_saya\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/#\\\/schema\\\/person\\\/00d808ed1edcd0c4d44ad11941ae4966\",\"name\":\"\u4e95\u5143\u525b\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g\",\"caption\":\"\u4e95\u5143\u525b\"},\"url\":\"https:\\\/\\\/kusanagi.tokyo\\\/column\\\/archives\\\/column_author\\\/tsuyoshi-imoto\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007","og_locale":"ja_JP","og_type":"article","og_title":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column","og_description":"\u524d\u56de\u306fDSPy\u306b\u3064\u3044\u3066\u306e\u57fa\u672c\u7684\u306a\u7d39\u4ecb\u3092\u81f4\u3057\u307e\u3057\u305f\u3002\u4eca\u56de\u306f\u3001\u5b9f\u969b\u306bDSPy\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3055\u305b\u3001\u305d\u308c\u306b\u3064\u3044\u3066\u306e\u56de\u7b54\u3092ChatGPT-3.5\u306b\u3055\u305b ... Read more","og_url":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007","og_site_name":"KUSANAGI Tech Column","article_published_time":"2024-09-25T04:17:07+00:00","article_modified_time":"2026-02-16T16:24:58+00:00","og_image":[{"width":2400,"height":1218,"url":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png","type":"image\/png"}],"author":"\u4e95\u5143\u525b","twitter_card":"summary_large_image","twitter_creator":"@kusanagi_saya","twitter_site":"@kusanagi_saya","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#article","isPartOf":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007"},"author":{"name":"\u4e95\u5143\u525b","@id":"https:\/\/kusanagi.tokyo\/column\/#\/schema\/person\/00d808ed1edcd0c4d44ad11941ae4966"},"headline":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9","datePublished":"2024-09-25T04:17:07+00:00","dateModified":"2026-02-16T16:24:58+00:00","mainEntityOfPage":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007"},"wordCount":80,"publisher":{"@id":"https:\/\/kusanagi.tokyo\/column\/#organization"},"image":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#primaryimage"},"thumbnailUrl":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png","keywords":["\u6280\u8853\u89e3\u8aac"],"articleSection":["AI"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007","url":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007","name":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9 - KUSANAGI Tech Column","isPartOf":{"@id":"https:\/\/kusanagi.tokyo\/column\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#primaryimage"},"image":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#primaryimage"},"thumbnailUrl":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png","datePublished":"2024-09-25T04:17:07+00:00","dateModified":"2026-02-16T16:24:58+00:00","breadcrumb":{"@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kusanagi.tokyo\/column\/archives\/column_9007"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#primaryimage","url":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png","contentUrl":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/09\/9de945479d466c7ca5a59cc6ac64a9cc.png","width":2400,"height":1218},{"@type":"BreadcrumbList","@id":"https:\/\/kusanagi.tokyo\/column\/archives\/column_9007#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/kusanagi.tokyo\/column"},{"@type":"ListItem","position":2,"name":"DSPy\u3092\u7528\u3044\u305f\u30b7\u30f3\u30d7\u30eb\u306aRAG\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9"}]},{"@type":"WebSite","@id":"https:\/\/kusanagi.tokyo\/column\/#website","url":"https:\/\/kusanagi.tokyo\/column\/","name":"KUSANAGI Tech Column","description":"\u901f\u3055\u306e\u7406\u7531\u3092\u77e5\u308b\u3002\u5b89\u5168\u306e\u4ed5\u7d44\u307f\u3092\u77e5\u308b\u3002WordPress\u904b\u7528\u306e\u300c\u306a\u305c\uff1f\u300d\u3092\u89e3\u304f\u6280\u8853\u30b3\u30e9\u30e0","publisher":{"@id":"https:\/\/kusanagi.tokyo\/column\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kusanagi.tokyo\/column\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/kusanagi.tokyo\/column\/#organization","name":"KUSANAGI Tech Column","url":"https:\/\/kusanagi.tokyo\/column\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/kusanagi.tokyo\/column\/#\/schema\/logo\/image\/","url":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/07\/logo-tc.png","contentUrl":"https:\/\/kusanagi.tokyo\/column\/wp-content\/uploads\/2024\/07\/logo-tc.png","width":716,"height":57,"caption":"KUSANAGI Tech Column"},"image":{"@id":"https:\/\/kusanagi.tokyo\/column\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/kusanagi_saya"]},{"@type":"Person","@id":"https:\/\/kusanagi.tokyo\/column\/#\/schema\/person\/00d808ed1edcd0c4d44ad11941ae4966","name":"\u4e95\u5143\u525b","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/secure.gravatar.com\/avatar\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/af5c2c21b45ac98a5ceaa557735da47de70f34dfc30c25b9dcbcca08455cb307?s=96&d=mm&r=g","caption":"\u4e95\u5143\u525b"},"url":"https:\/\/kusanagi.tokyo\/column\/archives\/column_author\/tsuyoshi-imoto"}]}},"_links":{"self":[{"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/posts\/9007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/comments?post=9007"}],"version-history":[{"count":1,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/posts\/9007\/revisions"}],"predecessor-version":[{"id":9008,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/posts\/9007\/revisions\/9008"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/media\/9009"}],"wp:attachment":[{"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/media?parent=9007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/categories?post=9007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/tags?post=9007"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/series?post=9007"},{"taxonomy":"journey","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/journey?post=9007"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/kusanagi.tokyo\/column\/wp-json\/wp\/v2\/product?post=9007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}