llm data_error ai_generated true

ValueError:无法从空文本创建 Document。节点内容为 None 或空字符串。

ValueError: Cannot create Document from empty text. Node content is None or empty string.

ID: llm/llamaindex-empty-node-from-parser

其他格式: JSON · Markdown 中文 · English
92%修复率
88%置信度
1证据数
2024-01-10首次发现

版本兼容性

版本状态引入弃用备注
llama-index==0.10.43 active
llama-index-core==0.10.43 active
pypdf==4.2.0 active

根因分析

LlamaIndex 文档解析器接收到无可提取文本的文件或块,通常来自二进制文件(无 OCR 的 PDF、图像)或空的 Markdown 部分。

English

LlamaIndex document parser received a file or chunk with no extractable text, often from binary files (PDFs without OCR, images) or empty markdown sections.

generic

官方文档

https://docs.llamaindex.ai/en/stable/module_guides/loading/documents/

解决方案

  1. Add a filter to skip files with no text before parsing: `if not file_content.strip(): continue` in the ingestion loop.
  2. Use a try-except block to catch the ValueError and log the file path for manual review: `try: doc = parser.parse(file); except ValueError as e: logger.warning(f'Skipping {file}: {e}')`
  3. For PDFs, enable OCR with `pypdf` or `pdfplumber` to extract text from scanned documents: `pip install pypdf[ocr]` and set `parser = SimpleDirectoryReader(required_exts=['.pdf'], file_extractor={'.pdf': PDFReader(ocr=True)})`

无效尝试

常见但无效的做法:

  1. 70% 失败

    The pipeline may silently drop valid data if the error is not caught and logged; the empty node is still created but breaks downstream indexing.

  2. 95% 失败

    Empty text is not a chunk size issue; the source file itself has no extractable content.

  3. 80% 失败

    Conversion may still produce empty files for binary inputs; the root cause is lack of extractable text, not format.