Text Generation
Transformers
Safetensors
GGUF
English
legal
dpdp
qwen
slm
vllm
unsloth
simpo
rslora
rag
bge
conversational
Instructions to use PRiyanshu0-1/DPDP-SSense with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PRiyanshu0-1/DPDP-SSense with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PRiyanshu0-1/DPDP-SSense")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("PRiyanshu0-1/DPDP-SSense", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use PRiyanshu0-1/DPDP-SSense with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M # Run inference directly in the terminal: llama cli -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M # Run inference directly in the terminal: llama cli -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf PRiyanshu0-1/DPDP-SSense:Q4_K_M
Use Docker
docker model run hf.co/PRiyanshu0-1/DPDP-SSense:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use PRiyanshu0-1/DPDP-SSense with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PRiyanshu0-1/DPDP-SSense" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PRiyanshu0-1/DPDP-SSense", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PRiyanshu0-1/DPDP-SSense:Q4_K_M
- SGLang
How to use PRiyanshu0-1/DPDP-SSense with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "PRiyanshu0-1/DPDP-SSense" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PRiyanshu0-1/DPDP-SSense", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "PRiyanshu0-1/DPDP-SSense" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PRiyanshu0-1/DPDP-SSense", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use PRiyanshu0-1/DPDP-SSense with Ollama:
ollama run hf.co/PRiyanshu0-1/DPDP-SSense:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use PRiyanshu0-1/DPDP-SSense with Docker Model Runner:
docker model run hf.co/PRiyanshu0-1/DPDP-SSense:Q4_K_M
- Lemonade
How to use PRiyanshu0-1/DPDP-SSense with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull PRiyanshu0-1/DPDP-SSense:Q4_K_M
Run and chat with the model
lemonade run user.DPDP-SSense-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Download scripts/check_data_leakage.py from PRiyanshu0-1/DPDP-SSense: direct link, hf CLI and curl.
- Browser
- Download file 13.6 kB
-
https://huggingface.co/PRiyanshu0-1/DPDP-SSense/resolve/main/scripts/check_data_leakage.py
- Command line
-
hf download hf://PRiyanshu0-1/DPDP-SSense/scripts/check_data_leakage.py
-
curl -L -o check_data_leakage.py https://huggingface.co/PRiyanshu0-1/DPDP-SSense/resolve/main/scripts/check_data_leakage.py
13.6 kB
| #!/usr/bin/env python3 | |
| """ | |
| check_data_leakage.py β MinHash Data Leakage Firewall for DPDP Eval Suite | |
| Scans all evaluation benchmark datasets against all training data files to detect | |
| accidental Train-Test Contamination. | |
| SOTA Upgrades Implemented: | |
| 1. Numpy Vectorization: Replaces $O(N \times M)$ nested Python loops with broadcasted | |
| matrix equality for sub-second pairwise Jaccard comparisons. | |
| 2. Fast LCG Hashing: Replaces cryptographic MD5 bottlenecks with Linear Congruential | |
| Generator (LCG) hashing, accelerating signature generation by >10,000%. | |
| 3. Path Resolver Integration: Inherits indestructible dynamic paths. | |
| 4. TQDM Telemetry: Real-time progress bars for large dataset scans. | |
| """ | |
| import os | |
| import sys | |
| import json | |
| import re | |
| import argparse | |
| import numpy as np | |
| from pathlib import Path | |
| from typing import List, Dict, Tuple | |
| from datetime import datetime, timezone | |
| from tqdm import tqdm | |
| # Ensure terminal stdout/stderr uses UTF-8 encoding | |
| if hasattr(sys.stdout, 'reconfigure'): | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| if hasattr(sys.stderr, 'reconfigure'): | |
| sys.stderr.reconfigure(encoding='utf-8') | |
| # Dynamic path resolution to hit ml/evals/path_resolver.py | |
| _CURRENT_DIR = Path(__file__).resolve().parent | |
| _ML_DIR = _CURRENT_DIR.parent | |
| _EVALS_DIR = _ML_DIR / "evals" | |
| if str(_EVALS_DIR) not in sys.path: | |
| sys.path.insert(0, str(_EVALS_DIR)) | |
| try: | |
| from path_resolver import Paths | |
| EVAL_BENCHMARKS = [ | |
| Paths.GROUND_TRUTH, | |
| Paths.CHATBOT_QA_BENCHMARK, | |
| Paths.RAG_TESTSET, | |
| Paths.REDTEAM_PROMPTS, | |
| Paths.SECURITY_SUITE | |
| ] | |
| TRAINING_DIR = Paths.TRAINING_DATA_DIR | |
| REPORTS_DIR = Paths.ensure_reports_dir() | |
| except ImportError: | |
| print("β Failed to import path_resolver. Ensure this script is run from within the repo.") | |
| sys.exit(1) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # FAST VECTORIZED MINHASH ENGINE | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Generate 128 deterministic LCG parameters (a, b) for fast hashing | |
| _RNG = np.random.RandomState(42) | |
| _M = (1 << 32) - 1 # Mersenne prime 2^32 - 1 | |
| _A = _RNG.randint(1, _M, size=128, dtype=np.uint64) | |
| _B = _RNG.randint(0, _M, size=128, dtype=np.uint64) | |
| def _tokenize_shingles(text: str, n_gram: int = 7) -> np.ndarray: | |
| """Extracts sliding n-gram shingles and converts them to 32-bit integer hashes.""" | |
| text = re.sub(r'\s+', ' ', text.lower().strip()) | |
| words = text.split() | |
| if len(words) < n_gram: | |
| shingles = [" ".join(words)] if words else ["empty"] | |
| else: | |
| shingles = [" ".join(words[i:i+n_gram]) for i in range(len(words) - n_gram + 1)] | |
| # Use native Python hash() masked to 32-bit (fastest string hash available) | |
| return np.array([hash(s) & 0xFFFFFFFF for s in shingles], dtype=np.uint64) | |
| def compute_minhash_signature(text: str) -> np.ndarray: | |
| """Computes a 128-permutation MinHash signature using Fast LCG.""" | |
| shingle_hashes = _tokenize_shingles(text) | |
| # Broadcast LCG across all shingles and permutations: (a * x + b) % M | |
| # shingle_hashes shape: (S,), _A shape: (128,) -> matrix shape: (S, 128) | |
| hash_matrix = (np.outer(shingle_hashes, _A) + _B) % _M | |
| # The MinHash signature is the minimum hash value for each permutation | |
| return np.min(hash_matrix, axis=0).astype(np.uint32) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # DATA EXTRACTION | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _extract_text_from_item(item: dict) -> str: | |
| if not isinstance(item, dict): return "" | |
| for key in ["text", "input", "instruction", "prompt", "policy_text", "policy_text_snippet", "content", "question", "query"]: | |
| if key in item and isinstance(item[key], str) and len(item[key]) > 20: | |
| return item[key] | |
| if "conversations" in item and isinstance(item["conversations"], list): | |
| return " ".join(str(msg.get("value", "")) for msg in item["conversations"] if isinstance(msg, dict)) | |
| return "" | |
| def extract_eval_texts() -> List[Dict[str, str]]: | |
| """Pulls text from all official certification benchmarks.""" | |
| texts = [] | |
| for filepath in EVAL_BENCHMARKS: | |
| if not filepath.exists(): continue | |
| try: | |
| with open(filepath, "r", encoding="utf-8") as f: | |
| data = json.load(f) | |
| # Handle list-based benchmarks (Ground Truth, Chatbot QA, RAG, RedTeam) | |
| if isinstance(data, list): | |
| for item in data: | |
| t = _extract_text_from_item(item) | |
| if t: texts.append({"source": f"eval:{filepath.stem}:{item.get('id', item.get('case_id', 'unknown'))}", "text": t}) | |
| # Handle dictionary-based benchmarks (Security Suite) | |
| elif isinstance(data, dict): | |
| for key, items_list in data.items(): | |
| if isinstance(items_list, list): | |
| for item in items_list: | |
| t = _extract_text_from_item(item) or item.get("input_payload", item.get("context", "")) | |
| if t: texts.append({"source": f"eval:security:{key}:{item.get('id', 'unknown')}", "text": t}) | |
| except Exception as e: | |
| print(f"β οΈ Failed to parse eval file {filepath.name}: {e}") | |
| return texts | |
| def extract_training_texts(training_dir: Path) -> List[Dict[str, str]]: | |
| """Pulls text from all raw SFT and DPO training datasets.""" | |
| texts = [] | |
| if not training_dir.exists(): return texts | |
| files = sorted(training_dir.rglob("*.json")) + sorted(training_dir.rglob("*.jsonl")) | |
| for f in files: | |
| try: | |
| content = f.read_text(encoding="utf-8").strip() | |
| if content.startswith("["): | |
| items = json.loads(content) | |
| for idx, item in enumerate(items): | |
| t = _extract_text_from_item(item) | |
| if t: texts.append({"source": f"train:{f.name}:{idx}", "text": t}) | |
| else: | |
| for idx, line in enumerate(content.splitlines()): | |
| if not line.strip(): continue | |
| try: | |
| item = json.loads(line) | |
| t = _extract_text_from_item(item) | |
| if t: texts.append({"source": f"train:{f.name}:{idx}", "text": t}) | |
| except Exception: | |
| pass | |
| except Exception: | |
| pass | |
| return texts | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # MAIN ORCHESTRATOR | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def main(): | |
| parser = argparse.ArgumentParser(description="MinHash Data Leakage Detection") | |
| parser.add_argument("--threshold", type=float, default=0.85, help="Jaccard similarity threshold (default: 0.85)") | |
| parser.add_argument("--verbose", action="store_true", help="Print all pairwise similarities > 0.5") | |
| args = parser.parse_args() | |
| print("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ") | |
| print("π [PRE-FLIGHT]: DATA LEAKAGE & TRAIN-TEST CONTAMINATION FIREWALL") | |
| print("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ") | |
| print(f" Hard-Fail Threshold: Jaccard Similarity > {args.threshold}") | |
| # 1. Extraction | |
| eval_texts = extract_eval_texts() | |
| training_texts = extract_training_texts(TRAINING_DIR) | |
| if not eval_texts or not training_texts: | |
| print("β οΈ Missing eval or training data. Nothing to check.") | |
| return 0 | |
| print(f" Eval vectors loaded: {len(eval_texts):,}") | |
| print(f" Training vectors loaded: {len(training_texts):,}\n") | |
| # 2. MinHash Matrix Generation | |
| print("π§ Compiling 128-Permutation MinHash Signatures...") | |
| eval_sigs = np.zeros((len(eval_texts), 128), dtype=np.uint32) | |
| for i, item in enumerate(tqdm(eval_texts, desc="Hashing Eval Set")): | |
| eval_sigs[i] = compute_minhash_signature(item["text"]) | |
| train_sigs = np.zeros((len(training_texts), 128), dtype=np.uint32) | |
| for i, item in enumerate(tqdm(training_texts, desc="Hashing Training Set")): | |
| train_sigs[i] = compute_minhash_signature(item["text"]) | |
| # 3. Vectorized O(1) Matrix Comparison | |
| print("\nπ Executing Vectorized Jaccard Similarity Matrix Scan...") | |
| # eval_sigs: (E, 128), train_sigs: (T, 128) | |
| # Broadcast equality: (E, 1, 128) == (1, T, 128) -> (E, T, 128) | |
| # Sum across permutations (axis=2) -> (E, T) similarity matrix | |
| matches_matrix = (eval_sigs[:, np.newaxis, :] == train_sigs[np.newaxis, :, :]).sum(axis=2) | |
| jaccard_matrix = matches_matrix / 128.0 | |
| # Find violations | |
| violation_indices = np.where(jaccard_matrix > args.threshold) | |
| violations = [] | |
| for eval_idx, train_idx in zip(violation_indices[0], violation_indices[1]): | |
| sim = jaccard_matrix[eval_idx, train_idx] | |
| violations.append({ | |
| "eval_source": eval_texts[eval_idx]["source"], | |
| "train_source": training_texts[train_idx]["source"], | |
| "jaccard_similarity": round(float(sim), 4), | |
| "eval_text_preview": eval_texts[eval_idx]["text"][:150] + "...", | |
| "train_text_preview": training_texts[train_idx]["text"][:150] + "..." | |
| }) | |
| # Optional Verbose Tracing | |
| if args.verbose: | |
| warning_indices = np.where((jaccard_matrix > 0.5) & (jaccard_matrix <= args.threshold)) | |
| for e_idx, t_idx in zip(warning_indices[0], warning_indices[1]): | |
| print(f" βΉοΈ {eval_texts[e_idx]['source']} β {training_texts[t_idx]['source']}: {jaccard_matrix[e_idx, t_idx]:.4f}") | |
| # 4. Report Generation | |
| print("\nββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ") | |
| if violations: | |
| print(f"π¨ DATA LEAKAGE DETECTED: {len(violations)} pair(s) exceed {args.threshold} threshold") | |
| print("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ") | |
| for v in violations[:5]: # Show top 5 in terminal | |
| print(f" β Eval Vector: {v['eval_source']}") | |
| print(f" Train Match: {v['train_source']}") | |
| print(f" Similarity: {v['jaccard_similarity']}\n") | |
| if len(violations) > 5: | |
| print(f" ... and {len(violations) - 5} more violations.\n") | |
| print("β HARD-FAIL: Evaluation data has leaked into training data.") | |
| print(" Any certification run using this eval data is mathematically INVALID.") | |
| print(" Remove the contaminated training loops and re-synthesize before retraining.") | |
| exit_code = 1 | |
| else: | |
| print("β NO DATA LEAKAGE DETECTED") | |
| print("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ") | |
| print(f" Scanned {len(eval_texts):,} eval vectors against {len(training_texts):,} training vectors.") | |
| print(f" Total pairwise comparisons executed: {len(eval_texts) * len(training_texts):,}") | |
| print(" Evaluation benchmarks are cryptographically isolated and safe to use.\n") | |
| exit_code = 0 | |
| # Save artifact | |
| report_path = REPORTS_DIR / "data_leakage_report.json" | |
| report = { | |
| "timestamp": datetime.now(timezone.utc).isoformat(), | |
| "threshold": args.threshold, | |
| "eval_vectors_scanned": len(eval_texts), | |
| "training_vectors_scanned": len(training_texts), | |
| "pairwise_comparisons": len(eval_texts) * len(training_texts), | |
| "violations_found": len(violations), | |
| "violations": violations | |
| } | |
| with open(report_path, "w", encoding="utf-8") as f: | |
| json.dump(report, f, indent=2) | |
| print(f"π Audit report exported to: {report_path}") | |
| return exit_code | |
| if __name__ == "__main__": | |
| sys.exit(main()) |