ホームページ >テクノロジー周辺機器 >AI >DataBricksにDeepSeek R1を展開:ステップバイステップガイド

DataBricksにDeepSeek R1を展開:ステップバイステップガイド

Jennifer Aniston
Jennifer Anistonオリジナル
2025-02-28 16:33:10837ブラウズ

DataBricksにDeepSeek R1モデルを展開する:ステップバイステップガイド

人気のあるデータエンジニアリングプラットフォームである

Databricksは、AIおよび機械学習タスクにますます使用されています。 このチュートリアルは、Databricksに分散したDeepSeek R1モデルを展開することをガイドします。 これにより、データが外部サーバーに送信されなくなります。 DeepSeek R1の機能と比較に深く掘り下げるには、DeepSeek-R1:機能、比較、蒸留モデルなどのブログを参照してください。 このガイドは、アカウントのセットアップ、UIを使用したモデル登録、および遊び場およびローカルカールコマンドを介したアクセスをカバーしています。 Databricksは初めてですか? DataBricksコースの紹介は、Databricks Lakehouseプラットフォームとそのデータ管理機能の包括的な概要を提供します。 Databricks内のデータ管理をより深く理解するには、DataBricksコースのデータ管理を検討してください。

deepseek R1モデルの登録

ノートブックを起動する:
    DataBricksワークスペースを作成したら、「新しい」をクリックしてノートを選択します。

Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide パッケージのインストール:

必要なpythonライブラリ:
    をインストールします
モデルとトークン剤の負荷:
<code class="language-python">%%capture
!pip install torch transformers mlflow accelerate torchvision
%restart_python</code>
hugging hugging faceのdeepseek r1モデルとトークネイザーをロード:
<code class="language-python">import pandas as pd
import mlflow
import mlflow.transformers
import torch
from mlflow.models.signature import infer_signature
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig, pipeline

model_name = "deepseek-ai/DeepSeek-R1-Distill-Llama-8B"
tokenizer = AutoTokenizer.from_pretrained(model_name)
config = AutoConfig.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, config=config, torch_dtype=torch.float16)</code>

Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide モデルのテスト:

サンプルプロンプトでテストし、モデル登録の署名を生成します:
  1. 予想出力(わずかに変化する可能性があります):
<code class="language-python">text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
example_prompt = "How does a computer work?"
example_inputs = pd.DataFrame({"inputs": [example_prompt]})
example_outputs = text_generator(example_prompt, max_length=200)
signature = infer_signature(example_inputs, example_outputs)
print(example_outputs)</code>

コンドラ環境:
<code>[{'generated_text': "How does a computer work? What is the computer? What is the computer used for? What is the computer used for in real life?\n\nI need to answer this question, but I need to do it step by step. I need to start with the very basic level and build up from there. I need to make sure I understand each concept before moving on. I need to use a lot of examples to explain each idea. I need to write my thoughts as if I'm explaining them to someone else, but I need to make sure I understand how to structure the answer properly.\n\nOkay, let's start with the basic level. What is a computer? It's an electronic device, right? And it has a central processing unit (CPU) that does the processing. But I think the central processing unit is more efficient, so maybe it's the CPU. Then, it has memory and storage. I remember that memory is like RAM and storage is like ROM. But wait, I think"}]</code>
コンドマ環境を定義します:
モデルを登録します:
<code class="language-python">conda_env = {
    "name": "mlflow-env",
    "channels": ["defaults", "conda-forge"],
    "dependencies": [
        "python=3.11",
        "pip",
        {"pip": ["mlflow", "transformers", "accelerate", "torch", "torchvision"]}
    ]
}</code>
  1. を使用してモデルを登録します mlflow.transformers.log_model
<code class="language-python">with mlflow.start_run() as run:
    mlflow.transformers.log_model(
        transformers_model=text_generator,
        artifact_path="deepseek_model",
        signature=signature,
        input_example=example_inputs,
        registered_model_name="deepseek_r1_llama_8b",
        conda_env=conda_env
    )</code>

deepseek r1 Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide

の展開

モデルへのナビゲート:
    databricksダッシュボードで、[モデル]タブに移動します。
  1. モデルを提供します:

    モデルを選択し、「このモデルの提供」をクリックします。
    1. エンドポイントの構成:エンドポイントに名前を付け、コンピューティングオプションを選択し、並行性を設定し、「作成」をクリックします。

    Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide

    Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide

    カスタムデータセットでの微調整については、微調整DeepSeek R1チュートリアルを参照してください。

    展開されたモデルへのアクセス

      Databricks Playground:

Deploying DeepSeek R1 on Databricks: A Step-by-Step Guide curlコマンド:

DataBricks APIキー(Settings&GT; Developer)を生成し、環境変数として設定し、Curlを使用します。
  1. $DATABRICKS_TOKEN
<code class="language-python">%%capture
!pip install torch transformers mlflow accelerate torchvision
%restart_python</code>

Deepseek R1対V3の詳細については、Deepseek R1対V3ブログを参照してください。 LLMSは初めてですか? PythonコースのLLMSの紹介は、素晴らしい出発点です。 CPUの展開は可能ですが、それは遅くなるかもしれません。

以上がDataBricksにDeepSeek R1を展開:ステップバイステップガイドの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。