Skip to content

Question: Using SHAP with GPT-4 via API #3615

Open
@dyomed93

Description

@dyomed93

Good evening,

I'm trying to use SHAP for my graduation thesis with various LLM, as Falcon, Mistral and GPT 4 and Llama, and i'm trying to follow the instruction with GPT-2 as in documentation but it's not possible to apply it to GPT-4, is there any solution to obtain Shapley Values with GPT-4 using SHAP?

I put an example of my code

import json
from langchain.chat_models import ChatOpenAI
import shap

with open('path/to/apikey.json', 'r') as file_json:
dati_json = json.load(file_json)
openai.api_key = dati_json['OPENAI_API_KEY']

chat = ChatOpenAI(temperature=0.0, openai_api_key =dati_json["OPENAI_API_KEY"] )

review_template = ["I enjoy walking with my cute dog"]
explainer = shap.Explainer(chat)
shap_values = explainer(t)

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionwontfixIndicates that work won't continue on an issue, pull request, or discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions