0Pricing
LLM Apps in Production (RAG + Vector DB + Caching) · Ders

Veri Yükleme ve Metin Parçalama Temelleri

Yapılandırılmamış verileri nasıl yükleyeceğinizi ve en iyi geri getirme performansı için etkili metin parçalama stratejilerini nasıl uygulayacağınızı öğrenin.

Veri Yükleme ve Metin Parçalama Temelleri, CoddyKit'te ücretsiz bir LLM Apps in Production (RAG + Vector DB + Caching) dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, LLM Apps in Production (RAG + Vector DB + Caching) öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. LLM Apps in Production (RAG + Vector DB + Caching) kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Loading Data for RAG

Welcome to Lesson 2! In Retrieval Augmented Generation (RAG), the first step is always to get your data ready. This means loading your information and preparing it for the Large Language Model (LLM).

Most real-world data is unstructured, meaning it doesn't fit neatly into rows and columns like a spreadsheet. Think of documents, web pages, or books.

Common Unstructured Data Sources

RAG systems can work with many types of unstructured data. Here are some common examples:

  • Text files (.txt): Simple, plain text documents.
  • PDFs (.pdf): Often contain text, images, and complex layouts.
  • Word Documents (.docx): Rich text with formatting.
  • Web Pages (.html): Content from websites.
  • Databases/APIs: Text extracted from various fields.

The goal is to extract the raw text content from these sources.

Basic Text File Loading

Let's start with the simplest form: loading a plain text file. In Python, you can easily read the entire content of a file into a string.

This example creates a small sample.txt and then reads its content.

import os

def load_text_file(filepath):
    with open(filepath, 'r', encoding='utf-8') as f:
        return f.read()

if __name__ == "__main__":
    # Create a dummy file for demonstration
    file_content = "This is the first line.\nThis is the second line.\nAnd a final line of text."
    with open("sample.txt", "w", encoding="utf-8") as f:
        f.write(file_content)
    
    # Load and print the content
    loaded_data = load_text_file("sample.txt")
    print("--- Loaded Content ---")
    print(loaded_data)

    # Clean up the dummy file
    os.remove("sample.txt")

Why Text Chunking is Essential

Once you've loaded your data, you can't usually send an entire book or long document directly to an LLM. Why not?

  • Context Window Limits: LLMs have a maximum amount of text they can process at once.
  • Cost: Sending very long texts is expensive, as you're typically charged per token.
  • Relevance: Shorter, focused pieces of text are often more relevant for retrieval.

This is where text chunking comes in.

Understanding the Context Window

The context window is like an LLM's short-term memory. It's the maximum number of tokens (words or sub-words) it can consider when generating a response.

  • If your input text is too long, it gets truncated.
  • The LLM only 'sees' what's in its context window.

Chunking breaks your big document into smaller, manageable pieces that fit within this window.

Basic Chunking: Fixed Size

The simplest chunking strategy is fixed-size chunking. You define a specific number of characters or tokens, and then split your document into chunks of that exact size.

For example, if you have a 1000-character document and a chunk size of 100, you'll get 10 chunks.

  • Pros: Easy to implement.
  • Cons: Can cut sentences or paragraphs in half, losing context.

Fixed-Size Chunking in Action

Here's a Python example demonstrating fixed-size chunking. Notice how the text is simply cut at regular intervals, which might sometimes break words or sentences.

def fixed_size_chunker(text, chunk_size):
    chunks = []
    for i in range(0, len(text), chunk_size):
        chunks.append(text[i : i + chunk_size])
    return chunks

if __name__ == "__main__":
    sample_text = "Large language models are powerful tools for text generation and understanding. However, they have limitations, especially with very long inputs due to their context window size."
    
    chunk_size = 40
    chunks = fixed_size_chunker(sample_text, chunk_size)
    
    print(f"Original text length: {len(sample_text)}")
    print(f"Chunk size: {chunk_size}")
    print("--- Chunks ---")
    for i, chunk in enumerate(chunks):
        print(f"Chunk {i+1} ({len(chunk)} chars): '{chunk}'")

Improving Context with Overlap

Fixed-size chunking can be problematic if important context is split across two chunks. To mitigate this, we use overlapping chunks.

With overlap, each new chunk starts a bit before the previous one ended. This ensures that some text appears in multiple chunks, preserving continuity.

  • A common overlap size is 10-20% of the chunk size.
  • It helps the LLM connect ideas even if they span chunk boundaries.

Overlapping Chunking Example

See how adding an overlap helps maintain context. The start of each new chunk includes some text from the end of the previous one.

def overlapping_chunker(text, chunk_size, overlap_size):
    chunks = []
    start = 0
    while start < len(text):
        end = start + chunk_size
        chunk = text[start:end]
        chunks.append(chunk)
        start += chunk_size - overlap_size
        if start < 0: # Handle cases where overlap > chunk_size initially
            start = 0
    return chunks

if __name__ == "__main__":
    text_data = "The quick brown fox jumps over the lazy dog. Dogs are mammals and often friendly animals."
    
    chunk_size = 30
    overlap_size = 10
    chunks = overlapping_chunker(text_data, chunk_size, overlap_size)
    
    print(f"Original text length: {len(text_data)}")
    print(f"Chunk size: {chunk_size}, Overlap size: {overlap_size}")
    print("--- Overlapping Chunks ---")
    for i, chunk in enumerate(chunks):
        print(f"Chunk {i+1} ({len(chunk)} chars): '{chunk}'")

Check Your Understanding

You've learned about loading data and basic chunking strategies. Now, let's test your knowledge!

Recap: Data Loading & Chunking

Great job! In this lesson, we covered the foundational steps of preparing data for RAG applications:

  • Data Loading: Extracting raw text from various unstructured sources like text files, PDFs, and web pages.
  • Text Chunking: The essential process of breaking down long documents into smaller, manageable pieces.
  • Context Window: Understanding the LLM's limitation on input text length (measured in tokens).
  • Chunking Strategies: Explored basic fixed-size chunking and the improved method of fixed-size chunking with overlap to preserve context.

Next, we'll see how these chunks are used to build a simple RAG pipeline!

Sıkça Sorulan Sorular

“Veri Yükleme ve Metin Parçalama Temelleri” dersi ücretsiz mi?

Evet — “Veri Yükleme ve Metin Parçalama Temelleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve LLM Apps in Production (RAG + Vector DB + Caching) kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. LLM Apps in Production (RAG + Vector DB + Caching) kursu toplamda 4 dersten oluşur.

“Veri Yükleme ve Metin Parçalama Temelleri” dersinde ne öğreneceğim?

Yapılandırılmamış verileri nasıl yükleyeceğinizi ve en iyi geri getirme performansı için etkili metin parçalama stratejilerini nasıl uygulayacağınızı öğrenin. LLM Apps in Production (RAG + Vector DB + Caching) ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

LLM Apps in Production (RAG + Vector DB + Caching) öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te LLM Apps in Production (RAG + Vector DB + Caching), başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“Veri Yükleme ve Metin Parçalama Temelleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu LLM Apps in Production (RAG + Vector DB + Caching) dersinde kod yazıp çalıştırabilir miyim?

Evet. Her LLM Apps in Production (RAG + Vector DB + Caching) dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. LLM Sağlayıcısı Seçme
  2. Veri Yükleme ve Metin Parçalama Temelleri
  3. Basit Bir RAG İşlem Hattı Oluşturma
  4. RAG Uygulamanızı Sınama ve Değerlendirme
← LLM Apps in Production (RAG + Vector DB + Caching) Sayfasına Dön