← Back to all products
$39
NLP Starter Kit
Text processing pipelines, embedding workflows, fine-tuning scripts, and RAG implementation patterns.
MarkdownYAMLPythonLLMOpenAI
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 31 files
nlp-starter-kit/
├── LICENSE
├── README.md
├── configs/
│ ├── model_config.yaml
│ └── pipeline_config.yaml
├── free-sample.zip
├── guide/
│ ├── 01-fine-tuning.md
│ └── 02-text-preprocessing.md
├── guides/
│ ├── fine-tuning.md
│ └── text-preprocessing.md
├── index.html
├── requirements.txt
├── src/
│ └── nlp_starter_kit/
│ ├── __init__.py
│ ├── __pycache__/
│ │ ├── __init__.cpython-312.pyc
│ │ ├── classifier.cpython-312.pyc
│ │ ├── embeddings.cpython-312.pyc
│ │ ├── fine_tuning.cpython-312.pyc
│ │ ├── ner.cpython-312.pyc
│ │ ├── rag.cpython-312.pyc
│ │ └── text_processor.cpython-312.pyc
│ ├── classifier.py
│ ├── embeddings.py
│ ├── fine_tuning.py
│ ├── ner.py
│ ├── rag.py
│ └── text_processor.py
└── tests/
├── __pycache__/
│ ├── test_classifier_ner.cpython-312.pyc
│ ├── test_rag.cpython-312.pyc
│ └── test_text_processor.cpython-312.pyc
├── test_classifier_ner.py
├── test_rag.py
└── test_text_processor.py
📖 Documentation Preview README excerpt
NLP Starter Kit
End-to-end NLP toolkit: text preprocessing, embeddings, classification, NER, fine-tuning, and RAG — with stdlib reference implementations that run without a GPU.
Go from raw text to trained models and retrieval-augmented generation with a single coherent toolkit. Every component includes both a stdlib baseline (runs anywhere) and a production backend (Hugging Face, sentence-transformers, LoRA).
What You Get
- Text preprocessing pipeline — tokenization with offset tracking, Unicode normalization (NFC/NFKD/NFKC), HTML/URL/email cleaning, stopword filtering, all composable into a single
TextProcessorcall - Embedding engine — pluggable backends for TF-IDF (stdlib), sentence-transformers (SBERT), and OpenAI-compatible APIs, with caching, batch optimization, and cosine similarity utilities
- Text classifier — nearest-centroid baseline (stdlib, no sklearn) and Hugging Face transformer backend, with full metric computation (accuracy, precision, recall, F1, confusion matrix)
- Named entity recognition — rule-based extractor with regex patterns and gazetteers, plus transformer-based NER (Hugging Face token-classification), with span merging and deduplication
- Fine-tuning pipeline — Hugging Face Trainer wrapper with LoRA/PEFT support, learning rate schedulers, gradient accumulation, and checkpoint management
- RAG pipeline — document chunking, in-memory vector store, mock LLM client, and prompt assembly — the full retrieval-augmented generation loop runs on stdlib alone
- Comprehensive test suite — 50+ test cases covering all modules, runnable without external dependencies
- Configuration files — YAML configs for pipeline settings and fine-tuning hyperparameters with presets for common scenarios
File Tree
nlp-starter-kit/
├── README.md
├── LICENSE
├── requirements.txt
├── src/
│ └── nlp_starter_kit/
│ ├── __init__.py # Package exports
│ ├── text_processor.py # Tokenization, normalization, cleaning
│ ├── embeddings.py # Embedding backends and cosine similarity
│ ├── classifier.py # Text classification with metrics
│ ├── ner.py # Named entity recognition
│ ├── fine_tuning.py # HF fine-tuning with LoRA support
│ └── rag.py # RAG pipeline with vector store
├── configs/
│ ├── pipeline_config.yaml # Processing pipeline settings
│ └── model_config.yaml # Fine-tuning hyperparameter presets
├── tests/
│ ├── test_text_processor.py # Tokenizer, normalizer, cleaner tests
│ ├── test_classifier_ner.py # Classification and NER tests
│ └── test_rag.py # RAG pipeline tests
└── guides/
├── text-preprocessing.md # Preprocessing recipes and pitfalls
└── fine-tuning.md # Fine-tuning guide with LoRA walkthrough
Quick Start
1. Install Dependencies
pip install -r requirements.txt
Or for stdlib-only usage (no GPU, no external packages):
# Just use the toolkit directly — TF-IDF embeddings, nearest-centroid
# classifier, rule-based NER, and mock LLM all work on stdlib alone.
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/nlp_starter_kit/classifier.py
"""
Text Classifier — NLP Starter Kit
====================================
Training and inference pipeline for text classification using both
classical ML (TF-IDF + logistic regression) and transformer-based
approaches (Hugging Face).
The stdlib baseline classifier uses TF-IDF vectors with a simple
nearest-centroid approach — no scikit-learn required for basic demos.
By Datanest Digital — support@datanest.dev
"""
from __future__ import annotations
import json
import logging
import math
import os
import time
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
logger = logging.getLogger(__name__)
# ---------------------------------------------------------------------------
# Data structures
# ---------------------------------------------------------------------------
@dataclass
class ClassificationResult:
"""Prediction result for a single text.
Attributes:
text: The input text that was classified.
predicted_label: The top predicted class label.
confidence: Confidence score for the predicted label (0-1).
all_scores: Mapping of label → score for every class.
latency_ms: Inference time in milliseconds.
"""
text: str
predicted_label: str
confidence: float
all_scores: Dict[str, float] = field(default_factory=dict)
latency_ms: float = 0.0
# ... 487 more lines ...