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
Download scripts/train.py from mrsandip/Alfa-Code: direct link, hf CLI and curl.
- Browser
- Download file 2.4 kB
-
https://huggingface.co/mrsandip/Alfa-Code/resolve/main/scripts/train.py
- Command line
-
hf download hf://mrsandip/Alfa-Code/scripts/train.py
-
curl -L -o train.py https://huggingface.co/mrsandip/Alfa-Code/resolve/main/scripts/train.py
2.4 kB
| """Tiny Llama pretrain demo (CPU/4GB friendly). For 1B+ use cloud + DeepSpeed.""" | |
| import json | |
| from pathlib import Path | |
| import torch | |
| from transformers import LlamaConfig, LlamaForCausalLM, Trainer, TrainingArguments | |
| from torch.utils.data import Dataset | |
| class JsonlDS(Dataset): | |
| def __init__(self, path, tok_len=128): | |
| self.rows = [json.loads(l) for l in open(path, encoding="utf-8")] | |
| self.tok_len = tok_len | |
| def __len__(self): return len(self.rows) | |
| def __getitem__(self, i): | |
| import random | |
| r = self.rows[i] | |
| # char-level pseudo-tokenization for demo (real run uses train_tokenizer.py + proper encode) | |
| s = (r.get("prompt", "") + "\n" + r.get("think", "") + "\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)} | |
| def main(): | |
| import argparse | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--epochs", type=int, default=3) | |
| ap.add_argument("--out", default="outputs/tiny-50M") | |
| ap.add_argument("--cpu", action="store_true", help="force CPU") | |
| a = ap.parse_args() | |
| 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("data/processed/train.jsonl") | |
| use_cuda = torch.cuda.is_available() and not a.cpu | |
| import os | |
| os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True") | |
| args = TrainingArguments(output_dir=a.out, per_device_train_batch_size=1, | |
| gradient_accumulation_steps=32, | |
| num_train_epochs=a.epochs, logging_steps=5, save_steps=200, | |
| save_total_limit=1, fp16=use_cuda, use_cpu=a.cpu, | |
| gradient_checkpointing=True, report_to="none", | |
| optim="adafactor", | |
| dataloader_num_workers=0, dataloader_pin_memory=False, | |
| max_grad_norm=0.0) | |
| Trainer(model=model, args=args, train_dataset=ds).train() | |
| model.save_pretrained(a.out) | |
| print(f"saved -> {a.out}") | |
| if __name__ == "__main__": | |
| main() | |