Skip to content

Conversation

@sebsto
Copy link
Collaborator

@sebsto sebsto commented Oct 22, 2025

Add Text Embeddings Example for Swift Bedrock Library

Overview

This PR introduces a comprehensive text embeddings example that demonstrates how to use Amazon Bedrock's embedding capabilities with the Swift SDK.

What's Added

  • Complete embeddings example showing three key use cases:
    • Basic text similarity comparison
    • Batch processing and similarity search
    • Document storage with semantic search
  • Beginner-friendly documentation with Swift DocC headers and inline comments
  • Practical implementations of cosine similarity and vector search

Key Features

  • Uses Titan Text Embeddings V2 model for generating 1024-dimensional vectors
  • Demonstrates semantic similarity - finding related content by meaning, not exact words
  • Includes a simple in-memory vector database implementation
  • Shows how embeddings can group similar content (tech companies vs fruits example)

Code Structure

  • simple() - Basic embedding comparison between sentences
  • batch() - Finding most similar text in a collection
  • doc() - Document storage and semantic search
  • DocumentStore - Simple vector database with search capabilities
  • cosineSimilarity() - Mathematical similarity calculation

Use Cases Demonstrated

  • Content recommendation systems
  • Semantic search and FAQ matching
  • Document clustering and similarity detection
  • Knowledge base search by meaning

The example is designed for newcomers to embeddings with clear explanations of concepts like vector similarity, semantic search, and practical applications.

@sebsto sebsto added the documentation Improvements or additions to documentation label Oct 22, 2025
@sebsto sebsto self-assigned this Oct 22, 2025
@sebsto sebsto requested a review from Copilot October 22, 2025 11:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a comprehensive text embeddings example demonstrating Amazon Bedrock's embedding capabilities with the Swift SDK. The example is designed for beginners and shows practical implementations of semantic similarity, batch processing, and document search.

Key Changes:

  • Implements three progressive examples: basic similarity comparison, batch processing with similarity search, and document storage with semantic search
  • Adds a simple in-memory vector database (DocumentStore) with semantic search capabilities
  • Includes cosine similarity calculation for comparing embedding vectors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sebsto sebsto merged commit e07b33d into main Oct 22, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant