vecs icon indicating copy to clipboard operation
vecs copied to clipboard

Markdown `AdapterStep` for chunking by heading

Open olirice opened this issue 2 years ago • 3 comments

Context

Markdown is a common format for documents ingested into vector systems and has more exploitable structure than simple text.

This task is to create an vecs.adapters.base.AdapterStep that handles chunking markdown by heading.

Ideally it would also accept parameters for

  • The maximum number of words in each chunk

e.g.

from vecs.adapters import MarkdownChunker

MarkdownChunker(
  max_tokens=512
)

olirice avatar Jul 11 '23 14:07 olirice

Will give this a go if wanted

jbritain avatar Jul 11 '23 20:07 jbritain

According to the Markdown Guide

Markdown applications don’t agree on how to handle a missing space between the number signs (#) and the heading name. For compatibility, always put a space between the number signs and the heading name.

Should we count headings without this space as valid?

###like this

jbritain avatar Jul 24 '23 23:07 jbritain

My vote would be to require the space

you could reference https://python.langchain.com/docs/modules/data_connection/document_transformers/text_splitters/markdown_header_metadata for ideas

olirice avatar Jul 25 '23 15:07 olirice