Text Generation
Transformers
Safetensors
PEFT
English
Turkish
conversational
english
turkish
mistral
lora
hmc
reasoning
mathematical-reasoning
Eval Results (legacy)
Run this model with HF Jobs
Run DevHunterAI/RubiNet on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/DevHunterAI/RubiNet. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/DevHunterAI/RubiNet on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/DevHunterAI/RubiNet. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/DevHunterAI/RubiNet. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use DevHunterAI/RubiNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DevHunterAI/RubiNet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DevHunterAI/RubiNet")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("DevHunterAI/RubiNet", device_map="auto") - PEFT
How to use DevHunterAI/RubiNet with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use DevHunterAI/RubiNet with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DevHunterAI/RubiNet" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DevHunterAI/RubiNet", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/DevHunterAI/RubiNet
- SGLang
How to use DevHunterAI/RubiNet 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 "DevHunterAI/RubiNet" \ --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": "DevHunterAI/RubiNet", "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 "DevHunterAI/RubiNet" \ --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": "DevHunterAI/RubiNet", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use DevHunterAI/RubiNet with Docker Model Runner:
docker model run hf.co/DevHunterAI/RubiNet
Upload ministral_3b_hmc_chat.py with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186import argparseimport osimport sysimport traceback
import torchfrom transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
try: from transformers import Mistral3ForConditionalGenerationexcept ImportError: Mistral3ForConditionalGeneration = None
try: from transformers import Ministral3ForCausalLMexcept ImportError: Ministral3ForCausalLM = None
if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace")if hasattr(sys.stderr, "reconfigure"): sys.stderr.reconfigure(encoding="utf-8", errors="replace")
SYSTEM_PROMPT = "You are RubiNet. Your name is RubiNet, and your assistant identity is RubiNet. If the user asks your name, identity, who you are, or what model you are, answer explicitly that your name is RubiNet. Prefer replies like 'My name is RubiNet.' or 'I am RubiNet.' Do not present yourself as ChatGPT, Cascade, OpenAI, or any other assistant. You are a helpful, sharp, consistent assistant trained for high-quality dialogue and reasoning. Respond clearly and directly."DEFAULT_MODEL_ID = "mistralai/Ministral-3-3B-Base-2512"DEFAULT_ADAPTER_DIR = r"D:\Downloads"DEFAULT_OFFLOAD_DIR = r"C:\Users\ASUS\CascadeProjects\.hf-offload"
def build_prompt(user_text: str, system_prompt: str) -> str: return ( f"<|system|>\n{system_prompt}\n\n" f"<|user|>\n{user_text.strip()}\n\n" f"<|assistant|>\n" )
def resolve_dtype(dtype_name: str): mapping = { "float32": torch.float32, "float16": torch.float16, "bfloat16": torch.bfloat16, } if dtype_name not in mapping: raise ValueError(f"Unsupported dtype: {dtype_name}") return mapping[dtype_name]
def load_model(model_id: str, adapter_dir: str, use_4bit: bool, cpu_dtype: str, offload_folder: str): adapter_config_path = os.path.join(adapter_dir, "adapter_config.json") if not os.path.exists(adapter_config_path): raise FileNotFoundError(f"adapter_config.json not found in adapter dir: {adapter_dir}")
print("Loading base tokenizer...") tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True) if tokenizer.pad_token is None: tokenizer.pad_token = tokenizer.eos_token
model_kwargs = {"low_cpu_mem_usage": True} if use_4bit: if torch.cuda.is_available(): model_kwargs["device_map"] = {"": 0} model_kwargs["quantization_config"] = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True, ) else: model_kwargs["device_map"] = "cpu" model_kwargs["dtype"] = resolve_dtype(cpu_dtype) else: if torch.cuda.is_available(): model_kwargs["device_map"] = {"": 0} model_kwargs["dtype"] = torch.float16 else: model_kwargs["device_map"] = "cpu" model_kwargs["dtype"] = resolve_dtype(cpu_dtype) if offload_folder: os.makedirs(offload_folder, exist_ok=True) model_kwargs["offload_folder"] = offload_folder
try: from peft import PeftModel except ImportError as exc: raise ImportError( "Failed to import peft. Your installed peft/transformers versions are incompatible. " "This script needs a transformers version that exposes EncoderDecoderCache, or a peft version " "compatible with your current transformers install." ) from exc
print("Loading base model weights...") model_class = Mistral3ForConditionalGeneration or Ministral3ForCausalLM or AutoModelForCausalLM try: base_model = model_class.from_pretrained(model_id, trust_remote_code=True, **model_kwargs) except AttributeError as exc: if not use_4bit or "set_submodule" not in str(exc): raise print("4-bit loading is not supported for this Mistral3 model class in the current transformers build. Retrying without 4-bit quantization...") retry_kwargs = {"low_cpu_mem_usage": True} if torch.cuda.is_available(): retry_kwargs["device_map"] = {"": 0} retry_kwargs["dtype"] = torch.float16 else: retry_kwargs["device_map"] = "cpu" retry_kwargs["dtype"] = resolve_dtype(cpu_dtype) if offload_folder: os.makedirs(offload_folder, exist_ok=True) retry_kwargs["offload_folder"] = offload_folder base_model = model_class.from_pretrained(model_id, trust_remote_code=True, **retry_kwargs) print("Loading LoRA adapter...") model = PeftModel.from_pretrained(base_model, adapter_dir) model.eval() print("Model ready.") return tokenizer, model
def generate_reply(tokenizer, model, prompt: str, max_new_tokens: int, temperature: float, top_p: float): inputs = tokenizer(prompt, return_tensors="pt") inputs = {k: v.to(model.device) for k, v in inputs.items()}
print("Generating reply...") do_sample = temperature is not None and float(temperature) > 0 with torch.inference_mode(): output = model.generate( **inputs, max_new_tokens=max_new_tokens, do_sample=do_sample, temperature=temperature, top_p=top_p, pad_token_id=tokenizer.eos_token_id, eos_token_id=tokenizer.eos_token_id, use_cache=True, )
generated = tokenizer.decode(output[0], skip_special_tokens=False) if "<|assistant|>" in generated: reply = generated.split("<|assistant|>")[-1].strip() else: reply = generated[len(prompt):].strip() for stop_marker in ("<|user|>", "<|system|>", "<|assistant|>", "</s>"): if stop_marker in reply: reply = reply.split(stop_marker)[0].strip() return reply or "[empty reply]"
def main(): parser = argparse.ArgumentParser(description="Chat with Ministral 3B HMC-lite LoRA adapter") parser.add_argument("--model-id", default=DEFAULT_MODEL_ID) parser.add_argument("--adapter-dir", default=DEFAULT_ADAPTER_DIR) parser.add_argument("--system-prompt", default=SYSTEM_PROMPT) parser.add_argument("--max-new-tokens", type=int, default=192) parser.add_argument("--temperature", type=float, default=0.7) parser.add_argument("--top-p", type=float, default=0.9) parser.add_argument("--use-4bit", action="store_true") parser.add_argument("--cpu-dtype", choices=["float32", "float16", "bfloat16"], default="bfloat16") parser.add_argument("--offload-folder", default=DEFAULT_OFFLOAD_DIR) parser.add_argument("--message", default="") args = parser.parse_args()
print("Starting model load...") tokenizer, model = load_model(args.model_id, args.adapter_dir, args.use_4bit, args.cpu_dtype, args.offload_folder)
if args.message: prompt = build_prompt(args.message, args.system_prompt) print(generate_reply(tokenizer, model, prompt, args.max_new_tokens, args.temperature, args.top_p)) return
print("Interactive HMC-lite chat. Type 'exit' to quit.") while True: user_text = input("You: ").strip() if not user_text: continue if user_text.lower() in {"exit", "quit"}: break prompt = build_prompt(user_text, args.system_prompt) reply = generate_reply(tokenizer, model, prompt, args.max_new_tokens, args.temperature, args.top_p) print(f"Assistant: {reply}\n")
if __name__ == "__main__": try: main() except Exception: traceback.print_exc() raiseministral_3b_hmc_chat.pyAdded+186