NLP
Detect language, score sentiment, extract entities and tokenize text from queries
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/nlp/index.md to help me query NLP with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Extract named entities from a literal document, keyed back to its id.
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple is based in California.' AS body), id := 'id', lang := 'en')
| id | ent_text | label |
|---|---|---|
| 1 | Apple | ORG |
| 1 | California | GPE |
Quick start
Choose where to run NLP, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'nlp' AS nlp (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-nlp-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'nlp' AS nlp (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-nlp:0.5.0'
);
3. Run a query
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple is based in California.' AS body), id := 'id', lang := 'en')
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'nlp' AS nlp
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple is based in California.' AS body), id := 'id', lang := 'en')
Query Farm operates NLP for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use nlp as the catalog alias for the query below.
4. Run a query
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple is based in California.' AS body), id := 'id', lang := 'en')
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach with uvx
Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.
ATTACH 'nlp' AS nlp (
TYPE vgi,
LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-nlp-worker'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'nlp' AS nlp (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-nlp:0.5.0'
);
Overview
Classical NLP (spaCy + fastText + VADER): language ID, sentiment, NER, tokenization for SQL.
Run classical natural language processing in SQL -- language detection, sentiment analysis, named entity recognition (NER), lemmatization, and tokenization -- directly over your text columns in DuckDB, with no LLM and no API key required. This worker turns the proven open-source NLP stack of spaCy, fastText, and VADER into fast, deterministic SQL functions for bulk, cheap, per-row text enrichment.
Who it is for
Data engineers and analysts who want to enrich large text tables -- product reviews, support tickets, articles, social posts -- without leaving SQL or paying per token. Because the underlying models are rule- and statistics-based rather than generative, output is reproducible and runs at column scale -- ideal upstream of, not as a replacement for, LLM workers.
Key concepts
- Models load once per worker process and are cached, so the one-time model-load cost is amortized across every row of every query.
- Language identification uses Facebook's fastText lid.176 model (176 languages). When you do not pin a language, each row is routed to the matching language pipeline automatically.
- Sentiment uses the lexicon-and-rule-based VADER scorer, tuned for English and social media text; it understands negation, intensifiers, and emoji.
- Linguistic analysis -- structured span extraction, part-of-speech tagging, sentence boundaries, noun-phrase mining, lemmatization, and Unicode normalization -- uses spaCy's small English pipeline (
en_core_web_sm) by default; pin a language or name a specific model to override it.
When to reach for it
Use it whenever you need to enrich or filter free text at scale in SQL: detect and segment multilingual corpora, score or bucket opinion, clean and canonicalize text so free-text keys join and group reliably, or split documents into structured rows you can aggregate and join back to their source. Attach the worker, then call the functions directly from SQL -- nlp.main.detect_lang(body), nlp.main.sentiment(body), or nlp.main.entities((SELECT id, body FROM docs), id := 'id'):
INSTALL vgi FROM community;
LOAD vgi;
ATTACH 'nlp' (TYPE vgi, LOCATION 'uv run nlp_worker.py');Powered by spaCy (source - docs), fastText (source - docs), and VADER (source & docs). Source for this worker: Query-farm/vgi-nlp.
Catalog
Everything nlp exposes once attached — read straight from the worker's
released build.
main 1 table · 11 functions
Classical NLP: language ID, sentiment, NER, tokenization for SQL
Schema examples (10)
Detect the language of a French string.
SELECT nlp.main.detect_lang('Bonjour tout le monde') AS lang;
Score the sentiment of a positive English review.
SELECT nlp.main.sentiment('I absolutely love this product!') AS score;
Bucket a review into a neg/neu/pos sentiment label.
SELECT nlp.main.sentiment_label('This was a terrible experience') AS mood;
Lemmatize an English string with the language pinned.
SELECT nlp.main.lemmatize('The cats were running', 'en') AS lemmas;
6 more examples
Canonicalize a messy string for dedup/matching.
SELECT nlp.main.normalize(' Café DELUXE ') AS canonical;
Extract named entities from a literal document, keyed back to its id.
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple is based in California.' AS body), id := 'id', lang := 'en');
| id | ent_text | label |
|---|---|---|
| 1 | Apple | ORG |
| 1 | California | GPE |
Split each review into sentences and score every sentence's sentiment to find the single most negative sentence per review -- pinpointing the complaint inside otherwise mixed feedback.
WITH reviews(id, body) AS (VALUES (1, 'The hotel location was perfect. The room was filthy and the staff were rude. Breakfast was fine.'), (2, 'Checkout was a frustrating mess. Otherwise it was a wonderful stay with a lovely view!')) SELECT id, arg_min(sentence, nlp.main.sentiment(sentence)) AS worst_sentence, round(min(nlp.main.sentiment(sentence)), 3) AS worst_score
FROM nlp.main.sentences((SELECT id, body FROM reviews), id := 'id', lang := 'en')
GROUP BY id
ORDER BY id;
Extract the organizations (ORG entities) mentioned in each review, join them back to their review by id, and average the review sentiment per organization -- brand perception from free text.
WITH reviews(id, body) AS (VALUES (1, 'I love my new Apple laptop, the battery life is amazing.'), (2, 'Microsoft support was awful and rude.'), (3, 'The Apple store staff were friendly and quick to help.'), (4, 'Microsoft keeps crashing my laptop, which is incredibly frustrating.')) SELECT e.ent_text AS organization, count(*) AS mentions, round(avg(nlp.main.sentiment(r.body)), 3) AS avg_sentiment
FROM nlp.main.entities((SELECT id, body FROM reviews), id := 'id', lang := 'en') AS e
JOIN reviews AS r USING (id)
WHERE e.label = 'ORG'
GROUP BY e.ent_text
ORDER BY avg_sentiment DESC;
Detect each document's language and look it up in the supported_languages table to see which default spaCy pipeline would process it -- documents in a language without one (here Swahili) get NULL and cannot be tokenized or run through NER without naming a model.
WITH docs(id, body) AS (VALUES (1, 'The quarterly report shows strong growth in every region.'), (2, 'Le rapport trimestriel montre une forte croissance dans toutes les régions.'), (3, 'Ripoti ya robo mwaka inaonyesha ukuaji mkubwa katika kila mkoa.')), detected AS (SELECT id, nlp.main.detect_lang(body) AS lang FROM docs) SELECT d.id, d.lang, s.spacy_model, s.spacy_model IS NOT NULL AS has_default_pipeline
FROM detected AS d
LEFT JOIN nlp.main.supported_languages AS s ON s.lang_code = d.lang
ORDER BY d.id;
Keep only reviews labelled negative, extract their noun chunks, and lemmatize each chunk's head noun so 'rooms' and 'room' count together -- ranking the aspects that negative reviews mention.
WITH reviews(id, body) AS (VALUES (1, 'The rooms were dirty and the beds were terrible.'), (2, 'Awful service, and the room smelled bad.'), (3, 'The beds were comfortable and the view was great.'), (4, 'The breakfast was cold and the coffee was disgusting.')) SELECT nlp.main.lemmatize(lower(root), 'en') AS aspect, count(DISTINCT id) AS negative_reviews
FROM nlp.main.noun_chunks((SELECT id, body FROM reviews WHERE nlp.main.sentiment_label(body) = 'neg'), id := 'id', lang := 'en')
GROUP BY aspect
ORDER BY negative_reviews DESC, aspect;
supported_languages
Languages with a default spaCy pipeline: (lang_code, spacy_model) -- discovery table.
Count the languages that have a default spaCy pipeline.
SELECT count(*) AS n_languages FROM nlp.main.supported_languages;
Look up the default spaCy model for English.
SELECT spacy_model FROM nlp.main.supported_languages WHERE lang_code = 'en';
SELECT count(*) AS n_languages FROM nlp.main.supported_languages();
1 more example
SELECT spacy_model
FROM nlp.main.supported_languages()
WHERE lang_code = 'en';
detect_lang (text VARCHAR)
Detect the dominant language of each text (ISO-639 code, fastText lid.176)
Identify the language of a literal string
SELECT nlp.main.detect_lang('The quick brown fox jumps over the lazy dog') AS lang;
Detect each document's language and look it up in the supported_languages table to see which default spaCy pipeline would process it -- documents in a language without one (here Swahili) get NULL and cannot be tokenized or run through NER without naming a model.
WITH docs(id, body) AS (VALUES (1, 'The quarterly report shows strong growth in every region.'), (2, 'Le rapport trimestriel montre une forte croissance dans toutes les régions.'), (3, 'Ripoti ya robo mwaka inaonyesha ukuaji mkubwa katika kila mkoa.')), detected AS (SELECT id, nlp.main.detect_lang(body) AS lang FROM docs) SELECT d.id, d.lang, s.spacy_model, s.spacy_model IS NOT NULL AS has_default_pipeline
FROM detected AS d
LEFT JOIN nlp.main.supported_languages AS s ON s.lang_code = d.lang
ORDER BY d.id;
detect_lang_conf (text VARCHAR)
Confidence (0-1) of the detected language (fastText lid.176)
Confidence of the top language guess for a literal string
SELECT nlp.main.detect_lang_conf('The quick brown fox') AS conf;
lemmatize (text VARCHAR, lang VARCHAR, model VARCHAR) +2 overloads
Lemmatize each text (tokens replaced by their dictionary form); language auto-detected
lemmatize(text VARCHAR) → VARCHARlemmatize(text VARCHAR, lang VARCHAR) → VARCHARlemmatize(text VARCHAR, lang VARCHAR, model VARCHAR) → VARCHAR
Lemmatize a literal string with per-row language auto-detect
SELECT nlp.main.lemmatize('The cats were running quickly') AS lemmas;
Lemmatize a literal string with the language pinned to English
SELECT nlp.main.lemmatize('The cats were running quickly', 'en') AS lemmas;
Lemmatize a literal string with an explicit spaCy model
SELECT nlp.main.lemmatize('The cats were running quickly', 'en', 'en_core_web_sm') AS lemmas;
normalize (text VARCHAR)
Normalize text: Unicode NFKC, lowercase, and collapse whitespace
Canonicalize a messy literal string for dedup / matching
SELECT nlp.main.normalize(' Café DELUXE — ') AS canonical;
sentiment (text VARCHAR)
Sentiment score in [-1, 1] (VADER lexicon; tuned for English/social text)
Score the sentiment of a literal English string
SELECT nlp.main.sentiment('I absolutely love this, it is fantastic!') AS score;
sentiment_label (text VARCHAR)
Coarse sentiment label: neg / neu / pos (VADER thresholds)
Bucket a literal string into neg / neu / pos
SELECT nlp.main.sentiment_label('This is the worst experience ever') AS mood;
strip_stopwords (text VARCHAR, lang VARCHAR, model VARCHAR) +2 overloads
Remove stop-words and punctuation, returning the rest joined; language auto-detected
strip_stopwords(text VARCHAR) → VARCHARstrip_stopwords(text VARCHAR, lang VARCHAR) → VARCHARstrip_stopwords(text VARCHAR, lang VARCHAR, model VARCHAR) → VARCHAR
Drop stop-words from a literal string with per-row auto-detect
SELECT nlp.main.strip_stopwords('this is a really great movie') AS kept;
Drop English stop-words from a literal string
SELECT nlp.main.strip_stopwords('this is a really great movie', 'en') AS kept;
Drop stop-words from a literal string with an explicit spaCy model
SELECT nlp.main.strip_stopwords('this is a really great movie', 'en', 'en_core_web_sm') AS kept;
entities (data TABLE, id := VARCHAR, lang := VARCHAR, model := VARCHAR, text := VARCHAR)
Named entities per text row: (id, ent_text, label, start_char, end_char)
Explode a literal English document into entities, projecting its key columns
SELECT ent_text, label
FROM nlp.main.entities((SELECT 'Apple was founded by Steve Jobs in California.' AS body), lang := 'en');
Extract the organizations (ORG entities) mentioned in each review, join them back to their review by id, and average the review sentiment per organization -- brand perception from free text.
WITH reviews(id, body) AS (VALUES (1, 'I love my new Apple laptop, the battery life is amazing.'), (2, 'Microsoft support was awful and rude.'), (3, 'The Apple store staff were friendly and quick to help.'), (4, 'Microsoft keeps crashing my laptop, which is incredibly frustrating.')) SELECT e.ent_text AS organization, count(*) AS mentions, round(avg(nlp.main.sentiment(r.body)), 3) AS avg_sentiment
FROM nlp.main.entities((SELECT id, body FROM reviews), id := 'id', lang := 'en') AS e
JOIN reviews AS r USING (id)
WHERE e.label = 'ORG'
GROUP BY e.ent_text
ORDER BY avg_sentiment DESC;
SELECT id, ent_text, label
FROM nlp.main.entities((SELECT 1 AS id, 'Apple was founded by Steve Jobs in California.' AS body), id := 'id', lang := 'en');
3 more examples
SELECT id, token, pos
FROM nlp.main.tokens((SELECT 1 AS id, 'The quick brown fox jumps.' AS body), id := 'id', lang := 'en');
SELECT id, sent_index, sentence
FROM nlp.main.sentences((SELECT 1 AS id, 'First sentence here. Second one follows.' AS body), id := 'id', lang := 'en');
SELECT id, chunk, root
FROM nlp.main.noun_chunks((SELECT 1 AS id, 'The big red car drove down the long road.' AS body), id := 'id', lang := 'en');
noun_chunks (data TABLE, id := VARCHAR, lang := VARCHAR, model := VARCHAR, text := VARCHAR)
Noun chunks per text row: (id, chunk, root) -- keyword/topic candidates
Explode a literal English document into noun_chunks, projecting its key columns
SELECT chunk, root
FROM nlp.main.noun_chunks((SELECT 'The big red car drove down the long road.' AS body), lang := 'en');
Keep only reviews labelled negative, extract their noun chunks, and lemmatize each chunk's head noun so 'rooms' and 'room' count together -- ranking the aspects that negative reviews mention.
WITH reviews(id, body) AS (VALUES (1, 'The rooms were dirty and the beds were terrible.'), (2, 'Awful service, and the room smelled bad.'), (3, 'The beds were comfortable and the view was great.'), (4, 'The breakfast was cold and the coffee was disgusting.')) SELECT nlp.main.lemmatize(lower(root), 'en') AS aspect, count(DISTINCT id) AS negative_reviews
FROM nlp.main.noun_chunks((SELECT id, body FROM reviews WHERE nlp.main.sentiment_label(body) = 'neg'), id := 'id', lang := 'en')
GROUP BY aspect
ORDER BY negative_reviews DESC, aspect;
sentences (data TABLE, id := VARCHAR, lang := VARCHAR, model := VARCHAR, text := VARCHAR)
Sentences per text row: (id, sent_index, sentence) -- chunking for embeddings
Explode a literal English document into sentences, projecting its key columns
SELECT sent_index, sentence
FROM nlp.main.sentences((SELECT 'First sentence here. Second one follows.' AS body), lang := 'en');
Split each review into sentences and score every sentence's sentiment to find the single most negative sentence per review -- pinpointing the complaint inside otherwise mixed feedback.
WITH reviews(id, body) AS (VALUES (1, 'The hotel location was perfect. The room was filthy and the staff were rude. Breakfast was fine.'), (2, 'Checkout was a frustrating mess. Otherwise it was a wonderful stay with a lovely view!')) SELECT id, arg_min(sentence, nlp.main.sentiment(sentence)) AS worst_sentence, round(min(nlp.main.sentiment(sentence)), 3) AS worst_score
FROM nlp.main.sentences((SELECT id, body FROM reviews), id := 'id', lang := 'en')
GROUP BY id
ORDER BY id;
tokens (data TABLE, id := VARCHAR, lang := VARCHAR, model := VARCHAR, text := VARCHAR)
Tokens per text row: (id, token, lemma, pos, tag, is_stop, dep)
Explode a literal English document into tokens, projecting its key columns
SELECT token, pos
FROM nlp.main.tokens((SELECT 'The quick brown fox jumps.' AS body), lang := 'en');
Try these queries
Detect the language of a French string.
SELECT nlp.main.detect_lang('Bonjour tout le monde') AS lang
Uses detect_lang
Score the sentiment of a positive English review.
SELECT nlp.main.sentiment('I absolutely love this product!') AS score
Uses sentiment
Bucket a review into a neg/neu/pos sentiment label.
SELECT nlp.main.sentiment_label('This was a terrible experience') AS mood
Uses sentiment_label
Lemmatize an English string with the language pinned.
SELECT nlp.main.lemmatize('The cats were running', 'en') AS lemmas
Uses lemmatize
Canonicalize a messy string for dedup/matching.
SELECT nlp.main.normalize(' Café DELUXE ') AS canonical
Uses normalize
Count the languages that have a default spaCy pipeline.
SELECT count(*) AS n_languages FROM nlp.main.supported_languages
Uses supported_languages
26 more examples in the Catalog, each listed under the table or function it uses.
NLP is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Tantivy
AI & language
Rank documents by BM25 relevance, tokenize text, and stem words with Snowball stemmers for many languages
Translate
AI & language
Translate text and detect its language offline with local neural models
Anthropic
AI & language
Read-only view of your Anthropic organization's members, API keys, token usage and cost