Text Generation
Transformers
Safetensors
Serbian
qwen3_5
image-text-to-text
srpski
generativni
model
qa
summarization
translation
reasoning
conversational
Instructions to use procesaur/Orao2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use procesaur/Orao2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="procesaur/Orao2") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("procesaur/Orao2") model = AutoModelForMultimodalLM.from_pretrained("procesaur/Orao2", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use procesaur/Orao2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "procesaur/Orao2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "procesaur/Orao2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/procesaur/Orao2
- SGLang
How to use procesaur/Orao2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "procesaur/Orao2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "procesaur/Orao2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "procesaur/Orao2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "procesaur/Orao2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use procesaur/Orao2 with Docker Model Runner:
docker model run hf.co/procesaur/Orao2
Download tokenization_srna.py from procesaur/Orao2: direct link, hf CLI and curl.
- Browser
- Download file 15.6 kB
-
https://huggingface.co/procesaur/Orao2/resolve/main/tokenization_srna.py
- Command line
-
hf download hf://procesaur/Orao2/tokenization_srna.py
-
curl -L -o tokenization_srna.py https://huggingface.co/procesaur/Orao2/resolve/main/tokenization_srna.py
15.6 kB
| # Copyright 2026 Mihailo Škorić. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| """Tokenization classes for Serbian and Serbo-Croatian models.""" | |
| from transformers import PreTrainedTokenizerFast # | |
| from tokenizers import Regex, Tokenizer, decoders, normalizers, pre_tokenizers | |
| from tokenizers.models import BPE | |
| #from ...tokenization_utils_tokenizers import TokenizersBackend | |
| #from ...utils import logging | |
| import regex | |
| #logger = logging.get_logger(__name__) | |
| mapping = { | |
| "Љ": "Lj", "љ": "lj", "Њ": "Nj", "њ": "nj", "Џ": "Dž", "џ": "dž", | |
| "А": "A", "а": "a", "Б": "B", "б": "b", "В": "V", "в": "v", | |
| "Г": "G", "г": "g", "Д": "D", "д": "d", "Ђ": "Đ", "ђ": "đ", | |
| "Е": "E", "е": "e", "Ж": "Ž", "ж": "ž", "З": "Z", "з": "z", | |
| "И": "I", "и": "i", "Ј": "J", "ј": "j", "К": "K", "к": "k", | |
| "Л": "L", "л": "l", "М": "M", "м": "m", "Н": "N", "н": "n", | |
| "О": "O", "о": "o", "П": "P", "п": "p", "Р": "R", "р": "r", | |
| "С": "S", "с": "s", "Т": "T", "т": "t", "Ћ": "Ć", "ћ": "ć", | |
| "У": "U", "у": "u", "Ф": "F", "ф": "f", "Х": "H", "х": "h", | |
| "Ц": "C", "ц": "c", "Ч": "Č", "ч": "č", "Ш": "Š", "ш": "š", | |
| } | |
| reverse_mapping = {v: k for k, v in mapping.items()} | |
| reverse_mapping["dj"] = "ђ" | |
| digraphExceptions = { | |
| "dj": ["adjektiv", "adjon", "adjunkt", "adjuvat", "adjudik", "adjung", "adjunk", "adjutant", "autodjel", "bazdje", "bdje", | |
| "bezdje", "blijedje", "bludje", "bordje", "bridjе", "burdje", "vidjel", "vidjet", "vindjakn", "višedjel", "višenedje", | |
| "vrijedje", "vododjelni", "vodosnabdje", "gdje", "gudje", "gdjir", "daladje", "daždje", "dvodjel", "dvonedje", "devetonedje", | |
| "depardje", "desetonedje", "didje", "djb", "djeva", "djevi", "djevo", "djevstv", "djed", "djejstv", "djel", "djenem", "djeneš", | |
| "djenu", "djet", "djec", "dječ", "djuar", "djubison", "djubouz", "djuer", "djui", "djuks", "djulej", "djumars", "djupont", | |
| "djurant", "djusenberi", "djuharst", "djuherst", "dovdje", "dogrdje", "dodjel", "dosmrdj", "dugodjelujuć", "drvodje", | |
| "drugdje", "elektrosnabdje", "endjurans", "žudje", "zabludje", "zavidje", "zavrijedje", "zagudje", "zadjev", "zadjen", | |
| "zalebdje", "zaludje", "zaodje", "zapodje", "zaprdj", "zarudje", "zasjedje", "zasmrdje", "zastidje", "zaštedje", "zdje", | |
| "zemljedjel", "zlodje", "igdje", "izbledje", "izblijedje", "izvidje", "izdjejst", "izdjelj", "izludje", "isprdje", | |
| "jednodjel", "jednonedje", "koadjutor", "kojegdje", "kudjelj", "lebdje", "ludjel", "ludjet", "makfadjen", "marmadjuk", | |
| "međudjel", "najdjelatn", "najdjelotvornij", "nadjaha", "nadjača", "nadjeb", "nadjev", "nadježd", "nadjezik", "nadjezič", | |
| "nadjenul", "nadjenuo", "nadjenut", "nasmrdj", "neadjuvantne", "negdje", "nedjel", "nadjunač", "nenadjača", "nenadjebi", | |
| "nenavidje", "neoadjuvant", "neodje", "nepodjarm", "neopredjel", "nepodjeljenoj", "nerazdje", "nigdje", "obdjel", | |
| "obnevidje", "ovdje", "odjav", "odjad", "odjah", "odjaš", "odjeb", "odjev", "odjed", "odjezd", "odjek", "odjel", | |
| "odjen", "odjeć", "odjec", "odjur", "odsjedje", "odjesen", "odječ", "ondje", "opredje", "oskudje", "osijedje", | |
| "osmonedje", "otprdjeti", "pardju", "perdju", "petodjel", "petonedje", "poblijedje", "povidje", "pogdjegdje", "pogdje", | |
| "podjaz", "podjakn", "podjamč", "podjastrebačk", "podjastu", "podjemč", "podjar", "podjeb", "podjed", "podjezer", | |
| "podjezik", "podjezic", "podjezič", "podjel", "podjen", "podjesen", "podjet", "podjužnoslovenski", "podjurisdikcije", | |
| "podjurne", "podjurnu", "podjuhorskom", "pododjel", "podrazdjel", "pozavidje", "poludje", "poljodjel", "ponegdje", | |
| "ponedjelj", "poodjača", "poodjezdi", "poodjeknu", "poodjutri", "popridjevljen", "porazdje", "posijedje", "posjedje", | |
| "postadjektiv", "postidje", "potpodjel", "poštedje", "pradjed", "prdje", "preblijedje", "previdje", "predvidje", | |
| "preadjektiv", "predjel", "preodjen", "preraspodje", "presjedje", "pridjev", "pridjen", "predjugosl", "predjulijansk", | |
| "predjustinijansk", "predjutar", "predjutr", "presmrdje", "prisnodjev", "prismrdje", "prištedje", "probdje", | |
| "problijedje", "prodjen", "prolebdje", "prosijedje", "prosjedje", "prosmrdje", "protivdjel", "prošlonedje", "radjard", | |
| "razvidje", "razdjev", "razdjel", "razodje", "raspodje", "rasprdje", "remekdjel", "rudjen", "rudjet", "samoadjungovan", | |
| "samodjel", "samoopredjelje", "sadje", "svagdadjev", "svagdje", "svidje", "svugdje", "sedmonedjelj", "sijedje", | |
| "sjedje", "smrdje", "snabdje", "snovidje", "sredjužnoslovensk", "starosjedje", "stidje", "studje", "sudjel", "transdjus", | |
| "trejdjunion", "trodjeln", "tronedje", "ublijedje", "uvidje", "udjel", "udjen", "uprdje", "usidjel", "usjedje", "usmrdje", | |
| "uštedje", "cjelonedje", "četverodjel", "četvoronedje", "čukundjed", "šestonedjelj", "štedje", "štogdje", "šukundjed"], | |
| "dž": ["feldžandarm", "nadžanj", "nadžanr", "nadždrel", "nadžel", "nadžeo", "nadžet", "nadživ", "nadžinj", "nadžnj", | |
| "nadžrec", "nadžup", "odžali", "odžari", "odžel", "odživ", "odžubor", "odžvaka", "odžval", "odžvać", "podžanr", | |
| "podžargon", "podžel", "podže", "podžig", "podžiz", "podžil", "podžnje", "podžupan", "predželu", "predžetven", "predživot"], | |
| "nj": ["anjon", "benjamin", "vanjezičk", "vanjezičn", "guanju", "dianjon", "injaric", "injekc", "injekt", "injicira", | |
| "injurecesij", "injurij", "izvanjezičk", "izopolianjon", "kenjon", "konjug", "konjunk", "monoanjon", "nekonjug", | |
| "nekonjunk", "netanjahu", "oksianjon", "panjevrej", "panjelinsk", "panjeremen", "panjugosl", "panjudej", "panjuridizacij", | |
| "pinjin", "polianjon", "ssrnj", "subkonjunkt", "tanjug", "čanjol", "šenjang"], | |
| "lj": ["dablju", "epljard", "hiljemark", "metiljodid", "teljurajd"] | |
| } | |
| def cyr2lat(text: str) -> str: | |
| return "".join(mapping.get(ch, ch) for ch in text) | |
| def lat2cyr(text: str) -> str: | |
| result = [] | |
| word_buffer = "" | |
| i = 0 | |
| while i < len(text): | |
| ch = text[i] | |
| # If character not in any mapping key (single or digraph start), flush buffer | |
| if not any(ch.lower() == k[0] for k in reverse_mapping.keys()): | |
| if word_buffer: | |
| result.append(_convert_word(word_buffer)) | |
| word_buffer = "" | |
| result.append(ch) # keep the non‑mapped char (space, number, punctuation) | |
| i += 1 | |
| continue | |
| # Otherwise accumulate into buffer | |
| word_buffer += ch | |
| i += 1 | |
| # Flush last buffer | |
| if word_buffer: | |
| result.append(_convert_word(word_buffer)) | |
| return "".join(result) | |
| def _convert_word(word: str) -> str: | |
| i = 0 | |
| out = [] | |
| word_lower = word.lower() # compute once | |
| while i < len(word): | |
| matched = False | |
| for digraph in ["dž", "lj", "nj", "dj"]: | |
| if word_lower[i:i+len(digraph)] == digraph: | |
| # check exceptions for this digraph | |
| if any(word_lower.startswith(exc) for exc in digraphExceptions[digraph]): | |
| # expand into individual letters | |
| for ch in digraph: | |
| out.append(reverse_mapping.get(ch, ch)) | |
| i += len(digraph) | |
| else: | |
| out.append(reverse_mapping[word[i:i+len(digraph)]]) | |
| i += len(digraph) | |
| matched = True | |
| break | |
| if not matched: | |
| out.append(reverse_mapping.get(word[i], word[i])) | |
| i += 1 | |
| return "".join(out) | |
| class SrnaTokenizer(PreTrainedTokenizerFast): # | |
| model_input_names = ["input_ids", "attention_mask"] | |
| model = BPE | |
| def __init__( | |
| self, | |
| vocab: str | dict[str, int] | None = None, | |
| merges: str | list[str] | None = None, | |
| vocab_file=None, | |
| merges_file=None, | |
| unk_token: str = "<|endoftext|>", | |
| bos_token=None, | |
| eos_token: str = "<|endoftext|>", | |
| pad_token: str = "<|endoftext|>", | |
| add_prefix_space=None, | |
| boc_token = "<csta>", | |
| eoc_token = "<cend>", | |
| cap_token = "<capi>", | |
| up_token = "<uppe>", | |
| case_compression = False, | |
| script_compression = True, | |
| omit_tags = False, | |
| **kwargs, | |
| ): | |
| self.add_prefix_space = add_prefix_space if add_prefix_space is not None else False | |
| self._vocab = ( | |
| vocab | |
| if vocab is not None | |
| else { | |
| "<|endoftext|>": 0, | |
| } | |
| ) | |
| self.boc_token = boc_token | |
| self.eoc_token = eoc_token | |
| self.cap_token = cap_token | |
| self.up_token = up_token | |
| self.case_compression = case_compression | |
| self.script_compression = script_compression | |
| self.omit_tags = omit_tags | |
| self.PRETOKENIZE_REGEX = r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?[\p{L}\p{M}]+|\p{N}| ?[^\s\p{L}\p{M}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+""" | |
| self.CYRILLIC_REGEX = r"\s?\p{Cyrillic}[^\p{Latin}<\[|{}]*" | |
| self.CLEANUP_FIND = rf"(\s+){regex.escape(self.eoc_token)}" | |
| self.CLEANUP_REPLACE = rf"{regex.escape(self.eoc_token)}\1" | |
| self.CAPITAL_REGEX = r"\s?\b\p{Lu}\p{Ll}+\b" | |
| self.UPPER_REGEX = r"\s?\b\p{Lu}{2,}\b" | |
| self.UP_FIND = rf"{regex.escape(self.up_token)}(\s?\w+)" | |
| self.CAP_FIND = rf"{regex.escape(self.cap_token)}(\s?\w+)" | |
| self.CYR_FIND = rf"{regex.escape(self.boc_token)}([\s\S]*?)({regex.escape(self.eoc_token)}|$)" | |
| self._merges = merges or [] | |
| self._tokenizer = Tokenizer( | |
| BPE( | |
| vocab=self._vocab, | |
| merges=self._merges, | |
| dropout=None, | |
| unk_token=None, | |
| continuing_subword_prefix="", | |
| end_of_word_suffix="", | |
| fuse_unk=False, | |
| byte_fallback=False, | |
| ) | |
| ) | |
| self._tokenizer.decoder = decoders.ByteLevel() | |
| self._tokenizer.normalizer = normalizers.NFC() | |
| self._tokenizer.pre_tokenizer = pre_tokenizers.Sequence( | |
| [ | |
| pre_tokenizers.Split( | |
| Regex(self.PRETOKENIZE_REGEX), | |
| behavior="isolated", | |
| invert=False, | |
| ), | |
| pre_tokenizers.ByteLevel( | |
| add_prefix_space=self.add_prefix_space, | |
| use_regex=False, | |
| ), | |
| ] | |
| ) | |
| super().__init__( | |
| vocab_file=vocab_file, | |
| merges_file=merges_file, | |
| unk_token=unk_token, | |
| bos_token=bos_token, | |
| eos_token=eos_token, | |
| pad_token=pad_token, | |
| add_prefix_space=add_prefix_space, | |
| **kwargs, | |
| ) | |
| def prepare_for_tokenization(self, text, is_split_into_words=False, **kwargs): | |
| # Handle None or non-string types gracefully | |
| if text is None: | |
| return "" | |
| if isinstance(text, list): | |
| # If a list is passed, recursively process each element | |
| return [self.prepare_for_tokenization(t, is_split_into_words=is_split_into_words, **kwargs) for t in text] | |
| if not isinstance(text, str): | |
| text = str(text) | |
| def mark_cap(match): | |
| if self.omit_tags: | |
| return match.group(0).lower() | |
| return f"{self.cap_token}{match.group(0).lower()}" | |
| def mark_up(match): | |
| if self.omit_tags: | |
| return match.group(0).lower() | |
| return f"{self.up_token}{match.group(0).lower()}" | |
| def wrap_and_transliterate(match): | |
| cyr_text = match.group(0) | |
| latin_text = cyr2lat(cyr_text) | |
| if self.omit_tags: | |
| return latin_text | |
| return f"{self.boc_token}{latin_text}{self.eoc_token}" | |
| if self.script_compression: | |
| text = regex.sub(self.CYRILLIC_REGEX, wrap_and_transliterate, text) | |
| if text.endswith(self.eoc_token): | |
| text = text[: -len(self.eoc_token)] | |
| text = regex.sub(self.CLEANUP_FIND, self.CLEANUP_REPLACE, text) | |
| if self.case_compression: | |
| text = regex.sub(self.CAPITAL_REGEX, mark_cap, text) | |
| text = regex.sub(self.UPPER_REGEX, mark_up, text) | |
| return text | |
| def encode(self, text: str, *args, **kwargs): | |
| text = self.prepare_for_tokenization(text) | |
| return super().encode(text, *args, **kwargs) | |
| def _encode_plus(self, text, *args, **kwargs): | |
| if text is None: | |
| text = "" | |
| elif isinstance(text, list): | |
| text = [str(t) if t is not None else "" for t in text] | |
| elif not isinstance(text, str): | |
| text = str(text) | |
| if isinstance(text, str) and self.add_prefix_space: | |
| text = text.lstrip("\n\t") | |
| if not text.startswith(" "): | |
| text = " " + text | |
| # apply preprocessing hook safely | |
| text = self.prepare_for_tokenization(text, **kwargs) | |
| return super()._encode_plus(text, *args, **kwargs) | |
| def decode(self, token_ids, *args, **kwargs): | |
| text = super().decode(token_ids, *args, **kwargs) | |
| # Helper function to apply regex decoding logic to a single string safely | |
| def _decode_text_string(s: str) -> str: | |
| if not isinstance(s, str): | |
| s = str(s) if s is not None else "" | |
| def decode_cyr(match): | |
| return lat2cyr(match.group(1)) | |
| def decode_cap(match): | |
| inner = match.group(1) | |
| if not inner: | |
| return inner | |
| ws_match = regex.match(r"^\s*", inner) | |
| leading_ws = ws_match.group(0) if ws_match else "" | |
| if not leading_ws: | |
| return inner[0].upper() + inner[1:] if len(inner) > 0 else inner | |
| core = inner.lstrip() | |
| if core: | |
| core = core[0].upper() + core[1:] | |
| return leading_ws + core | |
| def decode_allcaps(match): | |
| return match.group(1).upper() | |
| if self.case_compression: | |
| s = regex.sub(self.UP_FIND, decode_allcaps, s) | |
| s = regex.sub(self.CAP_FIND, decode_cap, s) | |
| if self.script_compression: | |
| s = regex.sub(self.CYR_FIND, decode_cyr, s) | |
| return s | |
| # Safely process both single strings and list/batch returns | |
| if isinstance(text, list): | |
| return [_decode_text_string(t) for t in text] | |
| return _decode_text_string(text) | |
| __all__ = ["SrnaTokenizer"] | |