Text Generation
Transformers
Safetensors
tinyqwen3_novelty
qwen3
causal-lm
tiny-language-model
novelty-gated-attention
trust-remote-code
custom_code
Instructions to use User01110/tinyLM-8M-exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use User01110/tinyLM-8M-exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="User01110/tinyLM-8M-exp", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("User01110/tinyLM-8M-exp", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use User01110/tinyLM-8M-exp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "User01110/tinyLM-8M-exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "User01110/tinyLM-8M-exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/User01110/tinyLM-8M-exp
- SGLang
How to use User01110/tinyLM-8M-exp 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 "User01110/tinyLM-8M-exp" \ --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": "User01110/tinyLM-8M-exp", "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 "User01110/tinyLM-8M-exp" \ --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": "User01110/tinyLM-8M-exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use User01110/tinyLM-8M-exp with Docker Model Runner:
docker model run hf.co/User01110/tinyLM-8M-exp
Accept tokenizer token_type_ids during generation
Browse files
modeling_tinyqwen3_novelty.py
CHANGED
|
@@ -141,20 +141,24 @@ class TinyQwen3NoveltyForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 141 |
def set_input_embeddings(self, value):
|
| 142 |
self.embed_tokens = value
|
| 143 |
|
| 144 |
-
def prepare_inputs_for_generation(self, input_ids, attention_mask=None, **kwargs):
|
| 145 |
max_len = getattr(self.config, "max_position_embeddings", None)
|
| 146 |
if max_len is not None and input_ids.shape[-1] > max_len:
|
| 147 |
input_ids = input_ids[:, -max_len:]
|
| 148 |
if attention_mask is not None:
|
| 149 |
attention_mask = attention_mask[:, -max_len:]
|
|
|
|
|
|
|
| 150 |
|
| 151 |
model_inputs = {"input_ids": input_ids}
|
| 152 |
if attention_mask is not None:
|
| 153 |
model_inputs["attention_mask"] = attention_mask
|
|
|
|
|
|
|
| 154 |
return model_inputs
|
| 155 |
|
| 156 |
-
def forward(self, input_ids=None, attention_mask=None, labels=None, return_dict=True, **kwargs):
|
| 157 |
-
del attention_mask, kwargs
|
| 158 |
x = self.embed_tokens(input_ids)
|
| 159 |
for layer in self.layers:
|
| 160 |
x = layer(x)
|
|
|
|
| 141 |
def set_input_embeddings(self, value):
|
| 142 |
self.embed_tokens = value
|
| 143 |
|
| 144 |
+
def prepare_inputs_for_generation(self, input_ids, attention_mask=None, token_type_ids=None, **kwargs):
|
| 145 |
max_len = getattr(self.config, "max_position_embeddings", None)
|
| 146 |
if max_len is not None and input_ids.shape[-1] > max_len:
|
| 147 |
input_ids = input_ids[:, -max_len:]
|
| 148 |
if attention_mask is not None:
|
| 149 |
attention_mask = attention_mask[:, -max_len:]
|
| 150 |
+
if token_type_ids is not None:
|
| 151 |
+
token_type_ids = token_type_ids[:, -max_len:]
|
| 152 |
|
| 153 |
model_inputs = {"input_ids": input_ids}
|
| 154 |
if attention_mask is not None:
|
| 155 |
model_inputs["attention_mask"] = attention_mask
|
| 156 |
+
if token_type_ids is not None:
|
| 157 |
+
model_inputs["token_type_ids"] = token_type_ids
|
| 158 |
return model_inputs
|
| 159 |
|
| 160 |
+
def forward(self, input_ids=None, attention_mask=None, token_type_ids=None, labels=None, return_dict=True, **kwargs):
|
| 161 |
+
del attention_mask, token_type_ids, kwargs
|
| 162 |
x = self.embed_tokens(input_ids)
|
| 163 |
for layer in self.layers:
|
| 164 |
x = layer(x)
|