Downloads · 30 days
238
29% of all-time downloads
shreyasmeher/ConflLlama-NER
ConflLlama-NER is a machine learning model from shreyasmeher. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
<p align="center" <img src="images/logo.png" alt="ConflLlama-NER Logo" width="300"/ </p
Downloads · 30 days
238
29% of all-time downloads
All-time downloads
812
Public
Repo size
29.5 GB
Likes
0
Public
Click a slice to open those files.
.gguf29.5 GB · 100%
From the Hugging Face model README
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:
This model is part of the ConflLlama research project and complements the ConflLlama attack classification model.
The model was trained on a custom-annotated dataset derived from conflict event narratives:
| Tag | Entity Type | Description | Example |
|---|---|---|---|
| B-S | Source (Begin) | Actor initiating action | "Israeli forces", "Protesters" |
| I-S | Source (Inside) | Continuation of source | "forces" in "Israeli forces" |
| B-T | Target (Begin) | Recipient of action | "police", "civilians" |
| I-T | Target (Inside) | Continuation of target | "Bank" in "Central Bank" |
| B-R | Related (Begin) | Other relevant entities | "United Nations", "weapons" |
| I-R | Related (Inside) | Continuation of related | "Nations" in "United Nations" |
| O | Outside | Non-entity token | "conducted", "during", "the" |
unsloth/llama-3-8b-Instruct-bnb-4bitq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projIMPORTANT: 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.
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:
If your platform requires a single concatenated prompt:
prompt = """<|start_header_id|>system<|end_header_id|>
Extract 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|>
Text: {your_text_here}
Entities: <|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
Input:
Text: Security forces conducted an operation in the northern region. Armed groups fired upon government troops during the incident.
Entities:
Expected Output:
[
{"text": "Security forces", "type": "B-S", "start": 0, "end": 1},
{"text": "northern region", "type": "B-T", "start": 6, "end": 7},
{"text": "Armed groups", "type": "B-S", "start": 9, "end": 10},
{"text": "government troops", "type": "B-T", "start": 13, "end": 14}
]
# Download the Q4_K_M GGUF model
wget https://huggingface.co/shreyasmeher/confllama-ner-sft-GGUF/resolve/main/model-unsloth-Q4_K_M.gguf
# Run with llama.cpp
./llama-cli -m model-unsloth-Q4_K_M.gguf \
--system "Extract all named entities from the following text. Return them as a JSON list with 'text', 'type', 'start', and 'end' positions." \
--prompt "Text: [YOUR TEXT]\nEntities: " \
--temp 0.3 \
--n-predict 512
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model and tokenizer
model_name = "shreyasmeher/confllama-ner-sft"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto"
)
# Prepare input with correct formatting
text = "Israeli forces raided Palestinian villages in the West Bank."
prompt = f"""<|start_header_id|>system<|end_header_id|>
Extract 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|>
Text: {text}
Entities: <|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
# Generate
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.3,
do_sample=False,
pad_token_id=tokenizer.eos_token_id
)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="shreyasmeher/confllama-ner-sft",
max_seq_length=2048,
dtype=None,
load_in_4bit=True,
)
# Enable inference mode
FastLanguageModel.for_inference(model)
# Generate
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.3)
result = tokenizer.batch_decode(outputs)
This model is designed for academic research and analysis in the following domains:
Domain Specificity: Optimized for conflict and political violence texts. Performance may degrade on general-domain NER tasks.
Training Data Constraints:
Entity Boundary Detection:
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.
Prompt Sensitivity: Critical limitation - requires exact prompt formatting. Deviations will significantly degrade performance.
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:
Bias and Representation:
Dual-Use Concerns: While designed for research, entity extraction could theoretically support harmful applications:
Transparency: Users should:
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.
If you use ConflLlama-NER in your research, please cite:
@article{meher2025confllama,
title={ConflLlama: Domain-specific adaptation of large language models for conflict event classification},
author={Meher, Shreyas and Brandt, Patrick T.},
journal={Research \& Politics},
volume={12},
number={3},
year={2025},
publisher={SAGE Publications},
doi={10.1177/20531680251356282}
}
Note: A separate publication on the NER model is forthcoming. Please check back for updated citation information.
Apache 2.0 - See LICENSE for details.
For questions, issues, or collaboration inquiries: