Instructions to use psikosen/snow_spike with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use psikosen/snow_spike with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("psikosen/snow_spike") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use psikosen/snow_spike with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "psikosen/snow_spike" --prompt "Once upon a time"
- Atomic Chat
Download examples/normalize_example.py from psikosen/snow_spike: direct link, hf CLI and curl.
- Browser
- Download file 5.79 kB
-
https://huggingface.co/psikosen/snow_spike/resolve/main/examples/normalize_example.py
- Command line
-
hf download hf://psikosen/snow_spike/examples/normalize_example.py
-
curl -L -o normalize_example.py https://huggingface.co/psikosen/snow_spike/resolve/main/examples/normalize_example.py
5.79 kB
| """ | |
| Example usage of the normalization module. | |
| """ | |
| from src.normalization import ( | |
| normalize_logic_check, normalize_cross_check, normalize_corroboration_signal, | |
| min_max_scale, calculate_trust_delta, SignalTracker | |
| ) | |
| from src.utils.common import CrossCheckType | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def main(): | |
| print("Normalization Example") | |
| print("--------------------") | |
| # Logic check normalization | |
| print("\nLogic Check Normalization:") | |
| logic_values = [0, 1, True, False, "1", "0", "", []] | |
| for value in logic_values: | |
| try: | |
| normalized = normalize_logic_check(value) | |
| print(f" Raw: {value} ({type(value).__name__}) -> Normalized: {normalized}") | |
| except ValueError as e: | |
| print(f" Raw: {value} ({type(value).__name__}) -> Error: {e}") | |
| # Cross-check normalization | |
| print("\nCross-Check Normalization:") | |
| # Cosine similarity examples | |
| cos_sims = [-1.0, -0.5, 0.0, 0.5, 0.99] | |
| print(" Cosine Similarity:") | |
| for sim in cos_sims: | |
| normalized = normalize_cross_check(sim, CrossCheckType.COSINE_SIMILARITY) | |
| print(f" Raw: {sim} -> Normalized: {normalized}") | |
| # General score examples | |
| scores = [0, 50, 100, 150] | |
| max_score = 100 | |
| print(f" General Score (max = {max_score}):") | |
| for score in scores: | |
| normalized = normalize_cross_check(score, CrossCheckType.GENERAL_SCORE, max_score) | |
| print(f" Raw: {score} -> Normalized: {normalized}") | |
| # Corroboration signal normalization | |
| print("\nCorroboration Signal Normalization:") | |
| corroborators = [0, 1, 2, 5, 10, 20, 50] | |
| kappa_values = [0.1, 0.5, 1.0] | |
| for kappa in kappa_values: | |
| print(f" Kappa = {kappa}:") | |
| for n in corroborators: | |
| normalized = normalize_corroboration_signal(n, kappa) | |
| print(f" Corroborators: {n} -> Normalized: {normalized:.4f}") | |
| # Min-max scaling | |
| print("\nMin-Max Scaling:") | |
| values = [10, 20, 30, 40, 50] | |
| min_val, max_val = min(values), max(values) | |
| print(f" Range: [{min_val}, {max_val}]") | |
| for value in values + [0, 60]: # Include values outside the range | |
| scaled = min_max_scale(value, min_val, max_val) | |
| print(f" Raw: {value} -> Scaled: {scaled}") | |
| # Signal tracker | |
| print("\nSignal Tracker:") | |
| tracker = SignalTracker() | |
| stream = np.random.normal(10, 5, 10) # 10 random values | |
| print(" Updating with stream of values:") | |
| for i, value in enumerate(stream): | |
| tracker.update(value) | |
| print(f" Update {i+1}: {value:.2f} -> Range: [{tracker.min_value:.2f}, {tracker.max_value:.2f}]") | |
| print(" Normalizing values:") | |
| test_values = [tracker.min_value, tracker.max_value, (tracker.min_value + tracker.max_value)/2] | |
| for value in test_values: | |
| normalized = tracker.get_normalized(value) | |
| print(f" Raw: {value:.2f} -> Normalized: {normalized}") | |
| # Trust delta calculation | |
| print("\nTrust Delta Calculation:") | |
| test_cases = [ | |
| {"L": 1.0, "C": 0.8, "R": 0.6, "α": 0.3, "β": 0.4, "γ": 0.3}, | |
| {"L": 0.0, "C": 0.5, "R": 1.0, "α": 0.2, "β": 0.3, "γ": 0.5}, | |
| {"L": 0.5, "C": 0.5, "R": 0.5, "α": 0.4, "β": 0.4, "γ": 0.2} | |
| ] | |
| for i, case in enumerate(test_cases): | |
| delta = calculate_trust_delta( | |
| case["L"], case["C"], case["R"], case["α"], case["β"], case["γ"] | |
| ) | |
| print(f" Case {i+1}: L={case['L']}, C={case['C']}, R={case['R']}") | |
| print(f" α={case['α']}, β={case['β']}, γ={case['γ']}") | |
| print(f" ΔT = {delta}") | |
| # Verify the result | |
| expected = case["L"]*case["α"] + case["C"]*case["β"] + case["R"]*case["γ"] | |
| print(f" Expected: {expected} (matches: {delta == expected})") | |
| # Visualize corroboration normalization | |
| try: | |
| plt.figure(figsize=(15, 5)) | |
| # Plot 1: Corroboration normalization for different kappa values | |
| plt.subplot(1, 3, 1) | |
| corr_range = np.linspace(0, 20, 100) | |
| for kappa in kappa_values: | |
| norm_values = [normalize_corroboration_signal(n, kappa) for n in corr_range] | |
| plt.plot(corr_range, norm_values, label=f'κ = {kappa}') | |
| plt.xlabel('Number of Corroborators') | |
| plt.ylabel('Normalized Value') | |
| plt.title('Corroboration Normalization') | |
| plt.legend() | |
| plt.grid(True) | |
| # Plot 2: Cosine similarity normalization | |
| plt.subplot(1, 3, 2) | |
| sim_range = np.linspace(-1, 1, 100) | |
| norm_values = [normalize_cross_check(s, CrossCheckType.COSINE_SIMILARITY) for s in sim_range] | |
| plt.plot(sim_range, norm_values) | |
| plt.xlabel('Cosine Similarity') | |
| plt.ylabel('Normalized Value') | |
| plt.title('Cosine Similarity Normalization') | |
| plt.grid(True) | |
| # Plot 3: Trust delta calculation with varying L | |
| plt.subplot(1, 3, 3) | |
| L_range = np.linspace(0, 1, 100) | |
| C, R = 0.7, 0.5 # Fixed values for C and R | |
| alpha, beta, gamma = 0.4, 0.3, 0.3 # Weights | |
| delta_values = [calculate_trust_delta(L, C, R, alpha, beta, gamma) for L in L_range] | |
| plt.plot(L_range, delta_values) | |
| plt.xlabel('Logic Check Value (L)') | |
| plt.ylabel('Trust Delta (ΔT)') | |
| plt.title(f'Trust Delta with C={C}, R={R}\nα={alpha}, β={beta}, γ={gamma}') | |
| plt.grid(True) | |
| plt.tight_layout() | |
| plt.savefig('normalization_example.png') | |
| print("\nVisualization saved as 'normalization_example.png'") | |
| except Exception as e: | |
| print(f"\nCould not create visualization: {e}") | |
| if __name__ == "__main__": | |
| main() | |