Slide 1

Slide 1 text

4VQBCBTF &EHF'VODUJPOTY"* UPSBOPBOBEFOP!HFSV

Slide 2

Slide 2 text

͛͠Δ!HFSV 9 چ5XJUUFS ɿ!@HFSV ॴଐɿϚωʔϑΥϫʔυ झຯɿ📷🎱🐟🤿✈ ՝֎׆ಈɿ-*/&"1*&YQFSU ࣗݾ঺հ

Slide 3

Slide 3 text

4VQBCBTFY-*/&#PUͷ૬ੑͷྑ͞ w 4VQBCBTF&EHF'VODUJPOTͷσϓϩΠ͕؆୯ʂ w $-*ૢ࡞ͰσϓϩΠՄೳ w ଞͷαʔόʔϨεϑϨʔϜϫʔΫͱൺ΂ͯ6*͕γϯϓϧ w σʔλϕʔεϩάͷத਎͕ϒϥ΢β͔Β֬ೝͰ͖Δ w DPOTPMFMPHͰϩάग़ྗ΋Մೳʢ+40/Ͱ֬ೝՄೳʣ w -*/&#PUͷ6*͔Βͷจࣈྻը૾Ի੠(14͕ѻ͑Δ w ༷ʑͳ৘ใΛೖྗͰ͖Δ

Slide 4

Slide 4 text

-*/&#PUҎ֎΋ /FYU 7VF 'MVUUFSFUD αϯϓϧίʔυ͕ͨ͘͞Μ

Slide 5

Slide 5 text

4VQBCBTF-PWF🩷

Slide 6

Slide 6 text

Ұ൪͍͍ͱ͜Ζ͸ɺ ʂγϯϓϧʂ

Slide 7

Slide 7 text

ࠓճͷΰʔϧɿ 4VQBCBTF&EHF'VODUJPOT Λ࢖͍ͨ͘ͳΔʂ

Slide 8

Slide 8 text

4VQBCBTFͷ (" ਖ਼ࣜ൛ϦϦʔε

Slide 9

Slide 9 text

ੈք֤஍Ͱ ϛʔτΞοϓ ͕։࠵ʂʂ

Slide 10

Slide 10 text

4VQBCBTF("8FFL d w 4VQBCBTF͕(" (FOFSBM"WBJMBCJMJUZਖ਼ࣜ ϦϦʔε w "VUIʹಗ໊ϩάΠϯػೳ௥Ճ w 4UPSBHF͕4ϓϩτίϧରԠ w &EHF'VODUJPOT͕"*ωΠςΟϒରԠ w ΠϯσοΫεΞυόΠβʔػೳ௥Ճ

Slide 11

Slide 11 text

4VQBCBTFY"* ͷ࿩

Slide 12

Slide 12 text

4VQBCBTF("8FFL d w 4VQBCBTF͕(" (FOFSBM"WBJMBCJMJUZਖ਼ࣜ ϦϦʔε w "VUIʹಗ໊ϩάΠϯػೳ௥Ճ w 4UPSBHF͕4ϓϩτίϧରԠ w &EHF'VODUJPOT͕"*ωΠςΟϒରԠ w ΠϯσοΫεΞυόΠβʔػೳ௥Ճ

Slide 13

Slide 13 text

4VQBCBTF"*ػೳͷϦϦʔε #MPH"**OGFSFODFOPXBWBJMBCMFJO4VQBCBTF&EHF'VODUJPOT 8IZZPVTIPVMEVTF&EHF'VODUJPOTGPS"* -MBNBXJUI7FSDFM"*

Slide 14

Slide 14 text

4VQBCBTF"*ػೳͷϦϦʔε #MPH"**OGFSFODFOPXBWBJMBCMFJO4VQBCBTF&EHF'VODUJPOT &NCFEEJOH"1*Λఏڙ ྨࣅݕࡧ͕͠΍͍͢࢓૊Έ --. -MBNB.JTUSBM Λఏڙ $IBU(15ͷΑ͏ͳνϟοτػೳ

Slide 15

Slide 15 text

4VQBCBTF"*ػೳͷϦϦʔε #MPH"**OGFSFODFOPXBWBJMBCMFJO4VQBCBTF&EHF'VODUJPOT ཁ఺͕·ͱΊΒΕͨ ෼ͷಈը ϋϯζΦϯελΠϧͷ ෼ͷಈը

Slide 16

Slide 16 text

"*ؔ࿈ίʔυ͸ ߦͷΈ

Slide 17

Slide 17 text

--. -MBNB.JTUSBM Λఏڙ $IBU(15ͷΑ͏ͳνϟοτػೳ -MBNBXJUI7FSDFM"*

Slide 18

Slide 18 text

-MBNBXJUI7FSDFM"* w ·ͩɺϩʔΧϧͷΈରԠ w MMBNB NJTUSBMNPEFMͷΈରԠ w ଞͷNPEFM΋Ͱ͖ΔΑ͏ʹܭըத w PMMBNBΛϩʔΧϧͰ؀ڥߏங͢Δඞཁ͋Γ w কདྷతʹ͸4VQBCBTFͷதʹ૊Έࠐ·ΕΔ༧ఆ

Slide 19

Slide 19 text

σϞ

Slide 20

Slide 20 text

1 // / 2 // const session = new Supabase.ai.Session('mistral') 3 const session = new Supabase.ai.Session('llama2') 4 import { notifyMessage } from './messages.ts' 5 6 Deno.serve(async (req: Request) => { 7 const params = new URL(req.url).searchParams 8 const prompt = params.get('prompt') ?? '' 9 notifyMessage(`user prompt: ${prompt}`) 10 11 // Get the output as a stream 12 const output = await session.run(prompt, { stream: true }) NPEFMͷઃఆ͕؆୯

Slide 21

Slide 21 text

1 // / 2 // const session = new Supabase.ai.Session('mistral') 3 const session = new Supabase.ai.Session('llama2') 4 import { notifyMessage } from './messages.ts' 5 6 Deno.serve(async (req: Request) => { 7 const params = new URL(req.url).searchParams 8 const prompt = params.get('prompt') ?? '' 9 notifyMessage(`user prompt: ${prompt}`) 10 11 // Get the output as a stream 12 const output = await session.run(prompt, { stream: true }) NPEFMͷݺͼग़͕͠؆୯

Slide 22

Slide 22 text

18 // Create a stream 19 const stream = new ReadableStream({ 20 async start(controller) { 21 const encoder = new TextEncoder() 22 23 try { 24 let message = '' 25 for await (const chunk of output) { 26 controller.enqueue(encoder.encode(chunk.response ?? '')) 27 message = [...message, chunk.response].join('') 28 } 29 notifyMessage(message) 30 } catch (err) { 31 console.error('Stream error:', err) 32 } finally { 33 controller.close() 34 } 35 }, 36 }) 37 DIVOL͝ͱʹ෼ׂͯ͠ड͚औΔ

Slide 23

Slide 23 text

18 // Create a stream 19 const stream = new ReadableStream({ 20 async start(controller) { 21 const encoder = new TextEncoder() 22 23 try { 24 let message = '' 25 for await (const chunk of output) { 26 controller.enqueue(encoder.encode(chunk.response ?? '')) 27 message = [...message, chunk.response].join('') 28 } 29 notifyMessage(message) 30 } catch (err) { 31 console.error('Stream error:', err) 32 } finally { 33 controller.close() 34 } 35 }, 36 }) 37 DPOUSPMMFSͰॲཧΛ͢Δ

Slide 24

Slide 24 text

&NCFEEJOH"1*Λఏڙ ྨࣅݕࡧ͕͠΍͍͢࢓૊Έ 8IZZPVTIPVMEVTF&EHF'VODUJPOTGPS"*

Slide 25

Slide 25 text

8IZZPVTIPVMEVTF&EHF'VODUJPOTGPS"* w 4VQBCBTF&EHF'VODUJPOTͷΈͰɺ׬݁ɻ w 4VQBCBTFͰ৘ใΛอଘͰ͖Δɻγϯϓϧʂʂ w ྨࣅݕࡧ͕ؔ਺ͱ࣮ͯ͠૷ࡁΈ w ςΩετ͚ͩͰͳ͘ɺը૾ͳͲ΋Մೳ

Slide 26

Slide 26 text

σϞ

Slide 27

Slide 27 text

10 const session = new Supabase.ai.Session('gte-small'); 11 12 serve(async (req) => { 13 const { events } = await req.json() 14 console.log(events) 15 if (events && events[0]?.type === "message") { 16 const input = events[0].message.text 17 // Generate the embedding from the user input 18 const embedding = await session.run(input, { 19 mean_pool: true, 20 normalize: true, 21 }); 22 23 // จࣈྻԽͨ͠ϝοηʔδσʔλ 24 let messages:any = [ 25 { 26 "type": "text", 27 "text": events[0].message.text 28 }, 29 ] NPEFMͷݺͼग़͕͠؆୯ ϕΫτϧ৘ใ͕SFUVSO͞ΕΔ

Slide 28

Slide 28 text

31 // Store the vector in Postgres 32 const supabase = supabaseClient() 33 const { data: documents } = await supabase.rpc('match_documents', { 34 query_embedding: embedding, // Pass the embedding you want to compare 35 match_threshold: 0.78, // Choose an appropriate threshold for your data 36 match_count: 3, // Choose the number of matches 37 }) 38 console.log({documents}) 39 documents.map((doc) => { 40 messages.push({ 41 "type": "text", 42 "text": `Matched: ${doc.body}` 43 }) 44 }) 45 const { data, error } = await supabase.from('documents').insert({ 46 body: events[0].message.text, 47 embedding, 48 }) 49 replyMessage(events, messages) 50 } Ұக͢ΔυΩϡϝϯτΛݕࡧ

Slide 29

Slide 29 text

31 // Store the vector in Postgres 32 const supabase = supabaseClient() 33 const { data: documents } = await supabase.rpc('match_documents', { 34 query_embedding: embedding, // Pass the embedding you want to compare 35 match_threshold: 0.78, // Choose an appropriate threshold for your data 36 match_count: 3, // Choose the number of matches 37 }) 38 console.log({documents}) 39 documents.map((doc) => { 40 messages.push({ 41 "type": "text", 42 "text": `Matched: ${doc.body}` 43 }) 44 }) 45 const { data, error } = await supabase.from('documents').insert({ 46 body: events[0].message.text, 47 embedding, 48 }) 49 replyMessage(events, messages) 50 } ೖྗͨ͠ϕΫτϧͷ৘ใΛอଘ

Slide 30

Slide 30 text

31 // Store the vector in Postgres 32 const supabase = supabaseClient() 33 const { data: documents } = await supabase.rpc('match_documents', { 34 query_embedding: embedding, // Pass the embedding you want to compare 35 match_threshold: 0.78, // Choose an appropriate threshold for your dat 36 match_count: 3, // Choose the number of matches 37 }) 38 console.log({documents}) 39 documents.map((doc) => { 40 messages.push({ 41 "type": "text", 42 "text": `Matched: ${doc.body}` 43 }) 44 }) 45 const { data, error } = await supabase.from('documents').insert({ 46 body: events[0].message.text, 47 embedding, 48 }) 49 replyMessage(events, messages) 50 } ϩάͷ֬ೝ͕؆୯ʂ

Slide 31

Slide 31 text

ϩάͷ֬ೝ͕؆୯ʂ

Slide 32

Slide 32 text

4VQBCBTF͚ͩͰ "*ͷ1P$͕Ͱ͖Δʂ

Slide 33

Slide 33 text

4VQBCBTFY-*/&#PU ૬ੑ࠷ߴʂ

Slide 34

Slide 34 text

-*/&#PUҎ֎΋ /FYU 7VF 'MVUUFSFUD αϯϓϧίʔυ͕ͨ͘͞Μ

Slide 35

Slide 35 text

ࠓճͷΰʔϧɿ 4VQBCBTF&EHF'VODUJPOT Λ࢖͍ͨ͘ͳΔʂ