Summarization
Generate extractive summaries from text using the Knowledgator TypeScript SDK.
Example Usage
import { createClient } from '@knowledgator/typescript-sdk';
const kg = createClient();
const result = await kg.extract.summary({
text: `
The study examined the effects of climate change on coastal ecosystems.
Researchers found significant coral bleaching in tropical regions.
Temperature increases of 2°C led to 40% habitat loss.
The team recommends immediate conservation efforts.
Further research is needed to validate these results across different regions.
`,
prompt: "Extract the main findings and recommendations.",
threshold: 0.5,
adapter_id: "your-lora-adapter-id" // Optional LoRA adapter
});
for (const span of result.outputs) {
console.log(`[${span.score.toFixed(2)}] ${span.text}`);
}
LoRA Adapters vs. Open Models
adapter_id is for fine-tuned LoRA adapters attached to base services. If you trained a standalone Open Model, query it via kg.model(model_id).predict(...) instead.
---
## Expected Output
```text
[0.91] Researchers found significant coral bleaching in tropical regions.
[0.86] Temperature increases of 2°C led to 40% habitat loss.
[0.84] The team recommends immediate conservation efforts.
Result Object Structure
{
"outputs": [
{
"text": "Researchers found significant coral bleaching in tropical regions.",
"start": 82,
"end": 149,
"score": 0.91
},
{
"text": "Temperature increases of 2°C led to 40% habitat loss.",
"start": 154,
"end": 207,
"score": 0.86
},
{
"text": "The team recommends immediate conservation efforts.",
"start": 212,
"end": 263,
"score": 0.84
}
]
}