Skip to content

Commit

Permalink
fix: linting issues (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmachan authored Sep 15, 2023
1 parent 59123b4 commit ba4e6c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/integrations/langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"index = VectorstoreIndexCreator().from_loaders([loader])\n",
"\n",
"\n",
"llm = ChatOpenAI(temperature= 0)\n",
"llm = ChatOpenAI(temperature=0)\n",
"qa_chain = RetrievalQA.from_chain_type(\n",
" llm,\n",
" retriever=index.vectorstore.as_retriever(),\n",
Expand Down Expand Up @@ -373,6 +373,7 @@
],
"source": [
"from langchain.schema import Document\n",
"\n",
"fake_result = result.copy()\n",
"fake_result[\"source_documents\"] = [Document(page_content=\"I love christmas\")]\n",
"eval_result = context_recall_chain(fake_result)\n",
Expand Down
5 changes: 3 additions & 2 deletions src/ragas/metrics/answer_relevance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from datasets import Dataset
from langchain.callbacks.manager import trace_as_chain_group
from langchain.embeddings import OpenAIEmbeddings
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
from langchain.embeddings.base import Embeddings
from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate

from ragas.metrics.base import EvaluationMode, MetricWithLLM
from ragas.metrics.llms import generate

Expand Down Expand Up @@ -45,7 +46,7 @@ class AnswerRelevancy(MetricWithLLM):
Here indicates the number questions generated per answer.
Ideal range between 3 to 5.
embeddings: Embedding
The langchain wrapper of Embedding object.
The langchain wrapper of Embedding object.
E.g. HuggingFaceEmbeddings('BAAI/bge-base-en')
"""

Expand Down
15 changes: 13 additions & 2 deletions tests/benchmarks/benchmark_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
from torch.cuda import is_available

from ragas import evaluate
from ragas.metrics import answer_relevancy, context_relevancy, faithfulness
from ragas.metrics import (
answer_relevancy,
context_recall,
context_relevancy,
faithfulness,
)
from ragas.metrics.critique import harmfulness

DEVICE = "cuda" if is_available() else "cpu"
Expand All @@ -13,6 +18,12 @@
if __name__ == "__main__":
result = evaluate(
ds.select(range(5)),
metrics=[answer_relevancy, context_relevancy, faithfulness, harmfulness],
metrics=[
answer_relevancy,
context_relevancy,
faithfulness,
harmfulness,
context_recall,
],
)
print(result)

0 comments on commit ba4e6c8

Please sign in to comment.