Skip to content

Can not use custom embedding model #2154

@hanwendie

Description

@hanwendie

I followed the instructions and used doubao embedding model with LangchainEmbeddingsWrapper, but an error occurred

(<class 'openai.BadRequestError'>, BadRequestError("Error code: 400 - {'error': {'code': 'InvalidParameter', 'message': 'The parameter input[0] specified in the request are not valid: expected a string, but got [4599 574 279 1176 2307 19763 30] instead. Request id: 021754361159016ee5eb03f9031c9451997bdb14cb7183a6316d9', 'param': 'input[0]', 'type': 'BadRequest'}}"), <traceback object at 0x134f2a300>)

here is the code

def do():
    evaluator_llm = ChatOpenAI(
        openai_api_base="https://ark.cn-beijing.volces.com/api/v3",
        openai_api_key="xxxx",  # app_key
        model_name="ep-20241017183117-br5f4",  # 推理接入点
    )
    evaluator = LangchainLLMWrapper(evaluator_llm)

    # embedding_model = HuggingFaceEmbeddings(model_name="bert-base-uncased")
    embedding_model_doubao = OpenAIEmbeddings(
        base_url="https://ark.cn-beijing.volces.com/api/v3",
        api_key="xxx",  # app_key
        model="ep-20250805102725-7m5n4",  # 推理接入点
    )
    embedding = LangchainEmbeddingsWrapper(embedding_model_doubao)

    sample = SingleTurnSample(
        user_input="When was the first super bowl?",
        response="The first superbowl was held on Jan 15, 1967",
        retrieved_contexts=[
            "The First AFL–NFL World Championship Game was an American football game played on January 15, 1967, at the Los Angeles Memorial Coliseum in Los Angeles."
        ]
    )
    scorer = ResponseRelevancy(llm=evaluator, embeddings=embedding)
    result = scorer.single_turn_score(sample)
    print(result)

Metadata

Metadata

Assignees

No one assigned

    Labels

    answered🤖 The question has been answered. Will be closed automatically if no new commentsbugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions