Repository navigation
RAG / embeddings, bounding boxes, output customization and non-text documents — what is supported (and what is the recommended pattern)? #559
Replies: 2 comments
|
For question 2, import bisect
def locate(segs, start, end): # segs: sorted (start, end, page, bbox)
i = max(bisect.bisect_right([s[0] for s in segs], start) - 1, 0)
return [(s[2], s[3]) for s in segs[i:] if s[0] < end and s[1] > start]With Docling, each item's Disclosure: I build commercial data tools in this area (details in my GitHub profile). |
|
For the parts beyond the coordinate mapping already discussed, I checked the 1.7.0 source and ran offline checks against that release. Retrieval and document formats LangExtract does not build an embedding index or retrieve documents for you. Its input is text, including text inside For retrieval, pass each chunk as a Chunking plus additional extraction passes processes the supplied text repeatedly to improve recall. It is not semantic retrieval. Retrieval can reduce the text sent to the model, but it can also omit the passage containing an answer. The built-in chunker is sentence/token based and has no Markdown-table model. For wide tables, create row groups upstream that retain the column headers and identifiers. If you repeat headers or otherwise rewrite chunks, keep a mapping for that rewritten text rather than adding a single offset to every result. Output fields and model requests Use The OpenAI provider builds its own formatting system message and puts the rendered extraction prompt in a user message. In 1.7.0, passing The alignment cases
These checks used synthetic model responses and a fake SDK client, with no live provider, Docling or PDF processing. I cannot promise future retrieval/native-document support or offset compatibility across releases on behalf of the maintainers. Pinning the version and retaining small alignment regression cases would make this pipeline easier to validate when upgrading. |
Uh oh!
There was an error while loading. Please reload this page.
Hi, and thanks for LangExtract.
Context: we extract structured fields from long, multi-page PDF reports (fund reports with tables) and need the user to click a value and see exactly where it came from on the page. We parse PDFs to Markdown with Docling and send the text to LangExtract (v1.7.0, OpenAI-compatible endpoint). I read the README, the
extract()docstring and the source before asking, so I'm sharing what I found first. Please correct me where I'm wrong.What I checked in v1.7.0
lx.extract()acceptsstr(text, or a URL whenfetch_urls=True) or an iterable ofDocument(text). I found no PDF, DOCX, PPTX, XLSX or image handling anywhere in the package.Extractionhasextraction_class,extraction_text,char_interval(start_pos/end_pos),alignment_status,extraction_index,group_index,descriptionandattributes. I found no page, bounding-box or coordinate concept.extract()parameters mentions an embedding model, vector store, top-k or retriever.Questions
1. RAG / semantic search
extract()on just those chunks? Is there a supported hook for this (a custom provider, aDocumentper chunk), and is retrieval something the project wants to support in the future?extraction_passesthe intended approach, and when would you recommend retrieval instead?2. Source location (bounding boxes)
char_intervalthe only location information by design?char_intervalin it? I found the third-partylangextract-doclingwrapper does this, but it is a PDF-path-only wrapper pinned tolangextract==1.6.0.extract()with severalDocuments (e.g. retrieved chunks), arechar_intervaloffsets always relative to that document's own text, and is that guaranteed to stay stable across versions?3. Customizing the output
attributesthe intended mechanism, and doesoutput_schemaallow extra per-extraction keys?max_output_tokensandtop_pbeing forwarded. Is there a supported way to set a request timeout and retries? The client appears to be created internally with onlyapi_key/base_url/organization.4. Document types
Document)? Are PDF, Word, PowerPoint, Excel and scanned images meant to be converted to text before the call? Is there a recommended converter or pipeline, and are there plans for native document support?Behaviours I ran into (could you confirm whether they are expected?)
a) Crash when every value is empty. If the model returns only empty values (e.g.
{"extractions": [{"Auditor": ""}]}, which is what a careful model returns when the field is not in the text it was given), alignment raises and the whole call fails:Would you prefer empty values to be dropped (treated as "not found")? We currently filter them out ourselves before alignment.
b)
MATCH_FUZZYfor an exact substring. For values like92.80taken fromSales Tax (8%): 92.80, the returnedchar_intervalpoints at exactly that text, yetalignment_statusisMATCH_FUZZY. Is that expected for tokens such as numbers with punctuation?c) Short values and repeated text. A one-digit value (e.g.
6) appears to align to the first occurrence in the text, which may not be the occurrence the model read. Is there a recommended way to disambiguate (e.g. passing surrounding context, a quote, or an anchor)?d) Tables. When
max_char_buffersplits a wide Markdown table, the header row ends up in a different chunk from its figures. Any guidance on chunking tables?All reactions