You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Login into your hugging face using api_key.
!huggingface-cli login
Create an instance of your custom_llm.
custom_llm = CustomLlama3_8B()
Evaluate the test case using the Role Adherence metric
from deepeval.metrics import RoleAdherenceMetric
convo_test_case = ConversationalTestCase(
chatbot_role="You are a human marketing virtual assistant for question-answering tasks.",
turns=[LLMTestCase(input="What services does BizTech Analytics provide?", actual_output="BizTech Analytics provides tailored AI and data services designed to fit an organization’s needs, driving efficiency, growth, and innovation through deep industry insights and advanced technologies.")]
)
metric = RoleAdherenceMetric(threshold=0.5,model=custom_llm)
Describe the bug
A TypeError occurs when I try to evaluate a test_case for Role Adherence metric using CustomLlama3_8B model from the documentation.
To Reproduce
Steps to reproduce the behavior:
!pip install deepeval --upgrade
!pip install -U bitsandbytes
!pip install accelerate
!pip install lm-format-enforcer
!git config --global credential.helper store
import json
import transformers
import torch
from transformers import BitsAndBytesConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
from pydantic import BaseModel
from lmformatenforcer import JsonSchemaParser
from lmformatenforcer.integrations.transformers import (
build_transformers_prefix_allowed_tokens_fn,
)
from deepeval.models import DeepEvalBaseLLM
class CustomLlama3_8B(DeepEvalBaseLLM):
def init(self):
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
)
Login into your hugging face using api_key.
!huggingface-cli login
Create an instance of your custom_llm.
custom_llm = CustomLlama3_8B()
from deepeval.metrics import RoleAdherenceMetric
convo_test_case = ConversationalTestCase(
chatbot_role="You are a human marketing virtual assistant for question-answering tasks.",
turns=[LLMTestCase(input="What services does BizTech Analytics provide?", actual_output="BizTech Analytics provides tailored AI and data services designed to fit an organization’s needs, driving efficiency, growth, and innovation through deep industry insights and advanced technologies.")]
)
metric = RoleAdherenceMetric(threshold=0.5,model=custom_llm)
metric.measure(convo_test_case)
print(metric.score)
print(metric.reason)
Expected behavior
The result should be the score and reason output from the metric.
Screenshots
Desktop (please complete the following information):
Additional context
Ran all of this in Google colab. I have used all of this code from the deepeval documentation.
https://docs.confident-ai.com/docs/guides-using-custom-llms
The text was updated successfully, but these errors were encountered: