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- Párrafo, oración, ventana deslizante y troceado adaptativo, sin modelo y sin red.Paragraph, sentence, sliding-window and adaptive chunking, with no model and no network.
- Entidades, resúmenes, temas y contexto con cualquier modelo compatible con la API de OpenAI.Entities, summaries, topics and context with any OpenAI-compatible model.
- Pipelines que encadenan y ramifican estrategias con >> y |, y guardan el árbol completo.Pipelines that chain and branch strategies with >> and |, and keep the whole tree.
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