LinguistAgent: Reflective Dual-Agent Linguistic Annotation
This skill enables Claude to perform high-quality automated linguistic annotation by
implementing a reflective dual-agent architecture from the LinguistAgent paper. Instead
of a single-pass annotation, Claude alternates between an Annotator role (marking
target spans with XML tags and providing chain-of-thought justifications) and a
Reviewer role (critiquing annotations against a codebook, identifying false positives
and missed instances, and producing corrected output). This peer-review simulation
consistently outperforms single-agent annotation across zero-shot, few-shot, and
RAG-augmented paradigms.
When to Use
- When the user asks to annotate text for metaphors, metonymy, irony, or other figurative language
- When the user needs named entity recognition, sentiment labeling, or any token/span-level annotation with quality assurance
- When the user wants to compare annotation strategies (zero-shot vs. few-shot vs. codebook-augmented)
- When the user provides a codebook or annotation guidelines and wants automated labeling that respects those rules
- When the user asks to evaluate annotation quality against a gold standard using Precision, Recall, and F1
- When the user wants a self-correcting annotation pipeline that catches and fixes its own mistakes
Key Technique
The core insight of LinguistAgent is that annotation quality improves substantially when
you separate the task into two distinct agent roles that operate in sequence. The
Annotator receives the input text plus instructions (and optionally few-shot examples
or a full codebook) and produces annotations by wrapping target expressions in XML tags
(e.g., <Metaphor>broken heart</Metaphor>). Critically, the Annotator also emits a
structured reasoning field justifying each annotation decision based on the provided
linguistic protocol.
The Reviewer then receives both the original text and the Annotator's full output
(tags + reasoning). It performs comparative analysis: checking each tagged span against
the codebook to flag false positives, scanning the original text for missed instances to
flag false negatives, and producing a critique with a corrected version. This reflection
cycle exploits the fact that verification is easier than generation — the Reviewer
operates on a constrained evaluation task rather than open-ended labeling.
The system supports three paradigms of increasing knowledge injection: (1) Zero/Few-shot
Prompt Engineering, where the Annotator receives only instructions and optional
examples; (2) RAG / Full-Context, where the complete codebook is embedded in the
system prompt, leveraging long context windows; and (3) Fine-tuning, where a
domain-specialized model replaces the general-purpose Annotator. The Reviewer can use the
same or a different model, enabling cross-model validation. Evaluation uses token-level
binary sequences (1 = tagged, 0 = untagged) compared against gold standards to compute
Precision, Recall, and F1.
Step-by-Step Workflow
Define the annotation task and tag schema. Establish the target phenomenon
(e.g., metaphor, named entity, sentiment) and the XML tag names to use
(e.g., <Metaphor>, <Entity type="PER">). If the user provides a codebook or
annotation guidelines, parse them into a structured reference document.
Select the annotation paradigm. Choose zero-shot (instruction only), few-shot
(instruction + 2-5 annotated examples), or full-context RAG (instruction + complete
codebook). If the user has gold-standard examples, reserve some for few-shot and
the rest for evaluation.
Construct the Annotator system prompt. Include: (a) the task definition,
(b) the tag schema with examples of correct usage, (c) explicit instruction to wrap
target spans in XML tags within the original text, and (d) instruction to provide a
reasoning field as a JSON object explaining each annotation decision.
Run the Annotator pass. Send each text segment to the Annotator. Collect the
annotated text (with XML tags inline) and the reasoning chain. Store both in a
structured format (JSON with fields: original_text, annotated_text, reasoning).
Construct the Reviewer system prompt. Include: (a) the same codebook/guidelines
as the Annotator, (b) explicit instruction to compare the annotated text against
the original, (c) checklist: identify false positives (incorrectly tagged spans),
false negatives (missed spans), and boundary errors (partially tagged spans), and
(d) instruction to output a critique field and a corrected_text field.
Run the Reviewer pass. Send the original text, the Annotator's annotated text,
and the Annotator's reasoning to the Reviewer. Collect the critique and corrected
annotations.
Optional: iterate the reflection loop. If the Reviewer made corrections, feed
the corrected output back to a second Reviewer pass (or back to the Annotator) for
one additional round. Diminishing returns typically set in after 1-2 review cycles.
Extract tagged spans from the final annotated text. Parse XML tags to produce a
list of (span_text, start_index, end_index, label) tuples for downstream use.
Evaluate against gold standard (if provided). Convert both the system output and
the gold annotations into token-level binary vectors. Compute Precision (TP / (TP+FP)),
Recall (TP / (TP+FN)), and F1 (2PR / (P+R)). Report per-sentence and aggregate
scores.
Present results. Output the final annotated text, the list of extracted spans,
evaluation metrics (if applicable), and the Reviewer's critique log for
transparency.
Concrete Examples
Example 1: Metaphor Identification in Literary Text
User: "Annotate this paragraph for metaphors: 'The city was a jungle of concrete and steel. Her words cut through the silence like a knife, and he felt the weight of the world pressing down on his shoulders.'"
Approach:
- Define tag schema:
<Metaphor>...</Metaphor>
- Run Annotator (zero-shot):
{
"annotated_text": "The city was <Metaphor>a jungle of concrete and steel</Metaphor>. Her words <Metaphor>cut through the silence</Metaphor> like a knife, and he felt <Metaphor>the weight of the world pressing down on his shoulders</Metaphor>.",
"reasoning": {
"a jungle of concrete and steel": "Maps WILDERNESS domain onto CITY; concrete/steel are not literal jungle elements.",
"cut through the silence": "Maps PHYSICAL_CUTTING onto SPEECH; words cannot literally cut.",
"the weight of the world pressing down": "Maps PHYSICAL_BURDEN onto EMOTIONAL_STATE; responsibility is not literal weight."
}
}
- Run Reviewer — Reviewer checks for missed metaphor "like a knife" (simile, related but distinct), confirms the three annotations are valid per standard metaphor theory, and notes no false positives.
{
"critique": "All three annotations are valid metaphors. 'like a knife' is a simile (explicit comparison marker 'like'), which is conventionally excluded from metaphor annotation unless the codebook specifies otherwise. No false negatives detected for pure metaphor.",
"corrected_text": "(no changes needed)"
}
Output — Final spans:
| Span |
Start |
End |
Label |
| a jungle of concrete and steel |
17 |
47 |
Metaphor |
| cut through the silence |
59 |
82 |
Metaphor |
| the weight of the world pressing down on his shoulders |
112 |
167 |
Metaphor |
Example 2: Named Entity Annotation with Codebook
User: "I have these annotation guidelines: tag PERSON, ORG, and LOC entities. Annotate: 'Marie Curie worked at the University of Paris before moving to Warsaw. The Nobel Committee awarded her twice.'"
Approach:
- Tag schema:
<Entity type="PER">, <Entity type="ORG">, <Entity type="LOC">
- Embed codebook in system prompt (RAG paradigm).
- Annotator output:
<Entity type="PER">Marie Curie</Entity> worked at <Entity type="ORG">the University of Paris</Entity> before moving to <Entity type="LOC">Warsaw</Entity>. <Entity type="ORG">The Nobel Committee</Entity> awarded her twice.
- Reviewer catches boundary issue: "the" in "the University of Paris" — most NER conventions exclude articles from entity spans.
{
"critique": "Boundary error: 'the University of Paris' should be 'University of Paris' — articles are excluded per standard NER guidelines. All other spans are correct.",
"corrected_text": "<Entity type=\"PER\">Marie Curie</Entity> worked at the <Entity type=\"ORG\">University of Paris</Entity> before moving to <Entity type=\"LOC\">Warsaw</Entity>. The <Entity type=\"ORG\">Nobel Committee</Entity> awarded her twice."
}
Example 3: Batch Annotation with Evaluation
User: "Annotate these 3 sentences for sentiment-bearing words and evaluate against my gold standard."
Approach:
- Process each sentence through Annotator with
<Sentiment polarity="pos|neg"> tags.
- Run Reviewer on each to catch over/under-tagging.
- Convert final tags and gold standard to binary token vectors.
- Compute metrics:
Sentence 1: P=1.00 R=0.80 F1=0.89
Sentence 2: P=0.75 R=1.00 F1=0.86
Sentence 3: P=0.83 R=0.83 F1=0.83
---
Aggregate: P=0.86 R=0.88 F1=0.86
Best Practices
- Do: Always include the Reviewer pass — the paper shows it consistently outperforms
Annotator-only across all paradigms (zero-shot, few-shot, RAG).
- Do: Use structured JSON output with separate
reasoning and annotated_text
fields. This makes the Reviewer's job tractable and enables audit trails.
- Do: When a codebook exists, embed it fully in the system prompt (RAG paradigm)
rather than summarizing it. Full-context outperforms fragmented retrieval for
annotation guidelines.
- Do: Evaluate at the token level with binary vectors, not span-level exact match.
Token-level metrics are more granular and forgiving of minor boundary differences.
- Avoid: Running more than 2 Reviewer iterations. Diminishing returns set in quickly
and you risk the Reviewer introducing new errors through over-correction.
- Avoid: Using the same reasoning framing for both Annotator and Reviewer. The
Annotator should reason about why spans match the definition; the Reviewer should
reason about whether the Annotator's justifications hold up against the codebook.
Error Handling
- Malformed XML tags in Annotator output: If the Annotator produces unclosed or
nested tags incorrectly, re-prompt with explicit instruction to ensure well-formed XML.
Parse with a lenient XML parser that recovers partial tags.
- Reviewer disagrees on every annotation: This signals a prompt misalignment between
Annotator and Reviewer instructions. Verify both agents received identical codebook
definitions and tag schemas.
- Empty annotations (no spans tagged): The Annotator may be too conservative. Switch
from zero-shot to few-shot with 2-3 positive examples to calibrate detection threshold.
- Gold standard format mismatch: Ensure gold annotations use the same tokenization as
the system output. Normalize whitespace and punctuation handling before computing
binary vectors.
- Truncated JSON responses: For long texts, chunk input into segments of 200-500
tokens to avoid response truncation. Reassemble annotations after all chunks complete.
Limitations
- The dual-agent workflow doubles the token cost per annotation compared to single-pass
approaches. For budget-constrained bulk annotation, consider running the Reviewer only
on a sample to estimate quality.
- This approach works best for span-level and token-level annotation tasks. For
document-level classification (e.g., "is this document positive or negative?"), the
Reviewer adds less value since there is no span boundary to critique.
- The Reviewer cannot catch errors it doesn't know to look for. If the codebook is
ambiguous or incomplete, both agents will reproduce the same systematic biases.
- Performance depends on the base model's linguistic knowledge. Highly specialized
annotation tasks (e.g., phonological analysis, syntactic tree labeling) may still
require fine-tuned models rather than prompt-based approaches.
Reference
Paper: LinguistAgent: A Reflective Multi-Model Platform for Automated Linguistic
Annotation — Li, 2026. Key insight: a dual-agent
Annotator-Reviewer loop with structured reasoning fields consistently improves annotation
quality over single-pass LLM labeling across zero-shot, few-shot, and RAG paradigms.
1---2name: linguistagent-a-reflective-multimodel3description: Implements a reflective dual-agent (Annotator + Reviewer) workflow for automated linguistic annotation tasks such as metaphor identification, sentiment labeling, named entity recognition, and other sequence-labeling problems. The Annotator marks spans in text using XML tags and provides reasoning; the Reviewer critiques the annotations against a codebook, catching false positives and missed instances, then feeds corrections back for self-improvement. Trigger phrases: "annotate this text for metaphors", "dual-agent annotation pipeline", "reflective annotation workflow", "linguistic annotation with LLM review", "peer-review annotation system", "automated text labeling with self-correction"4---56# LinguistAgent: Reflective Dual-Agent Linguistic Annotation78This skill enables Claude to perform high-quality automated linguistic annotation by9implementing a reflective dual-agent architecture from the LinguistAgent paper. Instead10of a single-pass annotation, Claude alternates between an **Annotator** role (marking11target spans with XML tags and providing chain-of-thought justifications) and a12**Reviewer** role (critiquing annotations against a codebook, identifying false positives13and missed instances, and producing corrected output). This peer-review simulation14consistently outperforms single-agent annotation across zero-shot, few-shot, and15RAG-augmented paradigms.1617## When to Use1819- When the user asks to annotate text for **metaphors, metonymy, irony, or other figurative language**20- When the user needs **named entity recognition, sentiment labeling, or any token/span-level annotation** with quality assurance21- When the user wants to **compare annotation strategies** (zero-shot vs. few-shot vs. codebook-augmented)22- When the user provides a **codebook or annotation guidelines** and wants automated labeling that respects those rules23- When the user asks to **evaluate annotation quality** against a gold standard using Precision, Recall, and F124- When the user wants a **self-correcting annotation pipeline** that catches and fixes its own mistakes2526## Key Technique2728The core insight of LinguistAgent is that annotation quality improves substantially when29you separate the task into two distinct agent roles that operate in sequence. The30**Annotator** receives the input text plus instructions (and optionally few-shot examples31or a full codebook) and produces annotations by wrapping target expressions in XML tags32(e.g., `<Metaphor>broken heart</Metaphor>`). Critically, the Annotator also emits a33structured reasoning field justifying each annotation decision based on the provided34linguistic protocol.3536The **Reviewer** then receives both the original text and the Annotator's full output37(tags + reasoning). It performs comparative analysis: checking each tagged span against38the codebook to flag false positives, scanning the original text for missed instances to39flag false negatives, and producing a critique with a corrected version. This reflection40cycle exploits the fact that verification is easier than generation — the Reviewer41operates on a constrained evaluation task rather than open-ended labeling.4243The system supports three paradigms of increasing knowledge injection: (1) **Zero/Few-shot44Prompt Engineering**, where the Annotator receives only instructions and optional45examples; (2) **RAG / Full-Context**, where the complete codebook is embedded in the46system prompt, leveraging long context windows; and (3) **Fine-tuning**, where a47domain-specialized model replaces the general-purpose Annotator. The Reviewer can use the48same or a different model, enabling cross-model validation. Evaluation uses token-level49binary sequences (1 = tagged, 0 = untagged) compared against gold standards to compute50Precision, Recall, and F1.5152## Step-by-Step Workflow53541. **Define the annotation task and tag schema.** Establish the target phenomenon55 (e.g., metaphor, named entity, sentiment) and the XML tag names to use56 (e.g., `<Metaphor>`, `<Entity type="PER">`). If the user provides a codebook or57 annotation guidelines, parse them into a structured reference document.58592. **Select the annotation paradigm.** Choose zero-shot (instruction only), few-shot60 (instruction + 2-5 annotated examples), or full-context RAG (instruction + complete61 codebook). If the user has gold-standard examples, reserve some for few-shot and62 the rest for evaluation.63643. **Construct the Annotator system prompt.** Include: (a) the task definition,65 (b) the tag schema with examples of correct usage, (c) explicit instruction to wrap66 target spans in XML tags within the original text, and (d) instruction to provide a67 `reasoning` field as a JSON object explaining each annotation decision.68694. **Run the Annotator pass.** Send each text segment to the Annotator. Collect the70 annotated text (with XML tags inline) and the reasoning chain. Store both in a71 structured format (JSON with fields: `original_text`, `annotated_text`, `reasoning`).72735. **Construct the Reviewer system prompt.** Include: (a) the same codebook/guidelines74 as the Annotator, (b) explicit instruction to compare the annotated text against75 the original, (c) checklist: identify false positives (incorrectly tagged spans),76 false negatives (missed spans), and boundary errors (partially tagged spans), and77 (d) instruction to output a `critique` field and a `corrected_text` field.78796. **Run the Reviewer pass.** Send the original text, the Annotator's annotated text,80 and the Annotator's reasoning to the Reviewer. Collect the critique and corrected81 annotations.82837. **Optional: iterate the reflection loop.** If the Reviewer made corrections, feed84 the corrected output back to a second Reviewer pass (or back to the Annotator) for85 one additional round. Diminishing returns typically set in after 1-2 review cycles.86878. **Extract tagged spans from the final annotated text.** Parse XML tags to produce a88 list of `(span_text, start_index, end_index, label)` tuples for downstream use.89909. **Evaluate against gold standard (if provided).** Convert both the system output and91 the gold annotations into token-level binary vectors. Compute Precision (TP / (TP+FP)),92 Recall (TP / (TP+FN)), and F1 (2*P*R / (P+R)). Report per-sentence and aggregate93 scores.949510. **Present results.** Output the final annotated text, the list of extracted spans,96 evaluation metrics (if applicable), and the Reviewer's critique log for97 transparency.9899## Concrete Examples100101**Example 1: Metaphor Identification in Literary Text**102103User: "Annotate this paragraph for metaphors: 'The city was a jungle of concrete and steel. Her words cut through the silence like a knife, and he felt the weight of the world pressing down on his shoulders.'"104105Approach:1061. Define tag schema: `<Metaphor>...</Metaphor>`1072. Run Annotator (zero-shot):108109```json110{111 "annotated_text": "The city was <Metaphor>a jungle of concrete and steel</Metaphor>. Her words <Metaphor>cut through the silence</Metaphor> like a knife, and he felt <Metaphor>the weight of the world pressing down on his shoulders</Metaphor>.",112 "reasoning": {113 "a jungle of concrete and steel": "Maps WILDERNESS domain onto CITY; concrete/steel are not literal jungle elements.",114 "cut through the silence": "Maps PHYSICAL_CUTTING onto SPEECH; words cannot literally cut.",115 "the weight of the world pressing down": "Maps PHYSICAL_BURDEN onto EMOTIONAL_STATE; responsibility is not literal weight."116 }117}118```1191203. Run Reviewer — Reviewer checks for missed metaphor "like a knife" (simile, related but distinct), confirms the three annotations are valid per standard metaphor theory, and notes no false positives.121122```json123{124 "critique": "All three annotations are valid metaphors. 'like a knife' is a simile (explicit comparison marker 'like'), which is conventionally excluded from metaphor annotation unless the codebook specifies otherwise. No false negatives detected for pure metaphor.",125 "corrected_text": "(no changes needed)"126}127```128129Output — Final spans:130| Span | Start | End | Label |131|------|-------|-----|-------|132| a jungle of concrete and steel | 17 | 47 | Metaphor |133| cut through the silence | 59 | 82 | Metaphor |134| the weight of the world pressing down on his shoulders | 112 | 167 | Metaphor |135136---137138**Example 2: Named Entity Annotation with Codebook**139140User: "I have these annotation guidelines: tag PERSON, ORG, and LOC entities. Annotate: 'Marie Curie worked at the University of Paris before moving to Warsaw. The Nobel Committee awarded her twice.'"141142Approach:1431. Tag schema: `<Entity type="PER">`, `<Entity type="ORG">`, `<Entity type="LOC">`1442. Embed codebook in system prompt (RAG paradigm).1453. Annotator output:146147```148<Entity type="PER">Marie Curie</Entity> worked at <Entity type="ORG">the University of Paris</Entity> before moving to <Entity type="LOC">Warsaw</Entity>. <Entity type="ORG">The Nobel Committee</Entity> awarded her twice.149```1501514. Reviewer catches boundary issue: "the" in "the University of Paris" — most NER conventions exclude articles from entity spans.152153```json154{155 "critique": "Boundary error: 'the University of Paris' should be 'University of Paris' — articles are excluded per standard NER guidelines. All other spans are correct.",156 "corrected_text": "<Entity type=\"PER\">Marie Curie</Entity> worked at the <Entity type=\"ORG\">University of Paris</Entity> before moving to <Entity type=\"LOC\">Warsaw</Entity>. The <Entity type=\"ORG\">Nobel Committee</Entity> awarded her twice."157}158```159160---161162**Example 3: Batch Annotation with Evaluation**163164User: "Annotate these 3 sentences for sentiment-bearing words and evaluate against my gold standard."165166Approach:1671. Process each sentence through Annotator with `<Sentiment polarity="pos|neg">` tags.1682. Run Reviewer on each to catch over/under-tagging.1693. Convert final tags and gold standard to binary token vectors.1704. Compute metrics:171172```173Sentence 1: P=1.00 R=0.80 F1=0.89174Sentence 2: P=0.75 R=1.00 F1=0.86175Sentence 3: P=0.83 R=0.83 F1=0.83176---177Aggregate: P=0.86 R=0.88 F1=0.86178```179180## Best Practices181182- **Do:** Always include the Reviewer pass — the paper shows it consistently outperforms183 Annotator-only across all paradigms (zero-shot, few-shot, RAG).184- **Do:** Use structured JSON output with separate `reasoning` and `annotated_text`185 fields. This makes the Reviewer's job tractable and enables audit trails.186- **Do:** When a codebook exists, embed it fully in the system prompt (RAG paradigm)187 rather than summarizing it. Full-context outperforms fragmented retrieval for188 annotation guidelines.189- **Do:** Evaluate at the token level with binary vectors, not span-level exact match.190 Token-level metrics are more granular and forgiving of minor boundary differences.191- **Avoid:** Running more than 2 Reviewer iterations. Diminishing returns set in quickly192 and you risk the Reviewer introducing new errors through over-correction.193- **Avoid:** Using the same reasoning framing for both Annotator and Reviewer. The194 Annotator should reason about *why spans match the definition*; the Reviewer should195 reason about *whether the Annotator's justifications hold up against the codebook*.196197## Error Handling198199- **Malformed XML tags in Annotator output:** If the Annotator produces unclosed or200 nested tags incorrectly, re-prompt with explicit instruction to ensure well-formed XML.201 Parse with a lenient XML parser that recovers partial tags.202- **Reviewer disagrees on every annotation:** This signals a prompt misalignment between203 Annotator and Reviewer instructions. Verify both agents received identical codebook204 definitions and tag schemas.205- **Empty annotations (no spans tagged):** The Annotator may be too conservative. Switch206 from zero-shot to few-shot with 2-3 positive examples to calibrate detection threshold.207- **Gold standard format mismatch:** Ensure gold annotations use the same tokenization as208 the system output. Normalize whitespace and punctuation handling before computing209 binary vectors.210- **Truncated JSON responses:** For long texts, chunk input into segments of 200-500211 tokens to avoid response truncation. Reassemble annotations after all chunks complete.212213## Limitations214215- The dual-agent workflow doubles the token cost per annotation compared to single-pass216 approaches. For budget-constrained bulk annotation, consider running the Reviewer only217 on a sample to estimate quality.218- This approach works best for **span-level and token-level** annotation tasks. For219 document-level classification (e.g., "is this document positive or negative?"), the220 Reviewer adds less value since there is no span boundary to critique.221- The Reviewer cannot catch errors it doesn't know to look for. If the codebook is222 ambiguous or incomplete, both agents will reproduce the same systematic biases.223- Performance depends on the base model's linguistic knowledge. Highly specialized224 annotation tasks (e.g., phonological analysis, syntactic tree labeling) may still225 require fine-tuned models rather than prompt-based approaches.226227## Reference228229**Paper:** [LinguistAgent: A Reflective Multi-Model Platform for Automated Linguistic230Annotation](https://arxiv.org/abs/2602.05493v1) — Li, 2026. Key insight: a dual-agent231Annotator-Reviewer loop with structured reasoning fields consistently improves annotation232quality over single-pass LLM labeling across zero-shot, few-shot, and RAG paradigms.