SQL-style semantic query language and retrieval middleware for Agents & RAG
Project description
NLQL
NLQL lets you do semantic search with SQL-style statements. Relevance scoring, filtering, and sorting live in one query — no more scattered embedding calls and post-processing code.
Built for Agent and RAG applications: the query itself is structured data, usable directly as an LLM tool-call payload.
What it looks like
import nlql
engine = nlql.Engine(nlql.embed.FakeEmbedder()) # or OpenAIEmbedder, or any Embedder
engine.add_text("AI agents plan tasks and call tools.", metadata={"status": "published"})
engine.add_text("Banana bread needs flour and sugar.", metadata={"status": "draft"})
for unit in engine.search('''
SELECT SENTENCE
LET rel = SIMILARITY(content, "autonomous agents")
WHERE rel >= 0.2 AND meta.status == "published"
ORDER BY rel DESC
LIMIT 5
'''):
print(f"{unit.scores['rel']:+.3f} {unit.content}")
The statement reads almost like SQL: SELECT sets the return granularity, LET computes relevance, WHERE filters, ORDER BY / LIMIT sort and cap.
Features
- One statement, full intent — relevance, filtering, and sorting in one place, not scattered across business code
- Three ways to write, identical results — SQL statement, Python chained builder, or JSON IR; all compile to the same internal representation
- Pluggable backends — built-in store works out of the box; switch to Qdrant / Faiss / Chroma / HnswLib / pgvector with one line
- Two-stage retrieval — attach a reranker after recall for higher accuracy
- Multimodal — text and images share one vector space; retrieve images with text
- Explainable —
engine.explain()prints the query plan
Installation
pip install python-nlql
Optional extras:
| Command | Purpose |
|---|---|
pip install "python-nlql[faiss]" |
Faiss backend |
pip install "python-nlql[hnsw]" |
HnswLib backend (for large-scale data) |
pip install "python-nlql[qdrant]" |
Qdrant backend |
pip install "python-nlql[chroma]" |
Chroma backend |
pip install "python-nlql[pgvector]" |
Postgres + pgvector backend |
pip install "python-nlql[local]" |
local sentence-transformers / CLIP / cross-encoder |
pip install "python-nlql[loaders]" |
DOCX / PDF file loaders |
Switching backends
One line; ingestion and query code stay the same:
from nlql.store.qdrant_store import QdrantStore
engine = nlql.Engine(embedder, store=QdrantStore(location=":memory:"))
Documentation
Full docs, tutorials, and API reference: https://natural-language-query-language.github.io/python-nlql/en/
More examples in the examples/ directory.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_nlql-0.3.3.tar.gz.
File metadata
- Download URL: python_nlql-0.3.3.tar.gz
- Upload date:
- Size: 218.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7720edea5635faa1b0946690c77055f7e35abd966f6ccfae859ca22a17b0030
|
|
| MD5 |
573efc17ed0bc1b7b35455596ee1faab
|
|
| BLAKE2b-256 |
1abf0b46c46a0eb9fda927b070388d86383d16a126444df741c62669f2fe6bd4
|
Provenance
The following attestation bundles were made for python_nlql-0.3.3.tar.gz:
Publisher:
publish.yml on natural-language-query-language/python-nlql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_nlql-0.3.3.tar.gz -
Subject digest:
a7720edea5635faa1b0946690c77055f7e35abd966f6ccfae859ca22a17b0030 - Sigstore transparency entry: 2084190700
- Sigstore integration time:
-
Permalink:
natural-language-query-language/python-nlql@7b19cd55874c17aa152850cf479f2c1ec039fbb2 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/natural-language-query-language
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b19cd55874c17aa152850cf479f2c1ec039fbb2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file python_nlql-0.3.3-py3-none-any.whl.
File metadata
- Download URL: python_nlql-0.3.3-py3-none-any.whl
- Upload date:
- Size: 108.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79265e52e7e307b276e14f29184a250c8ac87557eb4e73acacdc021009549cd7
|
|
| MD5 |
1cc173a5a98659f33579d435b1125981
|
|
| BLAKE2b-256 |
3041401855f56ce1c80534ac9a615fe863cf149f54748aede2215b4f78b18a8a
|
Provenance
The following attestation bundles were made for python_nlql-0.3.3-py3-none-any.whl:
Publisher:
publish.yml on natural-language-query-language/python-nlql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_nlql-0.3.3-py3-none-any.whl -
Subject digest:
79265e52e7e307b276e14f29184a250c8ac87557eb4e73acacdc021009549cd7 - Sigstore transparency entry: 2084190707
- Sigstore integration time:
-
Permalink:
natural-language-query-language/python-nlql@7b19cd55874c17aa152850cf479f2c1ec039fbb2 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/natural-language-query-language
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b19cd55874c17aa152850cf479f2c1ec039fbb2 -
Trigger Event:
push
-
Statement type: