Text Generation
Transformers
Safetensors
lafa
feature-extraction
qwen3
flow-matching
speculative-decoding
custom_code
conversational
Instructions to use lafa-hf/lafa-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lafa-hf/lafa-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lafa-hf/lafa-8B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lafa-hf/lafa-8B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lafa-hf/lafa-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lafa-hf/lafa-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lafa-hf/lafa-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lafa-hf/lafa-8B
- SGLang
How to use lafa-hf/lafa-8B 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 "lafa-hf/lafa-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lafa-hf/lafa-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "lafa-hf/lafa-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lafa-hf/lafa-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lafa-hf/lafa-8B with Docker Model Runner:
docker model run hf.co/lafa-hf/lafa-8B
File size: 1,937 Bytes
b4477c1 | 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 | """
Base wrapper for HF Trainer compatibility.
Inherits PreTrainedModel so Trainer gets save_pretrained, from_pretrained,
tied weight handling, gradient checkpointing — all for free.
Subclasses store the backbone as `self.backbone` and must implement
forward() and generate().
"""
from abc import abstractmethod
from transformers import PreTrainedModel
class BaseModelWrapper(PreTrainedModel):
"""Abstract base that wraps a CausalLM backbone for HF Trainer.
Uses the backbone's config. The default state_dict strips the backbone
prefix for AR checkpoints; FlowModelWrapper overrides it to retain flow
layers in its checkpoints.
Subclasses must implement forward() and generate().
"""
base_model_prefix = "backbone"
supports_gradient_checkpointing = True
def __init__(self, backbone: PreTrainedModel):
import copy
config = copy.deepcopy(backbone.config)
config._attn_implementation_internal = "eager"
super().__init__(config)
self.backbone = backbone
if backbone._tied_weights_keys is not None:
self._tied_weights_keys = backbone._tied_weights_keys
def _init_weights(self, module):
pass
@abstractmethod
def forward(self, **kwargs): ...
@abstractmethod
def generate(self, **kwargs): ...
def state_dict(self, *args, **kwargs):
"""Strip 'backbone.' prefix so checkpoints are loadable by AutoModel."""
sd = super().state_dict(*args, **kwargs)
return {k.removeprefix("backbone."): v for k, v in sd.items()}
def load_state_dict(self, state_dict, *args, **kwargs):
"""Load into backbone directly (handles keys with or without prefix)."""
if any(k.startswith("backbone.") for k in state_dict):
state_dict = {k.removeprefix("backbone."): v for k, v in state_dict.items()}
return self.backbone.load_state_dict(state_dict, *args, **kwargs)
|