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

【OpenELM】iPhone・iPadでも動作できるApple最新小型オープンLLM

OpenELM iPhone・iPad 動作できる Apple 最新小型 オープンLLM

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

2024年4月24日、ついにあのAppleからオープンソースLLMである「OpenELM」が登場しました!

このモデルは、4つの異なるサイズ(270M、450M、1.1B、3B)で公開され、軽量で実行コストが低いためAppleデバイスでも動作します。また、「layer-wise scaling戦略」を使用し、効率的にパラメータを活用することで他の同規模モデルより高性能です。

さらに、OpenELMの透明性を保つため、公開データセットと学習コード、MLXライブラリも公開されています。

今回は、OpenELMの概要や実際に使ってみた感想をお伝えします。

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

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

目次

OpenELMの概要

OpenELMは、Appleが公開した最新の小型LLMで、270M、450M、1.1B、3Bという4つのサイズのモデルが公開されています。

このモデルは、非常に軽量なので、実行コストも低く抑えられており、なんとiPhoneでも動作できるとのことです。

今回のリリースには、OpenELMをAppleデバイス上でローカルに実行させるための「MLXライブラリへの変換コード」も含まれており、これを使うことでiPhoneやMac上でモデルを実行できます。

MLXライブラリでOpenELMを実行する方法は、以下を参考にしてください。

mlx_examples/open_elm

OpenELMの性能

Appleは、このモデルの公開の目的を「オープンな研究コミュニティを支援し、発展させること」としていますが、性能も妥協していません。

具体的には、トランスフォーマーモデルの各層で効率的にパラメータを割り当てるlayer-wise scaling戦略(レイヤーワイズスケーリング戦略)を採用しており、小さなパラメータのモデルでも精度を向上させることができます。

実際、OpenELMのパラメータが1B(1億)の場合、OLMoという約1.2Bのモデルと比較して精度が 2.36% 高くなっており、必要な事前学習用のトークン数は半分で済むそうです。

引用元:https://arxiv.org/pdf/2404.14619

また、Appleは論文の中で、タスクに特化した学習を行う「Instruction Tuning」を適用することで、OpenELMの精度が1〜2%向上したことも報告しています。


引用元:https://arxiv.org/pdf/2404.14619

また、OpenELMには、パラメーター効率のいい微調整を行う手法であるParameter-efficient fine-tuning (PEFT)が適用可能であることも、実験により実証されています。

Appleは、OpenELMの透明性を維持するため、モデルのトレーニングは約1.8兆トークンの公開データで行い、学習コードやログ等を公開しています。

ここからは、OpenELMを実際に使用してその性能に迫っていきます。

なお、Microsoftの小型LLMであるPhi-3-miniについて知りたい方はこちらの記事をご覧ください。

OpenELMのライセンス

OpenELMは、apple-sample-code-lisenceのもとで提供されており、これはオープンソースライセンスではありませんが、ライセンス通知を含める等の特定の制限の下で商用利用、改変、および再配布を許可しています。

利用用途可否
商用利用⭕️
改変⭕️
配布⭕️
特許使用
私的使用⭕️
参考:https://huggingface.co/apple/OpenELM-270M-Instruct/blob/main/LICENSE

OpenELMの使い方

OpenELMの使い方はいくつかあり、まずは公式にアナウンスされている方法を紹介します。

まず、モデルのリポジトリをクローンします。

git clone https://huggingface.co/apple/OpenELM-270M-Instruct

次に、必要なパッケージをインストールします。

pip install torch transformers

最後に、以下のコマンドでモデルのロードと推論を実行します。

python generate_openelm.py --model apple/OpenELM-270M-Instruct --hf_access_token [HF_ACCESS_TOKEN] --prompt 'Once upon a time there was' --generate_kwargs repetition_penalty=1.2

この際、注意点としてHugging Faceのアクセストークンが必要なので、事前に取得してコマンドの[HF_ACCESS_TOKEN]部分に入力してください。

また、OpenELMはトークナイザーにLlama 2のものを使用しているため、Llama 2のモデルへのアクセス許可が必要になりますので、こちらも事前に対応してください。

こちらの方法以外にも、有志の方がGradioデモでOpenELMを使用するためのColabノートブックを公開してくれています。

GPUバージョン

apple_OpenELM-3B_cuda_Gradio-Demo.ipynb

CPUバージョン

apple_OpenELM-270M_cpu_Gradio-Demo.ipynb

また、Hugging Face SpaceでOpenELM-3Bのオンラインデモが公開されており、こちらはアクセスするだけで使用できるので、簡単です。

ただ、このデモは微調整されたモデルではなく、事前トレーニングモデルのデモなので、期待するような結果は得られない可能性があります。

それではOpenELMを実際に使用していきましょう!

OpenELMを実際に使ってみた

今回は、最初に紹介した方法で最軽量モデルであるOpenELM-270M-Instructを試します。

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

Write a python code to reverse a string

文字列を反転するpythonコードを書いて

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

Write a python code to reverse a string in given input.

## Required
- Python 3.8+
- String Input

## STEPS
1. Read the input from stdin
2. Split the input into tokens and store them in dictionary
3. Loop through each token and reverse the index of current token

Example:
Input: "Aaaa" -> ["AA", "AA"]
Output: ["aa"]

Example:
Input: "aa" -> ["aa"]
Output: ["aa"]

```python
def reverse(input):
    result = {}
    while True:
        next_token = input.readline()
        if next_token not in result or result[next_token] != input.index(next_token):
            result[next_token] = input.index(next_token)
        input.clear()
        return result
```

## TEST
1. Run the program using `tox` command
2. Run the program with `-e test` flag

```bash
$ tox -e test
```

## LICENSE
MIT License

------------------------------------------------------------------------------------------------------------------------

Generation took 6.37 seconds.

与えられた入力の文字列を反転する python コードを書いてみましょう。

必須

  • Python 3.8+
  • 文字列の入力

ステップ

  1. 標準入力から入力を読み込みます
  2. 入力をトークンに分割して辞書に格納
  3. 各トークンをループし、現在のトークンのインデックスを反転します。


入力: 「Aaaa” -> [“AA”, “AA”].
出力: [“aa”]


入力:「aa” -> [“aa”] です。
出力:[“aa”]

def reverse(input):
    result = {}
    while True:
        next_token = input.readline()
        if next_token not in result or result[next_token] != input.index(next_token):
            result[next_token] = input.index(next_token)
        input.clear()
        return result

テスト

  1. tox`コマンドでプログラムを実行
  2. e test` フラグを付けてプログラムを実行
$ tox -e test

ライセンス

MIT ライセンス

生成に要した時間は6.37秒。

モデルのロードから推論の実行まで、非常に高速に動作しました。

推論の実行自体は6.37秒で終了しています。

ただ、270Mモデルなので、性能面は良いとは言えず、今回生成したコードも間違った内容を含んでいます。

OpenELMの実行に必要なスペック

OpenELMの実行に必要なスペックの具体的な情報は公開されていませんが、その必要要件は非常に低いことは明らかです。

参考までに、私のPCのスペックと生成にかかった時間を掲載しておきます。

PCスペック

  • CPU:Ryzen7 5800x3D
  • GPU:GeForce RTX 4070Ti Super 16GB
  • RAM:64GB

生成にかかった時間

  • OpenELM-270M-Instruct:約6秒
  • OpenELM-3B-Instruct:約14秒

是非参考にしてください。

ここからは、OpenELMをMicrosoftのphi-3-miniGPT-3.5との比較を行っていきます。

OpenELMをMicrosoftのphi-3-miniとGPT-3.5と比較してみた

今回は、OpenELM-3B-InstructをPhi-3-mini-4k-instruct(3.3B)と、参考までにGPT-3.5とも比較していきます。

OpenELM-3B-InstructとPhi-3-mini-4k-instructは、ほぼ同規模のモデルですが、果たしてどちらのほうが優れた回答をしてくれるでしょうか。

今回は、以下の3つの項目で比較検証を行います。

  • コーディング(形態素解析)
  • 東京大学の理系数学入試問題
  • ビジネスメールの作成(日本語)

早速検証していきましょう!

コーディング(形態素解析)

まずはコーディング能力を検証するため、英語のテキストを日本語に翻訳して形態素解析まで行うプログラムを生成してもらいます。

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

Generate a program that translates English text into Japanese and even performs morphological analysis.

英語のテキストを日本語に翻訳して形態素解析まで行うプログラムを生成して

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

OpenELM-3B-Instruct

## Requirements

1. Java Runtime Environment (JRE) version 8 or later.
2. Maven (version 3.5.0 or later).

## Setup

1. Download or clone this repository.

```sh
git clone https://github.com/yu-shinji/japanselect.git
```

2. Change the working directory to `japanselect`.

```sh
cd japanselect
```

3. Install Java dependencies.

```sh
./mvnw install
```

4. Run Japanselect.

```sh
./mvnw exec:java
```

5. Open a browser and navigate to `http://localhost:8080`.

6. Select an input text, and click `Translate`.

![Select Input Text](./docs/images/select_input_text.png)

7. The translated text will be displayed in the lower pane.

![Translated Text](./docs/images/translated
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Generation took 12.47 seconds.

必要条件

1. Java Runtime Environment (JRE) バージョン8以降。

2. Maven (バージョン 3.5.0 以降)。

セットアップ

1. このリポジトリをダウンロードまたはクローンします。

git clone https://github.com/yu-shinji/japanselect.git

2. 作業ディレクトリを japanselect に変更します。

cd japanselect

3. Java の依存関係をインストールします。

./mvnw install

4. Japanselect を実行します。

./mvnw exec:java

5. ブラウザを開き、http://localhost:8080に移動します。

6. 入力テキストを選択し、Translateをクリックします。

![Select Input Text](./docs/images/select_input_text.png)

7. 翻訳されたテキストが下のペインに表示されます。

![Translated Text](./docs/images/translated

Phi-3-mini

To create a program that translates English text into Japanese and performs morphological analysis, we can use a combination of Natural Language Processing (NLP) libraries and APIs. For this example, I'll guide you through creating a Python program using the `googletrans` library for translation and `MeCab` (a morphological analyzer for Japanese) for morphological analysis.

First, you need to install the required libraries:

```bash
pip install googletrans==4.0.0-rc1
python -m MeCabDotNet
```

Here's a simple Python program that translates English text into Japanese and performs morphological analysis:

```python
import googletrans
from googletrans import Translator
import MeCab

def translate_to_japanese(text):
    translator = Translator()
    translation = translator.translate(text, src='en', dest='ja')
    return translation.text

def perform_morphological_analysis(text):
    tagger = MeCab.Tagger("-Ochasen")
    node = tagger.parseToNode(text)

    morphemes = []
    while node:
        morpheme = {}
        morpheme['surface'] = node.surface
        morpheme['part_of_speech'] = node.feature.split(',')[0]
        morpheme['base_form'] = node.feature.split(',')[3]
        morphemes.append(morpheme)
        node = node.next

    return morphemes

def main():
    english_text = input("Enter English text: ")
    japanese_text = translate_to_japanese(english_text)
    print(f"Translated text: {japanese_text}")

    morphological_analysis = perform_morphological_analysis(japanese_text)
    print("\nMorphological Analysis:")
    for morpheme in morphological_analysis:
        print(f"Surface: {morpheme['surface']}, Part of Speech: {morpheme['part_of_speech']}, Base Form: {morpheme['base_form']}")

if __name__ == "__main__":
    main()
```

This program takes an English text as input, translates it into Japanese using the `googletrans` library, and then performs morphological analysis on the translated text using the `MeCab` library.

Please note that the `googletrans` library is a third-party library and may not always provide the most accurate translations. For more accurate translations, consider using other libraries like `googletrans` with a more stable version or using APIs like Google Cloud Translation API.

Also, keep in mind that the morphological analysis results may not be perfect due to the complexity of the Japanese language. The `MeCab` library provides a good starting point for understanding the morphemes in the translated text. 

英語のテキストを日本語に翻訳し、形態素解析を行うプログラムを作成するには、自然言語処理(NLP)のライブラリやAPIを組み合わせて使用します。この例では、翻訳に googletrans ライブラリを、形態素解析に MeCab (日本語用形態素解析器) を使った Python プログラムの作成方法を説明します。

まず、必要なライブラリをインストールします:

pip install googletrans==4.0.0-rc1
python -m MeCabDotNet

英文を日本語に翻訳し、形態素解析を行う簡単なPythonプログラムを紹介します:

import googletrans
from googletrans import Translator
import MeCab

def translate_to_japanese(text):
    translator = Translator()
    translation = translator.translate(text, src='en', dest='ja')
    return translation.text

def perform_morphological_analysis(text):
    tagger = MeCab.Tagger("-Ochasen")
    node = tagger.parseToNode(text)

    morphemes = []
    while node:
        morpheme = {}
        morpheme['surface'] = node.surface
        morpheme['part_of_speech'] = node.feature.split(',')[0]
        morpheme['base_form'] = node.feature.split(',')[3]
        morphemes.append(morpheme)
        node = node.next

    return morphemes

def main():
    english_text = input("Enter English text: ")
    japanese_text = translate_to_japanese(english_text)
    print(f"Translated text: {japanese_text}")

    morphological_analysis = perform_morphological_analysis(japanese_text)
    print("\nMorphological Analysis:")
    for morpheme in morphological_analysis:
        print(f"Surface: {morpheme['surface']}, Part of Speech: {morpheme['part_of_speech']}, Base Form: {morpheme['base_form']}")

if __name__ == "__main__":
    main()

このプログラムは英語の文章を入力とし、googletrans ライブラリを使って日本語に翻訳し、MeCab ライブラリを使って翻訳された文章を形態素解析します。

googletransライブラリはサードパーティのライブラリであり、必ずしも最も正確な翻訳を提供するとは限らないことに注意してください。より正確な翻訳のためには、より安定したバージョンのgoogletrans` のような他のライブラリを使用するか、Google Cloud Translation API のような API を使用することを検討してください。

また、日本語は複雑なため、形態素解析の結果が完全でない可能性があることに注意してください。MeCab`ライブラリは翻訳されたテキストの形態素を理解するための良い出発点を提供します。

GPT-3.5

Creating a program that translates English text into Japanese and performs morphological analysis involves several steps. Here's a basic outline of how you can achieve this using Python and some popular libraries:

1. **Install Required Libraries**: You'll need to install the necessary libraries. For translation, you can use `googletrans` and for morphological analysis, you can use `mecab-python3`.

2. **Code Implementation**: Write Python code that takes English text as input, translates it into Japanese, and performs morphological analysis on the translated text.

```python
from googletrans import Translator
import MeCab

def translate_to_japanese(text):
    translator = Translator()
    translation = translator.translate(text, src='en', dest='ja')
    return translation.text

def morphological_analysis(text):
    tagger = MeCab.Tagger("-Owakati")  # Tokenize text
    tokens = tagger.parse(text)
    return tokens

def main():
    # Input English text
    english_text = input("Enter the English text: ")

    # Translate English text to Japanese
    japanese_text = translate_to_japanese(english_text)
    print("Translated Japanese text:", japanese_text)

    # Perform morphological analysis on translated text
    analyzed_text = morphological_analysis(japanese_text)
    print("Morphological analysis:", analyzed_text)

if __name__ == "__main__":
    main()
```

3. **Run the Program**: Run the Python program and input the English text you want to translate and analyze.

4. **Output**: The program will output the translated Japanese text and the result of morphological analysis.

Remember that this is a basic implementation. Depending on your requirements, you might need to handle exceptions, improve error handling, or enhance the functionality further. Additionally, you may need to install and configure MeCab properly for your environment.

以下は、Pythonを使用して英文を日本語に翻訳し、その後形態素解析を行うプログラムです。

from googletrans import Translator
import MeCab

def translate_to_japanese(text):
    translator = Translator()
    translation = translator.translate(text, src='en', dest='ja')
    return translation.text

def morphological_analysis(text):
    tagger = MeCab.Tagger("-Owakati")  # テキストをトークン化
    tokens = tagger.parse(text)
    return tokens

def main():
    # 英文を入力
    english_text = input("英文を入力してください: ")

    # 英文を日本語に翻訳
    japanese_text = translate_to_japanese(english_text)
    print("翻訳された日本語のテキスト:", japanese_text)

    # 翻訳されたテキストに対して形態素解析を実行
    analyzed_text = morphological_analysis(japanese_text)
    print("形態素解析:", analyzed_text)

if __name__ == "__main__":
    main()

プログラムを実行し、翻訳および形態素解析を行いたい英文を入力してください。その後、プログラムは翻訳された日本語のテキストと形態素解析の結果を出力します。

なお、これは基本的な実装です。必要に応じて、例外処理の追加や機能の拡張など、プログラムの改善を行うことができます。また、MeCabを環境に適切にインストールおよび構成する必要があるかもしれません。

Phi-3-miniとGPT-3.5は、完璧とは言えませんが基本的には正しいコードと説明を出力してくれたのに対し、OpenELMは全く見当違いの回答を出力しました。

Javaの日本語翻訳プロジェクトをインストールして使用する方法のようですが、そもそも形態素解析ではないことに加え、japanselectというプロジェクトは存在しません。

他のモデルと同じように、Pythonコードを出力してくれることを期待していたので残念です。

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

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

黒玉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.

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

OpenELM

Find the probability q that exactly 3 white balls are adjacent to exactly 1 red ball.

Find p + q.

Let's consider removing balls from the bag individually. When we remove the first ball, there are 2 balls remaining: (black, white). Since these balls were placed in the horizontal line independently, their order is irrelevant. So let's denote these balls as (B_1) and (W_1). Now if we remove ball (B_1), then either (B_2 = B_1) or (B_2 \neq B_1). If (B_2=B_1) then (W_2 = W_1). Similarly, if (B_2\neq B_1) then either (W_2=W_1) or (\overline{W_2}=\overline{W_1}). In either case, all balls (B_i) and (W_{i-1}) remain adjacent, and (W_i) and (\overline{W_{i-l}}) are adjacent, for (i=2,\dots,n). Thus, the configuration obtained after removing ball (B_n) consists of (n) black balls and (n-1) white balls. This process repeats itself recursively, until (n=0).

Now let's analyze the configurations when (n) is odd. Suppose (n=2k). Then (W_{2k}) and (\overline{w_{2k-1}}) are adjacent. Moreover, since (B_k) and (W_{(k-1)d}) remain adjacent, (B_k, W_{(k-1)(d+1)}) forms a closed polygon, denoted (\mathcal{P}{k,d}). Note that this polygon intersects both (W{2(k-1)+1}) and (\overline {W_{2k-2}}). Let (\mathcal{A}k) denote the event that (\mathcal{P}k) intersects (\overline {W_k}). Clearly, (\mathcal{A}{k}) occurs with probability (p). Furthermore, by symmetry (\mathcal{A}{\frac{k}{2}}) occurs with probability (q). Therefore, [\sum_{k=1}^{\infty}p^{k}q^{\frac{k}{d}}\leq\sum_{k=0}^{\infty}p^kq^{\frac{dk}{d}}\leq (pq)^{\frac{d}{d-1}}\leq e.] Combining these estimates completes the proof.

ちょうど3個の白球がちょうど1個の赤球に隣接する確率qを求めなさい。

p + q を求めなさい。

袋から玉を一つずつ取り除くことを考えてみましょう。最初のボールを取り除くと、(黒、白)の2つのボールが残ります。これらの玉はそれぞれ独立に横一列に置かれているので、順番は関係ありません。そこで、これらのボールを(B_1)と(W_1)とします。ここで(B_1)のボールを取り除くと、(B_2=B_1)か(B_2 ⑬ B_1)のどちらかになります。もし(B_2=B_1)なら、(W_2=W_1)。同様に、(B_2=B_1)なら、(W_2=W_1)か、(W_2=W_1)のどちらか。(B_i)と(W_{i-1})は隣接し、(W_i)と(we_{i-l})は隣接します。したがって、(B_n)のボールを取り除いた後の構成は、(n)個の黒ボールと(n-1)個の白ボールからなります。この処理を(n=0)まで再帰的に繰り返します。

では、(n)が奇数のときの構成を分析してみましょう。仮に(n=2k)とします。すると、(W_{2k})と( \overline{w_{2k-1}}) は隣接しています。さらに、(B_k)と(W_{(k-1)d})は隣接したままなので、(B_k, W_{(k-1)(d+1)})は閉じた多角形を形成し、(˶mathcal{P}{k,d})と表します。この多角形は(W{2(k-1)+1})と(W_{2k-2})の両方に交差していることに注意してください。(◆mathcal{A}k)は(◆mathcal{P}k)が(◆overline{W_k})と交差する事象を表します。明らかに、(˶mathcal{A}{k})は確率(p)で発生します。さらに、対称性により、(˶‾᷄‾᷅˵)は確率(q)で発生します。Therefore, [\sum_{k=1}^{\infty}p^{k}q^{\frac{k}{d}}\leq\sum_{k=0}^{\infty}p^kq^{\frac{dk}{d}}\leq (pq)^{\frac{d}{d-1}}\leq e.] これらの推定を組み合わせると、証明が完了します。

Phi-3-mini

To solve this problem, we can use combinatorics and probability theory. We need to find the probability that none of the red balls are adjacent to each other when 12 balls are arranged in a horizontal line.

First, let's calculate the total number of ways to arrange 12 balls from the bag without any restrictions. There are 12 balls in total, so the total number of arrangements is 12! (12 factorial).

Now, let's calculate the number of ways to arrange the balls such that none of the red balls are adjacent. We can approach this problem by first arranging the non-red balls and then placing the red balls in the gaps between them.

There are 3 black balls and 5 white balls, so there are 8 non-red balls. We can arrange these 8 balls in 8! ways.

Now, we need to place the 4 red balls in the gaps between the non-red balls. There are 9 gaps (before the first ball, between the balls, and after the last ball). We need to choose 4 of these gaps to place the red balls. This can be done in C(9, 4) ways, where C(n, k) is the binomial coefficient.

The probability p that none of the red balls are adjacent to each other is then:

p = (Number of ways to arrange non-red balls and red balls without adjacent red balls) / (Total number of ways to arrange 12 balls)

p = (8! * C(9, 4)) / 12!

p = (8! * 126) / 479001600

p ≈ 0.0000216

So, the probability that none of the red balls are adjacent to each other is approximately 0.00216%.

Note: This solution assumes that the balls are distinguishable, and the order in which they are removed from the bag matters. If the balls are indistinguishable, the problem becomes more complex and requires a different approach.

この問題を解くには、組み合わせ論と確率論を使います。12個のボールを横一列に並べたとき、赤いボールが1個も隣り合わない確率を求めます。
まず、袋から12個の玉を制限なしに並べる方法の総数を計算しましょう。ボールは全部で12個あるので、並べ方の総数は12通り!(12階乗)。
では、赤いボールが1つも隣接しないようにボールを並べる方法の数を計算してみましょう。この問題には、まず赤以外の玉を並べ、その隙間に赤の玉を入れるという方法があります。
黒いボールが3個、白いボールが5個なので、赤以外のボールは8個あります。この8個のボールを8通りに並べます。
次に、赤以外の玉の隙間に赤の玉を4個入れます。隙間は9つあります(最初のボールの前、ボールとボールの間、最後のボールの後)。これらの隙間のうち4つを選んで赤玉を置く必要があります。これはC(9, 4)の方法で行うことができ、C(n, k)は二項係数です。
赤玉が1つも隣接しない確率 p は
p = (赤玉と赤玉が隣接しないように並べる方法の数) / (12個の玉を並べる方法の総数)
p = (8! * C(9, 4)) / 12!
p = (8! * 126) / 479001600
p ≈ 0.0000216
つまり、赤いボールが1つも隣接しない確率は約0.00216%です。
注意:この解答は、ボールが区別でき、袋から取り出される順番が重要であることを仮定しています。ボールが区別できない場合、問題はより複雑になり、別のアプローチが必要になります。

GPT-3.5

To find the probability \( p \) that none of the red balls are adjacent to each other when arranging the balls in a horizontal line, we can use the concept of permutations.

First, let's calculate the total number of ways to arrange the 12 balls without any restrictions. This is equal to the permutation of 12 balls taken all at once:

\[ \text{Total arrangements} = P(12, 12) = 12! \]

Now, let's consider the restriction that none of the red balls are adjacent. We can treat the red balls as a single unit and find the number of arrangements of this unit and the other balls.

There are \( (12 - 3 + 1) = 10 \) positions where we can place the unit of red balls among the other balls (including at the beginning and at the end). Then, within this arrangement, we can permute the remaining 9 balls (3 black balls and 5 white balls) among themselves. So, the number of arrangements where none of the red balls are adjacent is:

\[ \text{Arrangements without adjacent red balls} = 10 \times P(9, 9) = 10 \times 9! \]

Therefore, the probability \( p \) that none of the red balls are adjacent to each other is:

\[ p = \frac{\text{Arrangements without adjacent red balls}}{\text{Total arrangements}} = \frac{10 \times 9!}{12!} \]

Let's calculate \( p \):

\[ p = \frac{10 \times 9!}{12!} \]

\[ p = \frac{10 \times 9!}{12 \times 11 \times 10 \times 9!} \]

\[ p = \frac{10}{12 \times 11} \]

\[ p = \frac{5}{66} \]

So, the probability \( p \) that none of the red balls are adjacent to each other is \( \frac{5}{66} \).

赤いボールが隣り合わない確率( p )を求めるには、ボールを横一列に並べる方法の総数を考え、その中で赤いボールが隣り合わないような並べ方の数を見つければ良いです。

まず、制約なしで12個のボールを並べる方法の総数を計算します。これは、12個のボールを全て一度に並べる置換組み合わせの数です。

[ \text{全ての並べ方} = P(12, 12) = 12! ]

次に、赤いボールが隣り合わないという制約を考慮します。赤いボールを1つの単位として扱い、その単位と他のボールの並べ方の数を見つけます。

赤いボールの単位を他のボールの間に配置することができる場所は、( (12 – 3 + 1) = 10 )箇所あります(始めと終わりを含む)。その後、残りの9個のボール(黒いボール3個と白いボール5個)の並べ方を考えます。したがって、赤いボールが隣り合わないような並べ方の数は次のようになります。

[ \text{赤いボールが隣り合わない並べ方} = 10 \times P(9, 9) = 10 \times 9! ]

したがって、赤いボールが隣り合わない確率( p )は以下の式で求められます。

[ p = \frac{\text{赤いボールが隣り合わない並べ方}}{\text{全ての並べ方}} = \frac{10 \times 9!}{12!} ]

これを計算しましょう。

[ p = \frac{10 \times 9!}{12!} ]

[ p = \frac{10 \times 9!}{12 \times 11 \times 10 \times 9!} ]

[ p = \frac{10}{12 \times 11} ]

[ p = \frac{5}{66} ]

ということは、赤い玉が1個も隣り合わない確率は、\frac{5}{66}となります。

結果はすべて不正解でした。

ただ、OpenELMはなぜか最後のほうで証明を始めてしまっており、全く私の意図を理解できていないように感じます。

他の2つのモデルは、正解はできなかったものの、問題への取り組み方は正しいです。

この検証でも、OpenELMは残念な結果になってしまいました。

ビジネスメールの作成

最後に、文章力を比較するため、以下のプロンプトを入力して丁寧なビジネスメールを作成させてみます。

Create a polite business email

丁寧なビジネスメールを作成して

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

OpenELM

For example: Dear Mr. Smith,

In the first paragraph, introduce yourself (your full name, title, and company), mention what brought you to this email (e.g., "I've been following your blog for a while now and wanted to connect"), and briefly summarize the purpose of your email (e.gy "I hope you can spare some time to discuss X").

In the second paragraph, state the main goal of your email ("My goal is to learn more about X"). This shows the recipient that you are taking initiative.

In the third paragraph, restate the problem succinctly ("The issue I'm facing right now revolves around X").

Now it's time to propose a solution ("Here's my idea on how we could achieve X"). Make sure you have carefully considered all possible approaches and limitations before sending this email. Remember, you want your recipient(s) to appreciate your thoroughness!

Finally, wrap things up with a request ("Would you be open to a short call next week?"). Don't forget to include your preferred time and date, and confirmation details (phone number, Zoom link, etc.).

Remember, there's no need to write an essay when communicating professionally. Keep your sentences clear, concise, and direct. The clearer your message, the better your chances of getting a favorable response. Good luck!

例 :スミスさんへ

最初の段落では、自己紹介(フルネーム、肩書き、会社名)、このメールに至った経緯(例:「以前からあなたのブログを見ていて、連絡を取りたいと思っていました」)、メールの目的(例:「Xについて議論するために、お時間をいただけると幸いです」)を簡潔にまとめます。

段落目では、メールの主な目的を述べます(”My goal is to learn more about X”)。これは、あなたがイニシアチブをとっていることを相手に示すものです。

第3段落では、問題点を簡潔に述べます(”The issue I’m now faced revolves around X”)。

次に、解決策を提案しましょう(「どうすればXを達成できるか、私の考えを述べます」)。このメールを送る前に、考えられるすべてのアプローチと制限を注意深く検討したことを確認してください。受信者にあなたの徹底した姿勢を評価してもらいたいことを忘れないでください!

最後に、お願いを伝えましょう(「来週、短い電話でも構いませんか?) 希望の日時と確認事項(電話番号、Zoomのリンクなど)を忘れずに。

覚えておいてほしいのは、プロとしてコミュニケーションをとるときに、エッセイを書く必要はないということです。文章は明瞭、簡潔、率直を心がけましょう。メッセージが明確であればあるほど、好意的な返事をもらえる可能性が高まります。頑張ってください!

Phi-3-mini

Subject: Request for Meeting to Discuss Potential Collaboration

Dear [Recipient's Name],

I hope this email finds you well. My name is [Your Name], and I am the [Your Position] at [Your Company]. I am reaching out to express my admiration for the work your team has been doing at [Recipient's Company].

I have been following your company's progress and am impressed by the innovative solutions you have developed in the [specific industry or field]. I believe that a collaboration between our companies could lead to mutually beneficial outcomes and further advancements in our respective fields.

I would greatly appreciate the opportunity to discuss this potential collaboration further. If it suits your schedule, I would be delighted to arrange a meeting at your earliest convenience. Please let me know a date and time that works best for you, and I will make the necessary arrangements.

Thank you for considering my request. I look forward to the possibility of working together and exploring the potential synergies between our companies.

Best regards,

[Your Name]
[Your Position]
[Your Company]
[Your Contact Information] 

件名 協働の可能性について話し合うための面談のお願い

拝啓 [受信者名]様、

このメールにお気づきのことと存じます。私の名前は[あなたの名前]であり、[あなたの会社]の[あなたの役職]です。このたびは、[受信者の会社]で貴社のチームが行っている仕事に敬意を表するため、ご連絡を差し上げました。

貴社の発展を拝見し、[特定の業界や分野]で開発された革新的なソリューションに感銘を受けております。両社が協力することで、互いにとって有益な成果が得られ、それぞれの分野でさらなる進歩が期待できると信じています。

このコラボレーションの可能性について、さらに話し合う機会を頂ければ幸いです。もしご都合がよろしければ、できるだけ早くお会いできるよう手配させていただきます。ご都合のよい日時をお知らせください。

私の依頼をご検討いただき、ありがとうございます。両社が協力し、シナジー効果を発揮できることを楽しみにしております。

よろしくお願いいたします

[あなたの名前]
[あなたの役職]
[あなたの会社名]
[連絡先]

GPT-3.5

Subject: Inquiry Regarding Product Availability and Pricing

Dear [Recipient's Name],

I hope this email finds you well.

My name is [Your Name], and I am reaching out to inquire about the availability and pricing of [specific product/service] offered by your esteemed company.

After conducting thorough research, I am particularly impressed by the reputation and quality that your organization upholds in the industry. Therefore, I am keen on exploring the possibility of incorporating [specific product/service] into our operations.

Could you kindly provide me with detailed information regarding:

1. The availability of [specific product/service].
2. Pricing structure, including any discounts or bulk rates available.
3. Any customization options or additional services offered.
4. Terms of delivery and payment methods accepted.

Additionally, if possible, I would appreciate any relevant product documentation or brochures that could assist me in understanding the features and benefits of [specific product/service] better.

Please feel free to reach out to me at your earliest convenience to discuss further or schedule a meeting if necessary. Your prompt attention to this matter would be greatly appreciated.

Thank you for considering my inquiry. I look forward to the possibility of establishing a mutually beneficial business relationship with your esteemed company.

Warm regards,

[Your Name]
[Your Position/Company Name]
[Contact Information]

件名 製品の在庫および価格に関するお問い合わせ

拝啓 [受信者名]様、

本メールはご健勝のことと存じます。

御社が提供されている[特定の製品/サービス]の在庫状況と価格についてお尋ねしたく、ご連絡いたしました。

徹底的な調査の結果、貴社が業界で維持している評判と品質に特に感銘を受けました。そこで、[特定の製品/サービス]を当社の業務に取り入れる可能性を検討したいと考えています。

つきましては、以下の詳細情報をご提供いただけますでしょうか:

  1. 特定の製品/サービス]の入手可能性。
  2. 割引や一括料金などの価格体系
  3. 提供されるカスタマイズオプションまたは追加サービス。
  4. 納品条件と支払い方法

さらに、可能であれば、[特定の製品/サービス]の特徴や利点をよりよく理解するのに役立つ、関連する製品資料やパンフレットがあればありがたく存じます。

ご都合がよろしければ、ご遠慮なくご連絡ください。迅速なご対応をお願いいたします。

この度は私の問い合わせをご検討いただき、ありがとうございました。御社と相互に有益なビジネス関係を築けることを楽しみにしております。

よろしくお願いいたします、

[ あなたの名前]
[あなたの役職/会社名]
[連絡先]

結果は、OpenELMは実際のビジネスメールではなく、ビジネスメールを作成する上でのアドバイスを出力しました。

内容自体は具体的で問題ないですが、ビジネスメールを作成してという指示を理解していないようです。

Phi-3-miniとGPT-3.5は、非常に丁寧でそのまま使えそうなビジネスメールを作成してくれているので、その差は大きいです。

今回の検証の結果、OpenELMはすべての項目でプロンプトの意図が理解できていないか、理解できていても誤った回答を出力してしまいました。

同規模であるPhi-3-miniは、すべての項目でプロンプトの意図を理解し、GPT-3.5に匹敵する非常に精度の高い回答を出力してくれたので、かなりの性能に差があると感じました。

なお、Metaの最新オープンソースLLMであるLlama 3について知りたい方はこちらの記事をご覧ください。

OpenELMはiPhoneでも動作する超軽量LLM

OpenELMは、Appleが公開した最新の小型LLMで、270M、450M、1.1B、3Bという4つのサイズのモデルが公開されています。非常に軽量であり、実行コストが低く抑えられているため、iPhoneで動作することも想定されています。

Appleデバイス上のローカルで実行するための「MLXライブラリへの変換コード」も公開されています。

早速このMLXライブラリで、OpenELM-270Mの16ビットモデルをMac上で動かしているユーザーの方がいらっしゃいましたが、このように非常に高速に動作しています。

このように、軽量さや推論速度の速さが特徴のOpenELMですが、性能面も妥協していません。

ただ、実際に使ってみた感想は、プロンプトの意図を理解する能力が低く、回答の精度も低いため、同時期に公開された同規模のLLMであるMicrosoftのPhi-3-miniとの性能差はかなり大きいと感じました。

Appleは、iOS18でこのOpenELMをiPhoneに搭載するという噂があり、2024年6月にあるiOS18の発表に注目が集まっています。

今後の動向に目が離せませんね!

サービス紹介資料

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

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

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

・システム間API連携

最後に

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

弊社では

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

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

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

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

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

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

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

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

投稿者

  • ゆうや

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

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