Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.md | 2025-07-08 | 1.3 kB | |
v1.8.0 source code.tar.gz | 2025-07-08 | 88.3 MB | |
v1.8.0 source code.zip | 2025-07-08 | 88.3 MB | |
Totals: 3 Items | 176.7 MB | 0 |
Highlights
- embeddings are now possible to get
- embeddings can be compared with each other
- updated
xcframework
- started using claude code
Embeddings
LLM.swift supports text embeddings for semantic similarity and search applications:
:::swift
// Generate embeddings for text
let embeddings1 = try await bot.getEmbeddings("Hello world")
let embeddings2 = try await bot.getEmbeddings("Hi there")
let embeddings3 = try await bot.getEmbeddings("Goodbye")
// Compare similarity (returns 0.0 to 1.0)
let similarity = embeddings1.compare(with: embeddings2)
print(similarity) // 0.8 (high similarity)
// Find most similar embedding
let mostSimilar = embeddings1.findMostSimilar(in: embeddings2, embeddings3)
print(mostSimilar == embeddings2) // true
The Embeddings
struct provides:
- compare(with:)
- Computes cosine similarity between two embeddings (0.0 to 1.0)
- findMostSimilar(in:)
- Returns the most similar embedding from a set of candidates
- Equatable
conformance for direct comparison
What's Changed
- Add embeddings support with cosine similarity comparison by @eastriverlee in https://github.com/eastriverlee/LLM.swift/pull/55
Full Changelog: https://github.com/eastriverlee/LLM.swift/compare/v1.7.2...v1.8.0