Instructions to use Arain119/sophia 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 Arain119/sophia 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 Arain119/sophia:Q4_K_M # Run inference directly in the terminal: llama cli -hf Arain119/sophia:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Arain119/sophia:Q4_K_M # Run inference directly in the terminal: llama cli -hf Arain119/sophia:Q4_K_M
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 Arain119/sophia:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Arain119/sophia:Q4_K_M
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 Arain119/sophia:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Arain119/sophia:Q4_K_M
Use Docker
docker model run hf.co/Arain119/sophia:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use Arain119/sophia with Ollama:
ollama run hf.co/Arain119/sophia:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use Arain119/sophia with Docker Model Runner:
docker model run hf.co/Arain119/sophia:Q4_K_M
- Lemonade
How to use Arain119/sophia with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Arain119/sophia:Q4_K_M
Run and chat with the model
lemonade run user.sophia-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Arain119
Sophia 1.0.0 — 1B K3-hybrid Chinese chat model (HF remote-code export + native package)
d53adc9 Download input_mask.py from Arain119/sophia: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/Arain119/sophia/resolve/d630cc1b3ef1fc1f22e5be51e7d0192ca3ccb308/input_mask.py
- Command line
-
hf download hf://Arain119/sophia@d630cc1b3ef1fc1f22e5be51e7d0192ca3ccb308/input_mask.py
-
curl -L -o input_mask.py https://huggingface.co/Arain119/sophia/resolve/d630cc1b3ef1fc1f22e5be51e7d0192ca3ccb308/input_mask.py
2.3 kB
| # Generated by ml.integrations.export.runtime_packager.write_remote_code_bundle. | |
| # Exported for HuggingFace trust_remote_code loading. | |
| # This file is intentionally self-contained. | |
| from __future__ import annotations | |
| import torch | |
| def _as_bool_mask(attention_mask: torch.Tensor) -> torch.Tensor: | |
| return ( | |
| attention_mask if attention_mask.dtype == torch.bool else (attention_mask != 0) | |
| ) | |
| def is_all_ones_mask(attention_mask: torch.Tensor) -> bool: | |
| mask = _as_bool_mask(attention_mask) | |
| return bool(mask.all().item()) | |
| def validate_right_padding_mask( | |
| attention_mask: torch.Tensor, | |
| *, | |
| input_ids: torch.Tensor, | |
| ) -> None: | |
| if attention_mask.dim() != 2: | |
| raise ValueError("attention_mask must be [B,T]") | |
| if attention_mask.shape != input_ids.shape: | |
| raise ValueError("attention_mask shape must match input_ids") | |
| mask = _as_bool_mask(attention_mask) | |
| valid_rows = mask.any(dim=1) | |
| resumes_after_padding = (~mask[:, :-1] & mask[:, 1:]).any(dim=1) | |
| if not bool(valid_rows.all().item()): | |
| raise ValueError("attention_mask row has no valid tokens") | |
| if bool(resumes_after_padding.any().item()): | |
| raise ValueError("loss computation requires right-padded attention masks") | |
| def slice_valid_tokens( | |
| input_ids: torch.Tensor, | |
| attention_mask: torch.Tensor, | |
| ) -> list[tuple[int, int, torch.Tensor]]: | |
| if attention_mask.dim() != 2: | |
| raise ValueError("attention_mask must be [B,T]") | |
| mask = _as_bool_mask(attention_mask) | |
| if mask.shape != input_ids.shape: | |
| raise ValueError("attention_mask shape must match input_ids") | |
| rows: list[tuple[int, int, torch.Tensor]] = [] | |
| for batch_index in range(int(input_ids.size(0))): | |
| idx = mask[batch_index].nonzero(as_tuple=False).squeeze(-1) | |
| if int(idx.numel()) == 0: | |
| raise ValueError("attention_mask row has no valid tokens") | |
| start = int(idx[0].item()) | |
| end = int(idx[-1].item()) + 1 | |
| if int(idx.numel()) != (end - start): | |
| raise ValueError("Sophia only supports contiguous padding masks") | |
| rows.append((start, end, input_ids[batch_index : batch_index + 1, start:end])) | |
| return rows | |
| __all__ = [ | |
| "is_all_ones_mask", | |
| "slice_valid_tokens", | |
| "validate_right_padding_mask", | |
| ] | |