嵌入 `input 必须少于 8192 个 token` 的警告与 discourse ai

是否有工具可以分割输入文本?
或者哪种嵌入 API 支持超过 8192 个 token?

Message (15 copies reported)

OpenAI Embeddings failed with status: 413 body: {"code":20042,"message":"input must have less than 8192 tokens","data":null}

Backtrace

/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-8.0.3/lib/active_support/broadcast_logger.rb:218:in `block in dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-8.0.3/lib/active_support/broadcast_logger.rb:217:in `map'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-8.0.3/lib/active_support/broadcast_logger.rb:217:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activesupport-8.0.3/lib/active_support/broadcast_logger.rb:129:in `warn'
/var/www/discourse/plugins/discourse-ai/lib/inference/open_ai_embeddings.rb:34:in `perform!'
/var/www/discourse/plugins/discourse-ai/lib/embeddings/vector.rb:45:in `block (2 levels) in gen_bulk_reprensentations'
/var/www/discourse/lib/scheduler/thread_pool.rb:118:in `block (2 levels) in wrap_block'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management.rb:17:in `with_connection'
/var/www/discourse/lib/scheduler/thread_pool.rb:118:in `block in wrap_block'
/var/www/discourse/lib/scheduler/thread_pool.rb:163:in `thread_loop'
/var/www/discourse/lib/scheduler/thread_pool.rb:174:in `block in spawn_thread'

如果您自行托管相同的模型,最多可容纳 32k 个 token。

如果这不可行,那么您需要配置嵌入模型,将输入限制在您的提供商允许的最大值内。这样,我们的 AI Bot RAG 将把上传的文件分割成块,而“相关主题/搜索”将只取每个主题的前 8192 个 token。

1 个赞

如何在 Discourse 中配置嵌入模型?还是模型提供商?

我确信 Qwen/Qwen3-Embedding-0.6B 支持高达 32k 的 token
并且我已经配置了 32k 的序列长度

但仍然有很多 embedding 的错误

1 个赞

如果您的 API 提供商允许,它确实支持。

如果您的 API 提供商将其限制为 8192,您就必须遵守他们的规则。

1 个赞

好的,我正在询问 API 提供商

1 个赞