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
- Llama new
- 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 seq128 + adafactor + cpu flag
Browse files- scripts/train.py +12 -6
scripts/train.py
CHANGED
|
@@ -6,7 +6,7 @@ from transformers import LlamaConfig, LlamaForCausalLM, Trainer, TrainingArgumen
|
|
| 6 |
from torch.utils.data import Dataset
|
| 7 |
|
| 8 |
class JsonlDS(Dataset):
|
| 9 |
-
def __init__(self, path, tok_len=
|
| 10 |
self.rows = [json.loads(l) for l in open(path, encoding="utf-8")]
|
| 11 |
self.tok_len = tok_len
|
| 12 |
def __len__(self): return len(self.rows)
|
|
@@ -24,17 +24,23 @@ def main():
|
|
| 24 |
ap = argparse.ArgumentParser()
|
| 25 |
ap.add_argument("--epochs", type=int, default=3)
|
| 26 |
ap.add_argument("--out", default="outputs/tiny-50M")
|
|
|
|
| 27 |
a = ap.parse_args()
|
| 28 |
cfg = LlamaConfig(hidden_size=512, num_hidden_layers=8, num_attention_heads=8,
|
| 29 |
num_key_value_heads=4, intermediate_size=1376, vocab_size=32000, max_position_embeddings=2048)
|
| 30 |
model = LlamaForCausalLM(cfg)
|
| 31 |
ds = JsonlDS("data/processed/train.jsonl")
|
| 32 |
-
use_cuda = torch.cuda.is_available()
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
num_train_epochs=a.epochs, logging_steps=5, save_steps=200,
|
| 36 |
-
save_total_limit=1, fp16=use_cuda,
|
| 37 |
-
gradient_checkpointing=True, report_to="none"
|
|
|
|
|
|
|
|
|
|
| 38 |
Trainer(model=model, args=args, train_dataset=ds).train()
|
| 39 |
model.save_pretrained(a.out)
|
| 40 |
print(f"saved -> {a.out}")
|
|
|
|
| 6 |
from torch.utils.data import Dataset
|
| 7 |
|
| 8 |
class JsonlDS(Dataset):
|
| 9 |
+
def __init__(self, path, tok_len=128):
|
| 10 |
self.rows = [json.loads(l) for l in open(path, encoding="utf-8")]
|
| 11 |
self.tok_len = tok_len
|
| 12 |
def __len__(self): return len(self.rows)
|
|
|
|
| 24 |
ap = argparse.ArgumentParser()
|
| 25 |
ap.add_argument("--epochs", type=int, default=3)
|
| 26 |
ap.add_argument("--out", default="outputs/tiny-50M")
|
| 27 |
+
ap.add_argument("--cpu", action="store_true", help="force CPU")
|
| 28 |
a = ap.parse_args()
|
| 29 |
cfg = LlamaConfig(hidden_size=512, num_hidden_layers=8, num_attention_heads=8,
|
| 30 |
num_key_value_heads=4, intermediate_size=1376, vocab_size=32000, max_position_embeddings=2048)
|
| 31 |
model = LlamaForCausalLM(cfg)
|
| 32 |
ds = JsonlDS("data/processed/train.jsonl")
|
| 33 |
+
use_cuda = torch.cuda.is_available() and not a.cpu
|
| 34 |
+
import os
|
| 35 |
+
os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
|
| 36 |
+
args = TrainingArguments(output_dir=a.out, per_device_train_batch_size=1,
|
| 37 |
+
gradient_accumulation_steps=32,
|
| 38 |
num_train_epochs=a.epochs, logging_steps=5, save_steps=200,
|
| 39 |
+
save_total_limit=1, fp16=use_cuda, use_cpu=a.cpu,
|
| 40 |
+
gradient_checkpointing=True, report_to="none",
|
| 41 |
+
optim="adafactor",
|
| 42 |
+
dataloader_num_workers=0, dataloader_pin_memory=False,
|
| 43 |
+
max_grad_norm=0.0)
|
| 44 |
Trainer(model=model, args=args, train_dataset=ds).train()
|
| 45 |
model.save_pretrained(a.out)
|
| 46 |
print(f"saved -> {a.out}")
|