Yapay Zeka Güvenliği BPE Tokenizer

🇹🇷 Türkçe | 🇬🇧 English

Repo: sadecebirisii/ai-security-bpe-tokenizer-32k


Türkçe

Bu depo, yapay zeka / LLM güvenliği konulu 5 akademik PDF kaynaktan çıkarılan metin üzerinde eğitilmiş, byte-level BPE (Byte Pair Encoding) mimarisine sahip özel bir tokenizer içerir. Tokenizer, Hugging Face tokenizers kütüphanesi ile eğitilmiş ve transformers kütüphanesindeki PreTrainedTokenizerFast ile doğrudan uyumlu hale getirilmiştir.

Model Detayları

Özellik Değer
Tokenizer tipi Byte-Level BPE
Vocab boyutu (üst sınır) 32.000
Gerçek eğitilmiş vocab boyutu ~7.500
Min. frekans 2
Pre-tokenizer ByteLevel (add_prefix_space=False)
Decoder ByteLevel
Özel tokenlar <pad>, <unk>, <s>, </s>, <mask/>

vocab_size=32000 eğiticiye verilen bir üst sınırdır; korpus boyutuna göre BPE, daha fazla sık geçen bayt çifti kalmayınca eğitimi ~7.500 token'da durdurmuştur.

Eğitim Verisi

Tokenizer, kaynaklar/ klasöründeki 5 PDF'ten pypdf ile çıkarılan metin (corpus.txt, ~234 KB, ~27.700 kelime) üzerinde eğitilmiştir:

  • LLM Güvenlik Katmanları ve Savunmaları.pdf
  • Yapay Zeka Güvenlik Katmanları: İçsel mi Dışsal mı?.pdf
  • YZ Odaklı Siber Risk ve Güvenlik Yönetimi.pdf
  • The Role and Essence of Artificial Intelligence in Cybersecurity: A Survey.pdf
  • İletişim ve Diplomasi (10.54722) makalesi.pdf

Kaynakların tokenizer ağırlıklı olarak Türkçe olsa da bir miktar İngilizce alt kelime birimi de öğrenmiştir. PDF'ten metin çıkarma aşamasında, orijinal pypdf çıktısında kelimelerin ayrı satırlara dağılması ve düzensiz boşluklar gibi sorunlar tespit edilip düzeltildi: tüm boşluk/satır sonları tek boşluğa indirgendi ve cümle akışına karışan dipnot rakamlarının bir kısmı temizlendi.

Kullanım

from transformers import PreTrainedTokenizerFast

tokenizer = PreTrainedTokenizerFast.from_pretrained("sadecebirisii/ai-security-bpe-tokenizer-32k")

encoded = tokenizer("Prompt enjeksiyonu, LLM güvenliği için kritik bir tehdittir.")
print(encoded["input_ids"])
print(tokenizer.decode(encoded["input_ids"]))

Sınırlamalar

  • Akademik makale/rapor tarzı, sınırlı ve niş bir korpus (234 KB, 5 kaynak) üzerinde eğitildiği için kelime dağarcığı hâlâ hedeflenen 32.000'in altındadır (7.500 token).
  • Kaynakların çoğunluğu Türkçe olduğundan tokenizer Türkçe ağırlıklıdır; İngilizce metinlerde daha az verimli sıkıştırma yapabilir.
  • Üretim (production) ortamları için değil, eğitim/ödev amaçlı hazırlanmıştır.
  • PDF çıkarımındaki dipnot rakamı temizliği bir sezgisel (heuristic) kurala dayanır; bazı dipnot artıkları metinde kalmış olabilir.

Lisans

Bu depo için henüz bir lisans belirlenmemiştir. Yayınlamadan önce uygun bir lisans (ör. MIT, Apache-2.0) eklemeniz önerilir.


English

This repository contains a custom byte-level BPE (Byte Pair Encoding) tokenizer trained on text extracted from 5 academic PDF sources about AI / LLM security. The tokenizer was trained with the Hugging Face tokenizers library and wrapped with PreTrainedTokenizerFast for direct compatibility with 🤗 transformers.

Model Details

Property Value
Tokenizer type Byte-Level BPE
Vocab size (upper bound) 32,000
Actual trained vocab size ~7,500
Min. frequency 2
Pre-tokenizer ByteLevel (add_prefix_space=False)
Decoder ByteLevel
Special tokens <pad>, <unk>, <s>, </s>, <mask/>

vocab_size=32000 is an upper bound passed to the trainer; given the corpus size, BPE training stopped at ~7,500 tokens once no more frequent byte pairs remained.

Training Data

The tokenizer was trained on text extracted with pypdf from 5 PDFs in the kaynaklar/ folder (corpus.txt, ~234 KB, ~27,700 words):

  • LLM Güvenlik Katmanları ve Savunmaları.pdf (LLM Security Layers and Defenses)
  • Yapay Zeka Güvenlik Katmanları: İçsel mi Dışsal mı?.pdf (AI Security Layers: Internal or External?)
  • YZ Odaklı Siber Risk ve Güvenlik Yönetimi.pdf (AI-Focused Cyber Risk and Security Management)
  • The Role and Essence of Artificial Intelligence in Cybersecurity: A Survey.pdf
  • İletişim ve Diplomasi (10.54722) journal article.pdf

Four sources are Turkish and one is English, so the tokenizer is predominantly Turkish but has also learned some English subword units. During extraction, issues in the raw pypdf output were identified and fixed — words were being split across separate lines with irregular spacing — so all whitespace/line breaks are now normalized to single spaces, and some footnote reference numbers bleeding into the text were stripped.

Usage

from transformers import PreTrainedTokenizerFast

tokenizer = PreTrainedTokenizerFast.from_pretrained("sadecebirisii/ai-security-bpe-tokenizer-32k")

encoded = tokenizer("Prompt enjeksiyonu, LLM güvenliği için kritik bir tehdittir.")
print(encoded["input_ids"])
print(tokenizer.decode(encoded["input_ids"]))

Limitations

  • Trained on a still-modest, niche corpus of academic papers/reports (234 KB, 5 sources), so vocabulary coverage remains below the 32,000 target (7,500 tokens).
  • Predominantly Turkish, since most sources are Turkish; it may compress English text less efficiently.
  • Built for learning/coursework purposes, not intended for production use.
  • Footnote-number cleanup during PDF extraction relies on a heuristic rule; some footnote artifacts may remain in the text.

License

No license has been set for this repository yet. It is recommended to add an appropriate license (e.g. MIT, Apache-2.0) before publishing.

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