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
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -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: 3 epochs + grad-accum + checkpointing
Browse files- scripts/train.py +13 -4
scripts/train.py
CHANGED
|
@@ -20,15 +20,24 @@ class JsonlDS(Dataset):
|
|
| 20 |
return {"input_ids": torch.tensor(ids, dtype=torch.long), "labels": torch.tensor(ids, dtype=torch.long)}
|
| 21 |
|
| 22 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
cfg = LlamaConfig(hidden_size=512, num_hidden_layers=8, num_attention_heads=8,
|
| 24 |
num_key_value_heads=4, intermediate_size=1376, vocab_size=32000, max_position_embeddings=2048)
|
| 25 |
model = LlamaForCausalLM(cfg)
|
| 26 |
ds = JsonlDS("data/processed/train.jsonl")
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
Trainer(model=model, args=args, train_dataset=ds).train()
|
| 30 |
-
model.save_pretrained(
|
| 31 |
-
print("saved ->
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|
| 34 |
main()
|
|
|
|
| 20 |
return {"input_ids": torch.tensor(ids, dtype=torch.long), "labels": torch.tensor(ids, dtype=torch.long)}
|
| 21 |
|
| 22 |
def main():
|
| 23 |
+
import argparse
|
| 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 |
+
args = TrainingArguments(output_dir=a.out, per_device_train_batch_size=2,
|
| 34 |
+
gradient_accumulation_steps=8,
|
| 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}")
|
| 41 |
|
| 42 |
if __name__ == "__main__":
|
| 43 |
main()
|