{"data":{"slug":"github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-keywords-d21f76cb7f50","title":"Extract Keywords, Language, and Embeddings from Documents","summary":"Extract keywords using YAKE\/RAKE, detect document language, and generate embeddings for RAG and search.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-keywords-d21f76cb7f50","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-keywords-d21f76cb7f50","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-keywords-d21f76cb7f50.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-keywords-d21f76cb7f50\/download","category":{"slug":"content-editorial","name":"Content & Editorial"},"editor_note":"Keyword extraction requires the CLI to be built with the `keywords-yake` and\/or `keywords-rake` Cargo features. If not, the config block is ignored and `result.extracted_keywords` remains empty.","instructions":"---\ndescription: Use when extracting keywords (YAKE\/RAKE) from documents \u2014 and, secondarily, when detecting document language or generating embeddings for RAG and search. Covers the keyword config (and its feature gating), `--detect-language`, and the standalone `embed` command with real flags.\nname: xberg-extracting-keywords\n---\n\n<!--\nAI-RULEZ :: GENERATED FILE \u2014 DO NOT EDIT\nContent-Hash: blake3:491d3cbcd4f6128d43e32b39c13d03a023b397f97c71da48ed5a02d6be00ae28\nSource-Hash: blake3:ab2bcd453f9c2ded67752f6a9800186d42b6921f4be16f6ab3a773254a9fba00\nSchema-Version: v1\n-->\n\n# Extracting keywords, language, and embeddings\n\nUse this for the enrichment surface around extraction: statistical keyword\nextraction, language detection, and vector embeddings. Keywords and\nlanguage detection ride along with extraction and land on the result;\nembeddings are produced by a dedicated `embed` command.\n\n## Keywords (YAKE \/ RAKE)\n\nKeyword extraction is configured via the `[keywords]` config block (or\ninline JSON) \u2014 there is no single `--keywords` CLI flag. When enabled,\nextracted keywords appear on `result.extracted_keywords` (`extractedKeywords`\nin Node.js; the CLI JSON field is `extracted_keywords`). Two algorithms are\navailable:\n\n- **YAKE** (`\"yake\"`) \u2014 statistical, unsupervised single-document\n  extraction. Good general default.\n- **RAKE** (`\"rake\"`) \u2014 co-occurrence \/ phrase-based. Favors multi-word\n  key phrases.\n\n> Feature-gated: keyword extraction requires the CLI to be built with the\n> `keywords-yake` and\/or `keywords-rake` Cargo features (both are in the\n> default\/`full` build). If the CLI was built without them, the `[keywords]`\n> config block is silently ignored \u2014 `result.extracted_keywords` simply stays empty\n> rather than erroring. The `\"yake\"` algorithm needs `keywords-yake`; `\"rake\"`\n> needs `keywords-rake`.\n\nEnable via inline JSON on the CLI:\n\n```bash\nxberg extract paper.pdf --format json \\\n  --config-json '{\"keywords\":{\"algorithm\":\"yake\",\"max_keywords\":15,\"language\":\"en\"}}' \\\n  | jq '.result.extracted_keywords'\n```\n\nOr in a config file:\n\n```toml\n[keywords]\nalgorithm = \"rake\"       # \"yake\" or \"rake\"\nmax_keywords = 10        # default 10\nmin_score = 0.0          # filter below this score (normalized 0.0-1.0 for both algorithms)\nngram_range = [1, 3]     # unigrams..trigrams (default); config-file only\nlanguage = \"en\"          # stopword language; omit to skip stopword filtering\n```\n\n```bash\nxberg extract report.pdf --config xberg.toml --format json | jq '.result.extracted_keywords'\n```\n\nField notes:\n\n- `max_keywords` caps how many keywords are returned (default 10).\n- `min_score` filters low-scoring keywords. Both YAKE and RAKE normalize\n  their scores to the `0.0`-`1.0` range with *higher-is-better*, so\n  `min_score` retains keywords with `score >= min_score` identically for\n  either algorithm.\n- `ngram_range` is `[min, max]`: `[1,1]` unigrams only, `[1,2]` adds\n  bigrams, `[1,3]` (default) adds trigrams. Config-file only \u2014 it is not a\n  field on the language bindings' `KeywordConfig`.\n- `language` enables stopword filtering for that language; omit it to\n  disable stopword filtering entirely.\n\n## Language detection\n\nLanguage detection is a real CLI flag: `--detect-language`. Detected\nlanguages appear on `result.detected_languages`:\n\n```bash\nxberg extract multilingual.pdf --detect-language true --format json \\\n  | jq '.result.detected_languages'\n```\n\nIn a config file it lives under `[language_detection]`:\n\n```toml\n[language_detection]\nenabled = true\nmin_confidence = 0.8\ndetect_multiple = false\n```\n\nThe CLI flag enables detection with `min_confidence = 0.8` and\nsingle-language mode; use the config block to detect multiple languages or\ntune confidence.\n\n## Embeddings (`embed` command)\n\nThe standalone `embed` command produces vector embeddings for text from\n`--text` (repeatable) or stdin. It does not run extraction \u2014 pipe\nextracted content in if you want document embeddings.\n\n```bash\n# Local ONNX preset model (default provider)\nxberg embed --text \"first passage\" --text \"second passage\" --preset balanced\n\n# Embed extracted document text\nxberg extract report.pdf | xberg embed --preset quality\n```\n\nPresets for the local provider: `fast`, `balanced` (default), `quality`,\n`multilingual`. Output defaults to JSON (`--format json`).\n\n`--provider` selects the embedding source:\n\n| Provider | Flag                                  | Notes                                         |\n| -------- | ------------------------------------- | --------------------------------------------- |\n| `local`  | `--preset <fast\\|balanced\\|quality\\|multilingual>` | **Default.** ONNX model, no API key. |\n| `llm`    | `--model <id>` `--api-key <key>`      | liter-llm routing, e.g. `openai\/text-embedding-3-small`. |\n| `plugin` | `--plugin <name>`                     | A backend pre-registered in-process via the plugin API. |\n\n```bash\n# Provider-hosted embeddings via an LLM\nxberg embed --text \"query text\" \\\n  --provider llm --model openai\/text-embedding-3-small --api-key \"$OPENAI_API_KEY\"\n```\n\nLocal embedding presets must be downloaded first if not cached. Pre-warm\nthem with the cache command:\n\n```bash\nxberg cache warm --embedding-model balanced   # one preset\nxberg cache warm --all-embeddings             # all available presets (currently 8)\n```\n\n## Programmatic access\n\nKeywords and detected languages live on the document in the result envelope:\n\n```python\nfrom xberg import ExtractInput, extract, ExtractionConfig, KeywordConfig, KeywordAlgorithm\n\nconfig = ExtractionConfig(\n    keywords=KeywordConfig(algorithm=KeywordAlgorithm.YAKE, max_keywords=15, language=\"en\"),\n)\nresult = await extract(ExtractInput(uri=\"paper.pdf\"), config)\ndoc = result.results[0]\nprint(doc.extracted_keywords)   # extracted keywords (when enabled)\nprint(doc.detected_languages)   # detected languages (when enabled)\n```\n\nSee `references\/python-api.md` and `references\/configuration.md` for the keyword \/ language-detection config\nclasses and the embedding presets.\n\n## Common pitfalls\n\n- **No `--keywords` flag** \u2014 keyword extraction is config-only. Use\n  `--config-json '{\"keywords\":{...}}'` or a `[keywords]` config block.\n- **`min_score` direction** \u2014 scores are normalized to `0.0`-`1.0` with\n  higher-is-better for both YAKE and RAKE, so the same threshold behaves\n  identically for either algorithm.\n- **Embeddings \u2260 extraction** \u2014 `embed` only takes raw text. Pipe\n  `xberg extract` output into it for document vectors.\n- **Cold embedding models** \u2014 first local run downloads the preset; run\n  `xberg cache warm --all-embeddings` to pre-populate.\n\nSee `references\/advanced-features.md` for the embeddings pipeline and\n`references\/cli-reference.md` for the `embed` and `cache warm` flag sets.\n","use_cases":["Extract keywords from a research paper for content summarization.","Detect the language of a multilingual document for translation purposes.","Generate embeddings for a document to use in a retrieval-augmented generation (RAG) system."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/plugin\/.cursor-plugin\/skills\/xberg-extracting-keywords\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T14:34:17.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Extract Keywords, Language, and Embeddings from Documents","seo_description":"Extract keywords, detect language, and generate embeddings for document analysis and search. Use YAKE\/RAKE algorithms and standalone embed command.","seo_keywords":["extract keywords from document","detect document language","generate embeddings for RAG","YAKE keyword extraction","RAKE keyword extraction"]}}