Skip to content

Models via ChatOllama raise ConnectError() #1478

@Sohammhatre10

Description

@Sohammhatre10

For this code section using ChatMistralAI and MistralAIEmbeddings

from langchain_ollama.chat_models import ChatOllama
from langchain_ollama.embeddings import OllamaEmbeddings
import ragas
from ragas import evaluate
from ragas.metrics import answer_relevancy
from ragas.llms import LangchainLLMWrapper
from ragas.embeddings import LangchainEmbeddingsWrapper
from datasets import Dataset
import json

# The model should be specified using the `model` parameter
req_llm = ChatOllama(model="mistral")
wrapper = LangchainLLMWrapper(req_llm)
embeddings = OllamaEmbeddings(model="mistral")
wrapper_embedding = LangchainEmbeddingsWrapper(embeddings)

metrics=[answer_relevancy]

for m in metrics:
    m.__setattr__("llm", wrapper)
    if hasattr(m, "embeddings"):
      m.__setattr__("embeddings", wrapper_embedding)

# Step 3: Run the evaluation
results = evaluate(
    dataset=amnesty_qa["eval"].select(range(2)),
    metrics=[answer_relevancy],
    llm=wrapper,
    embeddings=wrapper_embedding,
)

# Step 4: Print the results
print(json.dumps(results, indent=3))

The error here is

Evaluating: 100%2/2 [02:08<00:00, 53.55s/it]
ERROR:ragas.executor:Exception raised in Job[0]: ConnectError(All connection attempts failed)
ERROR:ragas.executor:Exception raised in Job[1]: ConnectError(All connection attempts failed)
{
   "answer_relevancy": NaN
}

Will anyone please tell me a way around here using open-source llms (I don't have access to the OpenAI API). Any suggestions or solutions are appreiciated as its urgent

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions