Skip to content

[ENH](rust-client): Add embedding functions#7116

Open
rescrv wants to merge 4 commits into
mainfrom
rescrv/rust-embed
Open

[ENH](rust-client): Add embedding functions#7116
rescrv wants to merge 4 commits into
mainfrom
rescrv/rust-embed

Conversation

@rescrv
Copy link
Copy Markdown
Contributor

@rescrv rescrv commented May 22, 2026

Description of changes

Implement Chroma Cloud embedding functions for the Rust client:

  • Add ChromaCloudQwenEmbeddingFunction for dense embeddings
  • Add ChromaCloudSpladeEmbeddingFunction for sparse embeddings
  • Extend EmbeddingFunction trait with embed_query_strs method
  • Auto-attach embedding function from collection schema on get
  • Allow add/upsert/update to compute embeddings from documents
    when explicit embeddings are omitted (IntoOptionalEmbeddings)
  • Add fluent builders for embedding functions and configurations
  • Expose chroma_cloud_api_key through client for auto-config
  • Add embeddings example demonstrating dense and sparse usage
  • Add unit tests for embedding resolution and auto-attach

Test plan

CI

Migration plan

Backwards-compatible for people not using embeddings already.

Observability plan

N/A

Documentation Changes

Doc strings updated.

Co-authored-by: AI

Implement Chroma Cloud embedding functions for the Rust client:

- Add ChromaCloudQwenEmbeddingFunction for dense embeddings
- Add ChromaCloudSpladeEmbeddingFunction for sparse embeddings
- Extend EmbeddingFunction trait with embed_query_strs method
- Auto-attach embedding function from collection schema on get
- Allow add/upsert/update to compute embeddings from documents
  when explicit embeddings are omitted (IntoOptionalEmbeddings)
- Add fluent builders for embedding functions and configurations
- Expose chroma_cloud_api_key through client for auto-config
- Add embeddings example demonstrating dense and sparse usage
- Add unit tests for embedding resolution and auto-attach

Co-authored-by: AI
@github-actions
Copy link
Copy Markdown

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

.filter_map(|document| document.as_deref())
.collect::<Vec<_>>();
if input.is_empty() {
return Ok(None);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right return value here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no documents it'll return no embeddings. This makes sense because it's for update. No doc, no embed.

Comment thread rust/chroma/src/collection.rs Outdated
Ok(Some(
documents
.iter()
.map(|document| document.as_ref().map(|_| embeddings.next().unwrap()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would prefer avoid unwrap if possible

@blacksmith-sh

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants