0Pricing
NLP Academy · レッスン

文書をチャンク分割して埋め込む

検索可能なナレッジベースを準備する

「文書をチャンク分割して埋め込む」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはNLP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 NLP Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Documents Are Too Big to Search Whole

A long PDF holds many topics at once. To retrieve precisely, you first split it into smaller pieces called chunks.

What Makes a Good Chunk

A good chunk is one coherent thought: a paragraph or two. Too big buries the answer; too small loses the surrounding context.

Splitting by Size

The simplest method cuts text every fixed number of characters or tokens. It is quick but can slice a sentence in half.

chunks = [text[i:i+500] for i in range(0, len(text), 500)]

Overlapping Chunks

To avoid cutting an idea apart, let chunks share an overlap. Repeating the last lines keeps context flowing across boundaries.

Splitting on Structure

Smarter splitters break on paragraphs or headings first. Respecting structure keeps each chunk on a single, clean topic.

From Text to Vectors

Search needs numbers, not words. An embedding turns each chunk into a dense vector that captures its meaning.

Meaning Lives in Distance

Embeddings place similar text close together. Two chunks about the same idea sit near each other in vector space.

Calling an Embedding Model

You pass text to an embedding model and get back a list of floats. The same model must encode both chunks and queries.

from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")

Encoding Your Chunks

Run every chunk through the model to build its vector. One call can encode the whole list at once for speed.

vectors = model.encode(chunks)

Vector Dimensions

Each vector has a fixed length, its dimension. A small model may give 384 numbers; larger ones give 768 or more.

print(vectors.shape)  # (n_chunks, 384)

Store Chunk and Vector Together

Keep each vector linked to its original text and source. Later you retrieve by vector but show the human-readable chunk.

Quick Check

Consider why we add overlap when splitting documents.

Recap

You split documents into chunks, optionally overlapping, then embed each into a vector. Store text and vector together for retrieval. ✅

よくある質問

「文書をチャンク分割して埋め込む」レッスンは無料ですか?

はい。「文書をチャンク分割して埋め込む」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。

「文書をチャンク分割して埋め込む」で何を学びますか?

検索可能なナレッジベースを準備する ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

NLP Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「文書をチャンク分割して埋め込む」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このNLP Academyレッスンでコードを書いて実行できますか?

はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. LLM に検索が必要な理由
  2. 文書をチャンク分割して埋め込む
  3. ベクトルストアでベクトル検索する
  4. 検索結果をプロンプトに組み込む
← NLP Academyに戻る