Skip to main content

Comprehend-it

The comprehend_inference tool allows LLMs and autonomous agents to execute zero-shot and few-shot text categorization and comprehension via Knowledgator's deterministic classification engine.


Tool Overview​

  • Tool Name: comprehend_inference
  • Underlying Endpoint: POST /inference/comprehend/
  • SDK Methods: kg.comprehend.it (Python) / kg.comprehend.it (TypeScript)
LoRA Adapters vs. Open Models

adapter_id is for fine-tuned LoRA adapters attached to the base Comprehend-it service. If you trained or deployed a standalone Open Model (e.g., GLiClass or GLiNER checkpoint), use the open_model_inference tool instead.


Parameters​

ParameterTypeRequiredDescription
textStringYesInput text to categorize or comprehend.
tasksObject / DictionaryYesDictionary of classification tasks following the Unified Inference API specification (e.g. {"topic": {"type": "classify", "labels": ["shipping", "billing"], "threshold": 0.5}}).
adapter_idStringNoOptional LoRA adapter ID for fine-tuned adapters (attaches KnowledgatorAPI-Model-ID header).
timeout_msIntegerNoRequest timeout in milliseconds (default: 60000 = 60s).

Example Usage​

Natural Language Prompt to Agent​

"Classify this customer review using Knowledgator: 'The delivery was lightning fast and the packaging kept the fragile items completely intact!' Possible categories: Shipping, Product Quality, Customer Service, Billing."

Tool Call Arguments​

{
"name": "comprehend_inference",
"arguments": {
"text": "The delivery was lightning fast and the packaging kept the fragile items completely intact!",
"tasks": {
"review_category": {
"type": "classify",
"labels": ["Shipping", "Product Quality", "Customer Service", "Billing"],
"threshold": 0.3
}
}
}
}

Tool Response​

{
"outputs": {
"review_category": {
"type": "classify",
"value": ["Shipping", "Product Quality"],
"scores": {
"Shipping": 0.942,
"Product Quality": 0.781,
"Customer Service": 0.125,
"Billing": 0.042
},
"threshold": 0.3
}
}
}