Intelligent data ingestion and tokenization pipeline
Project description
Suur Data
Intelligent data ingestion, filtering, and tokenization pipeline.
Installation
pip install suur-data
See It In Action
from suur_data import suur_data
tokens = suur_data("https://en.wikipedia.org/wiki/Neural_network", topic="neural networks")
print(tokens)
That one line downloads a full Wikipedia page, filters it down to only the relevant paragraphs, and returns token IDs ready for any ML model.
Full Documentation
All Installation Options
pip install suur-data
pip install suur-data[pdf]
pip install suur-data[docx]
pip install suur-data[epub]
pip install suur-data[hf]
pip install suur-data[all]
Supported Input Formats
| Format | Notes |
|---|---|
| .txt .md .rst | Plain text, auto encoding detection |
| Requires suur-data[pdf] | |
| .docx | Requires suur-data[docx] |
| .csv .tsv | All cells joined as text |
| .json | Recursively flattened key-value pairs |
| .html .htm | Scripts and styles stripped automatically |
| .epub | Requires suur-data[epub] |
| HTTP/HTTPS URL | Auto-downloaded, parsed by extension |
Python API
from suur_data import suur_data
# From a URL
tokens = suur_data("https://en.wikipedia.org/wiki/Neuroscience", topic="brain neurons")
# From a local file
tokens = suur_data("data.txt", topic="machine learning")
# Multiple sources at once
tokens = suur_data(
["file1.txt", "file2.pdf", "https://en.wikipedia.org/wiki/Deep_learning"],
topic="neural networks"
)
# Custom BPE tokenizer trained on your data
tokens = suur_data("data.txt", topic="machine learning", tokenizer="custom", vocab_size=4000)
# Strict filter
tokens = suur_data("data.pdf", topic="quantum computing", threshold=0.15)
# Save tokenizer to disk
tokens = suur_data("data.txt", topic="biology", save_dir="./my_tokenizer")
# Skip filter entirely
tokens = suur_data("data.txt", no_filter=True)
All Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| data_location | str or List[str] | required | URL, file path, or list of multiple sources |
| topic | str | "" | Subject for relevance filtering. Empty skips filter |
| tokenizer | str | "pretrained" | "pretrained" or "custom" |
| model | str | "gpt2" | HuggingFace model name or Hub ID |
| vocab_size | int | 8000 | BPE vocab size for custom tokenizer |
| threshold | float | 0.05 | Relevance cutoff between 0.0 and 1.0 |
| save_dir | str | None | Directory to save tokenizer files |
| no_filter | bool | False | Skip the relevance filter |
| verbose | bool | True | Show progress output |
Pretrained Model Shortcuts
| Shortcut | Model |
|---|---|
| gpt2 | GPT-2 (OpenAI) |
| bert | BERT base uncased |
| roberta | RoBERTa base |
| distilbert | DistilBERT base uncased |
| t5 | T5 small |
You can also pass any HuggingFace Hub model ID directly:
tokens = suur_data("data.txt", model="facebook/opt-125m")
How the Filter Works
The filter splits text into paragraph chunks, converts each chunk and the topic into TF-IDF vectors, then scores them using cosine similarity. Chunks below the threshold are deleted. If the threshold is too strict and everything gets dropped, it automatically relaxes and keeps the top 30 percent.
tokens = suur_data("data.txt", topic="AI", threshold=0.10) # strict
tokens = suur_data("data.txt", topic="AI", threshold=0.02) # loose
Saving and Loading Tokens
import json
tokens = suur_data("data.txt", topic="neural networks")
with open("tokens.json", "w") as f:
json.dump(tokens, f)
with open("tokens.json", "r") as f:
tokens = json.load(f)
Decoding Tokens Back to Text
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained("gpt2")
text = tok.decode(tokens)
print(text)
Architecture
Source (URL or file or list of sources)
|
v
Stage 1 — Ingest
Handles 8 file types and HTTP download.
Merges all sources into one text string.
|
v
Stage 2 — Neural Filter
Splits text into paragraph chunks.
Scores each chunk against topic via TF-IDF cosine similarity.
Shows progress bar while scoring.
Drops chunks below the relevance threshold.
|
v
Stage 3 — Tokenize
Pretrained: HuggingFace AutoTokenizer (GPT-2, BERT, etc.)
Custom: trains a BPE tokenizer on the filtered corpus.
|
v
List[int] — token IDs
License
MIT
Project details
Release history Release notifications | RSS feed
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 suur_data-1.0.4.tar.gz.
File metadata
- Download URL: suur_data-1.0.4.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c695bfe67ed75909080c951c5a2d7b91eabe56be279164ed3435c405f19852c2
|
|
| MD5 |
1c69899c5f52fc4370e57186a50e15cd
|
|
| BLAKE2b-256 |
7b2ae821aced547dc6b172b1429bbf637ac14f3fa78ad8e5632b6f32f65a18b4
|
File details
Details for the file suur_data-1.0.4-py3-none-any.whl.
File metadata
- Download URL: suur_data-1.0.4-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
364ed61ce7e0cc878eb4ced6ba9396850aea79a0c9b4ef2d361b0c9591b60fbb
|
|
| MD5 |
023beeda96ca0b96ce6c4c3b1d8c7ca5
|
|
| BLAKE2b-256 |
88f6ba373a51d4ad9c1d30ab6782650ba229d471945800617c6a9264216bcf3e
|