Uploaded model

  • Developed by: Piece-Of-Schmidt
  • License: apache-2.0
  • Finetuned from model : unsloth/gemma-3-4b-it-unsloth-bnb-4bit

This gemma3 model was trained 2x faster with Unsloth and Huggingface's TRL library.


Model Card for NEClass_location

NEClass_location is a fine-tuned version of Gemma-3-4b-it designed for context-dependent entity classification. While standard Named Entity Recognition (NER) only identifies that "Brussels" is a location, this model determines its political or geographical affiliation (e.g., "Belgium" vs. "EU") based on the surrounding text.

Model Details

  • Developed by: Tobias Schmidt (TU Dortmund University)
  • Model type: Causal Language Model (Fine-tuned via LoRA)
  • Base model: google/gemma-3-4b-it
  • Language(s): Multilingual (Optimized for DE, EN, FR, IT, ES)
  • Task: Entity-to-Country/Region Mapping (Location Attribution)

πŸ›  Usage (Standalone)

If you want to use the model outside of the NEClass Pipeline, follow this example. We recommend using Unsloth for significantly faster inference and lower VRAM usage.

1. Installation

pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps xformers trl peft accelerate bitsandbytes

2. Inference Code

from unsloth import FastLanguageModel
import torch

# 1. Load Model and Tokenizer
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "Piece-Of-Schmidt/NEClass_location",
    max_seq_length = 1024,
    load_in_4bit = True,
)
FastLanguageModel.for_inference(model) # Enable native 2x faster inference

# 2. Define the Task and Input
task = "Your task is to classify the provided Named Entity in terms of its Location, that is, the country/region that this entity is most closely associated with. Use the provided surrounding context as decision support whenever available."

# Example: Ambiguous case "Brussels"
context = "The decision made in Brussels today will affect all member states of the European Union."
entity = "Brussels"

input_text = f"# Context:\n{context}\n\n# Entity:\n{entity}"

# 3. Apply Chat Template
messages = [
    {"role": "system", "content": task},
    {"role": "user", "content": input_text}
]

prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

# 4. Generate Prediction
inputs = tokenizer([prompt], return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=10, use_cache=True)
prediction = tokenizer.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]

print(f"Entity: {entity} -> Predicted Location: {prediction.strip()}")
# Output: Entity: Brussels -> Predicted Location: Europe

🎯 Intended Use

This model is intended for researchers in the social sciences, specifically for Foreign News Coverage (FNC) analysis.

πŸ“Š Evaluation Results

Across a diverse test set of multilingual news entities, the model achieves:

  • Accuracy: 0.94
  • Weighted F1-Score: 0.95

⚠️ Limitations

  • NER Quality: The model's performance depends on the quality of the upstream entity extraction.
  • Bias: The training data has a Western/Northern bias. Accuracy for entities from the Global South might be lower - something I will address in future iterations.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Piece-Of-Schmidt/NEClass_location

Finetuned
(989)
this model