Feature Extraction
Transformers
Safetensors
English
multilingual
laya_browser
laya
custom_code
system-1
browser-agent
web-navigation
decision-model
mmbert
mind2web
tilelang
Instructions to use cklxx/laya-browser with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use cklxx/laya-browser with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="cklxx/laya-browser", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("cklxx/laya-browser", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download code/apps/common.py from cklxx/laya-browser: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/cklxx/laya-browser/resolve/main/code/apps/common.py
- Command line
-
hf download hf://cklxx/laya-browser/code/apps/common.py
-
curl -L -o common.py https://huggingface.co/cklxx/laya-browser/resolve/main/code/apps/common.py
2.47 kB
| """Shared helpers: model loading + pretty printing.""" | |
| import os, sys, time | |
| os.environ.setdefault("USE_TF", "0") | |
| os.environ.setdefault("TOKENIZERS_PARALLELISM", "false") | |
| _AGENTS = {} | |
| def get_agent(variant="english"): | |
| """variant: english | multilingual | typed""" | |
| if variant in _AGENTS: | |
| return _AGENTS[variant] | |
| import laya | |
| t = time.time() | |
| if os.path.isdir(variant): | |
| a = laya.load(variant) | |
| elif variant == "english": | |
| # download only the root checkpoint (the other subfolders are several GB each) | |
| from huggingface_hub import snapshot_download | |
| path = snapshot_download("convaiinnovations/laya", ignore_patterns=["multilingual/*", "typed-decisions/*"]) | |
| a = laya.load(path) | |
| elif variant == "multilingual": | |
| a = laya.load("convaiinnovations/laya", subfolder="multilingual") | |
| else: | |
| from huggingface_hub import snapshot_download | |
| path = snapshot_download("convaiinnovations/laya", allow_patterns=["typed-decisions/*"]) | |
| a = laya.load(path, subfolder="typed-decisions") | |
| print(f"[laya] loaded {variant} in {time.time()-t:.1f}s", file=sys.stderr) | |
| if os.environ.get("LAYA_FAST", "1") == "1": | |
| try: | |
| sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "kernels")) | |
| from fast_laya import accelerate | |
| accelerate(a) | |
| print("[laya] TileLang fast path enabled (LAYA_FAST=0 to disable)", file=sys.stderr) | |
| except Exception as e: | |
| print(f"[laya] fast path unavailable: {e}", file=sys.stderr) | |
| _AGENTS[variant] = a | |
| return a | |
| def bar(p, width=20): | |
| n = int(round(p * width)) | |
| return "█" * n + "░" * (width - n) | |
| def show(result, indent=" "): | |
| """Pretty-print a laya predict() result.""" | |
| for name, a in result["answers"].items(): | |
| t = a["type"] | |
| if t == "choice": | |
| print(f"{indent}{name}: {a['choice']} (conf {a['confidence']:.2f})") | |
| for k, v in sorted(a["probabilities"].items(), key=lambda kv: -kv[1]): | |
| print(f"{indent} {bar(v)} {v:5.2f} {k}") | |
| elif t == "score": | |
| print(f"{indent}{name}: score={a['score']:.2f} (conf {a['confidence']:.2f})") | |
| for k, v in a["probabilities"].items(): | |
| print(f"{indent} {bar(v)} {v:5.2f} {a['legend'][k]}") | |
| else: | |
| p = a["noul"] | |
| print(f"{indent}{name}: P(true)={p:.2f} {bar(p)}") | |