Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
vSphere環境でLLMをServeする
Search
masanara
December 20, 2023
Technology
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
vSphere環境でLLMをServeする
masanara
December 20, 2023
More Decks by masanara
See All by masanara
Cartographer入門
masanara
0
530
EKS Anywhere on vSphere
masanara
0
56
kpackによるコンテナイメージのビルド
masanara
0
130
Harbor RegistryのReplication機能
masanara
0
440
Kubernetes Operator for vSphere VM
masanara
0
67
Other Decks in Technology
See All in Technology
Hub & Spoke 環境のネットワークルーティングを分解してみる
tsuyataku
1
520
PM領域でのAI Agentの活用
lycorptech_jp
PRO
0
270
V8コントリビュート超入門
riyaamemiya
0
130
Azure Cost Management の FOCUS コストデータを迷わず読むための“3つの軸”
tetsuyaooooo
0
140
Tab5をRubyで動くパソコンにする
kishima
1
170
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
220
Bet AI Day 2026丨バクラク Autopilot、業務システムの再設計
layerx
PRO
2
1.1k
Jetpack Compose で挑む新聞紙面UI ─ 複合ジェスチャー・ポリゴン記事領域・適応的ページ構成という3つの壁/droidkaigi2026
nikkei_engineer_recruiting
0
190
Bet AI Day 2026丨Agentは、「金融」という巨大産業の何を変えられるのか
layerx
PRO
0
720
AIエージェントを雇う前に決める5つのこと
knishioka
1
150
設計の世代交代を乗り越える、14年続くAndroidアプリの開発戦略
sansantech
PRO
1
120
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
250
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
New Earth Scene 8
popppiees
3
2.5k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
Design in an AI World
tapps
1
300
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
520
Un-Boring Meetings
codingconduct
0
410
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Crafting Experiences
bethany
1
280
The browser strikes back
jonoalderson
0
1.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Transcript
vSphere 環境で日本語対応 LLM を利用する Japan VMUG vExpert が語る #32 2023/12/20
本日の内容 VMware Private AI Reference Architecture for Open Sourceを参考に、vSphere環境 で日本語に対応したLLMを利用してみました。
• VMware Private AI Reference Architecture for Open Source https://github.com/vmware-ai-labs/VMware-generative-ai-reference-architecture • Ray Serveを利用した日本語LLM ELYZAの利用 - VMware Private AI https://www.netone.co.jp/media/detail/20231201-1/
VMware Private AI データのプライバシーと管理を可能にし、オープンソースや商用の様々な AIソリューションを環境に合わせて柔 軟に組み合わせて利用し、企業における AIの導入を促進するアーキテクチャ。 • VMware Private
AI Reference Architecture for Open Source • VMware Private AI Foundation with NVIDIA (2024年 提供予定)
ELYZA 株式会社ELYZA社が開発。Metaの「Llama2」をベースに、日本語による追加事前学習 を行なった日本語言語モデル。ELYZA独自の事後学習、日本語の語彙追加により高速 化。Hugging Face上でモデルが公開されている。 https://huggingface.co/elyza/ https://elyza.ai
vSphere環境でLLMを使うステップ 1. vSphereクラスターの作成 2. Supervisor Clusterの有効化 3. Tanzu Kubernetes Clusterの作成
4. GPU Operatorの有効化 5. Ray Operatorの有効化 6. Ray Serveリソースの作成 7. Web UIの作成 (オプション) 今日話す内容
GPU Operator Kubernetesクラスターを構成するノードにGPUのドライバーをインストールする仕組み。 NFD(Node Feature Discovery) Podにより、GPUが搭載されたノードを認識。GPU搭載ノードにだけPodとして ドライバーがインストールされる。 ESXiのGPUをvGPUとしてVMに接続し、Kubernetesノードとして 利用可能。
Kubernetes vSphere Node (VM) vGPU Physical Server GPU Node (VM) vGPU Node (VM) GPU Driver nvidia.com/gpu: 1 NFD GPU Driver NFD NFD
Ray PythonやJavaにおける分散並列処理を高速に実行するためのフレームワークや処理 基盤を提供するオープンソースソフトウェア。Ray ServeはPythonを利用してMLモデル を簡単・スケーラブルにデプロイすることができるモデルサービング機能を提供。 https://www.ray.io/
KubeRay Operator RayをKubernetes上で利用するためのOperator。RayのHead NodeとWorker Nodeを Kubernetes上でPodとして起動。 • Cluster : クラスタの作成/削除、オートスケールなど、
RayClusterのライフサイクルを管理。 • Job : RayClusterを作成してJobを送信。Jobが終了すると自動的に RayClusterを削除可能。 • Service : RayClusterとRay Serveの2つのパートで構成される。 RayClusterのダウンタイムなしのアップ グレードと高可用性を提供。 $ helm repo add kuberay https://ray-project.github.io/kuberay-helm/ $ helm install kuberay-operator kuberay/kuberay-operator --version 0.6.0 $ kubectl get crd | grep ray.io rayclusters.ray.io 2023-12-09T11:33:47Z rayjobs.ray.io 2023-12-09T11:33:47Z rayservices.ray.io 2023-12-09T11:33:47Z
Ray Serveリソース apiVersion: ray.io/v1alpha1 kind: RayService metadata: name: vllm spec:
serveConfigV2: | applications: - name: vllm import_path: Examples.LLM-serving-wt-vLLM-and-RayServe-example.vllm_falcon_7b:deployment runtime_env: working_dir: "https://github.com/vmware-ai-labs/VMware-generative-ai-reference-architecture/archive/refs/heads/main.zip" pip: ["vllm==0.1.3"] workerGroupSpecs: - replicas: 1 minReplicas: 1 maxReplicas: 4 groupName: gpu-group template: spec: containers: - name: ray-worker image: rayproject/ray:2.6.2-py310-cu118 resources: limits: cpu: 32 memory: "64G" nvidia.com/gpu: 1 requests: cpu: 16 memory: "32G" nvidia.com/gpu: 1 rayClusterConfig: rayVersion: '2.6.2' headGroupSpec: serviceType: LoadBalancer rayStartParams: dashboard-host: '0.0.0.0' template: spec: containers: - name: ray-head image: rayproject/ray:2.6.2-py310-cu118 resources: limits: cpu: 32 memory: "64G" requests: cpu: 16 memory: "32G" https://github.com/vmware-ai-labs/VMware-generative-ai-reference-architecture/blob/main/Examples/LLM-serving-wt-vLLM-and-RayServe-example/ray-service.vllm.yaml Ray Cluster上で実行する Pythonアプリケーションを指定する
vLLM vLLM はHugging Face Transformersに対応したさまざまなTransformerモデルをサ ポート。PythonでRay Serveにデプロイするモデルを指定することで、Hugging Face上 のモデルを利用可能。 https://vllm.ai/
リファレンスアーキテクチャではTechnology Innovation Instituteが開発したFalcon-7B (tiiuae/falcon-7b-instruct)が利用されてい るため、ELYZA-japanese-Llama-2-7b (elyza/ELYZA-japanese-Llama-2-7b-fast-instruct)を利用するよう変更。 https://github.com/vmware-ai-labs/VMware-generative-ai-reference-architecture/blob/main/Examples/LLM-serving-wt-vLLM-and-RayServe-example/vllm_falcon_7b.py deployment = VLLMPredictDeployment.bind(model="tiiuae/falcon-7b-instruct", dtype="bfloat16", trust_remote_code=True, ) deployment = VLLMPredictDeployment.bind(model="elyza/ELYZA-japanese-Llama-2-7b-fast-instruct", dtype="bfloat16", trust_remote_code=True, )
Gradio 機械学習モデルを操作するWeb UIを作成するためのPythonライブラリ。シンプルにUI を実装可能。 https://www.gradio.app/ def build_demo(): with gr.Blocks() as
demo: gr.Markdown("# vLLM on Ray Serve: Prompt Completion Demo\n") inputbox = gr.Textbox(label="Input", placeholder="Enter your prompt and press ENTER") outputbox = gr.Textbox(label="Output", placeholder="Prompt completion from the model") inputbox.submit(http_bot, [inputbox], [outputbox]) return demo https://github.com/vmware-ai-labs/VMware-generative-ai-reference-architecture/blob/main/Examples/LLM-serving-wt-vLLM-and-RayServe-example/gradio_webserver.py
システムプロンプトの利用 システムプロンプトを利用して期待通りの回答を得る。 def http_bot(prompt, system_prompt): headers = {"User-Agent": "vLLM Client"}
system_prompt = "あなたは誠実で優秀な日本人のアシスタントです。 " prompt = "<s>[INST]<<SYS>>\n"+system_prompt+"\n<</SYS>>\n\n"+prompt+"[/INST]\n" pload = { "prompt": prompt, "stream": False, "max_tokens": 200, "temperature": 0, "n": 1, "stop": ">", # Stop generation character } response = requests.post(model_url, headers=headers, json=pload, stream=True) for chunk in response.iter_lines(chunk_size=8192, decode_unicode=False, delimiter=b"\0"): if chunk: data = json.loads(chunk.decode("utf-8")) output = data["text"][0] #yield output o = re.sub("<s>\[INST\]<<SYS\>>.*?\[/INST\]\n",'',output, flags=re.DOTALL) #print(o) yield o https://huggingface.co/elyza/ELYZA-japanese-Llama-2-7b-fast-instruct
ありがとうございました