GIA Universidad de La HabanaUniversity of Havana

Pumpking

Troceado de documentos para RAGDocument chunking for RAG

Convierte un documento en un árbol de fragmentos para buscar y recuperar sobre él. Las estrategias básicas funcionan sin red; las avanzadas piden a un modelo entidades, resúmenes o temas.Turns a document into a tree of chunks to search and retrieve over. The basic strategies run offline; the advanced ones ask a model for entities, summaries or topics.

pip install git+https://github.com/gia-uh/pumpking

Un ejemploAn example

from pumpking.pipeline import PumpkingPipeline, Step
from pumpking.strategies.basic import ParagraphChunking, SentenceChunking

text = "La Habana tiene muchos barrios. El Vedado es uno.\n\nCentro Habana queda al lado."
pipeline = PumpkingPipeline(Step(ParagraphChunking()) >> Step(SentenceChunking()))
doc = pipeline.run(text)

def show(node, depth=0):
    for chunk in node.results:
        print("  " * depth + chunk.content)
    for branch in node.branches:
        show(branch, depth + 1)

for node in doc.branches:
    show(node)

Camino a la 1.0 · licencia MITOn the way to 1.0 · MIT licence