Release 0.9

Refs #192, #209, #211, #213, #215, #217, #218, #219, #222

Closes #205
This commit is contained in:
Simon Willison 2023-09-03 19:35:14 -07:00
parent e6e1da321d
commit 5efb300c42
5 changed files with 81 additions and 7 deletions

View file

@ -1,5 +1,35 @@
# Changelog
(v0_9)=
## 0.9 (2023-09-03)
The big new feature in this release is support for **embeddings**.
{ref}`Embedding models <embeddings>` take a piece of text - a word, sentence, paragraph or even a whole article, and convert that into an array of floating point numbers. [#185](https://github.com/simonw/llm/issues/185)
This embedding vector can be thought of as representing a position in many-dimensional-space, where the distance between two vectors represents how semantically similar they are to each other within the content of a language model.
Embeddings can be used to find **related documents**, and also to implement **semantic search** - where a user can search for a phrase and get back results that are semantically similar to that phrase even if they do not share any exact keywords.
LLM now provides both CLI and Python APIs for working with embeddings. Embedding models are defined by plugins, so you can install additional models using the {ref}`plugins mechanism <installing-plugins>`.
The first two embedding models supported by LLM are:
- OpenAI's [ada-002](https://platform.openai.com/docs/guides/embeddings) embedding model, available via an inexpensive API if you set an OpenAI key using `llm keys set openai`.
- The [sentence-transformers](https://www.sbert.net/) family of models, available via the new [llm-sentence-transformers](https://github.com/simonw/llm-sentence-transformers) plugin.
See {ref}`embeddings-cli` for detailed instructions on working with embeddings using LLM.
The new commands for working with embeddings are:
- **{ref}`llm embed <embeddings-cli-embed>`** - calculate embeddings for content and return them to the console or store them in a SQLite database.
- **{ref}`llm embed-multi <embeddings-cli-embed-multi>`** - run bulk embeddings for multiple strings, using input from a CSV, TSV or JSON file, data from a SQLite database or data found by scanning the filesystem. [#215](https://github.com/simonw/llm/issues/215)
- **{ref}`llm similar <embeddings-cli-similar>`** - run similarity searches against your stored embeddings - starting with a search phrase or finding content related to a previously stored vector. [#190](https://github.com/simonw/llm/issues/190)
- **{ref}`llm embed-models <embeddings-cli-embed-models>`** - list available embedding models.
- **{ref}`llm embed-db <help-embed-db>`** - commands for inspecting and working with the default embeddings SQLite database.
There's also a new {ref}`llm.Collection <embeddings-python-collections>` class for creating and searching collections of embedding from Python code, and a {ref}`llm.get_embedding_model() <embeddings-python-api>` interface for embedding strings directly. [#191](https://github.com/simonw/llm/issues/191)
(v0_8_1)=
## 0.8.1 (2023-08-31)

View file

@ -3,7 +3,7 @@
LLM provides command-line utilities for calculating and storing embeddings for pieces of content.
(embeddings-llm-embed)=
(embeddings-cli-embed)=
## llm embed
The `llm embed` command can be used to calculate embedding vectors for a string of content. These can be returned directly to the terminal, stored in a SQLite database, or both.
@ -110,7 +110,7 @@ llm similar phrases -c 'hound'
{"id": "hound", "score": 0.8484683588631485, "content": "my happy hound", "metadata": {"name": "Hound"}}
```
(embeddings-llm-embed-multi)=
(embeddings-cli-embed-multi)=
## llm embed-multi
The `llm embed` command embeds a single string at a time.
@ -130,7 +130,7 @@ All three mechanisms support these options:
- `--store` to store the original content in the embeddings table in addition to the embedding vector
- `--prefix` to prepend a prefix to the stored ID of each item
(embeddings-llm-embed-multi-csv-etc)=
(embeddings-cli-embed-multi-csv-etc)=
### Embedding data from a CSV, TSV or JSON file
You can embed data from a CSV, TSV or JSON file using the `-i/--input` option.
@ -188,7 +188,7 @@ llm embed-multi items \
--store
```
(embeddings-llm-embed-multi-sqlite)=
(embeddings-cli-embed-multi-sqlite)=
### Embedding data from a SQLite database
You can embed data from a SQLite database using `--sql`, optionally combined with `--attach` to attach an additional database.
@ -213,7 +213,7 @@ llm embed-multi docs \
-m ada-002
```
(embeddings-llm-embed-multi-directories)=
(embeddings-cli-embed-multi-directories)=
### Embedding data from files in directories
LLM can embed the content of every text file in a specified directory, using the file's path and name as the ID.

View file

@ -37,7 +37,7 @@ class SentenceTransformerModel(llm.EmbeddingModel):
results = self._model.encode(texts)
return (list(map(float, result)) for result in results)
```
Once installed, the model provided by this plugin can be used with the {ref}`llm embed <embeddings-llm-embed>` command like this:
Once installed, the model provided by this plugin can be used with the {ref}`llm embed <embeddings-cli-embed>` command like this:
```bash
cat file.txt | llm embed -m sentence-transformers/all-MiniLM-L6-v2

View file

@ -24,6 +24,10 @@ def all_help(cli):
for command in commands:
heading_level = len(command) + 2
result = CliRunner().invoke(cli, command + ["--help"])
hyphenated = "-".join(command)
if hyphenated:
hyphenated = "-" + hyphenated
output.append(f"(help{hyphenated})=")
output.append("#" * heading_level + " llm " + " ".join(command) + " --help")
output.append("```")
output.append(result.output.replace("Usage: cli", "Usage: llm").strip())
@ -31,6 +35,7 @@ def all_help(cli):
return "\n".join(output)
cog.out(all_help(cli))
]]] -->
(help)=
## llm --help
```
Usage: llm [OPTIONS] COMMAND [ARGS]...
@ -69,6 +74,7 @@ Commands:
templates Manage stored prompt templates
uninstall Uninstall Python packages from the LLM environment
```
(help-prompt)=
### llm prompt --help
```
Usage: llm prompt [OPTIONS] [PROMPT]
@ -92,6 +98,7 @@ Options:
--save TEXT Save prompt with this template name
--help Show this message and exit.
```
(help-keys)=
### llm keys --help
```
Usage: llm keys [OPTIONS] COMMAND [ARGS]...
@ -106,6 +113,7 @@ Commands:
path Output the path to the keys.json file
set Save a key in the keys.json file
```
(help-keys-list)=
#### llm keys list --help
```
Usage: llm keys list [OPTIONS]
@ -115,6 +123,7 @@ Usage: llm keys list [OPTIONS]
Options:
--help Show this message and exit.
```
(help-keys-path)=
#### llm keys path --help
```
Usage: llm keys path [OPTIONS]
@ -124,6 +133,7 @@ Usage: llm keys path [OPTIONS]
Options:
--help Show this message and exit.
```
(help-keys-set)=
#### llm keys set --help
```
Usage: llm keys set [OPTIONS] NAME
@ -139,6 +149,7 @@ Options:
--value TEXT Value to set
--help Show this message and exit.
```
(help-logs)=
### llm logs --help
```
Usage: llm logs [OPTIONS] COMMAND [ARGS]...
@ -155,6 +166,7 @@ Commands:
path Output the path to the logs.db file
status Show current status of database logging
```
(help-logs-path)=
#### llm logs path --help
```
Usage: llm logs path [OPTIONS]
@ -164,6 +176,7 @@ Usage: llm logs path [OPTIONS]
Options:
--help Show this message and exit.
```
(help-logs-status)=
#### llm logs status --help
```
Usage: llm logs status [OPTIONS]
@ -173,6 +186,7 @@ Usage: llm logs status [OPTIONS]
Options:
--help Show this message and exit.
```
(help-logs-on)=
#### llm logs on --help
```
Usage: llm logs on [OPTIONS]
@ -182,6 +196,7 @@ Usage: llm logs on [OPTIONS]
Options:
--help Show this message and exit.
```
(help-logs-off)=
#### llm logs off --help
```
Usage: llm logs off [OPTIONS]
@ -191,6 +206,7 @@ Usage: llm logs off [OPTIONS]
Options:
--help Show this message and exit.
```
(help-logs-list)=
#### llm logs list --help
```
Usage: llm logs list [OPTIONS]
@ -209,6 +225,7 @@ Options:
--json Output logs as JSON
--help Show this message and exit.
```
(help-models)=
### llm models --help
```
Usage: llm models [OPTIONS] COMMAND [ARGS]...
@ -222,6 +239,7 @@ Commands:
list* List available models
default Show or set the default model
```
(help-models-list)=
#### llm models list --help
```
Usage: llm models list [OPTIONS]
@ -232,6 +250,7 @@ Options:
--options Show options for each model, if available
--help Show this message and exit.
```
(help-models-default)=
#### llm models default --help
```
Usage: llm models default [OPTIONS] [MODEL]
@ -241,6 +260,7 @@ Usage: llm models default [OPTIONS] [MODEL]
Options:
--help Show this message and exit.
```
(help-templates)=
### llm templates --help
```
Usage: llm templates [OPTIONS] COMMAND [ARGS]...
@ -256,6 +276,7 @@ Commands:
path Output the path to the templates directory
show Show the specified prompt template
```
(help-templates-list)=
#### llm templates list --help
```
Usage: llm templates list [OPTIONS]
@ -265,6 +286,7 @@ Usage: llm templates list [OPTIONS]
Options:
--help Show this message and exit.
```
(help-templates-show)=
#### llm templates show --help
```
Usage: llm templates show [OPTIONS] NAME
@ -274,6 +296,7 @@ Usage: llm templates show [OPTIONS] NAME
Options:
--help Show this message and exit.
```
(help-templates-edit)=
#### llm templates edit --help
```
Usage: llm templates edit [OPTIONS] NAME
@ -283,6 +306,7 @@ Usage: llm templates edit [OPTIONS] NAME
Options:
--help Show this message and exit.
```
(help-templates-path)=
#### llm templates path --help
```
Usage: llm templates path [OPTIONS]
@ -292,6 +316,7 @@ Usage: llm templates path [OPTIONS]
Options:
--help Show this message and exit.
```
(help-aliases)=
### llm aliases --help
```
Usage: llm aliases [OPTIONS] COMMAND [ARGS]...
@ -307,6 +332,7 @@ Commands:
remove Remove an alias
set Set an alias for a model
```
(help-aliases-list)=
#### llm aliases list --help
```
Usage: llm aliases list [OPTIONS]
@ -317,6 +343,7 @@ Options:
--json Output as JSON
--help Show this message and exit.
```
(help-aliases-set)=
#### llm aliases set --help
```
Usage: llm aliases set [OPTIONS] ALIAS MODEL_ID
@ -330,6 +357,7 @@ Usage: llm aliases set [OPTIONS] ALIAS MODEL_ID
Options:
--help Show this message and exit.
```
(help-aliases-remove)=
#### llm aliases remove --help
```
Usage: llm aliases remove [OPTIONS] ALIAS
@ -343,6 +371,7 @@ Usage: llm aliases remove [OPTIONS] ALIAS
Options:
--help Show this message and exit.
```
(help-aliases-path)=
#### llm aliases path --help
```
Usage: llm aliases path [OPTIONS]
@ -352,6 +381,7 @@ Usage: llm aliases path [OPTIONS]
Options:
--help Show this message and exit.
```
(help-plugins)=
### llm plugins --help
```
Usage: llm plugins [OPTIONS]
@ -361,6 +391,7 @@ Usage: llm plugins [OPTIONS]
Options:
--help Show this message and exit.
```
(help-install)=
### llm install --help
```
Usage: llm install [OPTIONS] [PACKAGES]...
@ -375,6 +406,7 @@ Options:
--no-cache-dir Disable the cache
--help Show this message and exit.
```
(help-uninstall)=
### llm uninstall --help
```
Usage: llm uninstall [OPTIONS] PACKAGES...
@ -385,6 +417,7 @@ Options:
-y, --yes Don't ask for confirmation
--help Show this message and exit.
```
(help-embed)=
### llm embed --help
```
Usage: llm embed [OPTIONS] [COLLECTION] [ID]
@ -402,6 +435,7 @@ Options:
Output format
--help Show this message and exit.
```
(help-embed-multi)=
### llm embed-multi --help
```
Usage: llm embed-multi [OPTIONS] COLLECTION [INPUT_PATH]
@ -433,6 +467,7 @@ Options:
-d, --database FILE
--help Show this message and exit.
```
(help-similar)=
### llm similar --help
```
Usage: llm similar [OPTIONS] COLLECTION [ID]
@ -454,6 +489,7 @@ Options:
-d, --database FILE
--help Show this message and exit.
```
(help-embed-models)=
### llm embed-models --help
```
Usage: llm embed-models [OPTIONS] COMMAND [ARGS]...
@ -467,6 +503,7 @@ Commands:
list* List available embedding models
default Show or set the default embedding model
```
(help-embed-models-list)=
#### llm embed-models list --help
```
Usage: llm embed-models list [OPTIONS]
@ -476,6 +513,7 @@ Usage: llm embed-models list [OPTIONS]
Options:
--help Show this message and exit.
```
(help-embed-models-default)=
#### llm embed-models default --help
```
Usage: llm embed-models default [OPTIONS] [MODEL]
@ -486,6 +524,7 @@ Options:
--remove-default Reset to specifying no default model
--help Show this message and exit.
```
(help-embed-db)=
### llm embed-db --help
```
Usage: llm embed-db [OPTIONS] COMMAND [ARGS]...
@ -500,6 +539,7 @@ Commands:
delete-collection Delete the specified collection
path Output the path to the embeddings database
```
(help-embed-db-path)=
#### llm embed-db path --help
```
Usage: llm embed-db path [OPTIONS]
@ -509,6 +549,7 @@ Usage: llm embed-db path [OPTIONS]
Options:
--help Show this message and exit.
```
(help-embed-db-collections)=
#### llm embed-db collections --help
```
Usage: llm embed-db collections [OPTIONS]
@ -520,6 +561,7 @@ Options:
--json Output as JSON
--help Show this message and exit.
```
(help-embed-db-delete-collection)=
#### llm embed-db delete-collection --help
```
Usage: llm embed-db delete-collection [OPTIONS] COLLECTION
@ -534,6 +576,7 @@ Options:
-d, --database FILE Path to embeddings database
--help Show this message and exit.
```
(help-openai)=
### llm openai --help
```
Usage: llm openai [OPTIONS] COMMAND [ARGS]...
@ -546,6 +589,7 @@ Options:
Commands:
models List models available to you from the OpenAI API
```
(help-openai-models)=
#### llm openai models --help
```
Usage: llm openai models [OPTIONS]

View file

@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
VERSION = "0.9a1"
VERSION = "0.9"
def get_long_description():