File tree 7 files changed +20
-24
lines changed
7 files changed +20
-24
lines changed Original file line number Diff line number Diff line change
1
+ Dockerfile
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ run-ci: format lint type ## Running all CI checks
28
28
run-benchmarks : # # Run benchmarks
29
29
@echo " Running benchmarks..."
30
30
@cd $(GIT_ROOT ) /tests/benchmarks && python benchmark_eval.py
31
+ run-benchmarks-in-docker : # # Run benchmarks in docker
32
+ @echo " Running benchmarks in docker..."
33
+ @cd $(GIT_ROOT )
34
+ docker buildx build --build-arg OPENAI_API_KEY=$(OPENAI_API_KEY ) -t ragas-benchmark -f $(GIT_ROOT ) /tests/benchmarks/Dockerfile .
35
+ docker inspect ragas-benchmark:latest | jq " .[0].Size" | numfmt --to=si
31
36
test : # # Run tests
32
37
@echo " Running tests..."
33
38
@pytest tests/unit $(shell if [ -n "$(k ) " ]; then echo "-k $(k ) "; fi)
Original file line number Diff line number Diff line change 2
2
name = " ragas"
3
3
dependencies = [
4
4
" numpy" ,
5
- " transformers" ,
6
- " sentence-transformers" ,
7
5
" datasets" ,
8
6
" tiktoken" ,
9
7
" langchain" ,
@@ -13,6 +11,11 @@ dependencies = [
13
11
]
14
12
dynamic = [" version" , " readme" ]
15
13
14
+ [project .optional-dependencies ]
15
+ all = [
16
+ " sentence-transformers" ,
17
+ ]
18
+
16
19
[tool .setuptools ]
17
20
package-dir = {"" = " src" }
18
21
Original file line number Diff line number Diff line change 16
16
from langchain .callbacks .manager import CallbackManager , trace_as_chain_group
17
17
from tqdm import tqdm
18
18
19
+ from ragas .embeddings .base import RagasEmbeddings
19
20
from ragas .llms import llm_factory
20
21
21
22
if t .TYPE_CHECKING :
22
23
from langchain .callbacks .base import Callbacks
23
24
24
- from ragas .embeddings .base import RagasEmbeddings
25
25
from ragas .llms import RagasLLM
26
26
27
27
Original file line number Diff line number Diff line change 2
2
3
3
import logging
4
4
import os
5
- import typing as t
6
5
from functools import lru_cache
7
- from warnings import warn
8
6
9
- import torch
10
- from torch import device as Device
11
-
12
- DEVICES = ["cpu" , "cuda" ]
13
7
DEBUG_ENV_VAR = "RAGAS_DEBUG"
14
8
# constant to tell us that there is no key passed to the llm/embeddings
15
9
NO_KEY = "no-key"
16
10
17
11
18
- def device_check (device : t .Literal ["cpu" , "cuda" ] | Device ) -> torch .device :
19
- if isinstance (device , Device ):
20
- return device
21
- if device not in DEVICES :
22
- raise ValueError (f"Invalid device { device } " )
23
- if device == "cuda" and not torch .cuda .is_available ():
24
- warn ("cuda not available, using cpu" )
25
- device = "cpu"
26
-
27
- return torch .device (device )
28
-
29
-
30
12
@lru_cache (maxsize = 1 )
31
13
def get_debug_mode () -> bool :
32
14
if os .environ .get (DEBUG_ENV_VAR , str (False )).lower () == "true" :
Original file line number Diff line number Diff line change
1
+ FROM python:3.9-slim
2
+ RUN apt-get update && apt-get install -y git make
3
+ COPY . /app
4
+ WORKDIR /app
5
+ RUN pip install -e /app/
6
+ ARG OPENAI_API_KEY
7
+ ENV OPENAI_API_KEY=$OPENAI_API_KEY
8
+ RUN make run-benchmarks
Original file line number Diff line number Diff line change 1
1
import time
2
2
3
3
from datasets import DatasetDict , load_dataset
4
- from torch .cuda import is_available
5
4
6
5
from ragas import evaluate
7
6
from ragas .metrics import (
12
11
)
13
12
from ragas .metrics .critique import harmfulness
14
13
15
- DEVICE = "cuda" if is_available () else "cpu"
16
-
17
14
# data
18
15
ds = load_dataset ("explodinggradients/fiqa" , "ragas_eval" )
19
16
assert isinstance (ds , DatasetDict )
You can’t perform that action at this time.
0 commit comments