-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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 | ||
``` |