Semantic role labeling (SRL) is the task of mapping natural language sentences to predicate-argument structures, answering questions such as who did what to whom, when, and where. Traditional approaches rely on supervised parsers trained on PropBank or FrameNet annotations, which require expensive labeled data and struggle to generalize across domains. Large language models (LLMs) offer a different path. With careful prompting and structured output, they can perform zero-shot and few-shot SRL on arbitrary text, adapting to new genres without retraining. The challenge shifts from feature engineering to inference infrastructure: you need an API that delivers consistent structured responses, supports long inputs for document-level labeling, and remains economical when you are processing thousands of sentences or running agentic refinement loops. Oxlo.ai fits this need directly.
What Is Semantic Role Labeling?
In SRL, the goal is to identify predicates (typically verbs) and assign semantic roles to their arguments. For the sentence The chef cooked the meal in the kitchen with a knife yesterday, the predicate is cooked. The chef fills the Agent role (ARG0), the meal fills the Patient role (ARG1), the kitchen is a location modifier (ARGM-LOC), the knife is an instrument modifier (ARGM-MNR), and yesterday is a temporal modifier (ARGM-TMP). PropBank and FrameNet provide standardized role inventories, but building custom annotators for new domains has historically required training specialized sequence models on manually labeled corpora.
From Feature Engineering to Prompt Engineering
Modern LLMs encode broad syntactic and semantic knowledge from pretraining, letting you frame SRL as a structured extraction task. Instead of training a BiLSTM or BERT-based classifier, you describe the annotation scheme in the system prompt and ask the model to return JSON. This approach generalizes immediately to new predicates and domains, and it allows you to relax or tighten the role definitions without retraining. The tradeoff is inference cost and latency, especially when you feed long documents or run multi-step agentic pipelines that iterate over candidate predicates. Oxlo.ai addresses this with request-based pricing: one flat cost per API call regardless of prompt length. Unlike token-based providers such as Together AI, Fireworks AI, OpenRouter, Replicate, or Anyscale, your cost does not scale with input length, which makes long-context SRL and iterative agent workflows significantly more predictable.
A Zero-Shot SRL Pattern with JSON Mode
The most reliable way to extract structured roles from an LLM is to combine explicit instructions with JSON mode. Below is a complete example using the OpenAI Python SDK pointed at Oxlo.ai. We use Llama 3.3 70B, a general-purpose flagship model with strong instruction-following capabilities.
import openai
import json
client = openai.OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key="YOUR_OXLO_API_KEY"
)
system_prompt = (
"You are a precise semantic role labeler. Given a sentence, identify the main predicate "
"and all associated arguments using PropBank-style roles: ARG0 (Agent), ARG1 (Patient), "
"ARG2 (Benefactive/Attribute), ARGM-TMP (Time), ARGM-LOC (Location), ARGM-MNR (Manner/Instrument). "
"Return only a compact JSON object with keys: predicate, arguments (a list of objects with "
"role and text), and modifiers (a list of objects with type and text). Do not wrap the output in markdown."
)
user_prompt = "Sentence: The committee awarded the student a scholarship during the ceremony."
completion = client.chat.completions.create(
model="meta-llama/Llama-3.3-70B-Instruct",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
],
response_format={"type": "json_object"},
temperature=0.1,
)
result = json.loads(completion.choices[0].message.content)
print(json.dumps(result, indent=2))
Typical output looks like this:
{
"predicate": "awarded",
"arguments": [
{"role": "ARG0", "text": "The committee"},
{"role": "ARG1", "text": "the student"},
{"role": "ARG2", "text": "a scholarship"}
],
"modifiers": [
{"type": "ARGM-TMP", "text": "during the ceremony"}
]
}
Because Oxlo.ai is fully OpenAI SDK compatible, you can use the same response_format={"type": "json_object"} trick across Python, Node.js, or cURL with no client-side changes beyond the base URL.
Scaling to Documents and Agentic Pipelines
Sentence-level SRL is useful, but real-world applications often require document-level coherence. Coreference resolution, implicit argument recovery, and event coreference all benefit from processing paragraphs or full pages in a single pass. This is where context window size and pricing structure become critical. Oxlo.ai hosts models with extended context windows, including DeepSeek V4 Flash with a 1 million token context and Kimi K2.6 with 131K tokens, both capable of ingesting entire sections of text for global role disambiguation.
More importantly, Oxlo.ai’s request-based pricing means that sending a 10,000-token document costs the same as sending a 50-token sentence. For document-level SRL, iterative agentic refinement, or multi-turn conversational annotation, this can be 10 to 100 times cheaper than token-based billing. You can afford to run verification steps, such as asking a second model pass to check the completeness of the first extraction, without watching token meters accumulate.
Model Selection for SRL on Oxlo.ai
Oxlo.ai offers more than 45 models across seven categories. For SRL workloads, the following are particularly effective:
- Llama 3.3 70B: A reliable general-purpose workhorse for English SRL with strong JSON mode adherence.
- DeepSeek R1 671B MoE: Use this when you need deep reasoning to resolve implicit arguments or ambiguous predicate senses.
- Qwen 3 32B: Ideal for multilingual SRL and agent workflows that mix reasoning with tool use.
- DeepSeek V4 Flash: The efficient choice for long-document labeling, offering a 1M context window and near state-of-the-art open-source reasoning.
- Kimi K2.6 and Kimi K2.5: Strong options for advanced chain-of-thought reasoning, agentic coding, and vision-enabled SRL on documents that contain both text and images.
All of these models are available with no cold starts, so latency remains consistent whether you are sending sporadic evaluation batches or sustained production traffic.
Evaluation and Production Tips
LLM-based SRL is only as good as your evaluation harness. We recommend holding out a small set of manually annotated sentences that match your target domain, then measuring exact-match F1 for predicates and role spans. Keep temperature at 0.1 or lower to improve determinism, and always use JSON mode or function calling to avoid parsing free text. If you are running large-scale benchmarks or prompt-sensitivity sweeps, Oxlo.ai’s flat per-request pricing makes the cost of these experiments predictable. You can compare prompts and models without calculating token overhead for every run. For current plan details, see the Oxlo.ai pricing page.
Getting Started
Semantic role labeling no longer requires training custom parsers. With a robust prompt, JSON mode, and the right inference backend, you can deploy accurate, domain-adaptive SRL in minutes. Oxlo.ai provides the model variety, long-context capacity, and request-based economics that modern extraction pipelines need. Sign up for a free account to get 60 requests per day across 16+ free models, including DeepSeek V3.2, and start experimenting with the code above. If you are migrating from a token-based provider, the Enterprise plan offers dedicated GPUs and guaranteed savings. For full model listings and plan details, visit oxlo.ai/pricing.
Top comments (0)