Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuring Embedding dimensions #47

Open
papgmez opened this issue Mar 19, 2025 · 1 comment · May be fixed by #73
Open

Add support for configuring Embedding dimensions #47

papgmez opened this issue Mar 19, 2025 · 1 comment · May be fixed by #73
Labels
enhancement New feature or request

Comments

@papgmez
Copy link

papgmez commented Mar 19, 2025

First of all, I want to thank you for creating RubyLLM, I’m particularly impressed with the clean code, design and documentation.

I’ve been exploring the embeddings functionality and noticed that there isn't a way to explicitly configure the dimensions of the embeddings generated as output.

For applications using pgvector or similar vector databases, this capability would allow developers to optimize their vector storage and query performance while maintaining consistency across all embeddings generated from the same model.

Models that generate embeddings allow you to configure the output dimension:

I’d like to propose adding support for configuring embedding dimensions, both globally and per-request.

This would allow users to:

  1. Ensure consistent dimensionality across different embedding
  2. Standardize embedding dimensions throughout an application, making vector operations more predictable
  3. Simplify integration with external systems that may expect specific vector dimensions

The implementation could look something like:

# Global configuration
RubyLLM.configure do |config|
  config.default_embedding_model = "text-embedding-3-small"
  config.default_embedding_dimensions = 1024
end

# Per-request configuration
embedding = RubyLLM.embed(
  "Ruby is a programmer's best friend",
  model: "text-embedding-3-small",
  dimensions: 512
)

I would be happy to implement this feature myself. Please let me know if this aligns with your vision for the project and if you have any specific implementation preferences or considerations.

Again, thank you for this work, and I look forward to potentially contributing to this project!

@papgmez papgmez changed the title Add Support for Configuring Embedding Dimensions Add support for configuring Embedding dimensions Mar 19, 2025
@crmne
Copy link
Owner

crmne commented Mar 23, 2025

Thanks for the kind words about RubyLLM! Your suggestion to add configurable embedding dimensions makes perfect sense - both the global and per-request implementation approach look good.

Feel free to open a PR with this feature. Just make sure to include tests verifying it works correctly with the underlying APIs.

Looking forward to your contribution!

@crmne crmne added the enhancement New feature or request label Mar 23, 2025
@papgmez papgmez linked a pull request Mar 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants