Instructions to use OpenCOReTechnologies/Flash-V1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenCOReTechnologies/Flash-V1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenCOReTechnologies/Flash-V1")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenCOReTechnologies/Flash-V1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use OpenCOReTechnologies/Flash-V1 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf OpenCOReTechnologies/Flash-V1:Q4_K_M # Run inference directly in the terminal: llama cli -hf OpenCOReTechnologies/Flash-V1:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf OpenCOReTechnologies/Flash-V1:Q4_K_M # Run inference directly in the terminal: llama cli -hf OpenCOReTechnologies/Flash-V1:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf OpenCOReTechnologies/Flash-V1:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf OpenCOReTechnologies/Flash-V1:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf OpenCOReTechnologies/Flash-V1:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf OpenCOReTechnologies/Flash-V1:Q4_K_M
Use Docker
docker model run hf.co/OpenCOReTechnologies/Flash-V1:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use OpenCOReTechnologies/Flash-V1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenCOReTechnologies/Flash-V1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenCOReTechnologies/Flash-V1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OpenCOReTechnologies/Flash-V1:Q4_K_M
- SGLang
How to use OpenCOReTechnologies/Flash-V1 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 "OpenCOReTechnologies/Flash-V1" \ --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": "OpenCOReTechnologies/Flash-V1", "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 "OpenCOReTechnologies/Flash-V1" \ --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": "OpenCOReTechnologies/Flash-V1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use OpenCOReTechnologies/Flash-V1 with Ollama:
ollama run hf.co/OpenCOReTechnologies/Flash-V1:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use OpenCOReTechnologies/Flash-V1 with Docker Model Runner:
docker model run hf.co/OpenCOReTechnologies/Flash-V1:Q4_K_M
- Lemonade
How to use OpenCOReTechnologies/Flash-V1 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull OpenCOReTechnologies/Flash-V1:Q4_K_M
Run and chat with the model
lemonade run user.Flash-V1-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Download flash-v1/modeling_core.py from OpenCOReTechnologies/Flash-V1: direct link, hf CLI and curl.
- Browser
- Download file 6.01 kB
-
https://huggingface.co/OpenCOReTechnologies/Flash-V1/resolve/main/flash-v1/modeling_core.py
- Command line
-
hf download hf://OpenCOReTechnologies/Flash-V1/flash-v1/modeling_core.py
-
curl -L -o modeling_core.py https://huggingface.co/OpenCOReTechnologies/Flash-V1/resolve/main/flash-v1/modeling_core.py
6.01 kB
| """CORe model architecture for HuggingFace transformers.""" | |
| import math | |
| from typing import Optional, Tuple | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.functional as F | |
| from transformers import PreTrainedModel, PretrainedConfig, GenerationMixin | |
| from transformers.modeling_outputs import CausalLMOutput | |
| class COReConfig(PretrainedConfig): | |
| model_type = "core" | |
| def __init__( | |
| self, | |
| n_layer=12, | |
| n_head=16, | |
| n_embd=1024, | |
| block_size=512, | |
| vocab_size=16384, | |
| rope=False, | |
| dropout=0.0, | |
| **kwargs, | |
| ): | |
| super().__init__(**kwargs) | |
| self.n_layer = n_layer | |
| self.n_head = n_head | |
| self.n_embd = n_embd | |
| self.block_size = block_size | |
| self.vocab_size = vocab_size | |
| self.rope = rope | |
| self.dropout = dropout | |
| class CausalSelfAttention(nn.Module): | |
| def __init__(self, config): | |
| super().__init__() | |
| assert config.n_embd % config.n_head == 0 | |
| self.c_attn = nn.Linear(config.n_embd, 3 * config.n_embd) | |
| self.c_proj = nn.Linear(config.n_embd, config.n_embd) | |
| self.attn_dropout = nn.Dropout(config.dropout) | |
| self.resid_dropout = nn.Dropout(config.dropout) | |
| self.n_head = config.n_head | |
| self.head_dim = config.n_embd // config.n_head | |
| self.register_buffer( | |
| "causal_mask", | |
| torch.tril(torch.ones(config.block_size, config.block_size)).view( | |
| 1, 1, config.block_size, config.block_size | |
| ), | |
| persistent=False, | |
| ) | |
| def forward(self, x): | |
| B, T, C = x.size() | |
| q, k, v = self.c_attn(x).split(C, dim=2) | |
| q = q.view(B, T, self.n_head, self.head_dim).transpose(1, 2) | |
| k = k.view(B, T, self.n_head, self.head_dim).transpose(1, 2) | |
| v = v.view(B, T, self.n_head, self.head_dim).transpose(1, 2) | |
| y = F.scaled_dot_product_attention( | |
| q, k, v, | |
| dropout_p=self.attn_dropout.p if self.training else 0.0, | |
| is_causal=True, | |
| ) | |
| y = y.transpose(1, 2).contiguous().view(B, T, C) | |
| return self.resid_dropout(self.c_proj(y)) | |
| class MLP(nn.Module): | |
| def __init__(self, config): | |
| super().__init__() | |
| self.c_fc = nn.Linear(config.n_embd, 4 * config.n_embd) | |
| self.c_proj = nn.Linear(4 * config.n_embd, config.n_embd) | |
| self.dropout = nn.Dropout(config.dropout) | |
| def forward(self, x): | |
| return self.dropout(self.c_proj(F.gelu(self.c_fc(x)))) | |
| class Block(nn.Module): | |
| def __init__(self, config): | |
| super().__init__() | |
| self.ln_1 = nn.LayerNorm(config.n_embd) | |
| self.attn = CausalSelfAttention(config) | |
| self.ln_2 = nn.LayerNorm(config.n_embd) | |
| self.mlp = MLP(config) | |
| def forward(self, x): | |
| x = x + self.attn(self.ln_1(x)) | |
| x = x + self.mlp(self.ln_2(x)) | |
| return x | |
| class COReModel(PreTrainedModel): | |
| config_class = COReConfig | |
| base_model_prefix = "core" | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.config = config | |
| self.tok_emb = nn.Embedding(config.vocab_size, config.n_embd) | |
| self.pos_emb = None if config.rope else nn.Embedding(config.block_size, config.n_embd) | |
| self.drop = nn.Dropout(config.dropout) | |
| self.blocks = nn.ModuleList(Block(config) for _ in range(config.n_layer)) | |
| self.ln_f = nn.LayerNorm(config.n_embd) | |
| self.post_init() | |
| def forward(self, input_ids, attention_mask=None, **kwargs): | |
| B, T = input_ids.size() | |
| if self.pos_emb is not None: | |
| pos = torch.arange(0, T, device=input_ids.device) | |
| x = self.drop(self.tok_emb(input_ids) + self.pos_emb(pos)) | |
| else: | |
| x = self.drop(self.tok_emb(input_ids)) | |
| for block in self.blocks: | |
| x = block(x) | |
| return self.ln_f(x) | |
| class COReForCausalLM(PreTrainedModel, GenerationMixin): | |
| config_class = COReConfig | |
| base_model_prefix = "core" | |
| main_input_name = "input_ids" | |
| _supports_cache_class = False | |
| _supports_static_cache = False | |
| def __init__(self, config): | |
| super().__init__(config) | |
| self.config = config | |
| self.tok_emb = nn.Embedding(config.vocab_size, config.n_embd) | |
| self.pos_emb = None if config.rope else nn.Embedding(config.block_size, config.n_embd) | |
| self.drop = nn.Dropout(config.dropout) | |
| self.blocks = nn.ModuleList(Block(config) for _ in range(config.n_layer)) | |
| self.ln_f = nn.LayerNorm(config.n_embd) | |
| self.head = nn.Linear(config.n_embd, config.vocab_size, bias=False) | |
| self.tok_emb.weight = self.head.weight | |
| self.post_init() | |
| def forward(self, input_ids, attention_mask=None, labels=None, **kwargs): | |
| B, T = input_ids.size() | |
| if self.pos_emb is not None: | |
| pos = torch.arange(0, T, device=input_ids.device) | |
| x = self.drop(self.tok_emb(input_ids) + self.pos_emb(pos)) | |
| else: | |
| x = self.drop(self.tok_emb(input_ids)) | |
| for block in self.blocks: | |
| x = block(x) | |
| x = self.ln_f(x) | |
| logits = self.head(x) | |
| loss = None | |
| if labels is not None: | |
| shift_logits = logits[..., :-1, :].contiguous() | |
| shift_labels = labels[..., 1:].contiguous() | |
| loss = F.cross_entropy( | |
| shift_logits.view(-1, shift_logits.size(-1)), | |
| shift_labels.view(-1), | |
| ignore_index=-100, | |
| ) | |
| return CausalLMOutput(loss=loss, logits=logits) | |
| def prepare_inputs_for_generation(self, input_ids, **kwargs): | |
| if input_ids.size(1) > self.config.block_size: | |
| input_ids = input_ids[:, -self.config.block_size:] | |
| return {"input_ids": input_ids} | |
| def _reorder_cache(self, past, beam_idx): | |
| return past | |