1. ํ์ ์ฌ์ ์ค์น ์๊ฑด & ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ฑ (Prerequisites)
๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
| ํญ๋ชฉ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) | ์ฐธ๊ณ ๋ฐ ๋น๊ณ |
|---|---|---|---|
| ์ด์์ฒด์ (OS) | macOS 12+ (Apple Silicon ๋๋ Intel), Windows 10/11 64-bit, Linux (Ubuntu 22.04+ AppImage) | macOS Sonoma 14+ / Windows 11 64-bit | Apple Silicon(M1/M2/M3/M4) ํตํฉ ๋ฉ๋ชจ๋ฆฌ ์ํคํ ์ฒ์ ์ต์ ํ |
| CPU | 4 ์ฝ์ด ์ด์ (AVX2 ๋ช ๋ น์ด ์ธํธ ํ์) | 8 ์ฝ์ด ~ 16 ์ฝ์ด ์ด์ (์ต์ Intel Core i7/i9 ๋๋ AMD Ryzen 7/9) | GPU ๋ฏธ์ง์ ์ CPU ์ถ๋ก ์ผ๋ก ์ ํ ๊ตฌ๋ |
| ๋ฉ๋ชจ๋ฆฌ (RAM) | 16 GB ์ด์ (DDR4) | 32 GB ~ 64 GB ์ด์ (DDR5 ๋๋ LPDDR5X) | 7B |
| GPU / VRAM | ๋ด์ฅ ๊ทธ๋ํฝ ๋๋ 6 GB VRAM (RTX 3060 ๋ฑ) | NVIDIA RTX 4070/4080/4090 (12GB~24GB VRAM) / Apple M2ยทM3 Max (36GB~128GB) | VRAM์ด ์ถฉ๋ถํ ์๋ก GPU ์์ ์คํ๋ก๋ฉ์ผ๋ก ๊ทน๋ํ๋ ์๋ ์ ๊ณต |
| ๋์คํฌ (Storage) | 30 GB ์ด์์ ์ฌ์ ๊ณต๊ฐ | 100 GB ~ 1 TB ์ด์์ NVMe SSD | ๋ชจ๋ธ๋น 4GB~40GB GGUF ํ์ผ ๋ณด๊ด |
| ๋คํธ์ํฌ / ๋ฐํ์ | ์ธํฐ๋ท ์ฐ๊ฒฐ (Hugging Face ๋ชจ๋ธ ํ๋ธ ๋ค์ด๋ก๋์ฉ) | lms CLI ๋๊ตฌ, Node.js 20+, Python 3.10+ | ๋ก์ปฌ ์๋ฒ ๊ธฐ๋ณธ ํฌํธ 1234 ๋ฐ์ธ๋ฉ (OpenAI ํธํ ๊ท๊ฒฉ) |
LM Studio๋ ๋ณต์กํ ํฐ๋ฏธ๋ ๋ช ๋ น์ด ์์ด๋ Hugging Face์ ์๋ง ๊ฐ ์คํ์์ค LLM(GGUF ํฌ๋งท)์ ๊ฒ์ํ์ฌ ํด๋ฆญ ํ ๋ฒ์ผ๋ก ๋ค์ด๋ก๋ํ๊ณ , ๊ฐ๋ ฅํ ์๊ฐ์ GUI ํ๊ฒฝ์์ ์ฑํ ํ๊ฑฐ๋ OpenAI ํธํ ๋ก์ปฌ ๊ฐ๋ฐ ์๋ฒ๋ฅผ ์ํด๋ฆญ์ผ๋ก ๊ตฌ๋ํ ์ ์๋ ์ต๊ณ ์ ๋ฐ์คํฌํฑ ๋๊ตฌ์ ๋๋ค.
๐ฅ 1. OS๋ณ LM Studio ์ค์น
- ๊ณต์ ์น์ฌ์ดํธ: lmstudio.ai ์ ์
- OS ์ ํ ๋ค์ด๋ก๋:
- Mac: Apple Silicon (M1/M2/M3/M4) ๋๋ Intel Mac ์ ํ
- Windows: Windows 10/11 ์ ์ฉ ์ธ์คํจ๋ฌ (
.exe) - Linux:
.AppImage์คํ ํ์ผ ๋ค์ด๋ก๋ ๋ฐ ์คํ ๊ถํ ๋ถ์ฌ:chmod +x LM_Studio-*.AppImage ./LM_Studio-*.AppImage
โก 2. lms ํฐ๋ฏธ๋ CLI ๋๊ตฌ ํ์ฑํ (์ ํ ์ฌํญ)
LM Studio ์ฑ ๋ด๋ถ์ [Settings] โ [Developer]์์ lms CLI๋ฅผ ์์คํ
๊ฒฝ๋ก(PATH)์ ๋ฑ๋กํ๋ฉด ํฐ๋ฏธ๋์์๋ ๋ชจ๋ธ์ ๋ก๋ํ๊ณ ์๋ฒ๋ฅผ ์ ์ดํ ์ ์์ต๋๋ค:
# macOS / Linux ํฐ๋ฏธ๋ ๋ฑ๋ก
lms bootstrap
# ์ค์น ๋ฐ ๋ฒ์ ํ์ธ
lms version
# ํฐ๋ฏธ๋์์ ์ฆ์ ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ธ ๋ชฉ๋ก ํ์ธ
lms ls
2. LM Studio ํต์ฌ ์ํคํ ์ฒ & ๋ฉํ ๋ชจ๋ธ (Mental Model)
LM Studio๋ ๋ชจ๋ธ ํ์๊ธฐ โ ์ถ๋ก ์์ง(llama.cpp) โ ๋ก์ปฌ API ์๋ฒ์ 3๋จ ํ์ดํ๋ผ์ธ์ผ๋ก ๊ตฌ์ฑ๋ฉ๋๋ค.
๐๏ธ LM Studio ๋์ ๊ตฌ์กฐ ๋ค์ด์ด๊ทธ๋จ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hugging Face Hub Integration (ํ์ & ๋ค์ด๋ก๋) โ
โ - ์ค์๊ฐ ๋ชจ๋ธ ๊ฒ์ (Llama 3, Mistral, Qwen, DeepSeek ๋ฑ) โ
โ - ์์ํ ๊ท๊ฒฉ ์ ํ (Q4_K_M, Q5_K_M, Q8_0, FP16) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GGUF ํ์ผ ์ ์ฅ (~/.cache/lm-studio/models)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Inference Configuration Engine โ
โ โโ GPU Offload Slider (CPU RAM โ GPU VRAM ๋ ์ด์ด ๋ถํ ๋ฐฐ๋ถ) โ
โ โโ Context Length (2048 ~ 128k ํ ํฐ ์ค์ ) โ
โ โโ Prompt Template (ChatML, Llama-3-Instruct, Mistral ์๋ ๊ฐ์ง) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Memory Allocation
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Output & Integration Endpoints โ
โ โโ Desktop Chat GUI (์ธํฐ๋ํฐ๋ธ ํ๋ผ๋ฏธํฐ ์ค์๊ฐ ์กฐ์ ) โ
โ โโ Local Inference Server (http://localhost:1234/v1) โ
โ โโ Cursor / Continue IDE ์ฐ๋ (๋ก์ปฌ ์ฝ๋ฉ ์๋์์ฑ) โ
โ โโ Python / Next.js / LangChain ์ ํ๋ฆฌ์ผ์ด์
์ฐ๊ฒฐ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
3. [์ด๋ณด์ 1๋จ๊ณ] GUI ๋ชจ๋ธ ๋ค์ด๋ก๋ & ์ฒซ ๋ํ (Getting Started)
๐ฑ๏ธ 1. ๋ชจ๋ธ ๊ฒ์ ๋ฐ ๋ค์ด๋ก๋
- ์ข์ธก ๋๋ณด๊ธฐ ์์ด์ฝ(Search)์ ํด๋ฆญํฉ๋๋ค.
- ๊ฒ์์ฐฝ์
Llama-3.2-3B-Instruct๋๋Qwen2.5-Coder-7B๋ฅผ ์ ๋ ฅํฉ๋๋ค. - ์ฐ์ธก ๊ฒฐ๊ณผ ์ฐฝ์์ ์ ๋ขฐํ ์ ์๋ ํผ๋ธ๋ฆฌ์
(์:
bartowski,TheBloke)์ ๋ชจ๋ธ์ ์ ํํฉ๋๋ค. - ์์ํ ์ต์
์ ํ ๊ฐ์ด๋:
Q4_K_M(์ถ์ฒ / ๊ท ํ): ๋๋ถ๋ถ์ ์ฌ์ฉ์์๊ฒ ๊ฐ์ฅ ๊ถ์ฅ๋๋ ํฌ๊ธฐ ๋๋น ํ์ง ์ต์ ํ ์ต์ Q5_K_M(๊ณ ํ์ง): VRAM ์ฌ์ ๊ฐ ์์ ๋ ํ์ง ์์ค์ด ๊ฑฐ์ ์๋ ์ต์ Q8_0(์ต๊ณ ํ์ง): ์์ํ ์์ค์ด ๊ทน๋๋ก ์ ์ผ๋ VRAM ์ฉ๋์ ๋ง์ด ์ฐจ์งํจ
- [Download] ๋ฒํผ์ ํด๋ฆญํ์ฌ ๋ชจ๋ธ์ ์ ์ฅํฉ๋๋ค.
๐ฌ 2. ๋ํ ์ธ์ ์์
- ์ข์ธก ๋งํ์ ์์ด์ฝ(Chat)์ ํด๋ฆญํฉ๋๋ค.
- ์๋จ ๋๋กญ๋ค์ด์์ ๋ฐฉ๊ธ ๋ค์ด๋ก๋ํ ๋ชจ๋ธ์ ์ ํํ์ฌ ๋ก๋ํฉ๋๋ค.
- ํ๋จ ํ๋กฌํํธ์ ๋ฉ์์ง๋ฅผ ์ ๋ ฅํ๊ณ ์๋ต์ ํ์ธํฉ๋๋ค.
4. [2๋จ๊ณ] ํ๋์จ์ด ๊ฐ์ & ํ๋กฌํํธ ํ๋ (GPU Offloading)
๐๏ธ 1. GPU ๋ ์ด์ด ์คํ๋ก๋ฉ (GPU Acceleration)
๋ชจ๋ธ์ CPU ๋์ ๊ทธ๋ํฝ ์นด๋(VRAM)์์ ๋น ๋ฅด๊ฒ ์ฐ์ฐํ๋๋ก ์ค์ ํฉ๋๋ค:
- ์ฐ์ธก ์ฌ์ด๋๋ฐ ์ค์ ํจ๋(Inference Parameters)์ ์ฝ๋๋ค.
- GPU Offload ์น์
์ ํ์ธํฉ๋๋ค:
- Apple Silicon (Mac): ๊ธฐ๋ณธ์ ์ผ๋ก ํตํฉ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ฏ๋ก
Max๋ก ์ค์ - NVIDIA GPU (Windows/Linux): ์ฌ๋ผ์ด๋๋ฅผ ์ฌ๋ ค
GPU Layers๋ฅผ ์ต๋๋ก ์ค์ (์: 32/32 ๋ ์ด์ด) - ๋ง์ฝ VRAM์ด ๋ถ์กฑํ๋ค๋ฉด(์: 8GB VRAM์ 14B ๋ชจ๋ธ ๋ก๋ ์), ์ฌ๋ผ์ด๋๋ฅผ ์กฐ์ ํ์ฌ ๋ ์ด์ด์ ์ผ๋ถ(์: 20 ๋ ์ด์ด)๋ง GPU๋ก ๋ณด๋ด๊ณ ๋๋จธ์ง๋ ์์คํ RAM(CPU)์ผ๋ก ๋ถํ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
- Apple Silicon (Mac): ๊ธฐ๋ณธ์ ์ผ๋ก ํตํฉ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ฏ๋ก
๐๏ธ 2. ํต์ฌ ์ถ๋ก ํ๋ผ๋ฏธํฐ ํ๋
| ํ๋ผ๋ฏธํฐ | ๊ธฐ๋ณธ๊ฐ | ์ถ์ฒ ์ค์ | ์ค๋ช |
|---|---|---|---|
| Temperature | 0.7 | 0.2 (์ฝ๋ฉ/๋ถ์) / 0.8 (์ฐฝ์) | ๋ฎ์์๋ก ์ผ๊ด๋๊ณ ๊ฒฐ์ ์ ์ธ ๋ต๋ณ, ๋์์๋ก ์ฐฝ์์ ์ธ ์์ฑ |
| Context Length | 4096 | 8192 ~ 32768 | ๋ํ ๊ธฐ์ต ๋ฐ ๋ฌธ์ ์ฐธ์กฐ ํ ํฐ ํ๋ (ํฌ๊ธฐ๋ฅผ ๋๋ฆด์๋ก RAM/VRAM ์๋ชจ ์ฆ๊ฐ) |
| Top P | 0.95 | 0.9 | ํ๋ฅ ์์ P% ํ ํฐ ์งํฉ ๋ด์์๋ง ๋จ์ด ์ํ๋ง |
| Repeat Penalty | 1.1 | 1.15 | ๋์ผ ๋ฌธ์ฅ์ด๋ ํํ์ด ๋ฌดํ ๋ฐ๋ณต๋๋ ๋ฃจํ ๋ฐฉ์ง |
5. [3๋จ๊ณ] ๋ก์ปฌ API ์๋ฒ & ์ธ๋ถ ๋๊ตฌ ์ฐ๋ (Local Server & IDE)
LM Studio์ ๊ฐ์ฅ ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ ์ํด๋ฆญ ๋ก์ปฌ OpenAI ํธํ ์๋ฒ์ ๋๋ค.
๐ 1. ๋ก์ปฌ ์ถ๋ก ์๋ฒ ์์ํ๊ธฐ
- ์ข์ธก ์๋ฐฉํฅ ํ์ดํ ์์ด์ฝ(Local Server)์ ํด๋ฆญํฉ๋๋ค.
- ์๋จ์์ ๋ก๋ํ ๋ชจ๋ธ์ ์ ํํฉ๋๋ค.
- [Start Server] ๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
- ์๋ฒ๊ฐ
http://localhost:1234ํฌํธ์์ ์คํ๋ฉ๋๋ค.
๐ป 2. cURL๋ก ๋ก์ปฌ ์๋ฒ ํธ์ถ ํ ์คํธ
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "system", "content": "You are a professional software architect." },
{ "role": "user", "content": "Microservices vs Monolith trade-offs in 3 bullet points." }
],
"temperature": 0.3,
"max_tokens": 500
}'
๐ 3. OpenAI Python SDK ์ฐ๋
๊ธฐ์กด์ openai ํ์ด์ฌ ํจํค์ง๋ฅผ ์ฝ๋ ๋ณ๊ฒฝ ์์ด ๊ทธ๋๋ก ๋ก์ปฌ LM Studio๋ก ์ฐ๊ฒฐํ ์ ์์ต๋๋ค:
from openai import OpenAI
# 1. LM Studio ๋ก์ปฌ ์๋ฒ ์ฃผ์๋ก ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
client = OpenAI(
base_url="http://localhost:1234/v1",
api_key="lm-studio" # ๋ก์ปฌ ์๋ฒ์ด๋ฏ๋ก ์์์ ๋ฌธ์์ด ์ ๋ฌ
)
# 2. ์ฑํ
์์ฑ ์์ฒญ
response = client.chat.completions.create(
model="local-model", # ํ์ฌ LM Studio์ ๋ก๋๋ ๋ชจ๋ธ ์๋ ์ฌ์ฉ
messages=[
{"role": "system", "content": "๋น์ ์ ํด๋ฆฐ ์ฝ๋ ์ ๋ฌธ๊ฐ์
๋๋ค."},
{"role": "user", "content": "TypeScript์์ ๋ถ๋ณ์ฑ์ ๋ณด์ฅํ๋ ๋ฐฉ๋ฒ 2๊ฐ์ง๋ฅผ ์ฝ๋๋ก ๋ณด์ฌ์ค."}
],
temperature=0.2,
)
print(response.choices[0].message.content)
๐ป 4. Cursor / VSCode Continue ๋ก์ปฌ AI ์ฝ๋ฉ ์ฐ๋
LM Studio๋ฅผ ์ฌ์ฉํ๋ฉด ์ธํฐ๋ท ์ฐ๊ฒฐ ์์ด๋ IDE์์ ๋ฌด๋ฃ๋ก ๋ฌด์ ํ ์ฝ๋ ์๋์์ฑ ๋ฐ ์ฝ๋ ๋ฆฌ๋ทฐ๋ฅผ ์ํํ ์ ์์ต๋๋ค:
Continue (~/.continue/config.json) ์ค์
{
"models": [
{
"title": "LM Studio Local Coder",
"provider": "openai",
"model": "qwen2.5-coder-7b",
"apiBase": "http://localhost:1234/v1",
"apiKey": "lm-studio"
}
]
}
๐ฅ๏ธ 5. lms ํฐ๋ฏธ๋ CLI ํ์ ์ ์ ๋ช
๋ น์ด
ํฐ๋ฏธ๋์์ ์ง์ ๋ชจ๋ธ์ ๋ก๋ํ๊ณ ์๋ฒ๋ฅผ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์ ์ดํฉ๋๋ค:
# 1. ํน์ ๋ชจ๋ธ์ VRAM์ผ๋ก ์ฆ์ ๋ก๋ (GPU 100% ์คํ๋ก๋)
lms load llama-3.2-3b-instruct --gpu=max
# 2. ๋ฐฑ๊ทธ๋ผ์ด๋ ๋ก์ปฌ API ์๋ฒ ์์
lms server start --port 1234
# 3. ๋ก์ปฌ ์๋ฒ ์ํ ๋ฐ ํ์ฑ ๋ชจ๋ธ ํ์ธ
lms status
# 4. ๋ชจ๋ธ ์ธ๋ก๋ ๋ฐ ์๋ฒ ์ค์ง
lms unload
lms server stop
6. ํธ๋ฌ๋ธ์ํ & ํ๋ก๋์ ์ด์ ์ฒดํฌ๋ฆฌ์คํธ
โ ๏ธ ์์ฃผ ๋ฐ์ํ๋ ๋ฌธ์ & ํด๊ฒฐ์ฑ
- ์๋ฒ ํธ์ถ ์
CORS Error๋ฐ์:- ์น ํ๋ก ํธ์๋(React/Vue)์์ ๋ก์ปฌ ์๋ฒ๋ฅผ ํธ์ถํ ๋ ๋ฐ์ํฉ๋๋ค. LM Studio [Local Server] ํญ์ [CORS] ํ ๊ธ ์ค์์น๋ฅผ
ON์ผ๋ก ํ์ฑํํ์ธ์.
- ์น ํ๋ก ํธ์๋(React/Vue)์์ ๋ก์ปฌ ์๋ฒ๋ฅผ ํธ์ถํ ๋ ๋ฐ์ํฉ๋๋ค. LM Studio [Local Server] ํญ์ [CORS] ํ ๊ธ ์ค์์น๋ฅผ
- ๋ชจ๋ธ ๋ก๋ ์ ์ฑ์ด ๊ฐ์ ์ข
๋ฃ๋๊ฑฐ๋ ๋ฉ์ถค:
- ์์คํ
RAM/VRAM ์ฉ๋๋ณด๋ค ํฐ ๋ชจ๋ธ์ ๋ก๋ํ์ฌ OOM์ด ๋ฐ์ํ ๊ฒฝ์ฐ์
๋๋ค. ํ๋ผ๋ฏธํฐ๊ฐ ๋ ์๊ฑฐ๋ ์์ํ ๋ ๋ฒจ์ด ๋ฎ์ ๋ชจ๋ธ(
Q4_K_M)์ ์ ํํ๊ณ ,Context Length๋ฅผ 2048 ๋๋ 4096์ผ๋ก ๋ฎ์ถ์ธ์.
- ์์คํ
RAM/VRAM ์ฉ๋๋ณด๋ค ํฐ ๋ชจ๋ธ์ ๋ก๋ํ์ฌ OOM์ด ๋ฐ์ํ ๊ฒฝ์ฐ์
๋๋ค. ํ๋ผ๋ฏธํฐ๊ฐ ๋ ์๊ฑฐ๋ ์์ํ ๋ ๋ฒจ์ด ๋ฎ์ ๋ชจ๋ธ(
- ์ถ๋ ฅ ๊ฒฐ๊ณผ์์
<|im_start|>๊ฐ์ ํน์ ํ ํฐ์ด ๊ทธ๋๋ก ๋ ธ์ถ๋ ๋:- ๋ชจ๋ธ์ Chat Template ํ์์ด ์ด๊ธ๋ ๊ฒฝ์ฐ์
๋๋ค. ์ฐ์ธก ์ค์ ์ Prompt Template ๋๋กญ๋ค์ด์์ ๋ชจ๋ธ ๊ท๊ฒฉ์ ๋ง๋ ํ
ํ๋ฆฟ(์:
ChatML,Llama 3,Mistral)์ ์๋ ์ ํํ์ธ์.
- ๋ชจ๋ธ์ Chat Template ํ์์ด ์ด๊ธ๋ ๊ฒฝ์ฐ์
๋๋ค. ์ฐ์ธก ์ค์ ์ Prompt Template ๋๋กญ๋ค์ด์์ ๋ชจ๋ธ ๊ท๊ฒฉ์ ๋ง๋ ํ
ํ๋ฆฟ(์:
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์