Text Generation
Transformers
Safetensors
mother_core
mother-core
agentic
tool-use
reasoning
rag
code
uk-sovereign
custom_code
Instructions to use MediaStreamAI/MOTHER_CORE_V3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MediaStreamAI/MOTHER_CORE_V3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MediaStreamAI/MOTHER_CORE_V3", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MediaStreamAI/MOTHER_CORE_V3", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MediaStreamAI/MOTHER_CORE_V3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MediaStreamAI/MOTHER_CORE_V3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MediaStreamAI/MOTHER_CORE_V3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MediaStreamAI/MOTHER_CORE_V3
- SGLang
How to use MediaStreamAI/MOTHER_CORE_V3 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 "MediaStreamAI/MOTHER_CORE_V3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MediaStreamAI/MOTHER_CORE_V3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "MediaStreamAI/MOTHER_CORE_V3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MediaStreamAI/MOTHER_CORE_V3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MediaStreamAI/MOTHER_CORE_V3 with Docker Model Runner:
docker model run hf.co/MediaStreamAI/MOTHER_CORE_V3
Download tokenization_mother.py from MediaStreamAI/MOTHER_CORE_V3: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/MediaStreamAI/MOTHER_CORE_V3/resolve/main/tokenization_mother.py
- Command line
-
hf download hf://MediaStreamAI/MOTHER_CORE_V3/tokenization_mother.py
-
curl -L -o tokenization_mother.py https://huggingface.co/MediaStreamAI/MOTHER_CORE_V3/resolve/main/tokenization_mother.py
3.16 kB
| """ | |
| MotherCoreTokenizer — HF-compatible wrapper around MotherTokenizer. | |
| Uses the SentencePiece model at /home/ckenna/model_archive/mother.model | |
| which is the sovereign MediaStream AI tokenizer — NOT a copy of any | |
| external tokenizer. | |
| """ | |
| import os | |
| import sys | |
| from typing import List, Optional | |
| from transformers import PreTrainedTokenizer | |
| import sentencepiece as spm | |
| class MotherCoreTokenizer(PreTrainedTokenizer): | |
| """ | |
| HF-compatible tokenizer wrapping the MOTHER CORE SentencePiece model. | |
| Uses the sovereign tokenizer at /home/ckenna/model_archive/mother.model. | |
| """ | |
| vocab_files_names = {"vocab_file": "tokenizer.model"} | |
| model_input_names = ["input_ids", "attention_mask"] | |
| def __init__( | |
| self, | |
| vocab_file: str = "tokenizer.model", | |
| bos_token: str = "<s>", | |
| eos_token: str = "</s>", | |
| pad_token: str = "<pad>", | |
| unk_token: str = "<unk>", | |
| add_bos_token: bool = False, | |
| add_eos_token: bool = False, | |
| **kwargs, | |
| ): | |
| self.vocab_file = vocab_file | |
| self.sp_model = spm.SentencePieceProcessor() | |
| self.sp_model.load(vocab_file) | |
| self.add_bos_token = add_bos_token | |
| self.add_eos_token = add_eos_token | |
| super().__init__( | |
| bos_token=bos_token, | |
| eos_token=eos_token, | |
| pad_token=pad_token, | |
| unk_token=unk_token, | |
| add_bos_token=add_bos_token, | |
| add_eos_token=add_eos_token, | |
| **kwargs, | |
| ) | |
| def vocab_size(self) -> int: | |
| return self.sp_model.get_piece_size() | |
| def get_vocab(self): | |
| vocab = {self.convert_ids_to_tokens(i): i for i in range(self.vocab_size)} | |
| vocab.update(self.added_tokens_encoder) | |
| return vocab | |
| def _tokenize(self, text: str) -> List[str]: | |
| return self.sp_model.encode(text, out_type=str) | |
| def _convert_token_to_id(self, token: str) -> int: | |
| return self.sp_model.piece_to_id(token) | |
| def _convert_id_to_token(self, index: int) -> str: | |
| return self.sp_model.id_to_piece(index) | |
| def convert_tokens_to_string(self, tokens: List[str]) -> str: | |
| return self.sp_model.decode(tokens) | |
| def build_inputs_with_special_tokens( | |
| self, | |
| token_ids_0: List[int], | |
| token_ids_1: Optional[List[int]] = None, | |
| ) -> List[int]: | |
| bos = [self.bos_token_id] if self.add_bos_token else [] | |
| eos = [self.eos_token_id] if self.add_eos_token else [] | |
| out = bos + token_ids_0 + eos | |
| if token_ids_1 is not None: | |
| out = out + bos + token_ids_1 + eos | |
| return out | |
| def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None): | |
| if not os.path.isdir(save_directory): | |
| os.makedirs(save_directory, exist_ok=True) | |
| out_file = os.path.join( | |
| save_directory, | |
| (filename_prefix + "-" if filename_prefix else "") + "tokenizer.model" | |
| ) | |
| if os.path.abspath(self.vocab_file) != os.path.abspath(out_file): | |
| import shutil | |
| shutil.copyfile(self.vocab_file, out_file) | |
| return (out_file,) | |