ConflLlama-NER: Domain-Specific Named Entity Recognition for Conflict Events
ConflLlama-NER Logo
⚠️ Important: Read Before Using
This model requires exact prompt formatting to work correctly. Please read the Critical: Inference & Prompt Formatting section below before attempting to use this model. Using incorrect prompts will result in poor performance or hallucinations.
ConflLlama-NER is a specialized large language model fine-tuned for Named Entity Recognition (NER) in conflict event narratives. Built upon Llama-3.1 8B Instruct, this model identifies and classifies three critical entity types in political violence texts:
Source (B-S/I-S): The actor or group initiating the action
Target (B-T/I-T): The recipient or victim of the action
Related (B-R/I-R): Other significant entities mentioned in the context
Batch Size: 1 per device with 8 gradient accumulation steps (effective batch size: 8)
Training Steps: 2,000 steps
Precision: BFloat16 (when supported)
Hardware: NVIDIA A100-SXM4-40GB GPU
Memory Footprint: ~6 GB VRAM (optimized for consumer GPUs)
Critical: Inference & Prompt Formatting
IMPORTANT: This model requires exact prompt formatting to function correctly. The model was instruction-tuned with a specific template. Deviating from this format will result in poor performance or hallucinations.
Option 1: Using LM Studio / Llama.cpp (Recommended)
System Prompt:
Extract all named entities from the following text. Return them as a JSON list with 'text', 'type', 'start', and 'end' positions.
User Message:
Text: [YOUR ARTICLE TEXT HERE]
Entities:
Option 2: Direct API/Python Integration
If your platform requires a single concatenated prompt:
python
1prompt ="""<|start_header_id|>system<|end_header_id|>
23Extract all named entities from the following text. Return them as a JSON list with 'text', 'type', 'start', and 'end' positions.<|eot_id|><|start_header_id|>user<|end_header_id|>
45Text: {your_text_here}
6Entities: <|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
Example Usage
Input:
Text: Security forces conducted an operation in the northern region. Armed groups fired upon government troops during the incident.
Entities:
Using Llama.cpp (Recommended for Local Deployment)
bash
1# Download the Q4_K_M GGUF model2wget https://huggingface.co/shreyasmeher/confllama-ner-sft-GGUF/resolve/main/model-unsloth-Q4_K_M.gguf
34# Run with llama.cpp5./llama-cli -m model-unsloth-Q4_K_M.gguf \6 --system "Extract all named entities from the following text. Return them as a JSON list with 'text', 'type', 'start', and 'end' positions."\7 --prompt "Text: [YOUR TEXT]\nEntities: "\8 --temp 0.3\9 --n-predict 512
Using Transformers (Python)
python
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
34# Load model and tokenizer5model_name ="shreyasmeher/confllama-ner-sft"6tokenizer = AutoTokenizer.from_pretrained(model_name)7model = AutoModelForCausalLM.from_pretrained(8 model_name,9 torch_dtype=torch.float16,10 device_map="auto"11)1213# Prepare input with correct formatting14text ="Israeli forces raided Palestinian villages in the West Bank."15prompt =f"""<|start_header_id|>system<|end_header_id|>
1617Extract all named entities from the following text. Return them as a JSON list with 'text', 'type', 'start', and 'end' positions.<|eot_id|><|start_header_id|>user<|end_header_id|>
1819Text: {text}20Entities: <|eot_id|><|start_header_id|>assistant<|end_header_id|>"""2122# Generate23inputs = tokenizer(prompt, return_tensors="pt").to(model.device)24outputs = model.generate(25**inputs,26 max_new_tokens=512,27 temperature=0.3,28 do_sample=False,29 pad_token_id=tokenizer.eos_token_id
30)3132result = tokenizer.decode(outputs[0], skip_special_tokens=True)33print(result)
This model is designed for academic research and analysis in the following domains:
Automated Event Coding: Extract structured actor information from conflict narratives
Political Violence Research: Identify sources and targets in terrorism and insurgency studies
Computational Social Science: Enable large-scale quantitative analysis of conflict data
Information Extraction: Build knowledge graphs from unstructured conflict reports
Preprocessing for Event Classification: Generate structured inputs for downstream tasks
Example Applications
Extracting actors from news articles for conflict databases (ICEWS, GDELT, ACLED)
Building relational networks between conflict actors
Identifying victim and perpetrator patterns in political violence
Preprocessing text for the ConflLlama attack classification model
Limitations
Domain Specificity: Optimized for conflict and political violence texts. Performance may degrade on general-domain NER tasks.
Training Data Constraints:
Trained on 1,094 sentences (relatively small for modern NER)
Class imbalance: "Related" entities (B-R/I-R) are underrepresented (1.9% of tokens)
May underperform on rare entity types or novel contexts
Entity Boundary Detection:
May occasionally split or merge multi-word entities incorrectly
Nested entities are not explicitly modeled
Temporal Scope: Training data reflects conflict patterns up to the model's knowledge cutoff (January 2025). Emerging actors or tactics may not be recognized.
Language: English-only. No support for multilingual entity recognition.
Output Parsing: Model outputs JSON, but may occasionally produce malformed JSON under edge cases. Implement robust parsing with error handling.
Research-Only Tool: This model is designed for academic analysis, not operational security decisions or real-time threat assessment.
Sensitive Data: The model processes information about real-world violence. Users must:
Handle extracted data with appropriate security measures
Respect privacy of individuals mentioned in source texts
Avoid using entity information to target or profile individuals/groups
Bias and Representation:
Training data may reflect biases in how conflict events are reported
Entity recognition may vary across different regions, actor types, or conflict contexts
Do not assume equal performance across all geopolitical contexts
Dual-Use Concerns: While designed for research, entity extraction could theoretically support harmful applications:
Do not use for surveillance, profiling, or targeting of individuals
Do not use to support operational military or security activities
Do not use to generate disinformation or manipulate public discourse
Transparency: Users should:
Clearly disclose when research findings are based on automated NER
Report model limitations in publications
Validate critical findings with manual review
Accountability
This model is released for research purposes under the Apache 2.0 license. Users are responsible for ensuring their applications comply with applicable laws, ethical guidelines, and institutional review board (IRB) requirements.
Citation
If you use ConflLlama-NER in your research, please cite:
bibtex
1@article{meher2025confllama,
2 title={ConflLlama: Domain-specific adaptation of large language models for conflict event classification},
3 author={Meher, Shreyas and Brandt, Patrick T.},
4 journal={Research \& Politics},
5 volume={12},
6 number={3},
7 year={2025},
8 publisher={SAGE Publications},
9 doi={10.1177/20531680251356282}
10}
Note: A separate publication on the NER model is forthcoming. Please check back for updated citation information.
Acknowledgments
Funding: NSF Award 2311142
Computing Resources: Delta system at NCSA (University of Illinois) through ACCESS allocation CIS220162
Base Model: Unsloth team for Llama-3.1 8B Instruct optimizations
Infrastructure: Hugging Face for model hosting and transformers library
Data Foundation: Global Terrorism Database (GTD) at the University of Maryland