How to use from
vLLM
Install from pip and serve model
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ariG23498/layer-skip-v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
	-H "Content-Type: application/json" \
	--data '{
		"model": "ariG23498/layer-skip-v1",
		"prompt": "Once upon a time,",
		"max_tokens": 512,
		"temperature": 0.5
	}'
Use Docker
docker model run hf.co/ariG23498/layer-skip-v1
Quick Links
class LayerSkipSFTTrainer(SFTTrainer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.early_exit_layer = 0 # initialize with 0
        self.always_last_layer = True

    def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None):
        self.early_exit_layer = (self.early_exit_layer % (model.config.num_hidden_layers - 1)) + 1 # rotates between [1, num_hidden_layers-1]

        labels = inputs.pop("labels")
        outputs = model(**inputs, output_hidden_states=True)
        
        hidden_state = outputs["hidden_states"][self.early_exit_layer]
        logits = model.lm_head(hidden_state)
        loss = model.loss_function(logits=logits, labels=labels, vocab_size=model.vocab_size)
        
        if self.always_last_layer:
            loss = loss + model.loss_function(logits=outputs["logits"], labels=labels, vocab_size=model.vocab_size)
                
        return loss
Downloads last month
52
Safetensors
Model size
1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for ariG23498/layer-skip-v1

Finetuned
(958)
this model

Collection including ariG23498/layer-skip-v1