サイトのデザインが新しくなりました。

【DeepSeek-V2】Llama3を完全に超えた?コスパ最強オープンソースLLM

DeepSeek-V2 Llama3 超えた コスパ 最強 オープンソースLLM

WEELメディア事業部LLMライターのゆうやです。

20204年5月6日、中国のAI企業であるDeepSeekから超コスパ最強LLM「DeepSeek-V2」が公開されました。

このモデルは、MoE(Mixture-of-Experts)アーキテクチャを採用し、合計230Bものパラメータを持ちながらも、推論時は21B程度しか使用しないため、推論時の計算コストを大幅に削減しています。

また、性能面についても多くのベンチマークでGPT-4と同等のスコアを記録しており、オープンソースモデルの中では最高クラスの性能を有しています。

それほどの性能を有していながらAPI料金が激安で、100万トークンあたり、入力が0.14ドル、出力が0.28ドルとなっており、これはGPT-4-turboのなんと1/107ほどの料金です。

今回は、DeepSeek-V2の概要や使ってみた感想をお伝えします。

是非最後までご覧ください!

なお弊社では、生成AIツール開発についての無料相談を承っています。こちらからお気軽にご相談ください。

目次

DeepSeek-V2の概要

DeepSeek-V2は、中国のAI企業であるDeepSeekが公開した最新のオープンソースLLMです。

このモデルは、昨今トレンドとなっているMoE(Mixture-of-Experts)アーキテクチャを採用しており、合計230Bものパラメータを持っています。

しかし、実際の推論時に使用するのはそのうちの約1割ほどの21Bなので、大規模なパラメータを維持しながら計算コストを大幅に低減しています。

MoEアーキテクチャを採用した結果、DeepSeek 67Bと比較してより強力な性能を獲得しただけでなく、トレーニング コストが42.5%節約され、KVキャッシュを93.3%削減し、最大生成スループットを5.76 倍に高められました。

引用元:https://huggingface.co/deepseek-ai/DeepSeek-V2-Chat

特にKVキャッシュが顕著に削減されていますが、これはMLA(Multi-head Latent Attention)というアテンションを採用したことによる効果です。

続いてDeepSeek-V2の性能について紹介します。

DeepSeek-V2は、非常に高い性能を有しており、中国語での言語能力を測るベンチマークであるAlignBenchでは、GPT-4 Turbo、GPT-4に次ぐスコアを獲得しています。

また、MT-BenchでもGPT-4 Turbo、Claude 3 Opusに次ぐスコアを獲得しており、GPT-4とほぼ同等です。

引用元:https://huggingface.co/deepseek-ai/DeepSeek-V2-Chat

DeepSeek-V2は「数学」、「コード」、「推論」を専門にしているとされており、実際にそれらのベンチマークスコアについても高スコアを獲得しています。

このように非常に高い性能を有しているDeepSeek-V2ですが、コストパフォーマンスの面でも他のモデルとの差別化を図っています。

以下の画像は、DeepSeek-V2およびその他のモデルの100万トークン当たりのAPI利用料金表ですが、他のクローズドモデルやオープンソースモデルと比較して、DeepSeek-V2の料金が極めて安いことが分かります。

引用元:https://twitter.com/deepseek_ai/status/1787478994478321872

Outputに関しては、GPT-4-Turbo-1106の1/107、Llama 3 70Bの1/40であり、高いコストパフォーマンスで話題になったClaude 3 Haikuの4.5倍ほども料金が安く設定されています。

正直異常なほど安く、実際の性能がベンチマーク通りなら今後のすべてのモデルのAPI価格設定に影響を与えることになりそうです。

さて、ここからはDeepSeek-V2の使い方を解説し、実際に使ってみようと思います。

なお、GPT-4 Turboついて知りたい方はこちらの記事をご覧ください。

DeepSeek-V2のライセンス

DeepSeek-V2はMITライセンスのもとで提供されており、無料で商用利用することも可能です。

利用用途可否
商用利用⭕️
改変⭕️
配布⭕️
特許使用
私的使用⭕️
参考:https://huggingface.co/deepseek-ai/DeepSeek-V2-Chat#8-license

DeepSeek-V2の使い方

DeepSeek-V2は、こちらのリンクからDeepSeekの公式Webサイトにアクセスして試すことができます。

DeepSeek-V2-Chat

また、DeepSeekプラットフォームでOpenAI互換APIも提供されています。

DeepSeekプラットフォーム

DeepSeek-V2は、モデルをダウンロードしてローカルに実装することもできるので、その方法も紹介します。

まず以下のコードを実行してモデルをダウンロードします。

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig

model_name = "deepseek-ai/DeepSeek-V2-Chat"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
<em># `max_memory` should be set based on your devices</em>
max_memory = {i: "75GB" for i in range(8)}
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, device_map="auto", torch_dtype=torch.bfloat16, max_memory=max_memory)
model.generation_config = GenerationConfig.from_pretrained(model_name)
model.generation_config.pad_token_id = model.generation_config.eos_token_id

次に、以下のコードで推論を実行します。

messages = [
    {"role": "user", "content": "Write a piece of quicksort code in C++"}
]
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)

result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
print(result)

こちらはTransformersを使用した一般的な実装方法ですが、公式からはvLLMを使用した実装が推奨されています。

vLLMを使用した方法も、まずは以下のコードでモデルをダウンロードし、

from transformers import AutoTokenizer
from vllm import LLM, SamplingParams

max_model_len, tp_size = 8192, 8
model_name = "deepseek-ai/DeepSeek-V2-Chat"
tokenizer = AutoTokenizer.from_pretrained(model_name)
llm = LLM(model=model_name, tensor_parallel_size=tp_size, max_model_len=max_model_len, trust_remote_code=True, enforce_eager=True)
sampling_params = SamplingParams(temperature=0.3, max_tokens=256, stop_token_ids=[tokenizer.eos_token_id])

以下のコードで推論を実行します。

messages_list = [
    [{"role": "user", "content": "Who are you?"}],
    [{"role": "user", "content": "Translate the following content into Chinese directly: DeepSeek-V2 adopts innovative architectures to guarantee economical training and efficient inference."}],
    [{"role": "user", "content": "Write a piece of quicksort code in C++."}],
]

prompt_token_ids = [tokenizer.apply_chat_template(messages, add_generation_prompt=True) for messages in messages_list]

outputs = llm.generate(prompt_token_ids=prompt_token_ids, sampling_params=sampling_params)

generated_text = [output.outputs[0].text for output in outputs]
print(generated_text)

これでローカルへの実装は完了です。

DeepSeek-V2の実行に必要なスペック

DeepSeek-V2は、MoEアーキテクチャを採用して計算量を抑えているとはいえ、BF16形式のDeepSeek-V2の推論には、80GBのVRAMを持つGPUが8台必要なようです。

量子化モデルであればもう少し要件が低くなりますが、それでもかなりのリソースを必要とすると思います。

DeepSeek-V2を実際に使ってみた

今回は、DeppSeekのサイトで使っていきます。

以下のプロンプトを入力してみましょう。

Write the code for regression analysis.

回帰分析のコードを書いて

結果はこのようになりました。

Sure, here is a simple example of a linear regression analysis using Python's `scikit-learn` library:

```python
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import numpy as np

# Assume we have a dataset with two columns: 'feature' and 'target'
# Load your data
# data = ...

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(data['feature'], data['target'], test_size=0.2, random_state=42)

# Create a linear regression model
model = LinearRegression()

# Train the model
model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)

# Evaluate the model
mse = mean_squared_error(y_test, predictions)
print(f'Mean Squared Error: {mse}')
```

This is a very basic example. In a real-world scenario, you would need to preprocess your data, handle missing values, possibly perform feature engineering, and tune your model. Also, this is a simple linear regression model. Depending on your data, you might need to use a different type of regression model, such as polynomial regression, ridge regression, lasso regression, etc.

Pythonの scikit-learn ライブラリを使った線形回帰分析の簡単な例を示します:

from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import numpy as np

# Assume we have a dataset with two columns: 'feature' and 'target'
# Load your data
# data = ...

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(data['feature'], data['target'], test_size=0.2, random_state=42)

# Create a linear regression model
model = LinearRegression()

# Train the model
model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)

# Evaluate the model
mse = mean_squared_error(y_test, predictions)
print(f'Mean Squared Error: {mse}')

これは非常に基本的な例です。実際のシナリオでは、データを前処理し、欠損値を処理し、特徴工学を実行し、モデルをチューニングする必要があるでしょう。また、これは単純な線形回帰モデルです。データによっては、多項回帰、リッジ回帰、ラッソー回帰など、異なるタイプの回帰モデルを使用する必要があるかもしれません。

生成されたコードは、ほとんど正しいですがいくつか修正が必要な点があり、そのままでは想定している結果は得られないものでした。

ここからは、Llama 3 70BとGPT-4 Turboと比較しながらさらにDeepSeek-V2の能力に迫っていきます。

DeepSeek-V2をLlama 3 70BとGPT-4 Turboと比較してみた

ここでは、DeepSeek-V2を数学、コーディング、言語能力(日本語)の3つの項目でLlama 3 70BとGPT-4 Turboとの比較を行います。

具体的な項目は以下の3つです。

  • コーディング(ピンポンゲーム)
  • 東京大学の理系数学入試問題
  • 企業戦略の提案(日本語)

早速行っていきましょう!

コーディング(ピンポンゲーム)

まずはコーディング能力を比較するため、簡単なピンポンゲームを作成してもらいます。

以下のプロンプトを入力します。

Create a ping pong game

ピンポンゲームを作成して

結果はこのようになりました。

DeepSeek-V2

Creating a ping pong game involves a lot of programming and game design. Here's a simple example of how you might start to create a ping pong game using Python and the Pygame library:

```python
import pygame
import sys

# Initialize Pygame
pygame.init()

# Set up some constants
WIDTH, HEIGHT = 800, 600
BALL_RADIUS = 10
PADDLE_WIDTH, PADDLE_HEIGHT = 20, 100
PADDLE_SPEED = 5

# Set up the display
screen = pygame.display.set_mode((WIDTH, HEIGHT))

# Set up the ball
ball_pos = [WIDTH // 2, HEIGHT // 2]
ball_vel = [4, 4]

# Set up the paddles
paddle1_pos = [0, (HEIGHT - PADDLE_HEIGHT) // 2]
paddle2_pos = [WIDTH - PADDLE_WIDTH, (HEIGHT - PADDLE_HEIGHT) // 2]

# Game loop
while True:
    # Event handling
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    # Ball movement
    ball_pos[0] += ball_vel[0]
    ball_pos[1] += ball_vel[1]

    # Ball collision with walls
    if ball_pos[0] - BALL_RADIUS <= 0 or ball_pos[0] + BALL_RADIUS >= WIDTH:
        ball_vel[0] = -ball_vel[0]
    if ball_pos[1] - BALL_RADIUS <= 0 or ball_pos[1] + BALL_RADIUS >= HEIGHT:
        ball_vel[1] = -ball_vel[1]

    # Paddle movement
    keys = pygame.key.get_pressed()
    if keys[pygame.K_w]:
        paddle1_pos[1] -= PADDLE_SPEED
    if keys[pygame.K_s]:
        paddle1_pos[1] += PADDLE_SPEED
    if keys[pygame.K_UP]:
        paddle2_pos[1] -= PADDLE_SPEED
    if keys[pygame.K_DOWN]:
        paddle2_pos[1] += PADDLE_SPEED

    # Draw everything
    screen.fill((0, 0, 0))
    pygame.draw.circle(screen, (255, 255, 255), ball_pos, BALL_RADIUS)
    pygame.draw.rect(screen, (255, 255, 255), (paddle1_pos[0], paddle1_pos[1], PADDLE_WIDTH, PADDLE_HEIGHT))
    pygame.draw.rect(screen, (255, 255, 255), (paddle2_pos[0], paddle2_pos[1], PADDLE_WIDTH, PADDLE_HEIGHT))

    # Update the display
    pygame.display.flip()

    # Cap the frame rate
    pygame.time.Clock().tick(60)
```

This is a very basic version of a ping pong game. It doesn't include scoring, AI for the second paddle, or many other features you might want in a complete game. But it should give you a starting point for creating your own game.

ピンポンゲームを作るには、多くのプログラミングとゲームデザインが必要です。ここでは、PythonとPygameライブラリを使ってピンポンゲームを作る簡単な例を示します:

import pygame
import sys

# Initialize Pygame
pygame.init()

# Set up some constants
WIDTH, HEIGHT = 800, 600
BALL_RADIUS = 10
PADDLE_WIDTH, PADDLE_HEIGHT = 20, 100
PADDLE_SPEED = 5

# Set up the display
screen = pygame.display.set_mode((WIDTH, HEIGHT))

# Set up the ball
ball_pos = [WIDTH // 2, HEIGHT // 2]
ball_vel = [4, 4]

# Set up the paddles
paddle1_pos = [0, (HEIGHT - PADDLE_HEIGHT) // 2]
paddle2_pos = [WIDTH - PADDLE_WIDTH, (HEIGHT - PADDLE_HEIGHT) // 2]

# Game loop
while True:
    # Event handling
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    # Ball movement
    ball_pos[0] += ball_vel[0]
    ball_pos[1] += ball_vel[1]

    # Ball collision with walls
    if ball_pos[0] - BALL_RADIUS <= 0 or ball_pos[0] + BALL_RADIUS >= WIDTH:
        ball_vel[0] = -ball_vel[0]
    if ball_pos[1] - BALL_RADIUS <= 0 or ball_pos[1] + BALL_RADIUS >= HEIGHT:
        ball_vel[1] = -ball_vel[1]

    # Paddle movement
    keys = pygame.key.get_pressed()
    if keys[pygame.K_w]:
        paddle1_pos[1] -= PADDLE_SPEED
    if keys[pygame.K_s]:
        paddle1_pos[1] += PADDLE_SPEED
    if keys[pygame.K_UP]:
        paddle2_pos[1] -= PADDLE_SPEED
    if keys[pygame.K_DOWN]:
        paddle2_pos[1] += PADDLE_SPEED

    # Draw everything
    screen.fill((0, 0, 0))
    pygame.draw.circle(screen, (255, 255, 255), ball_pos, BALL_RADIUS)
    pygame.draw.rect(screen, (255, 255, 255), (paddle1_pos[0], paddle1_pos[1], PADDLE_WIDTH, PADDLE_HEIGHT))
    pygame.draw.rect(screen, (255, 255, 255), (paddle2_pos[0], paddle2_pos[1], PADDLE_WIDTH, PADDLE_HEIGHT))

    # Update the display
    pygame.display.flip()

    # Cap the frame rate
    pygame.time.Clock().tick(60)

これはピンポンゲームの非常に基本的なバージョンです。得点やセカンドパドルのAIなど、完全なゲームに必要な機能は含まれていません。しかし、これはあなた自身のゲームを作るための出発点になるはずです。

GPT-4 Turbo

Let's create a simple text-based version of a ping pong game that you can play in the console! In this version, you'll be able to "serve" the ball and the computer will "return" it until one player fails to return, which counts as a point for the other player. 

Here's a basic outline of the game:

1. Each player takes turns serving the ball.
2. After a serve, a random outcome determines if the opponent returns the ball or misses.
3. The first player to reach a predetermined number of points wins.

Let's get started with the Python code for this game:

```python
import random

def play_ping_pong():
    player_score = 0
    computer_score = 0
    rounds = 5  # Number of points required to win the game

    while player_score < rounds and computer_score < rounds:
        # Player serves the ball
        input("Press Enter to serve the ball...")
        if random.choice([True, False]):
            print("Computer returns the ball!")
        else:
            print("Computer misses!")
            player_score += 1
            print(f"Score: You {player_score} - Computer {computer_score}")
            continue

        # Computer serves the ball
        print("Computer serves the ball...")
        if random.choice([True, False]):
            print("You return the ball!")
        else:
            print("You miss!")
            computer_score += 1
            print(f"Score: You {player_score} - Computer {computer_score}")

    if player_score > computer_score:
        print("You win!")
    else:
        print("Computer wins!")

# To play the game, call play_ping_pong()
```

You can run this script in a Python environment. It will allow you to interact with the game using the console, simulating a ping pong match where each "serve" and "return" is determined randomly. To start playing, you would call `play_ping_pong()` after defining the function.

ゲーム機で遊べる簡単なテキストベースの卓球ゲームを作ってみましょう!このバージョンでは、あなたがボールを「サーブ」し、一方のプレイヤーがリターンに失敗するまで、コンピュータがボールを「リターン」します。

ゲームの基本的な流れは以下の通りです:

1.各プレイヤーが交互にボールを出します。
2.サーブ後、ランダムな結果で相手が返球するか失敗するかを決定します。
3.最初に決められた点数に達したプレイヤーが勝ち。

さっそくこのゲームのPythonコードを見てみましょう:

import random

def play_ping_pong():
    player_score = 0
    computer_score = 0
    rounds = 5  # Number of points required to win the game

    while player_score < rounds and computer_score < rounds:
        # Player serves the ball
        input("Press Enter to serve the ball...")
        if random.choice([True, False]):
            print("Computer returns the ball!")
        else:
            print("Computer misses!")
            player_score += 1
            print(f"Score: You {player_score} - Computer {computer_score}")
            continue

        # Computer serves the ball
        print("Computer serves the ball...")
        if random.choice([True, False]):
            print("You return the ball!")
        else:
            print("You miss!")
            computer_score += 1
            print(f"Score: You {player_score} - Computer {computer_score}")

    if player_score > computer_score:
        print("You win!")
    else:
        print("Computer wins!")

# To play the game, call play_ping_pong()

このスクリプトはPython環境で実行できます。このスクリプトをPython環境で実行すると、コンソールを使ってゲームと対話することができ、それぞれの “サーブ “と “リターン “がランダムに決まるピンポンの試合をシミュレートすることができます。ゲームを始めるには、関数を定義した後に play_ping_pong() を呼び出します。

Llama 3 70B

Let's create a simple text-based ping pong game. Here's how we can play:
**The Game**
You will play as "Player A" and I'll play as "Player B". The game will take place on a standard ping pong table. The goal is to hit the ball back and forth until one of us fails to return it.
**The Rules**
1. I'll start by serving the ball.
2. You'll respond with one of the following actions:
* `hit`: Hit the ball back to me.
* `left`: Hit the ball to my left side.
* `right`: Hit the ball to my right side.
3. Based on your action, I'll respond with the outcome of the shot.
4. We'll keep playing until one of us fails to return the ball or makes an error.
Ready to start? Here's the serve:
**The Ball is Served**
The ball is coming towards you with moderate speed and spin. It's heading straight down the middle of the table.
What do you do?
Type `hit`, `left`, or `right` to respond.

簡単なテキストベースのピンポンゲームを作ってみましょう。遊び方は以下の通りです:
**ゲーム
あなたは「プレイヤーA」としてプレイし、私は「プレイヤーB」としてプレイします。ゲームは標準的な卓球台で行われます。ゴールは、どちらかがボールを返せなくなるまでボールを打ち合うことです。
**ルール

  1. 私がボールをサーブします。
  2. 2.あなたは以下のいずれかのアクションで応答します:
  • ヒット`: 私にボールを打ち返します。
  • left: left: ボールを私の左側に打ちます。
  • right: 私の右側にボールを打ちます: right: 私の右側にボールを打ちます。
  1. あなたの行動をもとに、ショットの結果を返答します。
  2. どちらかがボールを返せなかったり、エラーをするまでプレーを続けます。
    始める準備はできましたか?サーブです:
    **ボールのサーブ
    ボールは適度なスピードとスピンをかけてあなたに向かってきます。ボールはテーブルの真ん中に向かっています。
    どうしますか?
    hitleftright`とタイプしてください。

DeepSeek-V2とGPT-4 Turboは、ピンポンゲームを作成するPythonコードを出力してくれましたが、Llama 3はコードは出力せず、テキストのみでピンポンゲームの説明を出力しました。

DeepSeek-V2は、非常に簡単ですが私の意図していた通りのゲームを作成してくれました!

特にコードを修正することなく動くコードを生成してくれたので、評価は高いです。

GPT-4 Turboについては、DeepSeek-V2のようにpygameなどは使わず、CLIでテキストベースで対話をして疑似的なピンポンゲームをするコードを作成してくれました。

この比較では、私の意図していたゲームを生成してくれたDeepSeek-V2が最も優れていると言えます。

東京大学の理系数学入試問題

次に、以下の東京大学の理系数学入試問題を解かせてみます。

黒玉3個、赤玉4個、白玉5個が入っている袋から玉を1個ずつ取り出し、取り出した玉を順に横一列に12個並べる。ただし、袋から個々の玉が取り出される確率は等しいものとする。

(1) どの赤玉も隣り合わない確率pを求めよ。

この問題の正しい解答は、以下のようになっています。

引用元:https://math.nakaken88.com/problem/tokyo-u-r-2023-2/

上記の問題文を英訳して入力します。

Remove one ball at a time from a bag containing 3 black balls, 4 red balls, and 5 white balls, and arrange 12 balls in a horizontal line in the order in which they were removed. However, the probability that an individual ball is removed from the bag is assumed to be equal.

(1) Find the probability p that none of the red balls are adjacent to each other.

結果はこのようになりました。

DeepSeek-V2

To find the probability p that none of the red balls are adjacent to each other, we can first calculate the total number of ways to arrange the 12 balls and then find the number of ways to arrange the balls such that no red balls are adjacent to each other.

Total number of ways to arrange the 12 balls:
There are 3 black balls, 4 red balls, and 5 white balls, so the total number of ways to arrange them is:
(12!)/(3! * 4! * 5!) = 27,720

Now, let's find the number of ways to arrange the balls such that no red balls are adjacent to each other. We can think of the white and black balls as "separators" for the red balls. There are 8 positions (5 white balls + 3 black balls) that can be occupied by the red balls. We need to place the 4 red balls in such a way that they don't touch each other. This can be done using the "stars and bars" method:

Number of ways to arrange the red balls without touching each other:
(8!)/(4! * (8-4)!) = 70

Now, we need to arrange the black and white balls around the red balls. There are 3 black balls and 5 white balls, so the number of ways to arrange them is:
(8!)/(3! * 5!) = 56

Multiplying the number of ways to arrange the red balls without touching each other and the number of ways to arrange the black and white balls, we get:
70 * 56 = 3,920

Finally, the probability p that none of the red balls are adjacent to each other is:
p = (Number of ways to arrange the balls without red balls touching each other) / (Total number of ways to arrange the balls)
p = 3,920 / 27,720
p = 14 / 99

So, the probability p is 14/99.

赤いボールが1つも隣接しない確率pを求めるには、まず12個のボールの並べ方の総数を計算し、次に赤いボールが1つも隣接しないようなボールの並べ方の数を求めます。

12個のボールを並べる方法の総数:
黒玉が3個、赤玉が4個、白玉が5個なので、並べ方の総数は
(12!)/(3! * 4! * 5!) = 27,720

では、赤玉同士が隣り合わないように玉を並べる方法の数を求めてみましょう。白と黒のボールは、赤のボールの「セパレーター」と考えることができます。赤玉が入る位置は8個(白玉5個+黒玉3個)です。4つの赤玉が互いに触れないように配置する必要があります。これには「星と棒」を使います.

赤玉を互いに触れないように並べる方法の数:
(8!)/(4! * (8-4)!) = 70

次に、赤玉の周りに黒玉と白玉を並べます。黒玉は3個、白玉は5個あるので、並べ方の数は
(8!)/(3! * 5!) = 56

赤い玉を互いに触れずに並べる方法と、黒い玉と白い玉を並べる方法を掛けると、次のようになります:
70 * 56 = 3,920

最後に、赤いボールが1つも隣り合わない確率pは
p = (赤いボールが隣り合わないボールの並べ方の数) / (ボールの並べ方の総数)
p = 3,920 / 27,720
p = 14 / 99

つまり、確率 p は 14/99 です。

GPT-4 Turbo

To solve this problem, we will calculate the probability \( p \) that none of the red balls (which are 4 in total) are adjacent to each other when the 12 balls (3 black, 4 red, and 5 white) are arranged in a horizontal line.

We will approach this problem by first calculating the total number of ways to arrange the 12 balls, and then the number of favorable arrangements where no two red balls are adjacent.

1. **Total number of ways to arrange 12 balls**:
   Given that there are 3 black balls, 4 red balls, and 5 white balls, the total number of ways to arrange these balls is given by the multinomial coefficient:
   \[
   \frac{12!}{3! \times 4! \times 5!}
   \]

2. **Number of ways to arrange balls so that no two red balls are adjacent**:
   To find the number of favorable arrangements, we can think about placing the non-red balls first and then inserting the red balls in the gaps between them.

   - Arrange the 3 black and 5 white balls in any order. The total number of ways to do this is:
     \[
     \frac{8!}{3! \times 5!}
     \]
   - Once these 8 balls are placed, there will be 9 possible "gaps" to place the red balls (including the positions at the beginning and the end of the line). We need to choose 4 of these gaps to place the red balls, and this can be done in:
     \[
     \binom{9}{4}
     \]
   - Each choice corresponds to placing one red ball in each selected gap, ensuring that no two red balls are adjacent.

3. **Calculate the probability \( p \)**:
   The probability \( p \) that none of the red balls are adjacent is the ratio of the favorable arrangements to the total arrangements:
   \[
   p = \frac{\left(\frac{8!}{3! \times 5!}\right) \times \binom{9}{4}}{\frac{12!}{3! \times 4! \times 5!}}
   \]
   Simplifying this expression:
   \[
   p = \frac{8! \times \binom{9}{4}}{12! / (3! \times 4!)}
   \]

Let's calculate the probability \( p \) using this formula.

The probability \( p \) that none of the red balls are adjacent to each other when arranging 3 black balls, 4 red balls, and 5 white balls in a horizontal line is approximately 0.2545, or 25.45%.

この問題を解決するために、12個のボール(黒3個、赤4個、白5個)を一列に並べた際に、赤いボール同士が隣り合わない確率 ( p ) を計算します。

まず、12個のボールを並べる全ての方法を計算し、その後、赤いボール同士が隣り合わない有利な配置の数を計算します。

  1. ボールを並べる総数:
    黒のボールが3個、赤のボールが4個、白のボールが5個の場合、これらのボールを並べる方法の総数は多項係数で与えられます:
    [
    \frac{12!}{3! \times 4! \times 5!}
    ]
  2. 赤いボールが隣り合わないようにボールを並べる方法:
    有利な配置を見つけるために、まずは赤以外のボールを配置し、その後で赤いボールを間に挿入します。
  • 3個の黒と5個の白のボールを任意の順序で配置します。これを行う方法の総数は:
    [
    \frac{8!}{3! \times 5!}
    ]
  • これら8個のボールが配置されると、赤いボールを配置するための9つの「隙間」が生じます(列の始めと終わりを含む)。この隙間のうち4つを選んで赤いボールを配置することができ、その選び方は以下の通りです:
    [
    \binom{9}{4}
    ]
  • 選ばれた各隙間に1個の赤いボールを配置します。これにより、どの赤いボールも隣り合わないようにします。
  1. 確率 ( p ) の計算:
    赤いボールが隣り合わない確率 ( p ) は、有利な配置の数と総配置数の比率で計算されます:
    [
    p = \frac{\left(\frac{8!}{3! \times 5!}\right) \times \binom{9}{4}}{\frac{12!}{3! \times 4! \times 5!}}
    ]
    この式を簡略化すると:
    [
    p = \frac{8! \times \binom{9}{4}}{12! / (3! \times 4!)}
    ]

この式を使用して確率 ( p ) を計算しましょう。

黒3個、赤4個、白5個のボールを一列に並べた際に赤いボール同士が隣り合わない確率 ( p ) は約0.2545、または25.45%です。

Llama 3 70B

Let's break this problem down step by step.
Since there are 12 balls in total, we need to find the total number of ways to arrange them in a horizontal line. This is a permutation problem, and the total number of arrangements is:
12! / (3! \* 4! \* 5!) = 34,650
Now, let's count the number of arrangements where no two red balls are adjacent to each other. We can think of this as inserting the red balls into gaps between the black and white balls.
There are 4 red balls, and we need to find the number of ways to insert them into the gaps. Let's create a diagram to visualize this:
_ B _ B _ B _ (3 black balls)
_ W _ W _ W _ W _ (5 white balls)
We have 8 gaps (including the ends) where we can insert the red balls. We need to choose 4 gaps out of 8 to insert the red balls, which can be done in:
C(8, 4) = 70
ways. Once we've chosen the gaps, we can permute the red balls in 4! ways. Therefore, the total number of arrangements where no two red balls are adjacent is:
70 \* 4! = 1680
Finally, we can find the probability p that none of the red balls are adjacent to each other:
p = (number of favorable arrangements) / (total number of arrangements)
= 1680 / 34,650
= 5/108
So, the probability that none of the red balls are adjacent to each other is 5/108.

この問題をステップごとに分解してみましょう。
ボールは全部で12個あるので、ボールを横一列に並べる方法の総数を求めます。これは順列の問題で、並べ方の総数は
12! / (3! * 4! * 5!) = 34,650
では、2つの赤い玉が隣り合っていない配置の数を数えてみましょう。これは、黒と白の玉の隙間に赤の玉を入れると考えればよいでしょう。
赤玉は4個あるので、隙間に入れる方法を何通りか求めます。これを視覚化するために図を作ってみましょう:
B _ B _ B _ (黒いボール3個)
W _ W _ W _ W _ (5個の白ボール)
赤玉を入れることのできる隙間は(両端を含めて)8つあります。8つの隙間のうち4つを選んで赤玉を入れる必要があります:
C(8, 4) = 70
の方法で行います。隙間を選んだら、赤玉を4通り並べ替えることができます。したがって、2つの赤玉が隣接しない並べ方の総数は
70 * 4! = 1680
最後に、どの赤玉も隣り合わない確率pを求めます:
p = (有利な配置の数) / (配置の総数)
= 1680 / 34,650
= 5/108
つまり、赤いボールが1つも隣接しない確率は5/108です。

正しい解答を出力してくれたのは、GPT-4 Turboのみでした。

そこまで難易度の高くない問題だと思いますが、DeepSeek-V2(Llama 3 70Bも)数学能力ではまだまだGPT-4 Turboに追いつけていないようです。

企業戦略の提案(日本語)

最後に、文章力と日本語能力を比較するため、現在ある企業が置かれている状況から脱却するための施策を考えてもらいます。

以下のプロンプトを入力します。

ある企業が最近、新しい技術革新により市場での地位を強化しました。この技術は環境に優しい素材を使用しており、消費者からの関心も高いです。しかし、その企業は同時に労働者の権利に関する批判に直面しています。この状況を踏まえ、企業の評判を管理し、消費者の信頼を保つための戦略を提案してください。

結果はこのようになりました。

DeepSeek-V2

企業の評判管理と消費者信頼の維持は、企業の持続可能な成長に不可欠です。以下の戦略を提案いたします。

1. 労働者の権利に関する問題の解決:
   - 労働者の権利に関する批判を受け入れ、迅速かつ透明性の高い方法で問題を解決する。
   - 労働者の労働条件、賃金、福利厚生などを改善し、労働者の満足度を向上させる。
   - 労働者とのコミュニケーションを促進し、労働者の意見や懸念を積極的に聞く。

2. 社会的責任の実践:
   - 企業の社会的責任(CSR)活動を強化し、労働者の権利保護や環境保護に取り組む。
   - 持続可能なビジネスモデルを推進し、環境に優しい素材の使用を拡大する。
   - 社会的貢献活動を通じて、企業の社会的イメージを向上させる。

3. 透明性の高いコミュニケーション:
   - 企業の政策や行動に関する情報を消費者に迅速かつ透明性の高い方法で提供する。
   - 労働者の権利保護や環境保護に取り組む姿勢を積極的に宣伝し、消費者の理解を得る。
   - ソーシャルメディアや公式ウェブサイトを活用し、企業の取り組みをリアルタイムで共有する。

4. 消費者との対話:
   - 消費者からのフィードバックを重視し、意見や提案を積極的に受け入れる。
   - 消費者とのコミュニケーションループを構築し、企業の政策や製品に関する意見を収集する。
   - 消費者の信頼を築くために、企業の目標や価値観を消費者と共有する。

5. 品質管理と革新:
   - 製品の品質を維持し、消費者の期待に応える。
   - 新しい技術や素材を活用し、製品の革新を続ける。
   - 消費者のニーズや市場の変化に応じて、製品ラインナップを拡大する。

これらの戦略を実行することで、企業は労働者の権利に関する批判に対処し、消費者の信頼を維持し、評判を向上させることができます。

GPT-4 Turbo

企業が新しい技術革新で市場の地位を強化し、環境に優しい素材を使用することで消費者の関心を集めている一方で、労働者の権利に関する問題で批判に直面している場合、次のような戦略を採用することが効果的です:

1. **透明性の向上**:
   - 労働慣行に関する問題を公然と認め、改善のための具体的な計画を公表します。例えば、独立した監査を定期的に行い、その結果を公開することで、透明性を確保し、消費者と投資家の信頼を回復します。

2. **労働条件の改善**:
   - 労働者の権利保護を強化するため、適切な賃金、健康と安全の基準の向上、労働時間の合理化を図ります。また、従業員の声を聞くためのフォーラムや、不満を申し立てるための安全なチャネルを設置することが重要です。

3. **持続可能性と社会的責任の統合**:
   - 環境に優しいイニシアティブだけでなく、社会的責任も企業戦略の中心に置きます。地域社会とのパートナーシップを強化し、地域社会への投資を増やすことで、企業の社会的責任を実践します。

4. **コミュニケーション戦略の見直し**:
   - 効果的なコミュニケーション戦略を通じて、企業の取り組みと成果を定期的に報告します。消費者への直接的なコミュニケーションを強化し、ソーシャルメディアやPR活動を活用して、ポジティブなメッセージを発信します。

5. **ステークホルダーとの対話**:
   - 消費者、投資家、地域社会のリーダー、NGOなど、幅広いステークホルダーと定期的に対話を持ち、彼らの意見や懸念を企業活動に反映させます。これにより、ステークホルダーの支持を得られるだけでなく、潜在的な問題に迅速に対応できます。

6. **教育と訓練の強化**:
   - 従業員に対する教育と訓練を強化し、労働権利についての認識を高めることで、内部からの改善を促します。また、リーダーシップ開発を通じて、倫理的な決定を下す能力を育成します。

これらの戦略を組み合わせることで、企業は環境保護への取り組みを続けながら、労働者の権利問題にも積極的に対応し、長期的な信頼と評価を確保することができるでしょう。

Llama 3 70B

To manage the company's reputation and maintain consumer trust in the face of criticism regarding labor rights, I propose the following strategy:
**Short-term (Immediate Response)**
1. **Acknowledge and Apologize**: Issue a public statement acknowledging the concerns about labor rights and apologize for any wrongdoing.
2. **Investigate and Address**: Conduct an internal investigation to identify the root causes of the issue and take immediate action to address them.
3. **Transparency**: Provide regular updates on the progress made to address the labor rights concerns.
**Mid-term (Reputation Recovery)**
1. **Stakeholder Engagement**: Engage with stakeholders, including labor unions, NGOs, and industry experts, to understand their concerns and gather feedback.
2. **Develop a Labor Rights Policy**: Create a comprehensive labor rights policy that outlines the company's commitment to protecting workers' rights.
3. **Independent Audit**: Conduct an independent audit to ensure compliance with labor laws and international standards.
4. **Employee Engagement**: Engage with employees to understand their concerns and provide training on labor rights and responsibilities.
**Long-term (Sustainability and Trust Building)**
1. **Integrate Labor Rights into Sustainability Strategy**: Incorporate labor rights into the company's overall sustainability strategy and reporting.
2. **Supply Chain Transparency**: Implement a transparent supply chain management system to ensure that labor rights are respected throughout the entire value chain.
3. **Industry Collaboration**: Collaborate with industry peers and associations to promote best practices in labor rights and share knowledge.
4. **Continuous Monitoring and Improvement**: Regularly monitor and assess labor rights practices and implement improvements to maintain transparency and accountability.
**Communication Strategy**
1. **Authentic and Transparent Communication**: Communicate the company's commitment to labor rights and sustainability in an authentic and transparent manner.
2. **Multi-Channel Approach**: Utilize various communication channels, including social media, website, and traditional media, to reach a wider audience.
3. **Employee Ambassadors**: Empower employees to become ambassadors of the company's labor rights and sustainability initiatives.
4. **Regular Progress Updates**: Provide regular updates on the company's progress in addressing labor rights concerns and implementing sustainability initiatives.
By implementing this strategy, the company can effectively manage its reputation, maintain consumer trust, and demonstrate its commitment to labor rights and sustainability.

労働者の権利に関する批判に直面しても、会社の評判を管理し、消費者の信頼を維持するために、私は以下の戦略を提案します:


短期的(即時対応)

  1. 承認と謝罪: 労働者の権利に関する懸念を認める公式声明を発表し、不正行為について謝罪します。
  2. 調査と対処: 問題の根本原因を特定するために社内調査を実施し、それらに対処するために直ちに行動を起こします。
  3. 透明性: 労働者の権利に関する懸念に対処するための進捗状況に関する定期的な最新情報の提供。


中期(評判の回復)

  1. ステークホルダー・エンゲージメント:労働組合、NGO、業界専門家などの利害関係者と関わり、彼らの懸念を理解し、フィードバックを収集すること。
  2. 労働者の権利に関する方針の策定: 労働者の権利保護に対する企業のコミットメントを概説する包括的な労働者の権利に関する方針を策定します。
  3. 独立監査: 独立監査を実施し、労働法および国際基準の遵守を確認します。
  4. 従業員の参画: 従業員参画**:従業員の懸念を理解し、労働の権利と責任に関する研修を提供するために、従業員と協働します。

長期的(持続可能性と信頼構築)

  1. サステナビリティ戦略への労働者の権利の組み入れ:会社全体のサステナビリティ戦略および報告に労働者の権利を組み入れます。
  2. サプライチェーンの透明性*: バリューチェーン全体で労働権が尊重されるよう、透明性のあるサプライチェーン管理システムを導入すること。
  3. 業界との協働: 労働権のベストプラクティスを推進し、知識を共有するために業界の同業者や団体と協働すること。
  4. 継続的な監視と改善: 労働権の実践を定期的に監視・評価し、透明性と説明責任を維持するための改善を実施します。
  5. 誠実で透明なコミュニケーション戦略 : 労働者の権利と持続可能性に対する会社のコミットメントを真正かつ透明な方法で伝えます。
  6. マルチチャネル・アプローチ: ソーシャルメディア、ウェブサイト、伝統的メディアなど、さまざまなコミュニケーションチャネルを活用し、より多くの人々にリーチします。
  7. 従業員アンバサダー: 従業員アンバサダー**:従業員が会社の労働権および持続可能性に関するイニシアチブのアンバサダーとなるよう支援します。
  8. 定期的な進捗状況の更新: 労働権に関する懸念への対応と持続可能なイニシアティブの実施における会社の進捗状況について、定期的に最新情報を提供します

この戦略を実施することにより、会社はその評判を効果的に管理し、消費者の信頼を維持し、労働権と持続可能性へのコミットメントを示すことができます。

DeepSeek-V2とGPT-4 Turboは、日本語で出力してくれましたが、Llama 3のみ英語で出力しました。

DeepSeek-V2は、GPT-4 Turboと同等か分かりやすさでいえばそれ以上の非常に優れた施策を提案してくれました。

日本語も極めて自然で、その能力の高さが伺えます。

今回の検証の結果、DeepSeek-V2はGPT-4 Turboと同等かそれ以上のコーディング能力を持ち、高い文章力と日本語能力を有していますが、数学能力についてはまだまだ差があると感じました。

ただ、同じオープンソースモデルのLlama 3 70Bには完全に上回っており、現状最強クラスのオープンソースモデルといって差し支えないでしょう

非常に高い性能を持ちながら激安価格でAPIを利用できますので、もし気になった方は是非試してみてください!

なお、Llama 3について知りたい方はこちらの記事をご覧ください。

DeepSeek-V2は高い性能とコスパを両立したモデル

DeepSeek-V2は、中国のAI企業であるDeepSeekが公開した超高コスパLLMです。

このモデルは、ベンチマークでGPT-4 Turboなどと同等のパフォーマンスを発揮するほどの性能を有しながら、APIの使用量はGPT-4 Turboの1/107ほどと驚異的なコストパフォーマンスを持っています。

MoEアーキテクチャを採用しており、合計230Bものパラメータを持っていますが、実際の推論時に使用するのはそのうちの約1割ほどの21Bなので、大規模なパラメータを維持しながら計算コストを大幅に低減しています。

実際に使ってみた感想は、GPT-4 Turboと同等かそれ以上のコーディング能力を持ち、高い文章力と日本語能力を有していますが、数学能力についてはまだまだ差があると感じました。

ただ、Llama 3 70Bとの比較では入力の理解力や日本語能力などの点で上回っており、LLMとしての総合的な性能もDeepSeek-V2のほうが高いと感じました。

よって、DeepSeek-V2は現状最強クラスのオープンソースモデルと言って差し支えないと思います。

DeepSeek-V2は、公式サイトやAPIから気軽に使用できますので、もし気になった方は是非試してみてください!

サービス紹介資料

生成系AIの業務活用なら!

・生成系AIを活用したPoC開発

・生成系AIのコンサルティング

・システム間API連携

最後に

いかがだったでしょうか?

弊社では

・マーケティングやエンジニアリングなどの専門知識を学習させたAI社員の開発
・要件定義・業務フロー作成を80%自動化できる自律型AIエージェントの開発
・生成AIとRPAを組み合わせた業務自動化ツールの開発
・社内人事業務を99%自動化できるAIツールの開発
ハルシネーション対策AIツールの開発
自社専用のAIチャットボットの開発

などの開発実績がございます。

まずは、「無料相談」にてご相談を承っておりますので、ご興味がある方はぜひご連絡ください。

➡︎生成AIを使った業務効率化、生成AIツールの開発について相談をしてみる。

生成AIを社内で活用していきたい方へ

「生成AIを社内で活用したい」「生成AIの事業をやっていきたい」という方に向けて、生成AI社内セミナー・勉強会をさせていただいております。

セミナー内容や料金については、ご相談ください。

また、弊社紹介資料もご用意しておりますので、併せてご確認ください。

投稿者

  • ゆうや

    ロボット工学専攻。 大学時代は、対話ロボットのための画像キャプションの自動生成について研究。 趣味は、サウナとドライブ。

  • URLをコピーしました!
  • URLをコピーしました!
目次