/ Модель

Характеристики

Контекст
512 токенов
Параметры
138 млн
Лицензия
Apache 2.0
Архитектура
electra · dense
Базовая модель
bcms-bertic
Библиотека
transformers
Опубликована
14 фев 2025

NER4Legal_SRB

Разметка токеновТекст → label6 профессий

Дообученная ELECTRA-модель для распознавания сущностей в сербских юридических документах, например при их поиске и архивировании.

53скачиваний за 30 дней1лайквеса обновлены19 фев 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

NER4Legal_SRB — модель распознавания и классификации именованных сущностей в юридических текстах на сербском языке. Её разработали для автоматизации работы с документами, включая архивирование, поиск и извлечение сведений; модель обучена на публичных судебных решениях с ручной разметкой и предназначена для выделения заданных типов сущностей.

Это дообученная модель classla/bcms-bertic на архитектуре ELECTRA с 137,8 млн параметров и контекстом до 512 токенов. Она принимает текст и возвращает метки для токенов. В перекрёстной проверке на размеченном наборе данных авторы сообщают средний F1 0,96; модель можно запускать на CPU и GPU. Показатели относятся к описанному набору данных и не гарантируют такую же точность на иных текстах. Лицензия — Apache-2.0.

Сценарии применения

  • извлечение именованных сущностей из сербских судебных решений
  • разметка сущностей в сербских юридических документах
  • подготовка юридических документов к поиску и архивированию
  • извлечение структурированных сведений из сербских правовых текстов

Ограничения

Модель обучена на сербских юридических документах, поэтому её точность на других языках и типах текстов не установлена. Заявленный F1 0,96 получен при перекрёстной проверке на наборе данных авторов и может не переноситься на иные корпуса.

Для каких профессий подходит6

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

NER4Legal_SRB

Model Description

NER4Legal_SRB is a fine-tuned Named Entity Recognition (NER) model designed for processing Serbian legal documents. This model was created as part of the conference paper "Named Entity Recognition for Serbian Legal Documents: Design, Methodology and Dataset Development", accepted for publication at the 15th International Conference on Information Society and Technology, Kopaonik, Serbia, March 9-12, 2025. The model aims to automate tasks involving legal documents, such as document archiving, search, and retrieval. It leverages the classla/bcms-bertic pre-trained BERT model, carefully adapted to the specific task of identifying and classifying a predefined set of word entities in Serbian legal texts. Model can be run on both CPU and GPU. Provided model was trained on all data from NER4Legal_SRB dataset described in the reference paper.

Abstract

Recent advancements in the field of natural language processing (NLP) and especially large language models (LLMs) and their numerous applications have brought research attention to the design of different document processing tools and enhancements in the process of document archiving, search, and retrieval. The domain of official legal documents is especially interesting due to the vast amount of data generated daily, as well as the significant community of interested practitioners (lawyers, law offices, administrative workers, state institutions, and citizens). Providing efficient ways for automation of everyday work involving legal documents is therefore expected to have significant impact in different fields.

In this work, we present one LLM-based solution for Named Entity Recognition (NER) in the case of legal documents written in Serbian language. It leverages the pre-trained bidirectional encoder representations from transformers (BERT), carefully adapted to the specific task of identifying and classifying specific data points from textual content. Besides novel dataset development for Serbian language (involving public court rulings), presented system design and applied methodology, the paper also discusses achieved performance metrics and their implications for objective assessment of the proposed solution. Performed cross-validation tests on the created manually labeled dataset with a mean F1 score of 0.96 and additional results on the examples of intentionally modified text inputs confirm applicability of the proposed system design and robustness of the developed NER solution.

Base Model

The model is fine-tuned from the classla/bcms-bertic base model, which is a pre-trained BERT model designed for the BCMS (Bosnian, Croatian, Montenegrin, Serbian) languages.

Dataset

This model was fine-tuned on a manually labeled dataset of Serbian legal documents, including public court rulings. The dataset was specifically developed for this task to enable precise identification and classification of entities in Serbian legal texts.

Performance Metrics

The model achieved a mean F1 score of 0.96 during cross-validation tests on the labeled dataset, demonstrating robust performance and applicability to real-world scenarios. For detailed information about performed model evaluation and reported results please consult the original conference paper.

Contributors

Usage

Here’s how to use the model in Python:

from transformers import AutoModelForTokenClassification, AutoTokenizer
import torch

# Load the model and tokenizer
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = AutoTokenizer.from_pretrained("kalusev/NER4Legal_SRB", use_auth_token=True)
model = AutoModelForTokenClassification.from_pretrained("kalusev/NER4Legal_SRB", use_auth_token=True).to(device)

# Define the label mapping (id_to_label)
id_to_label = {
    0: 'O',
    1: 'B-COURT',
    2: 'B-DATE',
    3: 'B-DECISION',
    4: 'B-LAW',
    5: 'B-MONEY',
    6: 'B-OFFICIAL GAZZETE',
    7: 'B-PERSON',
    8: 'B-REFERENCE',
    9: 'I-COURT',
    10: 'I-LAW',
    11: 'I-MONEY',
    12: 'I-OFFICIAL GAZZETE',
    13: 'I-PERSON',
    14: 'I-REFERENCE'
}

# NER with GPU/CPU fallback
def perform_ner(text):
    """
    Perform Named Entity Recognition on a single text with GPU memory fallback.
    Args:
        text (str): Input text.
    Returns:
        list: List of tokens and predicted labels.
    """
    try:
        # Tokenize the input text
        inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
        # Get predictions from the model
        with torch.no_grad():
            outputs = model(**inputs)
        logits = outputs.logits
        predictions = torch.argmax(logits, dim=2).squeeze().tolist()

    except RuntimeError as e:
        if "CUDA out of memory" in str(e):
            print("Switching to CPU due to memory constraints.")
            inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
            with torch.no_grad():
                outputs = model.cpu()(**inputs)  # Run model on CPU
            logits = outputs.logits
            predictions = torch.argmax(logits, dim=2).squeeze().tolist()
        else:
            raise e  # Re-raise other exceptions

    tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"].squeeze())
    labels = [id_to_label[pred] for pred in predictions]

    # Filter out special tokens
    results = [
        (token, label)
        for token, label in zip(tokens, labels)
        if token not in tokenizer.all_special_tokens
    ]
    return results

# Example usage
text = """Rešenjem Apelacionog suda u Novom Sadu, Gž1. 1901/10 od 12.05.2010. godine žalba tuženog je usvojena, a presuda Opštinskog suda u Novom Sadu, P. 5734/04 od 29.01.2009. godine, ukinuta i predmet upućen ovom sudu na ponovno suđenje."""

# Perform NER
results = perform_ner(text)

# Print tokens and labels as a formatted table
print("Token             | Predicted Label")
print("----------------------------------------")
for token, label in results:
    print(f"{token:<17} | {label}")

If you would like to use this software, please consider citing the following publication:

  • Kalušev, V., Brkljač, B. (2026). Named Entity Recognition for Serbian Legal Documents: Design, Methodology and Dataset Development. In: Transformative Technologies Shaping a Smarter Society. ICIST 2025. Lecture Notes in Networks and Systems, vol 1621. Springer, Cham. https://doi.org/10.1007/978-3-032-04890-5_30

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers · token-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
ElectraForTokenClassification
Ревизия весов
4b7b235

0 моделей