Instructions to use appvoid/cortex with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use appvoid/cortex with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="appvoid/cortex", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("appvoid/cortex", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use appvoid/cortex with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "appvoid/cortex" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "appvoid/cortex", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/appvoid/cortex
- SGLang
How to use appvoid/cortex 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 "appvoid/cortex" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "appvoid/cortex", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "appvoid/cortex" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "appvoid/cortex", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use appvoid/cortex with Docker Model Runner:
docker model run hf.co/appvoid/cortex
| """Small text-generation helper for an exported SparkBET repository.""" | |
| from pathlib import Path | |
| import torch | |
| from safetensors.torch import load_file | |
| from bet_model import SparkBET,BETConfig,uniform_steps | |
| class Cortex: | |
| def __init__(self,model,device=None): | |
| self.model=model | |
| self.device=torch.device(device or ("cuda" if torch.cuda.is_available() else "cpu")) | |
| self.model.to(self.device).eval() | |
| def from_export(cls,folder,device=None): | |
| folder=Path(folder);model=SparkBET(BETConfig()) | |
| state=load_file(str(folder/"model.safetensors"),device="cpu") | |
| if state and all(k.startswith("core.") for k in state):state={k[5:]:v for k,v in state.items()} | |
| model.load_state_dict(state,strict=True) | |
| return cls(model,device) | |
| def generate_ids(self,ids,max_new_tokens=128,loops=8,temperature=0.0,top_k=None): | |
| out=list(map(int,ids)) | |
| for _ in range(int(max_new_tokens)): | |
| current=out[-self.model.c.max_seq_len:] | |
| x=torch.tensor([current],device=self.device,dtype=torch.long) | |
| with torch.inference_mode(),torch.autocast(self.device.type,dtype=torch.float16,enabled=self.device.type=="cuda"): | |
| logits=self.model(x,uniform_steps(loops))[0,-1].float() | |
| if temperature and temperature>0: | |
| logits=logits/float(temperature) | |
| if top_k: | |
| values,_=torch.topk(logits,min(int(top_k),logits.numel()));logits[logits<values[-1]]=-float("inf") | |
| nxt=int(torch.multinomial(torch.softmax(logits,-1),1)) | |
| else:nxt=int(logits.argmax()) | |
| out.append(nxt) | |
| if nxt==258:break | |
| return out | |
| def generate(self,text,max_new_tokens=128,loops=8,temperature=0.0,top_k=None): | |
| ids=[257]+list(text.encode("utf-8")) | |
| out=self.generate_ids(ids,max_new_tokens,loops,temperature,top_k) | |
| body=bytes(i for i in out[1:] if 0<=i<=255) | |
| return body.decode("utf-8",errors="replace") | |