Instructions to use Finisha-F-scratch/SoraForSLM-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Finisha-F-scratch/SoraForSLM-1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Finisha-F-scratch/SoraForSLM-1", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Finisha-F-scratch/SoraForSLM-1", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Finisha-F-scratch/SoraForSLM-1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Finisha-F-scratch/SoraForSLM-1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Finisha-F-scratch/SoraForSLM-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Finisha-F-scratch/SoraForSLM-1
- SGLang
How to use Finisha-F-scratch/SoraForSLM-1 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 "Finisha-F-scratch/SoraForSLM-1" \ --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": "Finisha-F-scratch/SoraForSLM-1", "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 "Finisha-F-scratch/SoraForSLM-1" \ --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": "Finisha-F-scratch/SoraForSLM-1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Finisha-F-scratch/SoraForSLM-1 with Docker Model Runner:
docker model run hf.co/Finisha-F-scratch/SoraForSLM-1
| import torch | |
| import torch.nn as nn | |
| from transformers import PreTrainedModel, GenerationMixin | |
| from transformers.modeling_outputs import CausalLMOutput | |
| from .configuration_sora import SoraConfig | |
| class SoraForSLM(PreTrainedModel, GenerationMixin): | |
| config_class = SoraConfig | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.embeddings = nn.Embedding(config.vocab_size, config.hidden_size) | |
| self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size) | |
| self.layers = nn.ModuleList([ | |
| nn.TransformerEncoderLayer( | |
| d_model=config.hidden_size, | |
| nhead=config.num_heads, | |
| dim_feedforward=config.hidden_size * 4, | |
| batch_first=True, | |
| activation="gelu" | |
| ) for _ in range(config.num_layers) | |
| ]) | |
| self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False) | |
| self.post_init() | |
| def get_input_embeddings(self): | |
| return self.embeddings | |
| def prepare_inputs_for_generation(self, input_ids, **kwargs): | |
| return {"input_ids": input_ids} | |
| def forward(self, input_ids=None, attention_mask=None, labels=None, **kwargs): | |
| # Calcul des positions | |
| seq_length = input_ids.size(1) | |
| positions = torch.arange(seq_length, device=input_ids.device).unsqueeze(0) | |
| # Embeddings | |
| x = self.embeddings(input_ids) + self.position_embeddings(positions) | |
| # Passage dans les couches (sans masque pour éviter tout conflit) | |
| for layer in self.layers: | |
| x = layer(x) | |
| logits = self.lm_head(x) | |
| loss = None | |
| if labels is not None: | |
| # Shift pour l'entraînement causal | |
| shift_logits = logits[..., :-1, :].contiguous() | |
| shift_labels = input_ids[..., 1:].contiguous() | |
| loss_fct = nn.CrossEntropyLoss() | |
| loss = loss_fct(shift_logits.view(-1, self.config.vocab_size), shift_labels.view(-1)) | |
| return CausalLMOutput(loss=loss, logits=logits) |