Skip to content

Commit d0fb10b

Browse files
authored
Merge pull request #185 from bsatapat-jpg/dev
[LEADS-199] Add CPU-only PyTorch support to reduce package size
2 parents 34cbae4 + 6e09554 commit d0fb10b

4 files changed

Lines changed: 4220 additions & 205 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ make install-tools
4040
By default, lightspeed-evaluation uses remote embedding providers (OpenAI, Gemini). If you need **local embedding models** (HuggingFace/sentence-transformers), install with:
4141

4242
```bash
43-
# Using pip
44-
pip install 'lightspeed-evaluation[local-embeddings]'
45-
```
46-
or
47-
```bash
48-
# Using uv (from already cloned repo for local development)
43+
# Using uv (from an already cloned repo) - CPU-only (default, ~2GB)
4944
uv sync --extra local-embeddings
45+
46+
# Using uv (from an already cloned repo) - GPU with CUDA support (~6GB)
47+
cp uv-gpu.lock uv.lock && uv sync --extra local-embeddings --frozen
48+
49+
# Using pip - CPU-only (install torch from CPU index first)
50+
pip install torch --index-url https://download.pytorch.org/whl/cpu
51+
pip install 'lightspeed-evaluation[local-embeddings]'
5052
```
5153

52-
> **Note**: Local embeddings require PyTorch and related packages (~6GB). Only install if you need `embedding.provider: huggingface` in your configuration.
54+
> **Note**: The `uv` commands above must be run from an already cloned repository checkout, since they use this project's `pyproject.toml`, `uv.lock`, and `uv-gpu.lock`. The default `uv.lock` uses CPU-only PyTorch (~2GB). For GPU/CUDA support, copy `uv-gpu.lock` to `uv.lock` before syncing (~6GB). When using pip, a plain `pip install` may install CUDA-dependent wheels on Linux; use the `--index-url` flag for guaranteed CPU-only installation. Only install if you need `embedding.provider: huggingface` in your configuration.
5355
5456
#### Optional: NLP metrics
5557
If you want to install Ragas NLP metrics like ROUGE or Bleu install additional dependencies with:

pyproject.toml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ dependencies = [
3232
]
3333

3434
[project.optional-dependencies]
35-
# Local embedding models - includes torch (~6GB with CUDA, ~1.2GB CPU-only)
35+
# Local embedding models - includes torch
3636
# Only needed when using embedding.provider: huggingface
37-
# For CPU-only installation (smaller footprint), first install PyTorch CPU:
38-
# pip install torch --index-url https://download.pytorch.org/whl/cpu
39-
# pip install 'lightspeed-evaluation[local-embeddings]' --no-deps
40-
# pip install sentence-transformers --no-deps
41-
# or
42-
# uv sync --extra local-embeddings
37+
#
38+
# Installation options:
39+
# CPU (default, ~2GB): uv sync --extra local-embeddings
40+
# GPU (~6GB): cp uv-gpu.lock uv.lock && uv sync --extra local-embeddings --frozen
4341
local-embeddings = [
42+
"torch>=2.0.0",
4443
"sentence-transformers>=5.1.0",
4544
]
4645

@@ -112,3 +111,23 @@ requires = ["hatchling"]
112111
build-backend = "hatchling.build"
113112
[tool.hatch.build.targets.wheel]
114113
packages = ["src/lightspeed_evaluation"]
114+
115+
# UV configuration for CPU-only PyTorch (reduces package size from ~6GB to ~2GB)
116+
[tool.uv]
117+
118+
[[tool.uv.index]]
119+
name = "pytorch-cpu"
120+
url = "https://download.pytorch.org/whl/cpu"
121+
explicit = true
122+
123+
# Use CPU index for torch by default
124+
[tool.uv.sources]
125+
torch = { index = "pytorch-cpu" }
126+
127+
# Lock files:
128+
# uv.lock - CPU-only PyTorch (default, ~2GB)
129+
# uv-gpu.lock - Full PyTorch with CUDA (~6GB)
130+
#
131+
# Installation:
132+
# CPU: uv sync --extra local-embeddings
133+
# GPU: cp uv-gpu.lock uv.lock && uv sync --extra local-embeddings --frozen

0 commit comments

Comments
 (0)