Metadata-Version: 2.1
Name: llm-interpolate
Version: 0.1
Summary: LLM plugin for interpolating between embeddings
Author: Evangelos Lamprou
License: Apache-2.0
Project-URL: Homepage, https://github.com/vagos/llm-interpolate
Project-URL: Changelog, https://github.com/vagos/llm-interpolate/releases
Project-URL: Issues, https://github.com/vagos/llm-interpolate/issues
Project-URL: CI, https://github.com/vagos/llm-interpolate/actions
Classifier: License :: OSI Approved :: Apache Software License
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: llm>=0.9
Requires-Dist: numpy
Requires-Dist: scipy
Provides-Extra: test
Requires-Dist: pytest; extra == "test"

# llm-interpolate

[LLM](https://llm.datasette.io/) plugin for interpolating between embeddings

## Installation

Install this plugin in the same environment as LLM.
```bash
llm install llm-interpolate
```

## Usage

The plugin adds a new command, `llm interpolate`. This command takes the name of an 
[embedding collection](https://llm.datasette.io/en/stable/embeddings/cli.html#storing-embeddings-in-sqlite) 
and two ids from that collection that will act as start and end points.

First, populate a collection.
In this case we are embedding a song library using the [CLAP](https://github.com/vagos/llm-clap) model.
```bash
llm embed-multi -m clap songs --files mysongs "*.wav" 
```

Now we can interpolate between those song embeddings with five intermediate points:
```bash
llm interpolate songs "MyRapSong.wav" "MyContrySong.wav" -n 5
```
You can use the `-d` option to use a different embeddings database.

What this will do is try and find points in the embedding space in-between the given points.

The output should look something like this (truncated):
```json
[
    "MyRapSong.wav",
    "HipHopMeetsCountry.wav",
    "SmoothCountryRap.wav",
    "CountryVibes.wav",
    "MyCountrySong.wav"
]
```

This output can then be used to build a cohesive playlist using only a starting and ending song.

```bash
llm interpolate songs "MyRapSong.wav" "MyContrySong.wav" -n 5 | jq .[] > playlist.m3u
```

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd llm-interpolate
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```
