query
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRules for agents (read first)
Agent使用规则(请先阅读)
- For a specific term you can name, use bounded first — it's leaner than ranked search.
grep -C "term" file | head - Use query when grep would FLOOD, or when you have no reliable exact term: a common/ambiguous term over a corpus too large to scan (grep returns dozens of matches to sift), OR you don't know the document's exact wording (grep may return zero hits, sending you into repeated synonym guessing). query ranks the best passages and returns a bounded top-k, so it keeps context small.
- Small (1-2) for a single fact;
-kfor non-English so inflected/umlaut forms match (German--language <lang><->Antrag).Anträge - Build an index () only for many queries over the same corpus.
--emit-index
- 若能明确指定术语,优先使用受限的—— 它比排序检索更高效。
grep -C "term" file | head - 当grep返回结果过多,或无可靠精确术语时使用query: 比如在过大的语料库中搜索常见/模糊术语(grep返回数十个匹配项需逐一筛选),或者不清楚文档的确切表述(grep可能返回零结果,导致你反复尝试同义词)。query会对最相关的段落进行排序,并返回数量受限的前k个结果,因此能保持上下文范围可控。
- 针对单一事实使用较小的值(1-2);针对非英文文本使用
-k参数,使变形词/带变音符号的词也能匹配(例如德语--language <lang>与Antrag)。Anträge - 仅当需要对同一语料库进行多次查询时,才构建索引()。
--emit-index
Query a document
文档查询
Ranked search over an already-extracted text or Markdown file. You give it a natural-language query; it returns the most relevant line windows (with line numbers), not the whole document. This is the "parse once, then query the file" pattern: convert a PDF a single time, then ask as many questions as you like against the cheap, local text.
This is built for agent economy. A converted document can be tens of thousands of lines and will blow out your context window if you read it back. Querying returns only the handful of passages that matter, with line numbers you can use for a precise follow-up read.
针对已提取的文本或Markdown文件进行排序检索。你输入自然语言查询,它会返回最相关的行窗口(带行号),而非整个文档。这是「解析一次,多次查询」的模式:将PDF转换一次,之后就可以针对本地的低成本文本随意提问。
该工具专为Agent经济性设计。转换后的文档可能有数万行内容,若直接读取会超出上下文窗口。查询仅返回少量关键段落,同时提供行号,你可借助行号进行精准的后续读取。
When to use this
使用场景
- Use when you have a converted file and a question — "what's the termination clause", "where are the FY24 revenue figures", "does this mention indemnification". It ranks every line and hands back the best windows.
query - Use /
pdf-to-markdownfirst to produce the file.pdf-to-textdoes not parse PDFs; it searches their extracted text.query - Don't read the whole converted file into context to find one thing, and don't run grep after grep — that's what this replaces. One ranked query beats many exact-match passes when you don't know the document's exact wording.
- 当你有转换后的文件并需要提问时使用—— 例如「终止条款是什么」「FY24营收数据在哪里」「文档中是否提及赔偿」。它会对每一行进行排序,并返回最优的内容窗口。
query - 先使用/
pdf-to-markdown生成文件。pdf-to-text不解析PDF,仅搜索已提取的文本。query - 不要为了找一个内容而读取整个转换后的文件,也不要反复运行grep——这正是本工具要替代的操作。当你不清楚文档确切表述时,一次排序检索胜过多次精确匹配查询。
Related Nutrient skills
相关Nutrient技能
query- — PDF → structured Markdown (headings, lists, tables); best for most RAG / LLM-context work.
pdf-to-markdown - — PDF → layout-preserving plain text; best when column/tabular alignment must survive.
pdf-to-text
query- —— 将PDF转换为结构化Markdown(包含标题、列表、表格);最适合大多数RAG/LLM上下文场景。
pdf-to-markdown - —— 将PDF转换为保留布局的纯文本;最适合需要保留列/表格对齐格式的场景。
pdf-to-text
Usage
使用方法
Before running any commands, set to the absolute path of the directory containing this SKILL.md file. Use in all commands below.
SKILL_DIR$SKILL_DIR/bin/queryThe wrapper installs the platform-specific binary into from the CDN (cached; it only checks for updates every 6 hours). The same binary backs , , , and ; installing any one of these skills gets you the same install — so once a PDF is converted you can search it with this skill.
$SKILL_DIR/bin/query~/.local/share/nutrient/cli/pdf-to-markdownpdf-to-textqueryself-update~/.local/share/nutrient/cli/bash
$SKILL_DIR/bin/query text INPUT.md "your natural-language query" [-k N] [-e N]- — the extracted text or Markdown file (the output of
INPUT.md/pdf-to-markdown), or a prebuilt index (see below). The input type is auto-detected.pdf-to-text - — natural-language query, matched case-insensitively. Put several relevant terms in one query; BM-25 rewards rare, on-topic words, so a richer query ranks better.
"query" - — maximum number of windows to return (default 8). Keep it small; you usually want the top 1–3.
-k N - — context lines around each hit (default 5). Use
-e Nfor just the matching line, or a larger value when you need more surrounding context.-e 0
Each result is a window (1-based, inclusive) followed by those lines. Line numbers are global to the document, so you can at that exact range for full context.
Lines A-BRead INPUT.md运行任何命令前,将设置为包含本SKILL.md文件的目录绝对路径。以下所有命令均使用。
SKILL_DIR$SKILL_DIR/bin/query$SKILL_DIR/bin/query~/.local/share/nutrient/cli/pdf-to-markdownpdf-to-textqueryself-update~/.local/share/nutrient/cli/bash
$SKILL_DIR/bin/query text INPUT.md "your natural-language query" [-k N] [-e N]- —— 已提取的文本或Markdown文件(
INPUT.md/pdf-to-markdown的输出),或预构建的索引(见下文)。输入类型会自动检测。pdf-to-text - —— 自然语言查询,匹配时不区分大小写。在一个查询中包含多个相关术语;BM-25算法会对稀有且贴合主题的词给予更高权重,因此内容更丰富的查询排序结果更优。
"query" - —— 返回的最大窗口数量(默认值为8)。请保持该值较小;通常你只需要前1–3个结果。
-k N - —— 每个匹配结果周围的上下文行数(默认值为5)。使用
-e N仅返回匹配行,当需要更多上下文时可增大该值。-e 0
每个结果都是一个窗口(从1开始计数,包含首尾行),后面跟着对应行内容。行号是文档全局的,因此你可以在该精确范围内以获取完整上下文。
Lines A-BRead INPUT.mdReusing an index for repeated questions
为重复提问复用索引
If you'll ask several questions about the same document, build the index once and query that instead of rebuilding it every call:
bash
undefined如果你需要对同一文档提出多个问题,可一次性构建索引,之后直接查询索引,无需每次调用都重新构建:
bash
undefinedFirst call: emit a reusable index alongside the answer.
首次调用:在返回答案的同时生成可复用索引。
$SKILL_DIR/bin/query text INPUT.md "first question" --emit-index INPUT.idx
$SKILL_DIR/bin/query text INPUT.md "first question" --emit-index INPUT.idx
Later calls: query the index — it's self-contained and skips the rebuild.
后续调用:查询索引——索引是自包含的,无需重新构建。
$SKILL_DIR/bin/query text INPUT.idx "second question"
$SKILL_DIR/bin/query text INPUT.idx "third question"
The index is a self-describing file (it carries the document's lines), so `$SKILL_DIR/bin/query text INPUT.idx "..."` needs nothing else. The wrapper auto-detects whether you passed text or an index — same command either way.$SKILL_DIR/bin/query text INPUT.idx "second question"
$SKILL_DIR/bin/query text INPUT.idx "third question"
索引是自描述文件(包含文档的行内容),因此`$SKILL_DIR/bin/query text INPUT.idx "..."`无需其他文件。包装器会自动检测你传入的是文本还是索引——两种情况使用同一命令。Workflow
工作流程
- Convert once: run or
pdf-to-markdownto producepdf-to-text/INPUT.md. Do this a single time per document.INPUT.txt - Query, don't read: ask your question with . Do not read the full converted file into context to answer — that's the cost this skill exists to avoid.
$SKILL_DIR/bin/query text INPUT.md "..." - Use the line numbers: the windows are usually enough to answer directly. If you need more, at the reported
Read INPUT.mdrange — a targeted read, not the whole file.Lines A-B - Don't waste time: for repeat questions on the same document, reuse the index (above) so each query skips the rebuild.
--emit-index - Report concisely: answer from the returned windows. Don't paste the whole document back to the user.
- 转换一次:运行或
pdf-to-markdown生成pdf-to-text/INPUT.md。每个文档仅需转换一次。INPUT.txt - 查询而非读取:使用提问。不要为了回答问题而读取整个转换后的文件——这正是本技能要避免的成本。
$SKILL_DIR/bin/query text INPUT.md "..." - 使用行号:返回的窗口通常足以直接回答问题。若需要更多内容,可在报告的范围内
Lines A-B——进行针对性读取,而非读取整个文件。Read INPUT.md - 避免浪费时间:对同一文档重复提问时,复用生成的索引(见上文),这样每次查询都无需重新构建索引。
--emit-index - 简洁汇报:基于返回的窗口内容作答。不要将整个文档粘贴给用户。
Tips for good queries
优质查询技巧
- Be specific and lexical. BM-25 is keyword ranking, not embeddings — it matches the words you give it. Use the terms you expect on the page ("indemnification", "net revenue", "effective date"), including synonyms, rather than a vague paraphrase.
- One rich query beats many narrow ones. Stack the relevant terms into a single query instead of issuing several.
- Adjust context with , not by reading the file. The default
-ealready gives a generous window; raise it for more surrounding text, or drop to-e 5for just the matching line. Only fall back to a full-e 0at the reported range when you truly need the wider section.Read - Raise only when you expect multiple distinct mentions. For a single fact,
-kis enough.-k 1
- 具体且用词精准。BM-25是关键词排序算法,而非嵌入模型——它匹配你输入的词汇。使用你预期会在文档中出现的术语(如「赔偿」「净收入」「生效日期」),包括同义词,而非模糊的转述。
- 一次丰富查询胜过多次窄范围查询。将相关术语整合到一个查询中,而非多次发起查询。
- 使用调整上下文,而非读取整个文件。默认的
-e已提供足够的上下文;需要更多周边文本时增大该值,仅需匹配行时可设为-e 5。仅当确实需要更广泛的内容时,才在报告的范围内进行完整-e 0操作。Read - 仅当预期存在多个不同提及内容时才增大值。针对单一事实,
-k足够。-k 1
Troubleshooting
故障排查
- (printed to stdout, exit 0): nothing ranked above the relevance threshold — the query words don't appear, or are too common. Try different/rarer terms, or
No relevant matches found. This is a message, not document content; don't treat it as a result.--mode lenient - Truly empty output / no text to search: the converted file has no text (an image-only PDF converts to an empty file; searches text only and does not OCR). Re-check the
query/pdf-to-markdownconversion before re-querying.pdf-to-text - Hits look off-topic: the query was too generic, so common words dominated. Add rarer, more specific terms, or tighten with .
--mode strict - Inflected words missed (e.g. "terminate" vs "termination"): pass (or another ISO code) to enable stemming; the default is no stemming, exact word forms only. Run
--language enfor the full flag list.$SKILL_DIR/bin/query --help - Non-zero exit code: read stderr. Common causes — the input file doesn't exist, or (on the very first run) a network issue while downloading the binary.
- First run is slow: the wrapper downloads the platform binary once (~a few seconds); later runs use the cache. Per-query cost after that is dominated by a one-time index build, which removes for subsequent calls.
--emit-index
- (输出到标准输出,退出码0):没有结果超过相关性阈值——查询词汇未出现,或过于常见。尝试使用不同/更稀有的术语,或添加
No relevant matches found参数。这是提示信息,而非文档内容;不要将其视为结果。--mode lenient - 完全无输出/无文本可搜索:转换后的文件无文本内容(仅含图片的PDF转换后为空文件;仅搜索文本,不支持OCR)。重新查询前,请检查
query/pdf-to-markdown的转换结果。pdf-to-text - 匹配结果偏离主题:查询过于宽泛,导致常见词汇主导排序。添加更稀有、更具体的术语,或使用参数收紧匹配规则。
--mode strict - 遗漏变形词(如「terminate」与「termination」):传入(或其他ISO代码)启用词干提取;默认不启用词干提取,仅匹配精确词形。运行
--language en查看完整参数列表。$SKILL_DIR/bin/query --help - 非零退出码:读取标准错误输出。常见原因——输入文件不存在,或(首次运行时)下载二进制文件时出现网络问题。
- 首次运行缓慢:包装器会一次性下载平台二进制文件(约几秒);后续运行会使用缓存。首次查询的耗时主要来自一次性索引构建,使用可避免后续查询的索引构建步骤。
--emit-index
License
许可证
Free for processing up to 1,000 documents per calendar month. Each call is one processing event and counts as one document against that quota — the same as a / conversion. The "parse once, query many" guidance saves your agent's context tokens and re-parse time, not the document quota (and an rebuild saved is time/CPU, not quota).
querypdf-to-markdownpdf-to-text--emit-indexCommercial license required for:
- processing over 1,000 documents/month
- redistributing the binary
- OEM/white-label use
Contact for commercial licensing.
sales@nutrient.io每个日历月最多可免费处理1000份文档。每次调用视为一次处理事件,计入文档配额——与 / 转换的计数规则相同。「解析一次,多次查询」的指导原则可节省Agent的上下文令牌和重复解析时间,但不节省文档配额(使用避免重新构建索引节省的是时间/CPU,而非配额)。
querypdf-to-markdownpdf-to-text--emit-index以下场景需商业许可证:
- 每月处理超过1000份文档
- 分发二进制文件
- OEM/白标使用
如需商业许可,请联系。
sales@nutrient.io