Sign inSign up

florents/spql

By florents

•Updated over 2 years ago

like sed, awk, and jq, but for LLMs. https://spql-lang.com

Image
0

372

florents/spql repository overview

⁠spql

like sed, awk, and jq, but for LLMs.

Usage ⁠ | Installation ⁠ | Examples ⁠ | Features ⁠ | How ⁠ | Reference ⁠

Static Badge

echo '"https://www.reddit.com/r/python/top.json"' |
spql '
    # Issue a get request
    http_get |
    # Process the json response with standard jq
    .data.children[] | 
    {
        "title": .data.title, 
        "author": .data.author,
        "title_tokens": .data.title | tokenize("hf-internal-testing/tiny-random-gpt2") ,
        "title_prompt": (.data.title | prompt("llama2c")),
        "title_embedding_4": (.data.title | embed("hf-internal-testing/tiny-random-gpt2") | .[0:4]),
        "title_embedding_ndims": (.data.title | embed("hf-internal-testing/tiny-random-gpt2") | ndims)
    }
'

spql is a command line tool, programming language and database extension for working with LLMs.

spql's goal is to allow the creation of composable pipelines of vectors in a minimal but powerful way. It is equally usable and flexible across different execution contexts.

It borrows from Unix philosophy⁠ but with a twist: It treats vector as a universal interface, not text. In an LLM world, however, text and vector are not that different, are they?

The pattern is clear: sed, awk, grep, and friends worked for text. jq worked for JSON data. spql works on vectors.

In the snippet above, notice how spql glues things together:

  • Everything is executed in the shell.
  • the http_get function is run within the program itself (powered by curl).
  • The tokenizer and the embedding model used are coded in Python and provided by huggingface.
  • The llama2c model is coded in C and is local.
  • Input and output are JSON.

⁠🚀 Getting Started

⁠Installation

In the current alpha version, the easiest way to try out spql is to alias bash functions to docker containers.

Running these in your shell will provide you with a spql bash function and a sqlite3 instance pre-bundled with spql.

function spql() {
  docker run -v $HOME/.cache/huggingface:/.cache/huggingface -i florents/spql:v0.1.0a1 "$@"
}
function sqlite3() {
  docker run -i --entrypoint /usr/bin/sqlite3 florents/spql:v0.1.0a1 "$@"
}

Tag summary

Content type

Image

Digest

sha256:9cc2e82c0…

Size

473 MB

Last updated

over 2 years ago

docker pull florents/spql:v0.1.0a1