Text Generation
GGUF
Japanese
japanese
instruction-tuning
little-language-model
tiny-language-model
edge-ai
embedded-ai
ex-word
llama-cpp
lm-studio
custom-code
conversational
Instructions to use ToTo-40417/EXLLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ToTo-40417/EXLLM 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 ToTo-40417/EXLLM:F16 # Run inference directly in the terminal: llama cli -hf ToTo-40417/EXLLM:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ToTo-40417/EXLLM:F16 # Run inference directly in the terminal: llama cli -hf ToTo-40417/EXLLM:F16
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 ToTo-40417/EXLLM:F16 # Run inference directly in the terminal: ./llama-cli -hf ToTo-40417/EXLLM:F16
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 ToTo-40417/EXLLM:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf ToTo-40417/EXLLM:F16
Use Docker
docker model run hf.co/ToTo-40417/EXLLM:F16
- LM Studio
- Jan
- vLLM
How to use ToTo-40417/EXLLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ToTo-40417/EXLLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ToTo-40417/EXLLM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ToTo-40417/EXLLM:F16
- Ollama
How to use ToTo-40417/EXLLM with Ollama:
ollama run hf.co/ToTo-40417/EXLLM:F16
- Unsloth Desktop
- Docker Model Runner
How to use ToTo-40417/EXLLM with Docker Model Runner:
docker model run hf.co/ToTo-40417/EXLLM:F16
- Lemonade
How to use ToTo-40417/EXLLM with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ToTo-40417/EXLLM:F16
Run and chat with the model
lemonade run user.EXLLM-F16
List all available models
lemonade list
- Atomic Chat
Download src/infer.py from ToTo-40417/EXLLM: direct link, hf CLI and curl.
- Browser
- Download file 3.14 kB
-
https://huggingface.co/ToTo-40417/EXLLM/resolve/main/src/infer.py
- Command line
-
hf download hf://ToTo-40417/EXLLM/src/infer.py
-
curl -L -o infer.py https://huggingface.co/ToTo-40417/EXLLM/resolve/main/src/infer.py
3.14 kB
| import json, math | |
| from pathlib import Path | |
| import torch | |
| from .model import EXLLM,EXLLMConfig | |
| from .tokenizer import HybridTokenizer,UTF8State,normalize_text | |
| def load_model(ckpt='weights/EXLLM-v1.1-5m-release3.pt'): | |
| tok=HybridTokenizer.load('tokenizer.json'); c=torch.load(ckpt,map_location='cpu'); cfg=EXLLMConfig(**c['config']); m=EXLLM(cfg); m.load_state_dict(c['model']); m.eval(); return m,tok,c | |
| def bad_text(s): | |
| if not s or '\ufffd' in s or '\x00' in s: return True | |
| if any((ord(c)<32 and c not in '\n\t') for c in s): return True | |
| # obvious repetition collapse | |
| if len(s)>=12: | |
| for n in range(1,7): | |
| unit=s[-n:] | |
| if len(unit)*4<=len(s) and s.endswith(unit*4): return True | |
| return False | |
| def generate(m,tok,prompt,max_new=64,temperature=0.0,top_k=12,confidence_fallback=True): | |
| ids=tok.encode_user(prompt) | |
| # Reserve output space. Left-trim user content but preserve role tokens. | |
| reserve=min(max_new, m.cfg.max_seq_len//2) | |
| if len(ids)>m.cfg.max_seq_len-reserve: | |
| keep=m.cfg.max_seq_len-reserve-3 | |
| body=ids[2:-1][-max(1,keep):]; ids=[tok.BOS,tok.USER,*body,tok.ASSIST] | |
| out=[]; state=UTF8State(); lps=[] | |
| for _ in range(min(max_new,m.cfg.max_seq_len-len(ids))): | |
| x=torch.tensor([ids+out],dtype=torch.long); logits=m(x)[0,-1].clone() | |
| # Structural specials are never generated inside assistant text. | |
| logits[tok.PAD]=logits[tok.BOS]=logits[tok.USER]=logits[tok.ASSIST]=-1e30 | |
| # UTF-8 constrained token mask. | |
| valid=torch.zeros_like(logits,dtype=torch.bool) | |
| if state.complete: | |
| valid[tok.EOS]=True | |
| for t in range(256): | |
| if state.accepts_byte(t): valid[t]=True | |
| if tok.chars: valid[256:256+len(tok.chars)]=True | |
| else: | |
| for t in range(256): | |
| if state.accepts_byte(t): valid[t]=True | |
| logits[~valid]=-1e30 | |
| lp=torch.log_softmax(logits,dim=-1) | |
| if temperature and temperature>0: | |
| z=logits/temperature | |
| if top_k and top_k<z.numel(): | |
| v,ix=torch.topk(z,top_k); probs=torch.softmax(v,dim=-1); t=int(ix[torch.multinomial(probs,1)].item()) | |
| else: t=int(torch.multinomial(torch.softmax(z,dim=-1),1).item()) | |
| else: t=int(torch.argmax(logits).item()) | |
| lps.append(float(lp[t])) | |
| if t==tok.EOS: break | |
| if t<256: state.push(t) | |
| elif not state.complete: continue | |
| out.append(t) | |
| # If max length stopped in a partial byte sequence, drop trailing raw bytes until valid. | |
| while out: | |
| try: text=tok.decode(out); break | |
| except UnicodeDecodeError: out.pop() | |
| else: text='' | |
| text=text.strip() | |
| avg_lp=sum(lps)/max(1,len(lps)) | |
| if confidence_fallback and (bad_text(text) or avg_lp < -2.8): | |
| text='γγΎγηγγγγΎγγγ§γγγθ³ͺεγηγθ¨γζγγ¦γγ γγγ' | |
| return text,avg_lp | |
| if __name__=='__main__': | |
| import sys; torch.set_num_threads(2); m,tok,c=load_model(); q=' '.join(sys.argv[1:]) or 'γγγ«γ‘γ―'; print(generate(m,tok,q)[0]) | |