/ Модель

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

Контекст
512 токенов
Параметры
190 млн
Архитектура
bert · dense
Опубликована
11 окт 2023

ALDi-Token-DI

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

BERT-модель для разметки арабских токенов как стандартного арабского языка или диалекта.

35скачиваний за 30 дней0лайковвеса обновлены22 сен 2026

Бенчмарки

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

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

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

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

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

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

VARabi/ALDi-Token-DI — модель классификации токенов на основе BERT, дообученная разработчиками проекта VARabi для определения того, относится ли каждый токен арабского предложения к современному стандартному арабскому языку (MSA) или диалектному арабскому (DA). Модель предназначена для анализа предложений со смешением стандартного языка и диалекта. Она дообучена на датасете MSA-DA code-switched и использует классификационную голову BertForTokenClassification.

Модель основана на MarBERT, содержит 190 млн параметров и рассчитана на контекст до 512 токенов. README указывает арабский язык. Доступны веса PyTorch и Safetensors. Лицензия в предоставленных данных не указана.

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

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

Ограничения

Модель предназначена для различения MSA и DA в арабском тексте; качество за пределами этого сценария не описано. Указанный максимальный контекст — 512 токенов.

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

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

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

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

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

Открыть на Hugging Face

Model Card for Token-DI

GitHub

A BERT-based model fine-tuned to tag each token in a sentence as being in MSA or DA.

ModelLink on 🤗
Sentence-ALDi (random seed: 42)https://huggingface.co/VARabic/Sentence-ALDi
Sentence-ALDi (random seed: 30)https://huggingface.co/VARabic/Sentence-ALDi-30
Sentence-ALDi (random seed: 50)https://huggingface.co/VARabic/Sentence-ALDi-50
Token-DI (random seed: 42)https://huggingface.co/VARabic/ALDi-Token-DI
Token-DI (random seed: 30)https://huggingface.co/VARabic/ALDi-Token-DI-30
Token-DI (random seed: 50)https://huggingface.co/VARabic/ALDi-Token-DI-50

Usage

from transformers import AutoTokenizer, AutoModelForTokenClassification

def tokenize_text(text):
    """Tokenize a string based on separator regexps."""
    tokens = text.split()
    return tokens

def tag_sentence(text, print_tags=False):
    logits = model(
        **tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
    ).logits

    # Ignore the labels for [CLS] and [SEP]
    subwords_labels = logits.argmax(axis=-1).numpy()[0][1:-1]
    tokens = tokenize_text(text)
    subwords = [
        tokenizer.tokenize(token)
        for token in tokens
        if tokenizer.tokenize(token)
    ]
    n_subwords = [len(l) for l in subwords]
    first_subword_indecies = [sum(n_subwords[0:i]) for i in range(len(n_subwords))]

    tokens_labels = [
        subwords_labels[index] for index in first_subword_indecies if index < 510
    ]
    tokens_tags = [INDECIES_TO_TAGS[l] for l in tokens_labels]

    if print_tags:
        for token, token_tag in zip(tokens, tokens_tags):
            print(f"{token} -> {token_tag}")
        print()

    # Compute the CMI (Code Mixing Index)
    # Ignore: "ambiguous", "ne" (named entity), "other" (emojis, ..)
    n_msa_tokens = sum([t == "lang1" for t in tokens_tags])
    n_da_tokens = sum([t in ["lang2", "mixed"] for t in tokens_tags])

    if n_msa_tokens + n_da_tokens != 0:
        return n_da_tokens / (n_msa_tokens + n_da_tokens)
    else:
        return 0

if __name__ == "__main__":
  model_name = "AMR-KELEG/ALDi-Token-DI"

  TAGS = ["ambiguous", "lang1", "lang2", "mixed", "ne", "other"] # lang1 -> MSA, lang2 -> Dialectal Arabic (DA)
  INDECIES_TO_TAGS = {i: tag for i, tag in enumerate(TAGS)}
  
  tokenizer = AutoTokenizer.from_pretrained(model_name)
  model = AutoModelForTokenClassification.from_pretrained(
      model_name, num_labels=len(TAGS)
  )
  
  # Example usage
  sentence = "ما هذا يا فتي؟ أنت متأكد من كده؟"
  CMI_index = tag_sentence(sentence, print_tags=True)
  print(f"CMI Index (as a proxy for ALDi): {CMI_index:.2f}")

Model Description

  • Model type: Token classification head on top of a BERT-based model.
  • Language(s) (NLP): Arabic.

Citation

If you find the model useful, please cite the following respective paper:

@inproceedings{keleg-etal-2023-aldi,
    title = "{ALD}i: Quantifying the {A}rabic Level of Dialectness of Text",
    author = "Keleg, Amr  and
      Goldwater, Sharon  and
      Magdy, Walid",
    editor = "Bouamor, Houda  and
      Pino, Juan  and
      Bali, Kalika",
    booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
    month = dec,
    year = "2023",
    address = "Singapore",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2023.emnlp-main.655",
    doi = "10.18653/v1/2023.emnlp-main.655",
    pages = "10597--10611",
    abstract = "Transcribed speech and user-generated text in Arabic typically contain a mixture of Modern Standard Arabic (MSA), the standardized language taught in schools, and Dialectal Arabic (DA), used in daily communications. To handle this variation, previous work in Arabic NLP has focused on Dialect Identification (DI) on the sentence or the token level. However, DI treats the task as binary, whereas we argue that Arabic speakers perceive a spectrum of dialectness, which we operationalize at the sentence level as the Arabic Level of Dialectness (ALDi), a continuous linguistic variable. We introduce the AOC-ALDi dataset (derived from the AOC dataset), containing 127,835 sentences (17{\%} from news articles and 83{\%} from user comments on those articles) which are manually labeled with their level of dialectness. We provide a detailed analysis of AOC-ALDi and show that a model trained on it can effectively identify levels of dialectness on a range of other corpora (including dialects and genres not included in AOC-ALDi), providing a more nuanced picture than traditional DI systems. Through case studies, we illustrate how ALDi can reveal Arabic speakers{'} stylistic choices in different situations, a useful property for sociolinguistic analyses.",
}

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

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

GPU в ailist

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

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

Подбираем GPU…

Класс архитектуры
BertForTokenClassification
Ревизия весов
7868458

0 моделей