Text Generation
Transformers
Safetensors
PyTorch
English
axiom
causal-lm
fine-tuned
instruct-model
custom-architecture
tiktoken
chatml
custom_code
Instructions to use user-anto/Axiom-Dense-380M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use user-anto/Axiom-Dense-380M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="user-anto/Axiom-Dense-380M-Instruct", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("user-anto/Axiom-Dense-380M-Instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use user-anto/Axiom-Dense-380M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "user-anto/Axiom-Dense-380M-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "user-anto/Axiom-Dense-380M-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/user-anto/Axiom-Dense-380M-Instruct
- SGLang
How to use user-anto/Axiom-Dense-380M-Instruct 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 "user-anto/Axiom-Dense-380M-Instruct" \ --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": "user-anto/Axiom-Dense-380M-Instruct", "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 "user-anto/Axiom-Dense-380M-Instruct" \ --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": "user-anto/Axiom-Dense-380M-Instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use user-anto/Axiom-Dense-380M-Instruct with Docker Model Runner:
docker model run hf.co/user-anto/Axiom-Dense-380M-Instruct
Download tokenization_axiom.py from user-anto/Axiom-Dense-380M-Instruct: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/user-anto/Axiom-Dense-380M-Instruct/resolve/00b537b495488aa1568aab8b36aa4256141204a7/tokenization_axiom.py
- Command line
-
hf download hf://user-anto/Axiom-Dense-380M-Instruct@00b537b495488aa1568aab8b36aa4256141204a7/tokenization_axiom.py
-
curl -L -o tokenization_axiom.py https://huggingface.co/user-anto/Axiom-Dense-380M-Instruct/resolve/00b537b495488aa1568aab8b36aa4256141204a7/tokenization_axiom.py
2.47 kB
| import json | |
| import os | |
| import tiktoken | |
| from transformers import PreTrainedTokenizer | |
| class axiomTokenizer(PreTrainedTokenizer): | |
| vocab_files_names = {"tokenizer_file": "tokenizer.model"} | |
| model_input_names = ["input_ids", "attention_mask"] | |
| def __init__( | |
| self, | |
| tokenizer_file=None, | |
| encoding_name="cl100k_base", | |
| eos_token="<|endoftext|>", | |
| pad_token="<|endoftext|>", | |
| unk_token="<|unk|>", | |
| **kwargs, | |
| ): | |
| if tokenizer_file and os.path.isfile(tokenizer_file): | |
| with open(tokenizer_file, "r", encoding="utf-8") as f: | |
| payload = json.load(f) | |
| encoding_name = payload.get("encoding_name", encoding_name) | |
| self.encoding_name = encoding_name | |
| self._enc = tiktoken.get_encoding(self.encoding_name) | |
| super().__init__( | |
| eos_token=eos_token, | |
| pad_token=pad_token, | |
| unk_token=unk_token, | |
| **kwargs, | |
| ) | |
| def vocab_size(self): | |
| return int(self._enc.n_vocab) | |
| def get_vocab(self): | |
| return {f"<|{i}|>": i for i in range(self.vocab_size)} | |
| def _tokenize(self, text, **kwargs): | |
| ids = self._enc.encode_ordinary(text) | |
| return [f"<|{i}|>" for i in ids] | |
| def _convert_token_to_id(self, token): | |
| if token == self.eos_token or token == self.pad_token: | |
| return int(self._enc.eot_token) | |
| if token.startswith("<|") and token.endswith("|>"): | |
| n = token[2:-2] | |
| if n.isdigit(): | |
| return int(n) | |
| return int(self._enc.eot_token) | |
| def _convert_id_to_token(self, index): | |
| return f"<|{int(index)}|>" | |
| def convert_tokens_to_string(self, tokens): | |
| ids = [self._convert_token_to_id(t) for t in tokens] | |
| return self._enc.decode(ids) | |
| def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None): | |
| if token_ids_1 is None: | |
| return list(token_ids_0) | |
| return list(token_ids_0) + list(token_ids_1) | |
| def save_vocabulary(self, save_directory, filename_prefix=None): | |
| os.makedirs(save_directory, exist_ok=True) | |
| out_name = "tokenizer.model" if filename_prefix is None else f"{filename_prefix}-tokenizer.model" | |
| out_path = os.path.join(save_directory, out_name) | |
| with open(out_path, "w", encoding="utf-8") as f: | |
| json.dump({"encoding_name": self.encoding_name}, f) | |
| return (out_path,) | |