-
Notifications
You must be signed in to change notification settings - Fork 0
Python Unit Examples
Mike edited this page May 28, 2026
·
1 revision
llm = xlocllm.unit("LLM", "Qwen-3.5-0.8b", quant="q4")
with xlocllm.runtime([llm]) as rt:
rt.run()
print(rt.chat("Give me three local AI use cases."))with xlocllm.webgpu:
llm = xlocllm.unit("LLM", "SmolLM2-360M-Instruct-q4f16_1-MLC")
with xlocllm.runtime([llm], mode="web") as rt:
rt.run()
print(rt.chat("Hello from WebGPU"))with xlocllm.web:
clf = xlocllm.unit(
"text-classification",
"Xenova/distilbert-base-uncased-finetuned-sst-2-english",
)
with xlocllm.runtime([clf], mode="web") as rt:
rt.run()
print(rt.invoke("text.classify", {"text": "xlocllm is useful"}))emb = xlocllm.unit("embedding", "multilingual-e5-small")
rerank = xlocllm.unit("reranker", "bge-reranker-base")
rag = xlocllm.rag(emb=emb, rerank=rerank, name="docs")
llm = xlocllm.unit("LLM", "Qwen-3.5-0.8b-fp32", rag=rag)
with xlocllm.runtime([llm]) as rt:
rt.run()
rag.add(["Refunds take up to five business days."], ids=["refund"])
print(rt.chat("How long does a refund take?"))reg = xlocllm.unit(
"model.onnx",
type="regression",
name="local-regression",
input_name="float_input",
)
with xlocllm.runtime([reg]) as rt:
rt.run()
print(reg.predict([[1.0, 2.0, 3.0]]))- xlocllm
- Quickstart
- About
- Functions Python
- Functions TypeScript
- Use cases
- Examples Python
- Examples TypeScript
- Shared GPU mode
-
Models catalog
- Models The best
- Models Full model list
- Models Use your model
- For native mode
- Models Native LLM tiny small
- Models Native LLM medium
- Models Native LLM large
- Models Native embedding
- Models Native reranker
- Models Native translator
- Models Native tts
- Models Native vlm
- Models Native asr
- Models Native ocr
- Models Native image-classification
- Models Native object-detection
- Models Native image-segmentation
- Models Native depth-estimation
- Models Native document-layout
- Models Native table-detection
- Models Native document-qa
- Models Native language-id
- Models Native audio-classification
- Models Native text-classification
- Models Native ner
- Models Native zero-shot-text
- Models Native summarization
- Models Native text2text
- Models Native code
- For webgpu mode
- For web mode
- Models Web LLM
- Models Web embedding
- Models Web reranker
- Models Web translator
- Models Web tts
- Models Web vlm
- Models Web asr
- Models Web ocr
- Models Web image-classification
- Models Web object-detection
- Models Web image-segmentation
- Models Web depth-estimation
- Models Web document-layout
- Models Web table-detection
- Models Web document-qa
- Models Web zero-shot-image
- Models Web language-id
- Models Web audio-classification
- Models Web text-classification
- Models Web ner
- Models Web zero-shot-text
- Models Web summarization
- Models Web text2text
- Models Web code
- Dev