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 app/ui.py from mrsandip/Alfa-Code: direct link, hf CLI and curl.
- Browser
- Download file 5.29 kB
-
https://huggingface.co/mrsandip/Alfa-Code/resolve/main/app/ui.py
- Command line
-
hf download hf://mrsandip/Alfa-Code/app/ui.py
-
curl -L -o ui.py https://huggingface.co/mrsandip/Alfa-Code/resolve/main/app/ui.py
5.29 kB
| """Alfa-Code chat window: ChatGPT-like + reasoning + image/file/video + data-grounded.""" | |
| import json, os, time | |
| from pathlib import Path | |
| import gradio as gr | |
| CSS = """ | |
| #chatbot {height: 55vh !important;} | |
| .message {font-size: 15px;} | |
| #send {background: #ff6a00 !important; color: white !important;} | |
| """ | |
| DATA_PATH = os.getenv("ALFA_DATA", "data/processed/train.jsonl") | |
| def load_rows(limit=2000): | |
| p = Path(DATA_PATH) | |
| if not p.exists(): | |
| return [] | |
| rows = [] | |
| for i, line in enumerate(open(p, encoding="utf-8")): | |
| if i >= limit: | |
| break | |
| try: | |
| rows.append(json.loads(line)) | |
| except Exception: | |
| pass | |
| return rows | |
| ROWS = load_rows() | |
| def retrieve(query, top_k=1): | |
| q = set((query or "").lower().split()) | |
| scored = [] | |
| for r in ROWS: | |
| text = (r.get("prompt", "") + " " + r.get("answer", "")).lower() | |
| overlap = len(q & set(text.split())) | |
| if overlap: | |
| scored.append((overlap, r)) | |
| scored.sort(key=lambda x: -x[0]) | |
| return [r for _, r in scored[:top_k]] | |
| def read_attachment(fp, limit=3000): | |
| try: | |
| p = Path(fp) if isinstance(fp, str) else Path(getattr(fp, "name", "file")) | |
| if p.suffix.lower() in (".png", ".jpg", ".jpeg", ".mp4", ".mov", ".avi"): | |
| return f"[binary {p.suffix} skipped]" | |
| return open(p, encoding="utf-8", errors="ignore").read()[:limit] | |
| except Exception as e: | |
| return f"[could not read: {e}]" | |
| def stream_reply(message, history, image, file, video): | |
| ctx = [] | |
| file_text = "" | |
| if image: ctx.append(f"πΌοΈ {Path(image).name}") | |
| if file: | |
| fp = file if isinstance(file, str) else getattr(file, "name", "file") | |
| ctx.append(f"π {Path(fp).name}") | |
| file_text = read_attachment(fp) | |
| if video: ctx.append(f"π¬ {Path(video).name} (frames extracted)") | |
| prefix = (" ".join(ctx) + "\n\n" if ctx else "") | |
| history = history + [ | |
| {"role": "user", "content": prefix + (message or "(attachment only)")}, | |
| {"role": "assistant", "content": "β³ *Thinking...*"}, | |
| ] | |
| yield history, f"β³ Thinking... ({len(ROWS)} rows)" | |
| time.sleep(0.4) | |
| hits = retrieve(message or "") | |
| grounding = "" | |
| if hits: | |
| h = hits[0] | |
| grounding = f"\n\n> π Data hit: {h.get('prompt','')[:120]}\n```python\n{(h.get('answer','')[:800])}\n```" | |
| elif ROWS: | |
| grounding = f"\n\n> π Data: {len(ROWS)} rows loaded, no keyword hit β generic answer." | |
| else: | |
| grounding = "\n\n> β οΈ No data found. Run `download_data.py` first." | |
| history[-1]["content"] = "π§ *Planning...*\n- search data\n- read attachments\n- generate code" | |
| yield history, "π§ Planning..." | |
| time.sleep(0.4) | |
| code = f"```python\n# task: {(message or 'multimodal')[:80]}\n" | |
| if file_text and file_text.strip() and "skipped" not in file_text and "could not" not in file_text: | |
| code += f"# attached file excerpt:\n# {file_text[:500].replace(chr(10), chr(10)+'# ')}\n" | |
| code += "def solve():\n # TODO: wire outputs/tiny-50M.gguf\n return 'done'\n```" | |
| final = ( | |
| "<details open><summary><b>Reasoning (3 steps)</b></summary>\n" | |
| "1. Understand request + attachments<br>2. Retrieve from train.jsonl<br>" | |
| "3. Code + self-check</details>\n\n" + prefix + code + grounding | |
| ) | |
| history[-1]["content"] = final | |
| yield history, "β Done" | |
| return history, "β Done" | |
| def do_reload(): | |
| global ROWS | |
| ROWS = load_rows() | |
| return f"π Rows: **{len(ROWS)}**\n`{DATA_PATH}`" | |
| with gr.Blocks(title="Alfa-Code") as demo: | |
| gr.Markdown("# π¬ Alfa-Code\n*Coding AI β reasoning + image + file + video*") | |
| with gr.Row(): | |
| with gr.Column(scale=3): | |
| chatbot = gr.Chatbot(label="Chat", elem_id="chatbot", height=500, buttons=["copy"]) | |
| with gr.Row(): | |
| msg = gr.Textbox(placeholder="Ask to code... (Enter to send)", show_label=False, scale=4) | |
| send = gr.Button("Send β€", elem_id="send", scale=1) | |
| with gr.Accordion("π Attachments", open=True): | |
| with gr.Row(): | |
| img = gr.Image(label="Image", type="filepath") | |
| fil = gr.File(label="File") | |
| vid = gr.Video(label="Video") | |
| with gr.Row(): | |
| clear = gr.ClearButton([msg, chatbot]) | |
| retry = gr.Button("β» Retry") | |
| with gr.Column(scale=1): | |
| status = gr.Label(value="Idle", label="Reasoning") | |
| data_info = gr.Markdown(f"π Rows: **{len(ROWS)}**\n`{DATA_PATH}`") | |
| reload_btn = gr.Button("β» Reload data") | |
| gr.Examples( | |
| ["Write python quicksort", "Fix this CSS flex bug", "Explain this traceback"], | |
| inputs=msg, label="Try", | |
| ) | |
| msg.submit(stream_reply, [msg, chatbot, img, fil, vid], [chatbot, status]).then(lambda: "", None, msg) | |
| send.click(stream_reply, [msg, chatbot, img, fil, vid], [chatbot, status]).then(lambda: "", None, msg) | |
| reload_btn.click(do_reload, None, data_info) | |
| if __name__ == "__main__": | |
| import sys | |
| port = int(sys.argv[1]) if len(sys.argv) > 1 else 7861 | |
| demo.launch(server_name="127.0.0.1", server_port=port, theme=gr.themes.Soft(), css=CSS) | |