• Ruby langchainrb gem and custom configuration for the model setup


    题意Ruby 的 langchainrb gem 以及针对模型设置的自定义配置

    问题背景:

    I am working in a prototype using the gem langchainrb. I am using the module assistant module to implemente a basic RAG architecture.

    我正在使用 langchainrb 这个 gem 来开发一个原型。我利用其中的 assistant 模块来实现一个基本的 RAG(Retrieval-Augmented Generation,检索增强生成)架构。

    Everything works, and now I would like to customize the model configuration.

    一切运行正常,现在我想自定义模型的配置。

    In the documenation there is no clear way of setting up the Model. In my case, I would like to use OpenAi and use:

    在文档中,没有明确的方法来设置模型。在我的情况下,我想使用 OpenAI 并使用以下配置:

    • temperature: 0.1
    • Model: gpt-4o

    In the README, there is a mention about using llm_options.

    在 README 文件中,提到了使用 llm_options

    If I go to the OpenAI Module documentation:

    如果我去查看 OpenAI 模块的文档:

    It says I have to check here:        它说我要查看这里:

    But there is not any mention of temperature, for example. Also, in the example in the Langchain::LLM::OpenAI documentation, the options are totally different.

    但是在文档中并没有提到例如“温度”这样的设置。此外,在 Langchain::LLM::OpenAI 的文档示例中,给出的选项是完全不同的。

    I am working in a prototype using the gem langchainrb. I am using the module assistant module to implemente a basic RAG architecture.

    Everything works, and now I would like to customize the model configuration.

    In the documenation there is no clear way of setting up the Model. In my case, I would like to use OpenAi and use:

    In the README, there is a mention about using llm_options.

    If I go to the OpenAI Module documentation:

    It says I have to check here:

    But there is not any mention of temperature, for example. Also, in the example in the Langchain::LLM::OpenAI documentation, the options are totally different.

    1. # ruby-openai options:
    2. CONFIG_KEYS = %i[
    3. api_type
    4. api_version
    5. access_token
    6. log_errors
    7. organization_id
    8. uri_base
    9. request_timeout
    10. extra_headers
    11. ].freeze
    1. # Example in Class: Langchain::LLM::OpenAI documentation:
    2. {
    3. n: 1,
    4. temperature: 0.0,
    5. chat_completion_model_name: "gpt-3.5-turbo",
    6. embeddings_model_name: "text-embedding-3-small"
    7. }.freeze

    问题解决:

    I have a conflict between llm_options and default_options. I thought it was the same with different priorities.

    我在 llm_options 和 default_options 之间遇到了冲突。我原本以为它们只是优先级不同的相同设置。

    For the needs expressed in the question I have to use the default_options as in here:

    针对问题中表达的需求,我必须按照这里的示例来使用 default_options

    1. llm =
    2. Langchain::LLM::OpenAI.new(
    3. api_key: ,
    4. default_options: {
    5. temperature: 0.0,
    6. chat_completion_model_name: "gpt-4o"
    7. }
    8. )

  • 相关阅读:
    【每日一题】买卖股票的最佳时机 III
    机器学习(七)朴素贝叶斯、决策树与随机森林
    Jenkins 相关内容
    时间与日期
    【设计模式】中介者模式
    Mysql以key-val存储、正常存储的区别
    字符串中数据排序
    服务日志性能调优,由log引出的巨坑
    sentinel整合nacos在gateway中实现限流
    nodejs使用es-batis
  • 原文地址:https://blog.csdn.net/suiusoar/article/details/140000508