Text Generation
Transformers
Safetensors
GGUF
English
code
code-generation
multimodal
llama
conversational
Instructions to use mrsandip/Alfa-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrsandip/Alfa-Code with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrsandip/Alfa-Code")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrsandip/Alfa-Code", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mrsandip/Alfa-Code 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 mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
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 mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./llama-cli -hf mrsandip/Alfa-Code:Q4_0
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 mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf mrsandip/Alfa-Code:Q4_0
Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- LM Studio
- Jan
- vLLM
How to use mrsandip/Alfa-Code with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrsandip/Alfa-Code" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- SGLang
How to use mrsandip/Alfa-Code 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 "mrsandip/Alfa-Code" \ --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": "mrsandip/Alfa-Code", "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 "mrsandip/Alfa-Code" \ --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": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mrsandip/Alfa-Code with Ollama:
ollama run hf.co/mrsandip/Alfa-Code:Q4_0
- Unsloth Desktop
- Docker Model Runner
How to use mrsandip/Alfa-Code with Docker Model Runner:
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Lemonade
How to use mrsandip/Alfa-Code with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mrsandip/Alfa-Code:Q4_0
Run and chat with the model
lemonade run user.Alfa-Code-Q4_0
List all available models
lemonade list
- Atomic Chat
File size: 2,603 Bytes
492340a 5792a99 492340a 5792a99 492340a 5792a99 492340a 5792a99 492340a 5792a99 492340a | 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 | """HF Jobs compatible tiny-train: reads /data, writes /data/outputs + Hub."""
import argparse, json, os
os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
from pathlib import Path
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--data", default=os.getenv("ALFA_DATA", "/data/processed/train.jsonl"))
ap.add_argument("--out", default=os.getenv("ALFA_OUT", "/data/outputs/tiny-50M"))
ap.add_argument("--epochs", type=int, default=1)
ap.add_argument("--cpu", action="store_true", help="force CPU (no_cuda)")
args = ap.parse_args()
import torch
from transformers import LlamaConfig, LlamaForCausalLM, Trainer, TrainingArguments
from torch.utils.data import Dataset
class JsonlDS(Dataset):
def __init__(self, path, tok_len=256):
rows = [json.loads(l) for l in open(path, encoding="utf-8")]
self.rows, self.tok_len = rows, tok_len
def __len__(self): return len(self.rows)
def __getitem__(self, i):
r = self.rows[i]
s = (r.get("prompt", "") + "\n" + r.get("answer", ""))[:2000]
ids = [min(ord(c), 30000) for c in s][:self.tok_len]
ids += [0] * (self.tok_len - len(ids))
return {"input_ids": torch.tensor(ids, dtype=torch.long),
"labels": torch.tensor(ids, dtype=torch.long)}
print(f"data: {args.data} exists={Path(args.data).exists()}")
cfg = LlamaConfig(hidden_size=512, num_hidden_layers=8, num_attention_heads=8,
num_key_value_heads=4, intermediate_size=1376,
vocab_size=32000, max_position_embeddings=2048)
model = LlamaForCausalLM(cfg)
ds = JsonlDS(args.data)
use_cuda = torch.cuda.is_available() and not args.cpu
targs = TrainingArguments(output_dir=args.out, per_device_train_batch_size=1,
gradient_accumulation_steps=4,
num_train_epochs=args.epochs, logging_steps=2,
save_steps=50, save_total_limit=1,
fp16=use_cuda, use_cpu=args.cpu, report_to="none",
gradient_checkpointing=True,
gradient_checkpointing_kwargs={"use_reentrant": False},
dataloader_num_workers=0, dataloader_pin_memory=False,
max_grad_norm=0.0)
Trainer(model=model, args=targs, train_dataset=ds).train()
model.save_pretrained(args.out)
print(f"saved -> {args.out}")
if __name__ == "__main__":
main()
|