Instructions to use HyperionGrayAI/qwennifer-flash-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HyperionGrayAI/qwennifer-flash-bf16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="HyperionGrayAI/qwennifer-flash-bf16") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("HyperionGrayAI/qwennifer-flash-bf16") model = AutoModelForCausalLM.from_pretrained("HyperionGrayAI/qwennifer-flash-bf16", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use HyperionGrayAI/qwennifer-flash-bf16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "HyperionGrayAI/qwennifer-flash-bf16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "HyperionGrayAI/qwennifer-flash-bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/HyperionGrayAI/qwennifer-flash-bf16
- SGLang
How to use HyperionGrayAI/qwennifer-flash-bf16 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 "HyperionGrayAI/qwennifer-flash-bf16" \ --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": "HyperionGrayAI/qwennifer-flash-bf16", "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 "HyperionGrayAI/qwennifer-flash-bf16" \ --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": "HyperionGrayAI/qwennifer-flash-bf16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use HyperionGrayAI/qwennifer-flash-bf16 with Docker Model Runner:
docker model run hf.co/HyperionGrayAI/qwennifer-flash-bf16
Download ask.py from HyperionGrayAI/qwennifer-flash-bf16: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/HyperionGrayAI/qwennifer-flash-bf16/resolve/main/ask.py
- Command line
-
hf download hf://HyperionGrayAI/qwennifer-flash-bf16/ask.py
-
curl -L -o ask.py https://huggingface.co/HyperionGrayAI/qwennifer-flash-bf16/resolve/main/ask.py
3.02 kB
| """Generate an answer with a GPU-resident stock Transformers BF16 reference.""" | |
| import argparse | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| BASE = "HyperionGrayAI/qwennifer-flash-bf16" | |
| REVISION = "v0.1" | |
| def load(base=BASE, revision=REVISION, device="cuda"): | |
| if device == "cuda" and not torch.cuda.is_available(): | |
| raise RuntimeError( | |
| "CUDA is required for GPU-resident serving. For a host-memory control, choose --device cpu." | |
| ) | |
| kwargs = {"revision": revision, "dtype": torch.bfloat16, "trust_remote_code": False} | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| base, revision=revision, trust_remote_code=False | |
| ) | |
| if device == "cuda": | |
| free = [torch.cuda.mem_get_info(i)[0] for i in range(torch.cuda.device_count())] | |
| if sum(free) < 159348782592: | |
| raise RuntimeError( | |
| "The BF16 weights alone need 148.4 GiB. Supply enough free GPU memory plus room for context." | |
| ) | |
| kwargs["device_map"] = "auto" | |
| else: | |
| kwargs["device_map"] = {"": "cpu"} | |
| model = AutoModelForCausalLM.from_pretrained(base, **kwargs).eval() | |
| if model.config.num_experts_per_tok != 6: | |
| raise ValueError("The model configuration must route six experts per token.") | |
| if device == "cuda" and ( | |
| any(p.device.type != "cuda" for p in model.parameters()) | |
| or any(str(d) in ("cpu", "disk", "meta") for d in model.hf_device_map.values()) | |
| ): | |
| raise RuntimeError( | |
| "The device map offloaded part of the checkpoint. Provide more GPU memory or use --device cpu." | |
| ) | |
| return model, tokenizer | |
| def generate(model, tokenizer, question, max_tokens): | |
| text = tokenizer.apply_chat_template( | |
| [{"role": "user", "content": question}], | |
| tokenize=False, | |
| add_generation_prompt=True, | |
| ) | |
| inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt").to( | |
| model.get_input_embeddings().weight.device | |
| ) | |
| output = model.generate(**inputs, max_new_tokens=max_tokens, do_sample=False) | |
| suffix = output[0, inputs.input_ids.shape[1] :] | |
| return ( | |
| tokenizer.decode(suffix, skip_special_tokens=True), | |
| int(inputs.input_ids.shape[1]), | |
| int(suffix.numel()), | |
| ) | |
| if __name__ == "__main__": | |
| p = argparse.ArgumentParser(description=__doc__) | |
| p.add_argument("question") | |
| p.add_argument("--adapter", help="PEFT adapter directory or Hub model ID") | |
| p.add_argument("--adapter-revision", default="v0.1") | |
| p.add_argument("--max-tokens", type=int, default=160) | |
| p.add_argument("--device", choices=["cuda", "cpu"], default="cuda") | |
| args = p.parse_args() | |
| model, tokenizer = load(device=args.device) | |
| if args.adapter: | |
| from peft import PeftModel | |
| model = PeftModel.from_pretrained( | |
| model, args.adapter, revision=args.adapter_revision | |
| ).eval() | |
| print(generate(model, tokenizer, args.question, args.max_tokens)[0]) | |