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
File size: 2,708 Bytes
7709bf3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 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()
|