LLM Helpers
Rierino includes several Python helpers for fine-tuning and complementing GenAI models
LLM helpers provided by Rierino can be deployed as stand-alone Jobs for long running processes, serviced through Python-Java bridge to embed into saga flows, or served over our Python API runner, exposing these capabilities as following standalone API endpoints:
Tries pdfplumber first; falls back to Tesseract/Paddle OCR for scanned, rotated, or low-yield PDFs. Optionally chunks the extracted markdown.
Extracted text (and chunks when chunking is enabled).
Extracted text. null if no source; empty string if extraction yielded nothing.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.ocr/OCRProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 428
{
"args": {
"connections": [
{
"name": "local_fs",
"type": "fs",
"pandasOptions": []
}
],
"source": {
"connection": "local_fs",
"path": "/file/mail/260428/2b0af8f4-936b-4935-97fd-b351d486b257_invoice_text.pdf"
},
"parameters": {
"min_chars": 100,
"ocr_engine": "auto",
"ocr_page_min_chars": 50,
"dpi_retry": 300,
"extract": {},
"ocr": {
"device": "cpu",
"lang": "en"
},
"page": {
"dpi": 200,
"extract_tables": true,
"concatenate_pages": true,
"text_params": {
"layout": true
}
}
}
}
}{
"md": "# Invoice 2024\n\n## Billing Details\n...",
"chunks": [
{
"text": "# Invoice 2024\n\n## Billing Details\nAcme Corp ...",
"metadata": {
"index": 0,
"page_start": 1,
"page_end": 1,
"pages": [
1
],
"headings": [
"Invoice 2024",
"Billing Details"
],
"heading_path": "Invoice 2024 > Billing Details",
"char_count": 173,
"token_count": 48,
"is_table": false
}
}
]
}Renders each sheet as a Markdown table; sheet names become level-2 headings.
All sheets rendered as Markdown.
All sheets as Markdown tables. null if no source was provided.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.xlsx/XLSXProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 242
{
"args": {
"connections": [
{
"name": "local_fs",
"type": "fs"
}
],
"source": {
"connection": "local_fs",
"path": "/file/reports/data.xlsx"
},
"parameters": {
"excel": {
"usecols": [
"ID",
"Name",
"Amount",
"Date"
],
"dtype": {
"ID": "str"
}
},
"markdown": {
"floatfmt": ".2f"
}
}
}
}{
"md": "## Invoices\n\n| ID | Name | Amount |\n|---|---|---|\n| 1 | Acme | 100.00 |\n\n---\n\n"
}Converts PDFs, Office files, images, HTML, and audio into a chosen format, with an optional layout-aware chunking step.
Converted document (and chunks when chunking is enabled).
Converted document. null if no source or conversion failed.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.docling/DoclingProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 192
{
"args": {
"connections": [
{
"name": "s3",
"type": "s3"
}
],
"source": {
"connection": "s3",
"path": "docs/big-report.pdf"
},
"parameters": {
"format": "md",
"convert": {
"page_range": [
1,
50
],
"max_num_pages": 2000
}
}
}
}{
"format": "md",
"content": "# Report\n\n## Section 1\n..."
}Docling-native chunks.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.docling/ChunkerProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 123
{
"args": {
"source": {
"base64Data": "JVBERi0xLjQ...",
"filename": "report.pdf"
},
"parameters": {
"type": "hybrid",
"max_tokens": 512
}
}
}{
"chunks": [
{
"text": "text",
"metadata": {
"index": 1,
"page_start": null,
"page_end": null,
"pages": [
1
],
"headings": [
"text"
],
"heading_path": "text",
"char_count": 1,
"token_count": null,
"is_table": true,
"ANY_ADDITIONAL_PROPERTY": "anything"
}
}
]
}Chunks.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.chunk/ChunkProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 168
{
"args": {
"source": {
"text": "# Title\n\nSome long markdown to split ..."
},
"parameters": {
"strategy": "recursive",
"size_unit": "tokens",
"chunk_size": 512,
"chunk_overlap": 64
}
}
}{
"chunks": [
{
"text": "text",
"metadata": {
"index": 1,
"page_start": null,
"page_end": null,
"pages": [
1
],
"headings": [
"text"
],
"heading_path": "text",
"char_count": 1,
"token_count": null,
"is_table": true,
"ANY_ADDITIONAL_PROPERTY": "anything"
}
}
]
}Replaces detected PII with reversible <ENTITY_hex> placeholders (UUID mode) or Presidio operators. Supports custom entity lists with exact and fuzzy matching.
Anonymized text and reversal mapping.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.anonymizer/AnonymizerProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 354
{
"args": {
"parameters": {
"text": "Invoice from Acme Corp. for services rendered",
"uuid": true,
"analyzer": {
"language": "en",
"entities": [
"CUSTOM_ORG",
"PERSON",
"EMAIL_ADDRESS"
],
"score_threshold": 0.2
}
},
"lists": [
{
"entity": "CUSTOM_ORG",
"name": "companies",
"pattern": true,
"fuzzy": true,
"fuzzy_threshold": 0.85,
"records": [
{
"id": "42",
"label": "Acme Corporation Ltd."
}
]
}
]
}
}{
"result": "Invoice from <CUSTOM_ORG_a1b2c3d4> for services rendered",
"mapping": {
"<CUSTOM_ORG_a1b2c3d4>": {
"id": "42",
"label": "Acme Corporation Ltd.",
"text": "Acme Corp."
}
}
}Deanonymized result (string or body, plus per-field records in body mode).
Deanonymized string (text mode) or structure (body mode).
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.anonymizer/DeanonymizerProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 191
{
"args": {
"parameters": {
"mapping": {
"<CUSTOM_ORG_a1b2c3d4>": {
"id": "42",
"label": "Acme Corporation Ltd.",
"text": "Acme Corp."
}
},
"text": "Invoice from <CUSTOM_ORG_a1b2c3d4> for services rendered"
}
}
}{
"result": {
"seller": "Acme Corporation Ltd.",
"buyer": "Globex Corporation",
"amount": 1500
},
"records": {
"seller": {
"id": "42",
"label": "Acme Corporation Ltd.",
"text": "Acme Corp."
},
"buyer": {
"id": "99",
"label": "Globex Corporation",
"text": "Globex"
}
}
}Executes an ordered list of training steps (CPT, SFT, DPO, KTO, PPO, GRPO, Reward). Each step's base model defaults to the previous step's output.
Per-step training results.
Malformed request (bad args, unsupported format, or unresolvable source).
POST /api/request/rierino_llm.tuner/TuneProcess HTTP/1.1
Host: your-rierino-host
Content-Type: application/json
Accept: */*
Content-Length: 861
{
"args": {
"connections": [
{
"name": "s3-data",
"type": "s3"
}
],
"model": {
"id": "qwen-tuned",
"data": {
"name": "Qwen2.5-0.5B SFT+DPO",
"version": "1",
"status": "A",
"root": "rierino-models",
"directory": "qwen-tuned",
"steps": [
{
"id": "sft",
"parameters": {
"training": {
"method": "sft",
"model": "Qwen/Qwen2.5-0.5B",
"modelParams": {
"torch_dtype": "bfloat16"
},
"inputs": {
"path": "data/sft.jsonl",
"connection": "s3-data"
},
"batchSize": 4,
"epochs": 1,
"learningRate": 0.00002,
"peft": {
"r": 16,
"lora_alpha": 32,
"target_modules": "all-linear"
}
},
"optimization": {
"merge": true
}
}
},
{
"id": "dpo",
"parameters": {
"training": {
"method": "dpo",
"inputs": {
"hub_id": "trl-lib/ultrafeedback_binarized"
},
"batchSize": 2,
"learningRate": 0.000005,
"methodParams": {
"beta": 0.1,
"max_length": 1024
},
"peft": {
"r": 16,
"lora_alpha": 32,
"target_modules": "all-linear"
}
},
"optimization": {
"merge": true,
"push": true,
"hubModelId": "myorg/qwen-dpo"
}
}
}
]
}
}
}
}{
"model": "Qwen2.5-0.5B SFT+DPO",
"steps": [
{
"step": "sft",
"accepted": true,
"output_dir": "/work/qwen-tuned_1_sft",
"remote_path": "rierino-models/qwen-tuned",
"metrics": {
"train_loss": 1.23
}
},
{
"step": "dpo",
"accepted": true,
"hub_model_id": "myorg/qwen-dpo",
"metrics": {
"eval_loss": 0.44
}
}
]
}Last updated
