Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
llm.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nikawa2161
June 05, 2025
10
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
llm.pdf
nikawa2161
June 05, 2025
More Decks by nikawa2161
See All by nikawa2161
Node.js Subpath imports
nikawa2161
0
44
Sagaパターン入門(続編)
nikawa2161
0
52
Sagaパターン入門
nikawa2161
0
65
沖縄観光とPostgreSQL排他制約の話
nikawa2161
0
41
20251209_プログラミング原則の学び
nikawa2161
0
41
自分のコードを数年ぶりに読んだら
nikawa2161
0
26
ユーザーインタビュー分析に参加して得られたことと気づき
nikawa2161
0
44
oEmbedとは?
nikawa2161
0
250
はじめまして、にかわです
nikawa2161
0
29
Featured
See All Featured
Navigating Team Friction
lara
192
16k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Facilitating Awesome Meetings
lara
57
7.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
260
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
930
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
400
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
A better future with KSS
kneath
240
18k
Transcript
LLMをつくってみる
どうやって作る?
Vercel AI SDK https://ai-sdk.dev/
Vercel AI SDK https://ai-sdk.dev/docs/foundations/providers-and-models
Vercel AI SDK https://ai-sdk.dev/docs/foundations/streaming
3 データ出力を逐次的に、公立よく扱うためのデータ構 3 データ全体(ファイル一個)をそれより細かく分割された単位の連続した 流れを表現する ストリームとは
用意するもの E フロント(React' E ストリーミングで表& E バックエンド(Hono' E AI SDKでモデル選択
用意するもの E フロント(React' E ストリーミングで表& E バックエンド(Hono' E AI SDKでモデル選択
ライブラリ E ai-sdk/openaS E ai-sdk/reac` E aS E zor E aiの依存関係として必要
モデルの選択 1 2 3 4 5 6 7 8 9
import from const { createOpenAI } ; model ({ baseURL , apiKey process.env. , }). ( ); "@ai-sdk/openai" "https://models.github.ai/inference" "openai/gpt-4o-mini" = : : createOpenAI chat OPENAI_API_KEY
リクエスト 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 import from import from const async const await const return { createOpenAI } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); result. (); }); "@ai-sdk/openai" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." = : : => = = : createOpenAI chat post json streamText toDataStream OPENAI_API_KEY
リクエスト(Hono) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 import from import from import from const async const await const return { createOpenAI } ; { stream } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "@ai-sdk/openai" "hono/streaming" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : : => = = : => createOpenAI chat post json streamText header stream pipe toDataStream OPENAI_API_KEY
表示側 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import from export default function const return div div div form input button button form div { useChat } ; () { { messages, input, handleInputChange, handleSubmit } ({ api , }); ( < > {messages. ((message) ( < key={message.id}> {message.role } {message.content} </ > ))} < onSubmit={handleSubmit}> < name="prompt" placeholder="質問を入力してください" value={input} onChange={handleInputChange} /> < type="submit">送信</ > </ > </ > ); } "@ai-sdk/react" "http://localhost:5173/api/chat" "user" "User: " "AI: " Chat useChat map = : => === ? :
紹介
LLMはローカルでも動かせる ・モデルをダウンロード ・サーバーを立ち上げる ・https://ollama.com/
モデル選択(OpenAi) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 import from import from import from const async const await const return { createOpenAI } ; { stream } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "@ai-sdk/openai" "hono/streaming" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : : => = = : => createOpenAI chat post json streamText header stream pipe toDataStream OPENAI_API_KEY
モデル選択(ollama) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 // import { createOpenAI } from "@ai-sdk/openai"; import from import from import from const async const await const return { createOllama } ; { stream } ; { streamText } ; model ({ baseURL , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "ollama-ai-provider" "hono/streaming" "ai" "http://localhost:11434/api" "phi3" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : => = = : => createOllama chat post json streamText header stream pipe toDataStream
Chrome拡張機能 ・ローカルで動くLLMならChrome拡張機能に組み込める