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 loss_stats.py from Arain119/sophia: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/Arain119/sophia/resolve/main/loss_stats.py
- Command line
-
hf download hf://Arain119/sophia/loss_stats.py
-
curl -L -o loss_stats.py https://huggingface.co/Arain119/sophia/resolve/main/loss_stats.py
2.45 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 | |
| import torch.nn.functional as functional | |
| def supervised_token_count( | |
| labels: torch.Tensor | None, | |
| *, | |
| label_offset: int = 0, | |
| ignore_index: int = -100, | |
| ) -> torch.Tensor: | |
| if labels is None or not torch.is_tensor(labels): | |
| return torch.zeros((), dtype=torch.int64) | |
| if labels.ndim != 2: | |
| raise ValueError( | |
| f"labels must be 2D [B,S] to count supervised tokens (got shape={tuple(labels.shape)})" | |
| ) | |
| target_start = int(label_offset) + 1 | |
| if int(labels.size(1)) <= target_start: | |
| return torch.zeros((), device=labels.device, dtype=torch.int64) | |
| shifted = labels[:, target_start:] | |
| return (shifted != int(ignore_index)).sum(dtype=torch.int64) | |
| def shifted_loss_sum_and_count( | |
| logits: torch.Tensor, | |
| labels: torch.Tensor, | |
| *, | |
| label_offset: int = 0, | |
| ignore_index: int = -100, | |
| ) -> tuple[torch.Tensor, torch.Tensor]: | |
| if int(logits.size(1)) <= 1 or int(labels.size(1)) <= int(label_offset) + 1: | |
| zero = logits.new_zeros(()) | |
| return zero, zero | |
| shift_logits = logits[:, :-1, :].contiguous() | |
| target_start = int(label_offset) + 1 | |
| target_end = target_start + int(shift_logits.size(1)) | |
| if int(labels.size(1)) < target_end: | |
| shift_logits = shift_logits[:, : max(int(labels.size(1)) - target_start, 0), :] | |
| target_end = target_start + int(shift_logits.size(1)) | |
| if int(shift_logits.size(1)) <= 0: | |
| zero = logits.new_zeros(()) | |
| return zero, zero | |
| shift_labels = labels[:, target_start:target_end].contiguous() | |
| flat_labels = shift_labels.reshape(-1).to(dtype=torch.long) | |
| flat_logits = shift_logits.reshape(-1, int(shift_logits.size(-1))) | |
| loss_sum = functional.cross_entropy( | |
| flat_logits, | |
| flat_labels, | |
| ignore_index=int(ignore_index), | |
| reduction="sum", | |
| ) | |
| count = (flat_labels != int(ignore_index)).sum().to(dtype=loss_sum.dtype) | |
| return loss_sum, count | |
| def mean_loss_from_sum_and_count( | |
| *, | |
| loss_sum: torch.Tensor, | |
| count: torch.Tensor, | |
| reference: torch.Tensor, | |
| ) -> torch.Tensor: | |
| return torch.where( | |
| count > 0, | |
| loss_sum / count.clamp_min(1.0), | |
| reference.new_zeros(()), | |
| ) | |