This is the attribute-extraction model for
NGEC (Next Generation Event Coder),
a pipeline for generating custom political event datasets. You give it a news
document and the definition of a political event type. It returns every
instance of that event type in the document as a JSON list. Each record has an
anchor quote, plus the actor, recipient, date, and location as verbatim spans
from the text. It can also return other attributes, such as the people killed
or injured in violent events. It returns [] when the event type does not
occur in the document.
It replaces ahalt/qwen3-event-extraction-exp5.1
(the model in the submitted paper). On a 500-document test set of VOA articles,
it finds 71% of the events, against 22% for exp5.1. On the events each model finds,
its mean F1 is 71.7, against 54.7. See "Evaluation" below.
It uses a different prompt and output format from exp5.1. Multiple spans for an attribute are JSON lists (instead of semicolon-separated strings), and the prompt has changed.
A Q8_0 GGUF for CPU inference with llama.cpp is at
ahalt/qwen3.5-event-extraction-0.8b-GGUF.
Earlier version. The first upload of this repository (September 2026) was an
earlier training run. It is still available at the revision tag
prepfix-2026-09-24. Both versions use the same prompt and output format.
The prompt consists of a system message and a user message, formatted with the tokenizer's chat template.
System message. A fixed instruction. Optional attributes add a key to the record
schema, a sentence about verbatim spans, and a description block. killed and
injured are always on for ASSAULT, PROTEST and COERCE, and off for the other types.
reporter (the source the document attributes the report to) is off by default and
can be turned on for any type. The function below reproduces the exact training-time
text.
User message.
## Document: {document}
## Event Type: {definition}
Return the JSON list.
{definition} is the event type's definition taken from a codebook (during training, the PLOVER codebook). It should not be
an event label on its own, since that is not a well-defined task
(Halterman and Keith 2026).
The definitions.json in this repository has the exact definition strings
the model saw in training, from the PLOVER ontology: one per event type, and one
per sub-event (mode). You can also write a definition for an event type the
model was not trained on, to code custom event types. See the paper for evaluations of this (briefly, accuracy on detected events is comparable, but recall is somewhat lower on unseen event types).
The mode field of each record is the sub-event you asked for, or "" if it's a bare event type.
The model will not identify new sub-events/modes, but may decline to extract for a mode, to compensate for errors in the prior event detection step.
To code one sub-event, pass its definition, e.g. definitions[("ASSAULT", "explosives")].
{document} is the article text. The training documents were news articles of
up to about 1,000 words, with the headline first, followed by a period.
import json
import re
CORE_SYSTEM = (
"Extract every instance of the given political event type from the document "
"as a JSON list, or [] if there is none.\n\n"
"Each record:\n"
'{{"event_type": "<type>", "mode": "<sub-event name or empty string>",\n'
' "anchor_quote": "<short verbatim passage identifying this instance>",\n'
' "actor": [...], "recipient": [...], "date": [...], "location": [...]{extra_keys}}}\n\n'
"Every string in actor, recipient, date, and location must be an exact, "
"verbatim substring of the document.{extra_verbatim}\n"
"{extra_block}"
"Return the JSON list only."
)
ATTRIBUTE_TEXT = {
"killed": (
"Every person or group the document reports as killed in this event, whether "
"or not they were its target. Fill it whenever deaths are reported, even when "
"the dead are also the recipient. One list element per distinct party, counts "
"kept ('three officers'). Empty when no death is reported. Written like a "
"recipient: the verbatim noun phrase, counts and quantifiers kept, leading "
"articles dropped, one list element per distinct party."),
"injured": (
"Every person or group the document reports as injured in this event, whether "
"or not they were its target. Fill it whenever injuries are reported, even when "
"the injured are also the recipient. One list element per distinct party, "
"counts kept ('three officers'). Empty when no injury is reported. Written like "
"a recipient: the verbatim noun phrase, counts and quantifiers kept, leading "
"articles dropped, one list element per distinct party."),
"reporter": (
"The source the document attributes this report to: a named outlet, an "
"official statement, eyewitnesses, unnamed officials, a spokesperson. Verbatim "
"span of the attributing phrase's subject ('the defense ministry', "
"'witnesses', 'Reuters'). Empty when the report is in the publication's own "
"voice. Written like a recipient: the verbatim noun phrase of the attributing "
"subject, leading articles dropped, one list element per distinct source."),
}
CASUALTY_TYPES = {"ASSAULT", "PROTEST", "COERCE"}
def system_message(event_type, reporter=False):
attrs = ["killed", "injured"] if event_type in CASUALTY_TYPES else []
if reporter:
attrs.append("reporter")
if not attrs:
return CORE_SYSTEM.format(extra_keys="", extra_verbatim="", extra_block="")
extra_keys = "".join(f', "{a}": [...]' for a in attrs)
names = attrs[0] if len(attrs) == 1 else ", ".join(attrs[:-1]) + " and " + attrs[-1]
extra_block = ("ADDITIONAL ATTRIBUTES FOR THIS EVENT TYPE\n"
+ "".join(f"- {a}: {ATTRIBUTE_TEXT[a]}\n" for a in attrs))
return CORE_SYSTEM.format(extra_keys=extra_keys,
extra_verbatim=f" The same holds for {names}.",
extra_block=extra_block)
def user_message(document, definition):
document = re.sub(r"\s+", " ", document).strip()
return f"## Document: {document}\n\n## Event Type: {definition}\n\nReturn the JSON list."
definitions = {(d["event_type"], d["mode"]): d["definition"]
for d in json.load(open("definitions.json"))}
In a script (not a notebook), put this under if __name__ == "__main__":,
because vLLM starts its engine in a separate process.
from vllm import LLM, SamplingParams
from transformers import AutoTokenizer
MODEL = "ahalt/qwen3.5-event-extraction-0.8b"
# The checkpoint keeps Qwen3.5's vision tower, because vLLM only supports
# Qwen3.5's multimodal architecture. language_model_only=True skips loading it.
model = LLM(model=MODEL, enable_prefix_caching=True, max_model_len=8192,
language_model_only=True)
tokenizer = AutoTokenizer.from_pretrained(MODEL)
# Greedy decoding, which is how the model was evaluated
sampling_params = SamplingParams(temperature=0.0, max_tokens=768)
def make_prompt(document, event_type, mode="", reporter=False):
messages = [
{"role": "system", "content": system_message(event_type, reporter)},
{"role": "user", "content": user_message(document, definitions[(event_type, mode)])},
]
return tokenizer.apply_chat_template(messages, tokenize=False,
add_generation_prompt=True,
enable_thinking=False)
text = """Bosnia Arrests Srebrenica Massacre Suspect. Bosnian police have arrested a former Bosnian Serb police officer suspected of genocide in the 1995 massacre of 8,000 Muslim men and boys. Authorities Monday said Dragan Crnogorac has been arrested by the State Investigation and Protection agency in the northern town of Banja Luka. The 38-year-old is accused of personally taking part in the executions of Bosnian Muslim men and boys in Srebrenica, in what is considered the worst atrocity in Europe since World War Two. Prosecutors say Crnogorac was a member of Bosnian Serb forces that captured the U.N.-protected Srebrenica enclave on July 11, 1995, at the end of Bosnia's three-year war. The Bosnian war crimes court has put dozens of Bosnian Serbs on trial for complicity in the Srebrenica killings."""
output = model.generate(make_prompt(text, "COERCE"), sampling_params=sampling_params)
records = json.loads(output[0].outputs[0].text)
# [{"event_type": "COERCE", "mode": "",
# "anchor_quote": "Dragan Crnogorac has been arrested by the State Investigation and Protection agency in the northern town of Banja Luka",
# "actor": ["State Investigation and Protection agency"],
# "recipient": ["Dragan Crnogorac"],
# "date": ["Monday"],
# "location": ["Banja Luka"],
# "killed": [], "injured": []
# }
# ]
The output shown is the model's actual output for this document, produced by the code above. The document is from the 500-document test set described below.
The model may return several records for one document, one per instance of the event. Rarely, greedy decoding repeats the same few records until it reaches the token limit, which leaves the JSON unfinished. Keep the records that were completed before the cut-off and drop exact duplicates. NGEC's parser will automatically do this.
The Hugging Face transformers library (5.5.1 or later) loads the checkpoint
as a text-only model and ignores the vision weights. The GGUF does not contain
them.
The test set is 500 document–event type pairs from VOA news articles (1,048 events). Its answer key was drafted by three models and adjudicated by a fourth model, with a human spot check of the adjudicated key. exp5.1 was run with its own prompt and output format; both models' outputs were scored with the same code.
| exp5.1 | This model | |
|---|---|---|
| Events found (recall) | 22% | 71% |
| Mean F1 over actor, recipient, date, location, on the events found | 54.7 | 71.7 |
F1 per role on the events found: actor 71.7, recipient 65.0, date 77.9, location 72.2. A predicted span counts as correct when it matches the answer key under the project's span-matching rules.
Speed. On one RTX 4090 with vLLM and language_model_only=True, the 500 test
documents take about 27 seconds (18.5 documents per second). On a CPU, the Q8_0
GGUF takes about 4.5 seconds per document; see its card.
The model was fine-tuned from Qwen/Qwen3.5-0.8B (full fine-tune, no LoRA) on
13,743 training units. A unit is one document paired with one event type or
sub-event, with either the records to extract or [] (about half are []). The
documents are 884 VOA news articles and 2,404 synthetic news stories.
The training labels were written by a teacher model, GLM 5.3 flash, prompted with the consolidated PLOVER codebook and the project's written labeling decisions.
Training hyperparameters: 3,512 optimizer steps (about three passes over the data), learning rate 2e-5 with cosine decay and 10% warmup, weight decay 0.01, effective batch size 12, maximum length 4,096 tokens, seed 1. Training took 78 minutes on one RTX 4090.
The article describing NGEC is under review. Until it is published, please cite the repository: https://github.com/ahalterman/NGEC-2025
Qwen/Qwen3.5-0.8B