Text Generation
Transformers
Safetensors
ncp_smol
next-concept-prediction
conceptlm
causal-lm
smollm2
tessera
custom_code
Instructions to use yava-code/Tessera-135M-Gate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yava-code/Tessera-135M-Gate with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yava-code/Tessera-135M-Gate", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("yava-code/Tessera-135M-Gate", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yava-code/Tessera-135M-Gate with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yava-code/Tessera-135M-Gate" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yava-code/Tessera-135M-Gate", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yava-code/Tessera-135M-Gate
- SGLang
How to use yava-code/Tessera-135M-Gate 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 "yava-code/Tessera-135M-Gate" \ --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": "yava-code/Tessera-135M-Gate", "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 "yava-code/Tessera-135M-Gate" \ --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": "yava-code/Tessera-135M-Gate", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yava-code/Tessera-135M-Gate with Docker Model Runner:
docker model run hf.co/yava-code/Tessera-135M-Gate
Download configuration.py from yava-code/Tessera-135M-Gate: direct link, hf CLI and curl.
- Browser
- Download file 2.71 kB
-
https://huggingface.co/yava-code/Tessera-135M-Gate/resolve/main/configuration.py
- Command line
-
hf download hf://yava-code/Tessera-135M-Gate/configuration.py
-
curl -L -o configuration.py https://huggingface.co/yava-code/Tessera-135M-Gate/resolve/main/configuration.py
2.71 kB
| from __future__ import annotations | |
| from typing import Any | |
| from transformers import LlamaConfig, PretrainedConfig | |
| class NcpSmolConfig(PretrainedConfig): | |
| model_type = "ncp_smol" | |
| def __init__( | |
| self, | |
| backbone_config: dict[str, Any] | None = None, | |
| base_model_name_or_path: str = "HuggingFaceTB/SmolLM2-360M", | |
| base_model_revision: str | None = None, | |
| chunk_size: int = 4, | |
| segments: int | None = None, | |
| codebook_size: int = 64, | |
| concept_layers: int = 2, | |
| insert_layer: int = 1, | |
| ncp_target: str = "continuous", | |
| ncp_weight: float = 1.0, | |
| vq_weight: float = 1.0, | |
| **kwargs: Any, | |
| ) -> None: | |
| super().__init__(**kwargs) | |
| backbone_config = backbone_config or LlamaConfig().to_dict() | |
| hidden_size = int(backbone_config["hidden_size"]) | |
| heads = int(backbone_config["num_attention_heads"]) | |
| segments = heads if segments is None else segments | |
| if chunk_size < 2: | |
| raise ValueError("chunk_size must be at least 2") | |
| if hidden_size % segments: | |
| raise ValueError("hidden_size must be divisible by segments") | |
| if not 0 < insert_layer < int(backbone_config["num_hidden_layers"]): | |
| raise ValueError("insert_layer must split the token backbone") | |
| if concept_layers < 1: | |
| raise ValueError("concept_layers must be positive") | |
| if codebook_size < 2: | |
| raise ValueError("codebook_size must be at least 2") | |
| if ncp_target not in {"quantized", "continuous"}: | |
| raise ValueError("ncp_target must be 'quantized' or 'continuous'") | |
| self.backbone_config = backbone_config | |
| self.hidden_size = hidden_size | |
| self.vocab_size = int(backbone_config["vocab_size"]) | |
| self.num_hidden_layers = int(backbone_config["num_hidden_layers"]) | |
| self.num_attention_heads = heads | |
| self.num_key_value_heads = int(backbone_config["num_key_value_heads"]) | |
| self.use_cache = False | |
| self.base_model_name_or_path = base_model_name_or_path | |
| self.base_model_revision = base_model_revision | |
| self.chunk_size = chunk_size | |
| self.segments = segments | |
| self.codebook_size = codebook_size | |
| self.concept_layers = concept_layers | |
| self.insert_layer = insert_layer | |
| self.ncp_target = ncp_target | |
| self.ncp_weight = ncp_weight | |
| self.vq_weight = vq_weight | |
| self.architectures = ["NcpSmolForCausalLM"] | |
| self.auto_map = { | |
| "AutoConfig": "configuration.NcpSmolConfig", | |
| "AutoModelForCausalLM": "modeling.NcpSmolForCausalLM", | |
| } | |
| NcpSmolConfig.register_for_auto_class() | |