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
Train HF: use_cpu flag + grad fixes
Browse files- scripts/train_hf.py +11 -3
scripts/train_hf.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
"""HF Jobs compatible tiny-train: reads /data, writes /data/outputs + Hub."""
|
| 2 |
import argparse, json, os
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
def main():
|
|
@@ -7,6 +8,7 @@ def main():
|
|
| 7 |
ap.add_argument("--data", default=os.getenv("ALFA_DATA", "/data/processed/train.jsonl"))
|
| 8 |
ap.add_argument("--out", default=os.getenv("ALFA_OUT", "/data/outputs/tiny-50M"))
|
| 9 |
ap.add_argument("--epochs", type=int, default=1)
|
|
|
|
| 10 |
args = ap.parse_args()
|
| 11 |
|
| 12 |
import torch
|
|
@@ -14,7 +16,7 @@ def main():
|
|
| 14 |
from torch.utils.data import Dataset
|
| 15 |
|
| 16 |
class JsonlDS(Dataset):
|
| 17 |
-
def __init__(self, path, tok_len=
|
| 18 |
rows = [json.loads(l) for l in open(path, encoding="utf-8")]
|
| 19 |
self.rows, self.tok_len = rows, tok_len
|
| 20 |
def __len__(self): return len(self.rows)
|
|
@@ -32,10 +34,16 @@ def main():
|
|
| 32 |
vocab_size=32000, max_position_embeddings=2048)
|
| 33 |
model = LlamaForCausalLM(cfg)
|
| 34 |
ds = JsonlDS(args.data)
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
num_train_epochs=args.epochs, logging_steps=2,
|
| 37 |
save_steps=50, save_total_limit=1,
|
| 38 |
-
fp16=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
Trainer(model=model, args=targs, train_dataset=ds).train()
|
| 40 |
model.save_pretrained(args.out)
|
| 41 |
print(f"saved -> {args.out}")
|
|
|
|
| 1 |
"""HF Jobs compatible tiny-train: reads /data, writes /data/outputs + Hub."""
|
| 2 |
import argparse, json, os
|
| 3 |
+
os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
def main():
|
|
|
|
| 8 |
ap.add_argument("--data", default=os.getenv("ALFA_DATA", "/data/processed/train.jsonl"))
|
| 9 |
ap.add_argument("--out", default=os.getenv("ALFA_OUT", "/data/outputs/tiny-50M"))
|
| 10 |
ap.add_argument("--epochs", type=int, default=1)
|
| 11 |
+
ap.add_argument("--cpu", action="store_true", help="force CPU (no_cuda)")
|
| 12 |
args = ap.parse_args()
|
| 13 |
|
| 14 |
import torch
|
|
|
|
| 16 |
from torch.utils.data import Dataset
|
| 17 |
|
| 18 |
class JsonlDS(Dataset):
|
| 19 |
+
def __init__(self, path, tok_len=256):
|
| 20 |
rows = [json.loads(l) for l in open(path, encoding="utf-8")]
|
| 21 |
self.rows, self.tok_len = rows, tok_len
|
| 22 |
def __len__(self): return len(self.rows)
|
|
|
|
| 34 |
vocab_size=32000, max_position_embeddings=2048)
|
| 35 |
model = LlamaForCausalLM(cfg)
|
| 36 |
ds = JsonlDS(args.data)
|
| 37 |
+
use_cuda = torch.cuda.is_available() and not args.cpu
|
| 38 |
+
targs = TrainingArguments(output_dir=args.out, per_device_train_batch_size=1,
|
| 39 |
+
gradient_accumulation_steps=4,
|
| 40 |
num_train_epochs=args.epochs, logging_steps=2,
|
| 41 |
save_steps=50, save_total_limit=1,
|
| 42 |
+
fp16=use_cuda, use_cpu=args.cpu, report_to="none",
|
| 43 |
+
gradient_checkpointing=True,
|
| 44 |
+
gradient_checkpointing_kwargs={"use_reentrant": False},
|
| 45 |
+
dataloader_num_workers=0, dataloader_pin_memory=False,
|
| 46 |
+
max_grad_norm=0.0)
|
| 47 |
Trainer(model=model, args=targs, train_dataset=ds).train()
|
| 48 |
model.save_pretrained(args.out)
|
| 49 |
print(f"saved -> {args.out}")
|