Metadata-Version: 2.1
Name: llm-clip
Version: 0.1a0
Summary: Generate embeddings for images and text using CLIP with LLM
Author: Simon Willison
License: Apache-2.0
Project-URL: Homepage, https://github.com/simonw/llm-clip
Project-URL: Changelog, https://github.com/simonw/llm-clip/releases
Project-URL: Issues, https://github.com/simonw/llm-clip/issues
Project-URL: CI, https://github.com/simonw/llm-clip/actions
Classifier: License :: OSI Approved :: Apache Software License
Description-Content-Type: text/markdown
Requires-Dist: llm >=0.10a1
Requires-Dist: sentence-transformers
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'

# llm-clip

[![PyPI](https://img.shields.io/pypi/v/llm-clip.svg)](https://pypi.org/project/llm-clip/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm-clip?include_prereleases&label=changelog)](https://github.com/simonw/llm-clip/releases)
[![Tests](https://github.com/simonw/llm-clip/workflows/Test/badge.svg)](https://github.com/simonw/llm-clip/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-clip/blob/main/LICENSE)

[LLM](https://llm.datasette.io/) plugin for embedding images and text using [CLIP](https://openai.com/research/clip)

## Installation

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

## Usage

Once you have installed an embedding model you can use it to embed text like this:

```bash
llm embed -m clip -c 'Hello world'
```
Or an image like this:
```bash
llm embed -m clip --binary -i  IMG_4801.jpeg
```

Embeddings are more useful if you store them in a database - see [the LLM documentation](https://llm.datasette.io/en/stable/embeddings/cli.html#storing-embeddings-in-sqlite) for details.

To embed every photograph in a folder and save them in a collection called "photos":

```bash
llm embed-multi photos -m clip --binary --files photos/ '*.jpg'
```
You can then search for photos of specific things like this:
```bash
llm similar photos -c 'bunny'
```

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd llm-clip
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
```
