Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Amazon BedrockとOpenSearch Serviceでなんでも答えられる社内RA...

Amazon BedrockとOpenSearch Serviceでなんでも答えられる社内RAGを作成する!!

とすり

July 31, 2024
Tweet

More Decks by とすり

Other Decks in Technology

Transcript

  1. @tosuri13 RAGͱ͸? RAG(Retriev a l Augmented Gener a tion)ͱ͸ɺ֎෦͔Βऔಘͨ͠ճ౴ͷࢀߟͱͳ Δ৘ใΛLLMʹࢀরͤͯ͞ճ౴Λੜ੒͢Δख๏Ͱ͢ɻ

    RAGΛ࢖͏͜ͱʹΑͬͯɺLLM͕ຊདྷ஌Γಘͳ͍৘ใΛิ଍ͯ͠ճ౴Λੜ੒ͤ͞ Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳΓ·͢!! ֎෦DB LLM AIΛ༻͍ͯݕࡧ ྨࣅ͢Δ৘ใΛ౉͢ औಘͨ͠৘ใΛ ࢀরͯ͠ճ౴
  2. @tosuri13 ϕΫτϧݕࡧʹ͍ͭͯ ·ͨɺࢀߟ৘ใͱͯ͠౉͍ͨ͠υΩϡϝϯτΛݕࡧ͢ΔͨΊʹ͸ɺϕΫτϧݕࡧ ͱ͍͏ख๏͕RAGγεςϜͰ͸޿͘࠾༻͞Ε͍ͯ·͢ɻϕΫτϧݕࡧʹΑΓࣗવ ݴޠΛ༻͍ͨυΩϡϝϯτͷݕࡧ͕Ͱ͖ΔΑ͏ʹͳΓ·͢!! ϕΫτϧετΞ [0.8, 0.3, 0.1 …

    ] [0.4, 0.4, 0.3 … ] [0.5, 0.7, 0.8 … ] େྔͷυΩϡϝϯτ ࣭໰ [0.8, 0.3, 0.2 … ] ࣭໰΋ϕΫτϧԽͯ͠ ࣅ͍ͯΔϕΫτϧΛݕࡧ͢Δ!! υΩϡϝϯτΛϕΫτϧԽͯ͠ ྨࣅ͢ΔจষΛ୳͠΍͘͢͢Δ!!
  3. @tosuri13 ࢖༻͢ΔAWSαʔϏεΛϐοΫΞοϓ!! ɾAm a zon Bedrock ɹˠ ճ౴΍ϕΫτϧͷੜ੒ʹ࢖༻͠·͢ɻ࢖༻͢Δج൫Ϟσϧ͸ҎԼͷ2ͭͰ͢ɻ ɹɹ- Cl

    a ude 3.5 Sonnet (ճ౴ੜ੒༻) ɹɹ- Tit a n Text Embedding v2 (ϕΫτϧੜ੒༻) ɾAm a zon OpenSe a rch Service ɹˠ ϕΫτϧΛ֨ೲͯ͠ηϚϯςΟοΫݕࡧΛߦ͏ϕΫτϧετΞͱͯ͠࢖༻͠·͢ɻ ɾAm a zon S3 ɹˠ ݩͷυΩϡϝϯτͱࣝผࢠ΍ࢀরݩURLͳͲͷϝλσʔλΛอ؅͠·͢ɻ
  4. @tosuri13 RAGΞϓϦέʔγϣϯͷAWSߏ੒ਤ νϟοτΞϓϦ ؅ཧऀ API G a tew a y

    L a mbd a SNS Bedrock L a mbd a OpenSe a rch L a mbd a S3 Bedrock ճ ౴ ͷ ฦ ৴ ճ౴ͷੜ੒ ϕΫτϧετΞ υΩϡϝϯτ؅ཧ ϕΫτϧม׵ ॳճԠ౴ (λΠϜΞ΢τରࡦ) WebhookͰ࣭໰Λૹ৴
  5. @tosuri13 ᶃ νϟϯΫͷ෼ׂํ๏ νϟοτΞϓϦ ؅ཧऀ API G a L a

    SNS Bedrock L a OpenSe a rch L a mbd a S3 Bedrock ճ ౴ ͷ ฦ ৴ ճ౴ͷੜ੒ ϕΫτϧDB υΩϡϝϯτ؅ཧ ϕΫτϧม׵ ॳճԠ౴ (λΠϜΞ΢τରࡦ) WebhookͰ࣭໰Λૹ৴
  6. @tosuri13 ᶃ νϟϯΫͷ෼ׂํ๏ ͲͷυΩϡϝϯτ΋౷ҰతʹM a rkdownʹม׵Λߦ͍ɺH1΍H2λά͝ͱʹ෼ׂ͢ Δ͜ͱͰɺద౓ͳαΠζ͔ͭจ຺Λอ࣋ͨ͠ঢ়ଶͰνϟϯΫ෼ׂΛ͍ͯ͠·͢ɻ htmlɾcsvɾtxtͳͲ M a

    rkdown # ேྱMTGϝϞ ## ਐḿ֬ೝ ɹ- A͞Μ: ͍͢͝ਐΜͰΔɺେৎ෉ͦ͏ ɹ- B͞Μ: શવਐΜͰͳ͍ɺࠔͬͨ… ## ࠓ೔ͷλεΫ ɹ- Xࣾͱͷଧͪ߹Θͤ ɹ- ์ஔ͞Ε͍ͯΔίϯϑϦΫτΛमਖ਼͢Δ S3͔ΒͷΠϕϯτ௨஌Λड͚औͬͯ M a rkdownʹม׵!! ҎԼͷΑ͏ͳΠϝʔδͰνϟϯΫ෼ׂ!!
  7. @tosuri13 ᶄ Tool useʹΑΔCit a tions νϟοτΞϓϦ ؅ཧऀ API G

    a L a SNS Bedrock L a mbd a OpenSe a rch L a S3 Bedrock ճ ౴ ͷ ฦ ৴ ճ౴ͷੜ੒ ϕΫτϧDB υΩϡϝϯτ؅ཧ ϕΫτϧม׵ ॳճԠ౴ (λΠϜΞ΢τରࡦ) WebhookͰ࣭໰Λૹ৴
  8. @tosuri13 ᶄ Tool useʹΑΔCit a tions ϕΫτϧݕࡧʹΑΓऔಘͨ͠υΩϡϝϯτʹ͸ɺඞͣ͠΋ؔ࿈͢Δ৘ใͷΈؚ͕ ·Ε͍ͯΔͱ͸ݶΓ·ͤΜɻͦͷͨΊɺҾ༻ݩͱͳΔURLΛฦ͢৔߹͸࣭໰ͱؔ ܎ͷͳ͍URLؚ͕·Εͯ͠·͏ͳͲ໰୊͕͋Γ·͢ɻ RAGΞϓϦέʔγϣϯ

    ༗څͷਃ੥ํ๏Λڭ͑ͯ!! ͍͔ͭ͘ݟ͚͖ͭͯ·γλɻ ɾ{ܦඅਃ੥ํ๏ͷURL} ɾ{༗څਃ੥ํ๏ͷURL} ɾ{ೖୀࣨਃ੥ํ๏ͷURL} ٳΈ͍ͨࣾһ ؔ܎ͷͳ͍URL͸ ճ౴ʹؚΊͯ΄͘͠ͳ͍
  9. @tosuri13 ᶄ Tool useʹΑΔCit a tions LLM͕ࢀߟʹͨ͠಺༰ͷΈΛฦ͢ϓϩϯϓτΤϯδχΞϦϯάͷख๏ΛCit a tions ͱ͍͍ɺAm

    a zon BedrockͷConverse APIʹ౥ࡌ͞Ε͍ͯΔTool use (Function C a lling)Λ࢖༻࣮ͯ͠૷͠·ͨ͠ɻ Ϩεϙϯεͷܗࣜ΍આ໌Λهࡌͨ͠ πʔϧͷεΩʔϚΛఆٛͯ͠౉͢ εΩʔϚ LLM ߏ଄Խ͞Εͨঢ়ଶͰʮԿΛࢀߟʹͨ͠ͷ͔?ʯΛड͚औΕΔ!!
  10. @tosuri13 ᶄ Tool useʹΑΔCit a tions ·ͨɺఏڙ͞ΕͨπʔϧΛ࢖͏͔൱͔͸LLM͕൑அͯ͠ϨεϙϯεΛฦͨ͢Ίɺ ࢀߟʹͳΔ৘ใ͕શ͘ͳ͔ͬͨ৔߹ͳͲʹϋϧγωʔγϣϯΛ཈͑ΔΑ͏ͳ͜ͱ ΋Ͱ͖·͢!! RAGΞϓϦέʔγϣϯ

    ৯͍͠Μ๥ͳࣾһ େࡕपลͷඒຯ͍͠ ͓޷Έম͖ͷ͓ళΛڭ͑ͯ!! ͋ͳͨͷΦϑΟεʹʮܦඅਃ੥ʯ ͱ͍͏໊લͷ͓޷Έম͖԰͞Μ͕ ซઃ͞Ε͍ͯΔΑ͏σεɻ ɾ{ܦඅਃ੥ํ๏ͷURL} ࢀߟ৘ใΛݩʹӕͷ಺༰Λ ճ౴͢ΔΑ͏ͳ͜ͱΛ๷͛Δ!!