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
| """Direct UTF-8 bytes. Special IDs match BET, not the old Cortex tokenizer.""" | |
| from dataclasses import dataclass | |
| PAD,BOS,EOS=256,257,258 | |
| class Oversize(ValueError):pass | |
| class InvalidRecord(ValueError):pass | |
| def ids(text):return list(text.encode('utf-8')) | |
| def decode(tokens):return bytes(t for t in tokens if 0<=t<256).decode('utf-8',errors='replace') | |
| def record(prefix,answer,source,limit=1024,supervise_all=False,meta=None): | |
| p,a=ids(prefix),ids(answer) | |
| if not a:raise InvalidRecord('Empty target: '+source) | |
| tokens=[BOS]+p+a+[EOS] | |
| if len(tokens)>limit+1:raise Oversize(f'{source}: {len(tokens)} IDs exceeds {limit+1}; no truncation') | |
| weights=[0]+([1]*len(p) if supervise_all else [0]*len(p))+[1]*(len(a)+1) | |
| return dict(ids=tokens,weights=weights,source=source,prompt_len=1+len(p),meta=meta or {}) | |
| def plain_chunks(text,source,limit=1024): | |
| # Lossless bytes, including split UTF-8 sequences: decoder assembles the byte stream. | |
| # No false EOS at chunk boundaries. One-token overlap predicts each byte once. | |
| if not isinstance(text,str) or not text.strip():raise InvalidRecord('Empty/non-string text: '+source) | |
| raw_bytes=text.encode('utf-8') | |
| if len(raw_bytes)>1024*1024:raise Oversize('Document exceeds the 1 MiB bounded-buffer limit; rejected intact') | |
| raw=[BOS]+list(raw_bytes)+[EOS];out=[] | |
| for offset in range(0,len(raw)-1,limit): | |
| chunk=raw[offset:offset+limit+1] | |
| out.append(dict(ids=chunk,weights=[0]+[1]*(len(chunk)-1),source=source,prompt_len=1,meta={})) | |
| return out | |
| def validate(r,limit=1024): | |
| assert 2<=len(r['ids'])<=limit+1 | |
| assert len(r['ids'])==len(r['weights']) | |
| assert all(type(x)==int and 0<=x<259 for x in r['ids']) | |
| assert all(x in (0,1) for x in r['weights']) and sum(r['weights'][1:])>0 | |
| assert r['weights'][0]==0 | |
| return r | |