Text Generation
llama-cpp-python
GGUF
llama.cpp
Mixture of Experts
ssd-offload
smallthinker
expert-paging
low-ram
Instructions to use HelloSun/SmallThinker4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use HelloSun/SmallThinker4b with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="HelloSun/SmallThinker4b", filename="{{GGUF_FILE}}", )output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
Download tools/drop_model_cache.py from HelloSun/SmallThinker4b: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/HelloSun/SmallThinker4b/resolve/main/tools/drop_model_cache.py
- Command line
-
hf download hf://HelloSun/SmallThinker4b/tools/drop_model_cache.py
-
curl -L -o drop_model_cache.py https://huggingface.co/HelloSun/SmallThinker4b/resolve/main/tools/drop_model_cache.py
1.26 kB
| #!/usr/bin/env python3 | |
| """丟掉模型檔在系統 page cache 裡的頁(POSIX_FADV_DONTNEED)。 | |
| 為什麼需要:量 SSD 讀取量之前一定要做,否則「上一輪留在核心 page cache」 | |
| 會讓數字虛高(看起來像是 SSD 變快了,其實是記憶體)。 | |
| 用法: | |
| python3 tools/drop_model_cache.py <model.gguf> [more files...] | |
| """ | |
| import os | |
| import sys | |
| POSIX_FADV_DONTNEED = 4 | |
| SYNC = 2 | |
| def drop(path: str) -> tuple[bool, str]: | |
| try: | |
| fd = os.open(path, os.O_RDONLY) | |
| except OSError as e: | |
| return False, str(e) | |
| try: | |
| size = os.fstat(fd).st_size | |
| os.posix_fadvise(fd, 0, size, POSIX_FADV_DONTNEED) | |
| os.fsync(fd) | |
| return True, f"{size} bytes" | |
| except (AttributeError, OSError) as e: | |
| return False, str(e) | |
| finally: | |
| os.close(fd) | |
| def main() -> int: | |
| if len(sys.argv) < 2: | |
| print(__doc__) | |
| return 2 | |
| rc = 0 | |
| for p in sys.argv[1:]: | |
| if not os.path.exists(p): | |
| print(f"[drop] 找不到 {p}") | |
| rc = 1 | |
| continue | |
| ok, info = drop(p) | |
| print(f"[drop] {'ok ' if ok else 'fail'} {p} {info}") | |
| if not ok: | |
| rc = 1 | |
| return rc | |
| if __name__ == "__main__": | |
| sys.exit(main()) |