当前位置: 首页 > news >正文

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 模块的文档:

  • Class: Langchain::LLM::OpenAI — Documentation for langchainrb (0.13.4)

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.

# ruby-openai options:CONFIG_KEYS = %i[api_typeapi_versionaccess_tokenlog_errorsorganization_iduri_baserequest_timeoutextra_headers
].freeze
# Example in Class: Langchain::LLM::OpenAI documentation: {n: 1,temperature: 0.0,chat_completion_model_name: "gpt-3.5-turbo",embeddings_model_name: "text-embedding-3-small"
}.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

llm =Langchain::LLM::OpenAI.new(api_key: <OPENAI_KEY>,default_options: {temperature: 0.0,chat_completion_model_name: "gpt-4o"})

    • ruby-openai/lib/openai/client.rb at main · alexrudall/ruby-openai · GitHub
    • temperature: 0.1
    • Model: gpt-4o
    • Class: Langchain::LLM::OpenAI — Documentation for langchainrb (0.13.4)
    • ruby-openai/lib/openai/client.rb at main · alexrudall/ruby-openai · GitHub
    • Langchain.rb version: 0.13.4
     
http://www.lryc.cn/news/384086.html

相关文章:

  • 高校新生如何选择最优手机流量卡?
  • QT QML 生成二维码
  • IDEA中Maven--下载安装自己适配的版本---理解
  • 【osgEarth】Ubuntu 22.04 源码编译osgEarth 3.5
  • ASP.NET Core 6.0 使用 资源过滤器和行为过滤器
  • 电脑屏幕花屏怎么办?5个方法解决问题!
  • git 初基本使用-----------笔记
  • Redis-数据类型-Bit的基本操作-getbit-setbit-Bitmap
  • 统信UOS上鼠标右键菜单中添加自定义内容
  • 学习入门 chatgpt原理 一
  • 生命在于学习——Python人工智能原理(4.7)
  • 经典游戏案例:仿植物大战僵尸
  • [Day 18] 區塊鏈與人工智能的聯動應用:理論、技術與實踐
  • 【Mac】DMG Canvas for mac(DMG镜像制作工具)软件介绍
  • RAG分块方法 从固定大小到自然语言处理分块——深入研究文本分块技术
  • FFmpeg 系列
  • 240626_昇思学习打卡-Day8-稀疏矩阵
  • Docker: 使用容器化数据库
  • Oracle对用户敏感数据进行编码处理
  • VXLAN详解:概念、架构、原理、搭建过程、常用命令与实战案例
  • Redis-数据类型-Hash
  • 基于redisson实现tomcat集群session共享
  • postgres数据库的流复制
  • Dxf库中的DL_Extrusion类
  • “ONLYOFFICE 8.1版本评测:功能更强大,用户体验更佳”
  • 搜维尔科技:【研究】触觉手套比控制器更能带来身临其境、更安全、更高效的虚拟体验
  • 【小学期】实体类设计——以学生管理系统为例
  • Java测试类
  • python 中面向对象编程:深入理解封装、继承和多态
  • OpenCV练习(2)图像校正